@crystaldesign/product-detail-page 24.11.2 → 24.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*! For license information please see 599.product-detail-page.umd.min.js.LICENSE.txt */
2
- (self.webpackChunkCrystaldesignProductDetailPage=self.webpackChunkCrystaldesignProductDetailPage||[]).push([[599],{7526:(e,t)=>{"use strict";t.byteLength=function byteLength(e){var t=getLens(e),r=t[0],s=t[1];return 3*(r+s)/4-s},t.toByteArray=function toByteArray(e){var t,r,l=getLens(e),c=l[0],h=l[1],d=new o(function _byteLength(e,t,r){return 3*(t+r)/4-r}(0,c,h)),p=0,A=h>0?c-4:c;for(r=0;r<A;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],d[p++]=t>>16&255,d[p++]=t>>8&255,d[p++]=255&t;2===h&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,d[p++]=255&t);1===h&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,d[p++]=t>>8&255,d[p++]=255&t);return d},t.fromByteArray=function fromByteArray(e){for(var t,s=e.length,o=s%3,l=[],c=16383,h=0,d=s-o;h<d;h+=c)l.push(encodeChunk(e,h,h+c>d?d:h+c));1===o?(t=e[s-1],l.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[s-2]<<8)+e[s-1],l.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return l.join("")};for(var r=[],s=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0;c<64;++c)r[c]=l[c],s[l.charCodeAt(c)]=c;function getLens(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function encodeChunk(e,t,s){for(var o,l,c=[],h=t;h<s;h+=3)o=(e[h]<<16&16711680)+(e[h+1]<<8&65280)+(255&e[h+2]),c.push(r[(l=o)>>18&63]+r[l>>12&63]+r[l>>6&63]+r[63&l]);return c.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},8287:(e,t,r)=>{"use strict";var s=r(6763);const o=r(7526),l=r(251),c="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=Buffer,t.IS=50;const h=2147483647;function createBuffer(e){if(e>h)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"==typeof e)return function fromString(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|byteLength(e,t);let s=createBuffer(r);const o=s.write(e,t);o!==r&&(s=s.slice(0,o));return s}(e,t);if(ArrayBuffer.isView(e))return function fromArrayView(e){if(isInstance(e,Uint8Array)){const t=new Uint8Array(e);return fromArrayBuffer(t.buffer,t.byteOffset,t.byteLength)}return fromArrayLike(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const s=e.valueOf&&e.valueOf();if(null!=s&&s!==e)return Buffer.from(s,t,r);const o=function fromObject(e){if(Buffer.isBuffer(e)){const t=0|checked(e.length),r=createBuffer(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||numberIsNaN(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromArrayLike(e){const t=e.length<0?0:0|checked(e.length),r=createBuffer(t);for(let s=0;s<t;s+=1)r[s]=255&e[s];return r}function fromArrayBuffer(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let s;return s=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(s,Buffer.prototype),s}function checked(e){if(e>=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return 0|e}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(o)return s?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),o=!0}}function slowToString(e,t,r){let s=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function swap(e,t,r){const s=e[t];e[t]=e[r],e[r]=s}function bidirectionalIndexOf(e,t,r,s,o){if(0===e.length)return-1;if("string"==typeof r?(s=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,s)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,s,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,s,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,s,o){let l,c=1,h=e.length,d=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return-1;c=2,h/=2,d/=2,r/=2}function read(e,t){return 1===c?e[t]:e.readUInt16BE(t*c)}if(o){let s=-1;for(l=r;l<h;l++)if(read(e,l)===read(t,-1===s?0:l-s)){if(-1===s&&(s=l),l-s+1===d)return s*c}else-1!==s&&(l-=l-s),s=-1}else for(r+d>h&&(r=h-d),l=r;l>=0;l--){let r=!0;for(let s=0;s<d;s++)if(read(e,l+s)!==read(t,s)){r=!1;break}if(r)return l}return-1}function hexWrite(e,t,r,s){r=Number(r)||0;const o=e.length-r;s?(s=Number(s))>o&&(s=o):s=o;const l=t.length;let c;for(s>l/2&&(s=l/2),c=0;c<s;++c){const s=parseInt(t.substr(2*c,2),16);if(numberIsNaN(s))return c;e[r+c]=s}return c}function utf8Write(e,t,r,s){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,s)}function asciiWrite(e,t,r,s){return blitBuffer(function asciiToBytes(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,s)}function base64Write(e,t,r,s){return blitBuffer(base64ToBytes(t),e,r,s)}function ucs2Write(e,t,r,s){return blitBuffer(function utf16leToBytes(e,t){let r,s,o;const l=[];for(let c=0;c<e.length&&!((t-=2)<0);++c)r=e.charCodeAt(c),s=r>>8,o=r%256,l.push(o),l.push(s);return l}(t,e.length-r),e,r,s)}function base64Slice(e,t,r){return 0===t&&r===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(t,r))}function utf8Slice(e,t,r){r=Math.min(e.length,r);const s=[];let o=t;for(;o<r;){const t=e[o];let l=null,c=t>239?4:t>223?3:t>191?2:1;if(o+c<=r){let r,s,h,d;switch(c){case 1:t<128&&(l=t);break;case 2:r=e[o+1],128==(192&r)&&(d=(31&t)<<6|63&r,d>127&&(l=d));break;case 3:r=e[o+1],s=e[o+2],128==(192&r)&&128==(192&s)&&(d=(15&t)<<12|(63&r)<<6|63&s,d>2047&&(d<55296||d>57343)&&(l=d));break;case 4:r=e[o+1],s=e[o+2],h=e[o+3],128==(192&r)&&128==(192&s)&&128==(192&h)&&(d=(15&t)<<18|(63&r)<<12|(63&s)<<6|63&h,d>65535&&d<1114112&&(l=d))}}null===l?(l=65533,c=1):l>65535&&(l-=65536,s.push(l>>>10&1023|55296),l=56320|1023&l),s.push(l),o+=c}return function decodeCodePointsArray(e){const t=e.length;if(t<=d)return String.fromCharCode.apply(String,e);let r="",s=0;for(;s<t;)r+=String.fromCharCode.apply(String,e.slice(s,s+=d));return r}(s)}Buffer.TYPED_ARRAY_SUPPORT=function typedArraySupport(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),Buffer.TYPED_ARRAY_SUPPORT||void 0===s||"function"!=typeof s.error||s.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(e,t,r){return function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function isBuffer(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function compare(e,t){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,s=t.length;for(let o=0,l=Math.min(r,s);o<l;++o)if(e[o]!==t[o]){r=e[o],s=t[o];break}return r<s?-1:s<r?1:0},Buffer.isEncoding=function isEncoding(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function concat(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Buffer.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const s=Buffer.allocUnsafe(t);let o=0;for(r=0;r<e.length;++r){let t=e[r];if(isInstance(t,Uint8Array))o+t.length>s.length?(Buffer.isBuffer(t)||(t=Buffer.from(t)),t.copy(s,o)):Uint8Array.prototype.set.call(s,t,o);else{if(!Buffer.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(s,o)}o+=t.length}return s},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)swap(this,t,t+1);return this},Buffer.prototype.swap32=function swap32(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)swap(this,t,t+3),swap(this,t+1,t+2);return this},Buffer.prototype.swap64=function swap64(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)swap(this,t,t+7),swap(this,t+1,t+6),swap(this,t+2,t+5),swap(this,t+3,t+4);return this},Buffer.prototype.toString=function toString(){const e=this.length;return 0===e?"":0===arguments.length?utf8Slice(this,0,e):slowToString.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function equals(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function inspect(){let e="";const r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},c&&(Buffer.prototype[c]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(e,t,r,s,o){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===s&&(s=0),void 0===o&&(o=this.length),t<0||r>e.length||s<0||o>this.length)throw new RangeError("out of range index");if(s>=o&&t>=r)return 0;if(s>=o)return-1;if(t>=r)return 1;if(this===e)return 0;let l=(o>>>=0)-(s>>>=0),c=(r>>>=0)-(t>>>=0);const h=Math.min(l,c),d=this.slice(s,o),p=e.slice(t,r);for(let e=0;e<h;++e)if(d[e]!==p[e]){l=d[e],c=p[e];break}return l<c?-1:c<l?1:0},Buffer.prototype.includes=function includes(e,t,r){return-1!==this.indexOf(e,t,r)},Buffer.prototype.indexOf=function indexOf(e,t,r){return bidirectionalIndexOf(this,e,t,r,!0)},Buffer.prototype.lastIndexOf=function lastIndexOf(e,t,r){return bidirectionalIndexOf(this,e,t,r,!1)},Buffer.prototype.write=function write(e,t,r,s){if(void 0===t)s="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)s=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===s&&(s="utf8")):(s=r,r=void 0)}const o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let l=!1;for(;;)switch(s){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":case"latin1":case"binary":return asciiWrite(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(l)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),l=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const d=4096;function asciiSlice(e,t,r){let s="";r=Math.min(e.length,r);for(let o=t;o<r;++o)s+=String.fromCharCode(127&e[o]);return s}function latin1Slice(e,t,r){let s="";r=Math.min(e.length,r);for(let o=t;o<r;++o)s+=String.fromCharCode(e[o]);return s}function hexSlice(e,t,r){const s=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);let o="";for(let s=t;s<r;++s)o+=m[e[s]];return o}function utf16leSlice(e,t,r){const s=e.slice(t,r);let o="";for(let e=0;e<s.length-1;e+=2)o+=String.fromCharCode(s[e]+256*s[e+1]);return o}function checkOffset(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,s,o,l){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<l)throw new RangeError('"value" argument is out of bounds');if(r+s>e.length)throw new RangeError("Index out of range")}function wrtBigUInt64LE(e,t,r,s,o){checkIntBI(t,s,o,e,r,7);let l=Number(t&BigInt(4294967295));e[r++]=l,l>>=8,e[r++]=l,l>>=8,e[r++]=l,l>>=8,e[r++]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=c,c>>=8,e[r++]=c,c>>=8,e[r++]=c,c>>=8,e[r++]=c,r}function wrtBigUInt64BE(e,t,r,s,o){checkIntBI(t,s,o,e,r,7);let l=Number(t&BigInt(4294967295));e[r+7]=l,l>>=8,e[r+6]=l,l>>=8,e[r+5]=l,l>>=8,e[r+4]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=c,c>>=8,e[r+2]=c,c>>=8,e[r+1]=c,c>>=8,e[r]=c,r+8}function checkIEEE754(e,t,r,s,o,l){if(r+s>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,s,o){return t=+t,r>>>=0,o||checkIEEE754(e,0,r,4),l.write(e,t,r,s,23,4),r+4}function writeDouble(e,t,r,s,o){return t=+t,r>>>=0,o||checkIEEE754(e,0,r,8),l.write(e,t,r,s,52,8),r+8}Buffer.prototype.slice=function slice(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const s=this.subarray(e,t);return Object.setPrototypeOf(s,Buffer.prototype),s},Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function readUIntLE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=this[e],o=1,l=0;for(;++l<t&&(o*=256);)s+=this[e+l]*o;return s},Buffer.prototype.readUintBE=Buffer.prototype.readUIntBE=function readUIntBE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=this[e+--t],o=1;for(;t>0&&(o*=256);)s+=this[e+--t]*o;return s},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readBigUInt64LE=defineBigIntMethod((function readBigUInt64LE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(s)+(BigInt(o)<<BigInt(32))})),Buffer.prototype.readBigUInt64BE=defineBigIntMethod((function readBigUInt64BE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(s)<<BigInt(32))+BigInt(o)})),Buffer.prototype.readIntLE=function readIntLE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=this[e],o=1,l=0;for(;++l<t&&(o*=256);)s+=this[e+l]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s},Buffer.prototype.readIntBE=function readIntBE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=t,o=1,l=this[e+--s];for(;s>0&&(o*=256);)l+=this[e+--s]*o;return o*=128,l>=o&&(l-=Math.pow(2,8*t)),l},Buffer.prototype.readInt8=function readInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){e>>>=0,t||checkOffset(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function readInt16BE(e,t){e>>>=0,t||checkOffset(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readBigInt64LE=defineBigIntMethod((function readBigInt64LE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(s)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),Buffer.prototype.readBigInt64BE=defineBigIntMethod((function readBigInt64BE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(s)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),Buffer.prototype.readFloatLE=function readFloatLE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),l.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),l.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),l.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),l.read(this,e,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,r,s){if(e=+e,t>>>=0,r>>>=0,!s){checkInt(this,e,t,r,Math.pow(2,8*r)-1,0)}let o=1,l=0;for(this[t]=255&e;++l<r&&(o*=256);)this[t+l]=e/o&255;return t+r},Buffer.prototype.writeUintBE=Buffer.prototype.writeUIntBE=function writeUIntBE(e,t,r,s){if(e=+e,t>>>=0,r>>>=0,!s){checkInt(this,e,t,r,Math.pow(2,8*r)-1,0)}let o=r-1,l=1;for(this[t+o]=255&e;--o>=0&&(l*=256);)this[t+o]=e/l&255;return t+r},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeBigUInt64LE=defineBigIntMethod((function writeBigUInt64LE(e,t=0){return wrtBigUInt64LE(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeBigUInt64BE=defineBigIntMethod((function writeBigUInt64BE(e,t=0){return wrtBigUInt64BE(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeIntLE=function writeIntLE(e,t,r,s){if(e=+e,t>>>=0,!s){const s=Math.pow(2,8*r-1);checkInt(this,e,t,r,s-1,-s)}let o=0,l=1,c=0;for(this[t]=255&e;++o<r&&(l*=256);)e<0&&0===c&&0!==this[t+o-1]&&(c=1),this[t+o]=(e/l|0)-c&255;return t+r},Buffer.prototype.writeIntBE=function writeIntBE(e,t,r,s){if(e=+e,t>>>=0,!s){const s=Math.pow(2,8*r-1);checkInt(this,e,t,r,s-1,-s)}let o=r-1,l=1,c=0;for(this[t+o]=255&e;--o>=0&&(l*=256);)e<0&&0===c&&0!==this[t+o+1]&&(c=1),this[t+o]=(e/l|0)-c&255;return t+r},Buffer.prototype.writeInt8=function writeInt8(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeBigInt64LE=defineBigIntMethod((function writeBigInt64LE(e,t=0){return wrtBigUInt64LE(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeBigInt64BE=defineBigIntMethod((function writeBigInt64BE(e,t=0){return wrtBigUInt64BE(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function copy(e,t,r,s){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<r&&(s=r),s===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-r&&(s=e.length-t+r);const o=s-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,s):Uint8Array.prototype.set.call(e,this.subarray(r,s),t),o},Buffer.prototype.fill=function fill(e,t,r,s){if("string"==typeof e){if("string"==typeof t?(s=t,t=0,r=this.length):"string"==typeof r&&(s=r,r=this.length),void 0!==s&&"string"!=typeof s)throw new TypeError("encoding must be a string");if("string"==typeof s&&!Buffer.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(1===e.length){const t=e.charCodeAt(0);("utf8"===s&&t<128||"latin1"===s)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{const l=Buffer.isBuffer(e)?e:Buffer.from(e,s),c=l.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=l[o%c]}return this};const p={};function E(e,t,r){p[e]=class NodeError extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function addNumericalSeparator(e){let t="",r=e.length;const s="-"===e[0]?1:0;for(;r>=s+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function checkIntBI(e,t,r,s,o,l){if(e>r||e<t){const s="bigint"==typeof t?"n":"";let o;throw o=l>3?0===t||t===BigInt(0)?`>= 0${s} and < 2${s} ** ${8*(l+1)}${s}`:`>= -(2${s} ** ${8*(l+1)-1}${s}) and < 2 ** ${8*(l+1)-1}${s}`:`>= ${t}${s} and <= ${r}${s}`,new p.ERR_OUT_OF_RANGE("value",o,e)}!function checkBounds(e,t,r){validateNumber(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||boundsError(t,e.length-(r+1))}(s,o,l)}function validateNumber(e,t){if("number"!=typeof e)throw new p.ERR_INVALID_ARG_TYPE(t,"number",e)}function boundsError(e,t,r){if(Math.floor(e)!==e)throw validateNumber(e,r),new p.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new p.ERR_BUFFER_OUT_OF_BOUNDS;throw new p.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}E("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),E("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),E("ERR_OUT_OF_RANGE",(function(e,t,r){let s=`The value of "${e}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=addNumericalSeparator(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=addNumericalSeparator(o)),o+="n"),s+=` It must be ${t}. Received ${o}`,s}),RangeError);const A=/[^+/0-9A-Za-z-_]/g;function utf8ToBytes(e,t){let r;t=t||1/0;const s=e.length;let o=null;const l=[];for(let c=0;c<s;++c){if(r=e.charCodeAt(c),r>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&l.push(239,191,189);continue}if(c+1===s){(t-=3)>-1&&l.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&l.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&l.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;l.push(r)}else if(r<2048){if((t-=2)<0)break;l.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;l.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;l.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return l}function base64ToBytes(e){return o.toByteArray(function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(A,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function blitBuffer(e,t,r,s){let o;for(o=0;o<s&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e}const m=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const s=16*r;for(let o=0;o<16;++o)t[s+o]=e[r]+e[o]}return t}();function defineBigIntMethod(e){return"undefined"==typeof BigInt?BufferBigIntNotDefined:e}function BufferBigIntNotDefined(){throw new Error("BigInt not supported")}},251:(e,t)=>{t.read=function(e,t,r,s,o){var l,c,h=8*o-s-1,d=(1<<h)-1,p=d>>1,A=-7,m=r?o-1:0,f=r?-1:1,g=e[t+m];for(m+=f,l=g&(1<<-A)-1,g>>=-A,A+=h;A>0;l=256*l+e[t+m],m+=f,A-=8);for(c=l&(1<<-A)-1,l>>=-A,A+=s;A>0;c=256*c+e[t+m],m+=f,A-=8);if(0===l)l=1-p;else{if(l===d)return c?NaN:1/0*(g?-1:1);c+=Math.pow(2,s),l-=p}return(g?-1:1)*c*Math.pow(2,l-s)},t.write=function(e,t,r,s,o,l){var c,h,d,p=8*l-o-1,A=(1<<p)-1,m=A>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,g=s?0:l-1,_=s?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(h=isNaN(t)?1:0,c=A):(c=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-c))<1&&(c--,d*=2),(t+=c+m>=1?f/d:f*Math.pow(2,1-m))*d>=2&&(c++,d/=2),c+m>=A?(h=0,c=A):c+m>=1?(h=(t*d-1)*Math.pow(2,o),c+=m):(h=t*Math.pow(2,m-1)*Math.pow(2,o),c=0));o>=8;e[r+g]=255&h,g+=_,h/=256,o-=8);for(c=c<<o|h,p+=o;p>0;e[r+g]=255&c,g+=_,c/=256,p-=8);e[r+g-_]|=128*y}},7599:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CanvasTexture:()=>CanvasTexture,FileLoader:()=>three_module_FileLoader,Loader:()=>Loader,ModelViewerElement:()=>YA,NearestFilter:()=>Ae});const i=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(r){r.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(r){r.createProperty(t.key,e)}};function n(e){return(t,r)=>void 0!==r?((e,t,r)=>{t.constructor.createProperty(r,e)})(e,t,r):i(e,t)}var s;null===(s=window.HTMLSlotElement)||void 0===s||s.prototype.assignedElements;var o=r(6763);const l="160",c=1,h=2,d=3,p=0,A=1,m=2,f=100,g=101,_=102,y=200,x=201,S=202,C=203,b=204,I=205,T=206,B=207,U=208,F=209,O=210,Q=211,G=212,W=213,q=214,j=0,X=1,Y=2,K=0,J=1,$=2,ee=3,te=4,ie=5,ne=6,re="attached",se=300,ae=301,oe=302,le=303,ce=304,he=306,ue=1e3,de=1001,pe=1002,Ae=1003,me=1004,fe=1005,ge=1006,_e=1007,ve=1008,ye=1009,Ee=1012,xe=1013,Se=1014,Me=1015,Ce=1016,be=1020,we=1023,Ie=1026,Te=1027,Be=1028,Re=1030,Le=33776,De=33777,Ue=33778,Pe=33779,Fe=35840,Ne=35842,Oe=36196,Qe=37492,ke=37496,Ge=37808,Ve=37812,He=36492,ze=2201,We=2202,qe=2300,je=2301,Xe=2302,Ye=2400,Ke=2401,Je=2402,$e=2500,Ze=3001,et="",tt="srgb",it="srgb-linear",nt="display-p3",rt="display-p3-linear",st="linear",at="srgb",ot="rec709",lt="p3",ct=7680,ht=512,ut=513,dt=514,pt=515,At=516,mt=517,ft=518,gt=519,_t=35044,vt="300 es",yt=1035,Et=2e3,xt=2001;class EventDispatcher{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const r=this._listeners;return void 0!==r[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const r=this._listeners[e];if(void 0!==r){const e=r.indexOf(t);-1!==e&&r.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 r=t.slice(0);for(let t=0,s=r.length;t<s;t++)r[t].call(this,e);e.target=null}}}const St=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Mt=1234567;const Ct=Math.PI/180,bt=180/Math.PI;function generateUUID(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return(St[255&e]+St[e>>8&255]+St[e>>16&255]+St[e>>24&255]+"-"+St[255&t]+St[t>>8&255]+"-"+St[t>>16&15|64]+St[t>>24&255]+"-"+St[63&r|128]+St[r>>8&255]+"-"+St[r>>16&255]+St[r>>24&255]+St[255&s]+St[s>>8&255]+St[s>>16&255]+St[s>>24&255]).toLowerCase()}function clamp(e,t,r){return Math.max(t,Math.min(r,e))}function euclideanModulo(e,t){return(e%t+t)%t}function lerp(e,t,r){return(1-r)*e+r*t}function isPowerOfTwo(e){return!(e&e-1)&&0!==e}function floorPowerOfTwo(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function denormalize(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 normalize(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 wt={DEG2RAD:Ct,RAD2DEG:bt,generateUUID,clamp,euclideanModulo,mapLinear:function mapLinear(e,t,r,s,o){return s+(e-t)*(o-s)/(r-t)},inverseLerp:function inverseLerp(e,t,r){return e!==t?(r-e)/(t-e):0},lerp,damp:function damp(e,t,r,s){return lerp(e,t,1-Math.exp(-r*s))},pingpong:function pingpong(e,t=1){return t-Math.abs(euclideanModulo(e,2*t)-t)},smoothstep:function smoothstep(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function smootherstep(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function randInt(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function randFloat(e,t){return e+Math.random()*(t-e)},randFloatSpread:function randFloatSpread(e){return e*(.5-Math.random())},seededRandom:function seededRandom(e){void 0!==e&&(Mt=e);let t=Mt+=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 degToRad(e){return e*Ct},radToDeg:function radToDeg(e){return e*bt},isPowerOfTwo,ceilPowerOfTwo:function ceilPowerOfTwo(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo,setQuaternionFromProperEuler:function setQuaternionFromProperEuler(e,t,r,s,l){const c=Math.cos,h=Math.sin,d=c(r/2),p=h(r/2),A=c((t+s)/2),m=h((t+s)/2),f=c((t-s)/2),g=h((t-s)/2),_=c((s-t)/2),y=h((s-t)/2);switch(l){case"XYX":e.set(d*m,p*f,p*g,d*A);break;case"YZY":e.set(p*g,d*m,p*f,d*A);break;case"ZXZ":e.set(p*f,p*g,d*m,d*A);break;case"XZX":e.set(d*m,p*y,p*_,d*A);break;case"YXY":e.set(p*_,d*m,p*y,d*A);break;case"ZYZ":e.set(p*y,p*_,d*m,d*A);break;default:o.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+l)}},normalize,denormalize};class Vector2{constructor(e=0,t=0){Vector2.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,r=this.y,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6],this.y=s[1]*t+s[4]*r+s[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 r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=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 r=this.dot(e)/t;return Math.acos(clamp(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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 r=Math.cos(t),s=Math.sin(t),o=this.x-e.x,l=this.y-e.y;return this.x=o*r-l*s+e.x,this.y=o*s+l*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Matrix3{constructor(e,t,r,s,o,l,c,h,d){Matrix3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,r,s,o,l,c,h,d)}set(e,t,r,s,o,l,c,h,d){const p=this.elements;return p[0]=e,p[1]=s,p[2]=c,p[3]=t,p[4]=o,p[5]=h,p[6]=r,p[7]=l,p[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.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 r=e.elements,s=t.elements,o=this.elements,l=r[0],c=r[3],h=r[6],d=r[1],p=r[4],A=r[7],m=r[2],f=r[5],g=r[8],_=s[0],y=s[3],x=s[6],S=s[1],C=s[4],b=s[7],I=s[2],T=s[5],B=s[8];return o[0]=l*_+c*S+h*I,o[3]=l*y+c*C+h*T,o[6]=l*x+c*b+h*B,o[1]=d*_+p*S+A*I,o[4]=d*y+p*C+A*T,o[7]=d*x+p*b+A*B,o[2]=m*_+f*S+g*I,o[5]=m*y+f*C+g*T,o[8]=m*x+f*b+g*B,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],r=e[1],s=e[2],o=e[3],l=e[4],c=e[5],h=e[6],d=e[7],p=e[8];return t*l*p-t*c*d-r*o*p+r*c*h+s*o*d-s*l*h}invert(){const e=this.elements,t=e[0],r=e[1],s=e[2],o=e[3],l=e[4],c=e[5],h=e[6],d=e[7],p=e[8],A=p*l-c*d,m=c*h-p*o,f=d*o-l*h,g=t*A+r*m+s*f;if(0===g)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=A*_,e[1]=(s*d-p*r)*_,e[2]=(c*r-s*l)*_,e[3]=m*_,e[4]=(p*t-s*h)*_,e[5]=(s*o-c*t)*_,e[6]=f*_,e[7]=(r*h-d*t)*_,e[8]=(l*t-r*o)*_,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,r,s,o,l,c){const h=Math.cos(o),d=Math.sin(o);return this.set(r*h,r*d,-r*(h*l+d*c)+l+e,-s*d,s*h,-s*(-d*l+h*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(It.makeScale(e,t)),this}rotate(e){return this.premultiply(It.makeRotation(-e)),this}translate(e,t){return this.premultiply(It.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),r=Math.sin(e);return this.set(t,-r,0,r,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,r=e.elements;for(let e=0;e<9;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const It=new Matrix3;function arrayNeedsUint32(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function createCanvasElement(){const e=createElementNS("canvas");return e.style.display="block",e}const Tt={};function warnOnce(e){e in Tt||(Tt[e]=!0,o.warn(e))}const Bt=(new Matrix3).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Rt=(new Matrix3).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Lt={[it]:{transfer:st,primaries:ot,toReference:e=>e,fromReference:e=>e},[tt]:{transfer:at,primaries:ot,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[rt]:{transfer:st,primaries:lt,toReference:e=>e.applyMatrix3(Rt),fromReference:e=>e.applyMatrix3(Bt)},[nt]:{transfer:at,primaries:lt,toReference:e=>e.convertSRGBToLinear().applyMatrix3(Rt),fromReference:e=>e.applyMatrix3(Bt).convertLinearToSRGB()}},Dt=new Set([it,rt]),Ut={enabled:!0,_workingColorSpace:it,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!Dt.has(e))throw new Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,r){if(!1===this.enabled||t===r||!t||!r)return e;const s=Lt[t].toReference;return(0,Lt[r].fromReference)(s(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return Lt[e].primaries},getTransfer:function(e){return e===et?st:Lt[e].transfer}};function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function LinearToSRGB(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let Pt;class ImageUtils{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===Pt&&(Pt=createElementNS("canvas")),Pt.width=e.width,Pt.height=e.height;const r=Pt.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=Pt}return t.width>2048||t.height>2048?(o.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=createElementNS("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const s=r.getImageData(0,0,e.width,e.height),o=s.data;for(let e=0;e<o.length;e++)o[e]=255*SRGBToLinear(o[e]/255);return r.putImageData(s,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*SRGBToLinear(t[e]/255)):t[e]=SRGBToLinear(t[e]);return{data:t,width:e.width,height:e.height}}return o.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ft=0;class Source{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ft++}),this.uuid=generateUUID(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const r={uuid:this.uuid,url:""},s=this.data;if(null!==s){let e;if(Array.isArray(s)){e=[];for(let t=0,r=s.length;t<r;t++)s[t].isDataTexture?e.push(serializeImage(s[t].image)):e.push(serializeImage(s[t]))}else e=serializeImage(s);r.url=e}return t||(e.images[this.uuid]=r),r}}function serializeImage(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ImageUtils.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(o.warn("THREE.Texture: Unable to serialize Texture."),{})}let Nt=0;class Texture extends EventDispatcher{constructor(e=Texture.DEFAULT_IMAGE,t=Texture.DEFAULT_MAPPING,r=1001,s=1001,o=1006,l=1008,c=1023,h=1009,d=Texture.DEFAULT_ANISOTROPY,p=et){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Nt++}),this.uuid=generateUUID(),this.name="",this.source=new Source(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=s,this.magFilter=o,this.minFilter=l,this.anisotropy=d,this.format=c,this.internalFormat=null,this.type=h,this.offset=new Vector2(0,0),this.repeat=new Vector2(1,1),this.center=new Vector2(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Matrix3,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof p?this.colorSpace=p:(warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=p===Ze?tt:et),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==se)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ue:e.x=e.x-Math.floor(e.x);break;case de:e.x=e.x<0?0:1;break;case pe: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 ue:e.y=e.y-Math.floor(e.y);break;case de:e.y=e.y<0?0:1;break;case pe: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 warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===tt?Ze:3e3}set encoding(e){warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ze?tt:et}}Texture.DEFAULT_IMAGE=null,Texture.DEFAULT_MAPPING=se,Texture.DEFAULT_ANISOTROPY=1;class Vector4{constructor(e=0,t=0,r=0,s=1){Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=s}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,r,s){return this.x=e,this.y=t,this.z=r,this.w=s,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,r=this.y,s=this.z,o=this.w,l=e.elements;return this.x=l[0]*t+l[4]*r+l[8]*s+l[12]*o,this.y=l[1]*t+l[5]*r+l[9]*s+l[13]*o,this.z=l[2]*t+l[6]*r+l[10]*s+l[14]*o,this.w=l[3]*t+l[7]*r+l[11]*s+l[15]*o,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,s,o;const l=.01,c=.1,h=e.elements,d=h[0],p=h[4],A=h[8],m=h[1],f=h[5],g=h[9],_=h[2],y=h[6],x=h[10];if(Math.abs(p-m)<l&&Math.abs(A-_)<l&&Math.abs(g-y)<l){if(Math.abs(p+m)<c&&Math.abs(A+_)<c&&Math.abs(g+y)<c&&Math.abs(d+f+x-3)<c)return this.set(1,0,0,0),this;t=Math.PI;const e=(d+1)/2,h=(f+1)/2,S=(x+1)/2,C=(p+m)/4,b=(A+_)/4,I=(g+y)/4;return e>h&&e>S?e<l?(r=0,s=.707106781,o=.707106781):(r=Math.sqrt(e),s=C/r,o=b/r):h>S?h<l?(r=.707106781,s=0,o=.707106781):(s=Math.sqrt(h),r=C/s,o=I/s):S<l?(r=.707106781,s=.707106781,o=0):(o=Math.sqrt(S),r=b/o,s=I/o),this.set(r,s,o,t),this}let S=Math.sqrt((y-g)*(y-g)+(A-_)*(A-_)+(m-p)*(m-p));return Math.abs(S)<.001&&(S=1),this.x=(y-g)/S,this.y=(A-_)/S,this.z=(m-p)/S,this.w=Math.acos((d+f+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class RenderTarget extends EventDispatcher{constructor(e=1,t=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new Vector4(0,0,e,t);const s={width:e,height:t,depth:1};void 0!==r.encoding&&(warnOnce("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Ze?tt:et),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ge,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Texture(s,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps,this.texture.internalFormat=r.internalFormat,this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}setSize(e,t,r=1){this.width===e&&this.height===t&&this.depth===r||(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Source(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class WebGLRenderTarget extends RenderTarget{constructor(e=1,t=1,r={}){super(e,t,r),this.isWebGLRenderTarget=!0}}class DataArrayTexture extends Texture{constructor(e=null,t=1,r=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:s},this.magFilter=Ae,this.minFilter=Ae,this.wrapR=de,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Data3DTexture extends Texture{constructor(e=null,t=1,r=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:s},this.magFilter=Ae,this.minFilter=Ae,this.wrapR=de,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class three_module_Quaternion{constructor(e=0,t=0,r=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=s}static slerpFlat(e,t,r,s,o,l,c){let h=r[s+0],d=r[s+1],p=r[s+2],A=r[s+3];const m=o[l+0],f=o[l+1],g=o[l+2],_=o[l+3];if(0===c)return e[t+0]=h,e[t+1]=d,e[t+2]=p,void(e[t+3]=A);if(1===c)return e[t+0]=m,e[t+1]=f,e[t+2]=g,void(e[t+3]=_);if(A!==_||h!==m||d!==f||p!==g){let e=1-c;const t=h*m+d*f+p*g+A*_,r=t>=0?1:-1,s=1-t*t;if(s>Number.EPSILON){const o=Math.sqrt(s),l=Math.atan2(o,t*r);e=Math.sin(e*l)/o,c=Math.sin(c*l)/o}const o=c*r;if(h=h*e+m*o,d=d*e+f*o,p=p*e+g*o,A=A*e+_*o,e===1-c){const e=1/Math.sqrt(h*h+d*d+p*p+A*A);h*=e,d*=e,p*=e,A*=e}}e[t]=h,e[t+1]=d,e[t+2]=p,e[t+3]=A}static multiplyQuaternionsFlat(e,t,r,s,o,l){const c=r[s],h=r[s+1],d=r[s+2],p=r[s+3],A=o[l],m=o[l+1],f=o[l+2],g=o[l+3];return e[t]=c*g+p*A+h*f-d*m,e[t+1]=h*g+p*m+d*A-c*f,e[t+2]=d*g+p*f+c*m-h*A,e[t+3]=p*g-c*A-h*m-d*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,r,s){return this._x=e,this._y=t,this._z=r,this._w=s,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=!0){const r=e._x,s=e._y,l=e._z,c=e._order,h=Math.cos,d=Math.sin,p=h(r/2),A=h(s/2),m=h(l/2),f=d(r/2),g=d(s/2),_=d(l/2);switch(c){case"XYZ":this._x=f*A*m+p*g*_,this._y=p*g*m-f*A*_,this._z=p*A*_+f*g*m,this._w=p*A*m-f*g*_;break;case"YXZ":this._x=f*A*m+p*g*_,this._y=p*g*m-f*A*_,this._z=p*A*_-f*g*m,this._w=p*A*m+f*g*_;break;case"ZXY":this._x=f*A*m-p*g*_,this._y=p*g*m+f*A*_,this._z=p*A*_+f*g*m,this._w=p*A*m-f*g*_;break;case"ZYX":this._x=f*A*m-p*g*_,this._y=p*g*m+f*A*_,this._z=p*A*_-f*g*m,this._w=p*A*m+f*g*_;break;case"YZX":this._x=f*A*m+p*g*_,this._y=p*g*m+f*A*_,this._z=p*A*_-f*g*m,this._w=p*A*m-f*g*_;break;case"XZY":this._x=f*A*m-p*g*_,this._y=p*g*m-f*A*_,this._z=p*A*_+f*g*m,this._w=p*A*m+f*g*_;break;default:o.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,s=Math.sin(r);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],s=t[4],o=t[8],l=t[1],c=t[5],h=t[9],d=t[2],p=t[6],A=t[10],m=r+c+A;if(m>0){const e=.5/Math.sqrt(m+1);this._w=.25/e,this._x=(p-h)*e,this._y=(o-d)*e,this._z=(l-s)*e}else if(r>c&&r>A){const e=2*Math.sqrt(1+r-c-A);this._w=(p-h)/e,this._x=.25*e,this._y=(s+l)/e,this._z=(o+d)/e}else if(c>A){const e=2*Math.sqrt(1+c-r-A);this._w=(o-d)/e,this._x=(s+l)/e,this._y=.25*e,this._z=(h+p)/e}else{const e=2*Math.sqrt(1+A-r-c);this._w=(l-s)/e,this._x=(o+d)/e,this._y=(h+p)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(0===r)return this;const s=Math.min(1,t/r);return this.slerp(e,s),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 r=e._x,s=e._y,o=e._z,l=e._w,c=t._x,h=t._y,d=t._z,p=t._w;return this._x=r*p+l*c+s*d-o*h,this._y=s*p+l*h+o*c-r*d,this._z=o*p+l*d+r*h-s*c,this._w=l*p-r*c-s*h-o*d,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const r=this._x,s=this._y,o=this._z,l=this._w;let c=l*e._w+r*e._x+s*e._y+o*e._z;if(c<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,c=-c):this.copy(e),c>=1)return this._w=l,this._x=r,this._y=s,this._z=o,this;const h=1-c*c;if(h<=Number.EPSILON){const e=1-t;return this._w=e*l+t*this._w,this._x=e*r+t*this._x,this._y=e*s+t*this._y,this._z=e*o+t*this._z,this.normalize(),this}const d=Math.sqrt(h),p=Math.atan2(d,c),A=Math.sin((1-t)*p)/d,m=Math.sin(t*p)/d;return this._w=l*A+this._w*m,this._x=r*A+this._x*m,this._y=s*A+this._y*m,this._z=o*A+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=Math.random(),t=Math.sqrt(1-e),r=Math.sqrt(e),s=2*Math.PI*Math.random(),o=2*Math.PI*Math.random();return this.set(t*Math.cos(s),r*Math.sin(o),r*Math.cos(o),t*Math.sin(s))}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._onChangeCallback(),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 three_module_Vector3{constructor(e=0,t=0,r=0){three_module_Vector3.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return void 0===r&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,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(Qt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Qt.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[3]*r+o[6]*s,this.y=o[1]*t+o[4]*r+o[7]*s,this.z=o[2]*t+o[5]*r+o[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,s=this.z,o=e.elements,l=1/(o[3]*t+o[7]*r+o[11]*s+o[15]);return this.x=(o[0]*t+o[4]*r+o[8]*s+o[12])*l,this.y=(o[1]*t+o[5]*r+o[9]*s+o[13])*l,this.z=(o[2]*t+o[6]*r+o[10]*s+o[14])*l,this}applyQuaternion(e){const t=this.x,r=this.y,s=this.z,o=e.x,l=e.y,c=e.z,h=e.w,d=2*(l*s-c*r),p=2*(c*t-o*s),A=2*(o*r-l*t);return this.x=t+h*d+l*A-c*p,this.y=r+h*p+c*d-o*A,this.z=s+h*A+o*p-l*d,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,r=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*s,this.y=o[1]*t+o[5]*r+o[9]*s,this.z=o[2]*t+o[6]*r+o[10]*s,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 r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,s=e.y,o=e.z,l=t.x,c=t.y,h=t.z;return this.x=s*h-o*c,this.y=o*l-r*h,this.z=r*c-s*l,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Ot.copy(this).projectOnVector(e),this.sub(Ot)}reflect(e){return this.sub(Ot.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 r=this.dot(e)/t;return Math.acos(clamp(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,s=this.z-e.z;return t*t+r*r+s*s}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,r){const s=Math.sin(t)*e;return this.x=s*Math.sin(r),this.y=Math.cos(t)*e,this.z=s*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=s,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,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ot=new three_module_Vector3,Qt=new three_module_Quaternion;class Box3{constructor(e=new three_module_Vector3(1/0,1/0,1/0),t=new three_module_Vector3(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t+=3)this.expandByPoint(Gt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(Gt.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const r=Gt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(void 0!==r){const s=r.getAttribute("position");if(!0===t&&void 0!==s&&!0!==e.isInstancedMesh)for(let t=0,r=s.count;t<r;t++)!0===e.isMesh?e.getVertexPosition(t,Gt):Gt.fromBufferAttribute(s,t),Gt.applyMatrix4(e.matrixWorld),this.expandByPoint(Gt);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),Vt.copy(e.boundingBox)):(null===r.boundingBox&&r.computeBoundingBox(),Vt.copy(r.boundingBox)),Vt.applyMatrix4(e.matrixWorld),this.union(Vt)}const s=e.children;for(let e=0,r=s.length;e<r;e++)this.expandByObject(s[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Gt),Gt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Yt),Kt.subVectors(this.max,Yt),Ht.subVectors(e.a,Yt),zt.subVectors(e.b,Yt),Wt.subVectors(e.c,Yt),qt.subVectors(zt,Ht),jt.subVectors(Wt,zt),Xt.subVectors(Ht,Wt);let t=[0,-qt.z,qt.y,0,-jt.z,jt.y,0,-Xt.z,Xt.y,qt.z,0,-qt.x,jt.z,0,-jt.x,Xt.z,0,-Xt.x,-qt.y,qt.x,0,-jt.y,jt.x,0,-Xt.y,Xt.x,0];return!!satForAxes(t,Ht,zt,Wt,Kt)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,Ht,zt,Wt,Kt)&&(Jt.crossVectors(qt,jt),t=[Jt.x,Jt.y,Jt.z],satForAxes(t,Ht,zt,Wt,Kt)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Gt).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()||(kt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kt)),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 kt=[new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3],Gt=new three_module_Vector3,Vt=new Box3,Ht=new three_module_Vector3,zt=new three_module_Vector3,Wt=new three_module_Vector3,qt=new three_module_Vector3,jt=new three_module_Vector3,Xt=new three_module_Vector3,Yt=new three_module_Vector3,Kt=new three_module_Vector3,Jt=new three_module_Vector3,$t=new three_module_Vector3;function satForAxes(e,t,r,s,o){for(let l=0,c=e.length-3;l<=c;l+=3){$t.fromArray(e,l);const c=o.x*Math.abs($t.x)+o.y*Math.abs($t.y)+o.z*Math.abs($t.z),h=t.dot($t),d=r.dot($t),p=s.dot($t);if(Math.max(-Math.max(h,d,p),Math.min(h,d,p))>c)return!1}return!0}const Zt=new Box3,ei=new three_module_Vector3,ti=new three_module_Vector3;class Sphere{constructor(e=new three_module_Vector3,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const r=this.center;void 0!==t?r.copy(t):Zt.setFromPoints(e).getCenter(r);let s=0;for(let t=0,o=e.length;t<o;t++)s=Math.max(s,r.distanceToSquared(e[t]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const r=this.center.distanceToSquared(e);return t.copy(e),r>this.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;ei.subVectors(e,this.center);const t=ei.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),r=.5*(e-this.radius);this.center.addScaledVector(ei,r/e),this.radius+=r}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):(ti.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ei.copy(e.center).add(ti)),this.expandByPoint(ei.copy(e.center).sub(ti))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ii=new three_module_Vector3,ni=new three_module_Vector3,ri=new three_module_Vector3,si=new three_module_Vector3,ai=new three_module_Vector3,oi=new three_module_Vector3,li=new three_module_Vector3;class Ray{constructor(e=new three_module_Vector3,t=new three_module_Vector3(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.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,ii)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ii.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ii.copy(this.origin).addScaledVector(this.direction,t),ii.distanceToSquared(e))}distanceSqToSegment(e,t,r,s){ni.copy(e).add(t).multiplyScalar(.5),ri.copy(t).sub(e).normalize(),si.copy(this.origin).sub(ni);const o=.5*e.distanceTo(t),l=-this.direction.dot(ri),c=si.dot(this.direction),h=-si.dot(ri),d=si.lengthSq(),p=Math.abs(1-l*l);let A,m,f,g;if(p>0)if(A=l*h-c,m=l*c-h,g=o*p,A>=0)if(m>=-g)if(m<=g){const e=1/p;A*=e,m*=e,f=A*(A+l*m+2*c)+m*(l*A+m+2*h)+d}else m=o,A=Math.max(0,-(l*m+c)),f=-A*A+m*(m+2*h)+d;else m=-o,A=Math.max(0,-(l*m+c)),f=-A*A+m*(m+2*h)+d;else m<=-g?(A=Math.max(0,-(-l*o+c)),m=A>0?-o:Math.min(Math.max(-o,-h),o),f=-A*A+m*(m+2*h)+d):m<=g?(A=0,m=Math.min(Math.max(-o,-h),o),f=m*(m+2*h)+d):(A=Math.max(0,-(l*o+c)),m=A>0?o:Math.min(Math.max(-o,-h),o),f=-A*A+m*(m+2*h)+d);else m=l>0?-o:o,A=Math.max(0,-(l*m+c)),f=-A*A+m*(m+2*h)+d;return r&&r.copy(this.origin).addScaledVector(this.direction,A),s&&s.copy(ni).addScaledVector(ri,m),f}intersectSphere(e,t){ii.subVectors(e.center,this.origin);const r=ii.dot(this.direction),s=ii.dot(ii)-r*r,o=e.radius*e.radius;if(s>o)return null;const l=Math.sqrt(o-s),c=r-l,h=r+l;return h<0?null:c<0?this.at(h,t):this.at(c,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 r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return null===r?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,s,o,l,c,h;const d=1/this.direction.x,p=1/this.direction.y,A=1/this.direction.z,m=this.origin;return d>=0?(r=(e.min.x-m.x)*d,s=(e.max.x-m.x)*d):(r=(e.max.x-m.x)*d,s=(e.min.x-m.x)*d),p>=0?(o=(e.min.y-m.y)*p,l=(e.max.y-m.y)*p):(o=(e.max.y-m.y)*p,l=(e.min.y-m.y)*p),r>l||o>s?null:((o>r||isNaN(r))&&(r=o),(l<s||isNaN(s))&&(s=l),A>=0?(c=(e.min.z-m.z)*A,h=(e.max.z-m.z)*A):(c=(e.max.z-m.z)*A,h=(e.min.z-m.z)*A),r>h||c>s?null:((c>r||r!=r)&&(r=c),(h<s||s!=s)&&(s=h),s<0?null:this.at(r>=0?r:s,t)))}intersectsBox(e){return null!==this.intersectBox(e,ii)}intersectTriangle(e,t,r,s,o){ai.subVectors(t,e),oi.subVectors(r,e),li.crossVectors(ai,oi);let l,c=this.direction.dot(li);if(c>0){if(s)return null;l=1}else{if(!(c<0))return null;l=-1,c=-c}si.subVectors(this.origin,e);const h=l*this.direction.dot(oi.crossVectors(si,oi));if(h<0)return null;const d=l*this.direction.dot(ai.cross(si));if(d<0)return null;if(h+d>c)return null;const p=-l*si.dot(li);return p<0?null:this.at(p/c,o)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class three_module_Matrix4{constructor(e,t,r,s,o,l,c,h,d,p,A,m,f,g,_,y){three_module_Matrix4.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,r,s,o,l,c,h,d,p,A,m,f,g,_,y)}set(e,t,r,s,o,l,c,h,d,p,A,m,f,g,_,y){const x=this.elements;return x[0]=e,x[4]=t,x[8]=r,x[12]=s,x[1]=o,x[5]=l,x[9]=c,x[13]=h,x[2]=d,x[6]=p,x[10]=A,x[14]=m,x[3]=f,x[7]=g,x[11]=_,x[15]=y,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 three_module_Matrix4).fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[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,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,s=1/ci.setFromMatrixColumn(e,0).length(),o=1/ci.setFromMatrixColumn(e,1).length(),l=1/ci.setFromMatrixColumn(e,2).length();return t[0]=r[0]*s,t[1]=r[1]*s,t[2]=r[2]*s,t[3]=0,t[4]=r[4]*o,t[5]=r[5]*o,t[6]=r[6]*o,t[7]=0,t[8]=r[8]*l,t[9]=r[9]*l,t[10]=r[10]*l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,s=e.y,o=e.z,l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s),p=Math.cos(o),A=Math.sin(o);if("XYZ"===e.order){const e=l*p,r=l*A,s=c*p,o=c*A;t[0]=h*p,t[4]=-h*A,t[8]=d,t[1]=r+s*d,t[5]=e-o*d,t[9]=-c*h,t[2]=o-e*d,t[6]=s+r*d,t[10]=l*h}else if("YXZ"===e.order){const e=h*p,r=h*A,s=d*p,o=d*A;t[0]=e+o*c,t[4]=s*c-r,t[8]=l*d,t[1]=l*A,t[5]=l*p,t[9]=-c,t[2]=r*c-s,t[6]=o+e*c,t[10]=l*h}else if("ZXY"===e.order){const e=h*p,r=h*A,s=d*p,o=d*A;t[0]=e-o*c,t[4]=-l*A,t[8]=s+r*c,t[1]=r+s*c,t[5]=l*p,t[9]=o-e*c,t[2]=-l*d,t[6]=c,t[10]=l*h}else if("ZYX"===e.order){const e=l*p,r=l*A,s=c*p,o=c*A;t[0]=h*p,t[4]=s*d-r,t[8]=e*d+o,t[1]=h*A,t[5]=o*d+e,t[9]=r*d-s,t[2]=-d,t[6]=c*h,t[10]=l*h}else if("YZX"===e.order){const e=l*h,r=l*d,s=c*h,o=c*d;t[0]=h*p,t[4]=o-e*A,t[8]=s*A+r,t[1]=A,t[5]=l*p,t[9]=-c*p,t[2]=-d*p,t[6]=r*A+s,t[10]=e-o*A}else if("XZY"===e.order){const e=l*h,r=l*d,s=c*h,o=c*d;t[0]=h*p,t[4]=-A,t[8]=d*p,t[1]=e*A+o,t[5]=l*p,t[9]=r*A-s,t[2]=s*A-r,t[6]=c*p,t[10]=o*A+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(ui,e,di)}lookAt(e,t,r){const s=this.elements;return mi.subVectors(e,t),0===mi.lengthSq()&&(mi.z=1),mi.normalize(),pi.crossVectors(r,mi),0===pi.lengthSq()&&(1===Math.abs(r.z)?mi.x+=1e-4:mi.z+=1e-4,mi.normalize(),pi.crossVectors(r,mi)),pi.normalize(),Ai.crossVectors(mi,pi),s[0]=pi.x,s[4]=Ai.x,s[8]=mi.x,s[1]=pi.y,s[5]=Ai.y,s[9]=mi.y,s[2]=pi.z,s[6]=Ai.z,s[10]=mi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,s=t.elements,o=this.elements,l=r[0],c=r[4],h=r[8],d=r[12],p=r[1],A=r[5],m=r[9],f=r[13],g=r[2],_=r[6],y=r[10],x=r[14],S=r[3],C=r[7],b=r[11],I=r[15],T=s[0],B=s[4],U=s[8],F=s[12],O=s[1],Q=s[5],G=s[9],W=s[13],q=s[2],j=s[6],X=s[10],Y=s[14],K=s[3],J=s[7],$=s[11],ee=s[15];return o[0]=l*T+c*O+h*q+d*K,o[4]=l*B+c*Q+h*j+d*J,o[8]=l*U+c*G+h*X+d*$,o[12]=l*F+c*W+h*Y+d*ee,o[1]=p*T+A*O+m*q+f*K,o[5]=p*B+A*Q+m*j+f*J,o[9]=p*U+A*G+m*X+f*$,o[13]=p*F+A*W+m*Y+f*ee,o[2]=g*T+_*O+y*q+x*K,o[6]=g*B+_*Q+y*j+x*J,o[10]=g*U+_*G+y*X+x*$,o[14]=g*F+_*W+y*Y+x*ee,o[3]=S*T+C*O+b*q+I*K,o[7]=S*B+C*Q+b*j+I*J,o[11]=S*U+C*G+b*X+I*$,o[15]=S*F+C*W+b*Y+I*ee,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],r=e[4],s=e[8],o=e[12],l=e[1],c=e[5],h=e[9],d=e[13],p=e[2],A=e[6],m=e[10],f=e[14];return e[3]*(+o*h*A-s*d*A-o*c*m+r*d*m+s*c*f-r*h*f)+e[7]*(+t*h*f-t*d*m+o*l*m-s*l*f+s*d*p-o*h*p)+e[11]*(+t*d*A-t*c*f-o*l*A+r*l*f+o*c*p-r*d*p)+e[15]*(-s*c*p-t*h*A+t*c*m+s*l*A-r*l*m+r*h*p)}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,r){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],s=e[2],o=e[3],l=e[4],c=e[5],h=e[6],d=e[7],p=e[8],A=e[9],m=e[10],f=e[11],g=e[12],_=e[13],y=e[14],x=e[15],S=A*y*d-_*m*d+_*h*f-c*y*f-A*h*x+c*m*x,C=g*m*d-p*y*d-g*h*f+l*y*f+p*h*x-l*m*x,b=p*_*d-g*A*d+g*c*f-l*_*f-p*c*x+l*A*x,I=g*A*h-p*_*h-g*c*m+l*_*m+p*c*y-l*A*y,T=t*S+r*C+s*b+o*I;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/T;return e[0]=S*B,e[1]=(_*m*o-A*y*o-_*s*f+r*y*f+A*s*x-r*m*x)*B,e[2]=(c*y*o-_*h*o+_*s*d-r*y*d-c*s*x+r*h*x)*B,e[3]=(A*h*o-c*m*o-A*s*d+r*m*d+c*s*f-r*h*f)*B,e[4]=C*B,e[5]=(p*y*o-g*m*o+g*s*f-t*y*f-p*s*x+t*m*x)*B,e[6]=(g*h*o-l*y*o-g*s*d+t*y*d+l*s*x-t*h*x)*B,e[7]=(l*m*o-p*h*o+p*s*d-t*m*d-l*s*f+t*h*f)*B,e[8]=b*B,e[9]=(g*A*o-p*_*o-g*r*f+t*_*f+p*r*x-t*A*x)*B,e[10]=(l*_*o-g*c*o+g*r*d-t*_*d-l*r*x+t*c*x)*B,e[11]=(p*c*o-l*A*o-p*r*d+t*A*d+l*r*f-t*c*f)*B,e[12]=I*B,e[13]=(p*_*s-g*A*s+g*r*m-t*_*m-p*r*y+t*A*y)*B,e[14]=(g*c*s-l*_*s-g*r*h+t*_*h+l*r*y-t*c*y)*B,e[15]=(l*A*s-p*c*s+p*r*h-t*A*h-l*r*m+t*c*m)*B,this}scale(e){const t=this.elements,r=e.x,s=e.y,o=e.z;return t[0]*=r,t[4]*=s,t[8]*=o,t[1]*=r,t[5]*=s,t[9]*=o,t[2]*=r,t[6]*=s,t[10]*=o,t[3]*=r,t[7]*=s,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,s))}makeTranslation(e,t,r){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,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),s=Math.sin(t),o=1-r,l=e.x,c=e.y,h=e.z,d=o*l,p=o*c;return this.set(d*l+r,d*c-s*h,d*h+s*c,0,d*c+s*h,p*c+r,p*h-s*l,0,d*h-s*c,p*h+s*l,o*h*h+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,s,o,l){return this.set(1,r,o,0,e,1,l,0,t,s,1,0,0,0,0,1),this}compose(e,t,r){const s=this.elements,o=t._x,l=t._y,c=t._z,h=t._w,d=o+o,p=l+l,A=c+c,m=o*d,f=o*p,g=o*A,_=l*p,y=l*A,x=c*A,S=h*d,C=h*p,b=h*A,I=r.x,T=r.y,B=r.z;return s[0]=(1-(_+x))*I,s[1]=(f+b)*I,s[2]=(g-C)*I,s[3]=0,s[4]=(f-b)*T,s[5]=(1-(m+x))*T,s[6]=(y+S)*T,s[7]=0,s[8]=(g+C)*B,s[9]=(y-S)*B,s[10]=(1-(m+_))*B,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,r){const s=this.elements;let o=ci.set(s[0],s[1],s[2]).length();const l=ci.set(s[4],s[5],s[6]).length(),c=ci.set(s[8],s[9],s[10]).length();this.determinant()<0&&(o=-o),e.x=s[12],e.y=s[13],e.z=s[14],hi.copy(this);const h=1/o,d=1/l,p=1/c;return hi.elements[0]*=h,hi.elements[1]*=h,hi.elements[2]*=h,hi.elements[4]*=d,hi.elements[5]*=d,hi.elements[6]*=d,hi.elements[8]*=p,hi.elements[9]*=p,hi.elements[10]*=p,t.setFromRotationMatrix(hi),r.x=o,r.y=l,r.z=c,this}makePerspective(e,t,r,s,o,l,c=2e3){const h=this.elements,d=2*o/(t-e),p=2*o/(r-s),A=(t+e)/(t-e),m=(r+s)/(r-s);let f,g;if(c===Et)f=-(l+o)/(l-o),g=-2*l*o/(l-o);else{if(c!==xt)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);f=-l/(l-o),g=-l*o/(l-o)}return h[0]=d,h[4]=0,h[8]=A,h[12]=0,h[1]=0,h[5]=p,h[9]=m,h[13]=0,h[2]=0,h[6]=0,h[10]=f,h[14]=g,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,r,s,o,l,c=2e3){const h=this.elements,d=1/(t-e),p=1/(r-s),A=1/(l-o),m=(t+e)*d,f=(r+s)*p;let g,_;if(c===Et)g=(l+o)*A,_=-2*A;else{if(c!==xt)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);g=o*A,_=-1*A}return h[0]=2*d,h[4]=0,h[8]=0,h[12]=-m,h[1]=0,h[5]=2*p,h[9]=0,h[13]=-f,h[2]=0,h[6]=0,h[10]=_,h[14]=-g,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let e=0;e<16;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const ci=new three_module_Vector3,hi=new three_module_Matrix4,ui=new three_module_Vector3(0,0,0),di=new three_module_Vector3(1,1,1),pi=new three_module_Vector3,Ai=new three_module_Vector3,mi=new three_module_Vector3,fi=new three_module_Matrix4,gi=new three_module_Quaternion;class Euler{constructor(e=0,t=0,r=0,s=Euler.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=s}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,r,s=this._order){return this._x=e,this._y=t,this._z=r,this._order=s,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,r=!0){const s=e.elements,l=s[0],c=s[4],h=s[8],d=s[1],p=s[5],A=s[9],m=s[2],f=s[6],g=s[10];switch(t){case"XYZ":this._y=Math.asin(clamp(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-A,g),this._z=Math.atan2(-c,l)):(this._x=Math.atan2(f,p),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(h,g),this._z=Math.atan2(d,p)):(this._y=Math.atan2(-m,l),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-m,g),this._z=Math.atan2(-c,p)):(this._y=0,this._z=Math.atan2(d,l));break;case"ZYX":this._y=Math.asin(-clamp(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(f,g),this._z=Math.atan2(d,l)):(this._x=0,this._z=Math.atan2(-c,p));break;case"YZX":this._z=Math.asin(clamp(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(-A,p),this._y=Math.atan2(-m,l)):(this._x=0,this._y=Math.atan2(h,g));break;case"XZY":this._z=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(f,p),this._y=Math.atan2(h,l)):(this._x=Math.atan2(-A,g),this._y=0);break;default:o.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===r&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return fi.makeRotationFromQuaternion(e),this.setFromRotationMatrix(fi,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gi.setFromEuler(this),this.setFromQuaternion(gi,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}}Euler.DEFAULT_ORDER="XYZ";class Layers{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return!!(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let _i=0;const vi=new three_module_Vector3,yi=new three_module_Quaternion,xi=new three_module_Matrix4,Mi=new three_module_Vector3,Ci=new three_module_Vector3,bi=new three_module_Vector3,wi=new three_module_Quaternion,Ti=new three_module_Vector3(1,0,0),Bi=new three_module_Vector3(0,1,0),Ri=new three_module_Vector3(0,0,1),Li={type:"added"},Di={type:"removed"};class Object3D extends EventDispatcher{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_i++}),this.uuid=generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Object3D.DEFAULT_UP.clone();const e=new three_module_Vector3,t=new Euler,r=new three_module_Quaternion,s=new three_module_Vector3(1,1,1);t._onChange((function onRotationChange(){r.setFromEuler(t,!1)})),r._onChange((function onQuaternionChange(){t.setFromQuaternion(r,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new three_module_Matrix4},normalMatrix:{value:new Matrix3}}),this.matrix=new three_module_Matrix4,this.matrixWorld=new three_module_Matrix4,this.matrixAutoUpdate=Object3D.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return yi.setFromAxisAngle(e,t),this.quaternion.multiply(yi),this}rotateOnWorldAxis(e,t){return yi.setFromAxisAngle(e,t),this.quaternion.premultiply(yi),this}rotateX(e){return this.rotateOnAxis(Ti,e)}rotateY(e){return this.rotateOnAxis(Bi,e)}rotateZ(e){return this.rotateOnAxis(Ri,e)}translateOnAxis(e,t){return vi.copy(e).applyQuaternion(this.quaternion),this.position.add(vi.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ti,e)}translateY(e){return this.translateOnAxis(Bi,e)}translateZ(e){return this.translateOnAxis(Ri,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(xi.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?Mi.copy(e):Mi.set(e,t,r);const s=this.parent;this.updateWorldMatrix(!0,!1),Ci.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xi.lookAt(Ci,Mi,this.up):xi.lookAt(Mi,Ci,this.up),this.quaternion.setFromRotationMatrix(xi),s&&(xi.extractRotation(s.matrixWorld),yi.setFromRotationMatrix(xi),this.quaternion.premultiply(yi.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(o.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Li)):o.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Di)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),xi.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),xi.multiply(e.parent.matrixWorld)),e.applyMatrix4(xi),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let r=0,s=this.children.length;r<s;r++){const s=this.children[r].getObjectByProperty(e,t);if(void 0!==s)return s}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);const s=this.children;for(let o=0,l=s.length;o<l;o++)s[o].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ci,e,bi),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ci,wi,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 r=0,s=t.length;r<s;r++)t[r].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let r=0,s=t.length;r<s;r++)t[r].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let r=0,s=t.length;r<s;r++){const s=t[r];!0!==s.matrixWorldAutoUpdate&&!0!==e||s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const r=this.parent;if(!0===e&&null!==r&&!0===r.matrixWorldAutoUpdate&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,r=e.length;t<r;t++){const r=e[t];!0===r.matrixWorldAutoUpdate&&r.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};function serialize(t,r){return void 0===t[r.uuid]&&(t[r.uuid]=r.toJSON(e)),r.uuid}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),!0===this.castShadow&&(s.castShadow=!0),!0===this.receiveShadow&&(s.receiveShadow=!0),!1===this.visible&&(s.visible=!1),!1===this.frustumCulled&&(s.frustumCulled=!1),0!==this.renderOrder&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),s.maxGeometryCount=this._maxGeometryCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(e),null!==this.boundingSphere&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),null!==this.boundingBox&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=serialize(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const r=t.shapes;if(Array.isArray(r))for(let t=0,s=r.length;t<s;t++){const s=r[t];serialize(e.shapes,s)}else serialize(e.shapes,r)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(serialize(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let r=0,s=this.material.length;r<s;r++)t.push(serialize(e.materials,this.material[r]));s.material=t}else s.material=serialize(e.materials,this.material);if(this.children.length>0){s.children=[];for(let t=0;t<this.children.length;t++)s.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let t=0;t<this.animations.length;t++){const r=this.animations[t];s.animations.push(serialize(e.animations,r))}}if(t){const t=extractFromCache(e.geometries),s=extractFromCache(e.materials),o=extractFromCache(e.textures),l=extractFromCache(e.images),c=extractFromCache(e.shapes),h=extractFromCache(e.skeletons),d=extractFromCache(e.animations),p=extractFromCache(e.nodes);t.length>0&&(r.geometries=t),s.length>0&&(r.materials=s),o.length>0&&(r.textures=o),l.length>0&&(r.images=l),c.length>0&&(r.shapes=c),h.length>0&&(r.skeletons=h),d.length>0&&(r.animations=d),p.length>0&&(r.nodes=p)}return r.object=s,r;function extractFromCache(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,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;t<e.children.length;t++){const r=e.children[t];this.add(r.clone())}return this}}Object3D.DEFAULT_UP=new three_module_Vector3(0,1,0),Object3D.DEFAULT_MATRIX_AUTO_UPDATE=!0,Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ui=new three_module_Vector3,Fi=new three_module_Vector3,Ni=new three_module_Vector3,Oi=new three_module_Vector3,Qi=new three_module_Vector3,ki=new three_module_Vector3,Gi=new three_module_Vector3,Vi=new three_module_Vector3,Hi=new three_module_Vector3,zi=new three_module_Vector3;let Wi=!1;class Triangle{constructor(e=new three_module_Vector3,t=new three_module_Vector3,r=new three_module_Vector3){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,s){s.subVectors(r,t),Ui.subVectors(e,t),s.cross(Ui);const o=s.lengthSq();return o>0?s.multiplyScalar(1/Math.sqrt(o)):s.set(0,0,0)}static getBarycoord(e,t,r,s,o){Ui.subVectors(s,t),Fi.subVectors(r,t),Ni.subVectors(e,t);const l=Ui.dot(Ui),c=Ui.dot(Fi),h=Ui.dot(Ni),d=Fi.dot(Fi),p=Fi.dot(Ni),A=l*d-c*c;if(0===A)return o.set(0,0,0),null;const m=1/A,f=(d*h-c*p)*m,g=(l*p-c*h)*m;return o.set(1-f-g,g,f)}static containsPoint(e,t,r,s){return null!==this.getBarycoord(e,t,r,s,Oi)&&(Oi.x>=0&&Oi.y>=0&&Oi.x+Oi.y<=1)}static getUV(e,t,r,s,l,c,h,d){return!1===Wi&&(o.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Wi=!0),this.getInterpolation(e,t,r,s,l,c,h,d)}static getInterpolation(e,t,r,s,o,l,c,h){return null===this.getBarycoord(e,t,r,s,Oi)?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(o,Oi.x),h.addScaledVector(l,Oi.y),h.addScaledVector(c,Oi.z),h)}static isFrontFacing(e,t,r,s){return Ui.subVectors(r,t),Fi.subVectors(e,t),Ui.cross(Fi).dot(s)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,s){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,r,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,s),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 Ui.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),.5*Ui.cross(Fi).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,s,l){return!1===Wi&&(o.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Wi=!0),Triangle.getInterpolation(e,this.a,this.b,this.c,t,r,s,l)}getInterpolation(e,t,r,s,o){return Triangle.getInterpolation(e,this.a,this.b,this.c,t,r,s,o)}containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,s=this.b,o=this.c;let l,c;Qi.subVectors(s,r),ki.subVectors(o,r),Vi.subVectors(e,r);const h=Qi.dot(Vi),d=ki.dot(Vi);if(h<=0&&d<=0)return t.copy(r);Hi.subVectors(e,s);const p=Qi.dot(Hi),A=ki.dot(Hi);if(p>=0&&A<=p)return t.copy(s);const m=h*A-p*d;if(m<=0&&h>=0&&p<=0)return l=h/(h-p),t.copy(r).addScaledVector(Qi,l);zi.subVectors(e,o);const f=Qi.dot(zi),g=ki.dot(zi);if(g>=0&&f<=g)return t.copy(o);const _=f*d-h*g;if(_<=0&&d>=0&&g<=0)return c=d/(d-g),t.copy(r).addScaledVector(ki,c);const y=p*g-f*A;if(y<=0&&A-p>=0&&f-g>=0)return Gi.subVectors(o,s),c=(A-p)/(A-p+(f-g)),t.copy(s).addScaledVector(Gi,c);const x=1/(y+_+m);return l=_*x,c=m*x,t.copy(r).addScaledVector(Qi,l).addScaledVector(ki,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const qi={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},ji={h:0,s:0,l:0},Xi={h:0,s:0,l:0};function hue2rgb(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}class Color{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(void 0===t&&void 0===r){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,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=tt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Ut.toWorkingColorSpace(this,t),this}setRGB(e,t,r,s=Ut.workingColorSpace){return this.r=e,this.g=t,this.b=r,Ut.toWorkingColorSpace(this,s),this}setHSL(e,t,r,s=Ut.workingColorSpace){if(e=euclideanModulo(e,1),t=clamp(t,0,1),r=clamp(r,0,1),0===t)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,o=2*r-s;this.r=hue2rgb(o,s,e+1/3),this.g=hue2rgb(o,s,e),this.b=hue2rgb(o,s,e-1/3)}return Ut.toWorkingColorSpace(this,s),this}setStyle(e,t=tt){function handleAlpha(t){void 0!==t&&parseFloat(t)<1&&o.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const l=r[1],c=r[2];switch(l){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return handleAlpha(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return handleAlpha(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return handleAlpha(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:o.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],l=s.length;if(3===l)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(6===l)return this.setHex(parseInt(s,16),t);o.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=tt){const r=qi[e.toLowerCase()];return void 0!==r?this.setHex(r,t):o.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=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=tt){return Ut.fromWorkingColorSpace(Yi.copy(this),e),65536*Math.round(clamp(255*Yi.r,0,255))+256*Math.round(clamp(255*Yi.g,0,255))+Math.round(clamp(255*Yi.b,0,255))}getHexString(e=tt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ut.workingColorSpace){Ut.fromWorkingColorSpace(Yi.copy(this),t);const r=Yi.r,s=Yi.g,o=Yi.b,l=Math.max(r,s,o),c=Math.min(r,s,o);let h,d;const p=(c+l)/2;if(c===l)h=0,d=0;else{const e=l-c;switch(d=p<=.5?e/(l+c):e/(2-l-c),l){case r:h=(s-o)/e+(s<o?6:0);break;case s:h=(o-r)/e+2;break;case o:h=(r-s)/e+4}h/=6}return e.h=h,e.s=d,e.l=p,e}getRGB(e,t=Ut.workingColorSpace){return Ut.fromWorkingColorSpace(Yi.copy(this),t),e.r=Yi.r,e.g=Yi.g,e.b=Yi.b,e}getStyle(e=tt){Ut.fromWorkingColorSpace(Yi.copy(this),e);const t=Yi.r,r=Yi.g,s=Yi.b;return e!==tt?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*r)},${Math.round(255*s)})`}offsetHSL(e,t,r){return this.getHSL(ji),this.setHSL(ji.h+e,ji.s+t,ji.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(ji),e.getHSL(Xi);const r=lerp(ji.h,Xi.h,t),s=lerp(ji.s,Xi.s,t),o=lerp(ji.l,Xi.l,t);return this.setHSL(r,s,o),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,r=this.g,s=this.b,o=e.elements;return this.r=o[0]*t+o[3]*r+o[6]*s,this.g=o[1]*t+o[4]*r+o[7]*s,this.b=o[2]*t+o[5]*r+o[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Yi=new Color;Color.NAMES=qi;let Ki=0;class Material extends EventDispatcher{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ki++}),this.uuid=generateUUID(),this.name="",this.type="Material",this.blending=1,this.side=p,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=f,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Color(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ct,this.stencilZFail=ct,this.stencilZPass=ct,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 r=e[t];if(void 0===r){o.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];void 0!==s?s&&s.isColor?s.set(r):s&&s.isVector3&&r&&r.isVector3?s.copy(r):this[t]=r:o.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 r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function extractFromCache(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(r.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(r.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(r.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(r.combine=this.combine)),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(r.blending=this.blending),this.side!==p&&(r.side=this.side),!0===this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=!0),204!==this.blendSrc&&(r.blendSrc=this.blendSrc),205!==this.blendDst&&(r.blendDst=this.blendDst),this.blendEquation!==f&&(r.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(r.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(r.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(r.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(r.depthFunc=this.depthFunc),!1===this.depthTest&&(r.depthTest=this.depthTest),!1===this.depthWrite&&(r.depthWrite=this.depthWrite),!1===this.colorWrite&&(r.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(r.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(r.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(r.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ct&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ct&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ct&&(r.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(r.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.alphaHash&&(r.alphaHash=!0),!0===this.alphaToCoverage&&(r.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=!0),!0===this.forceSinglePass&&(r.forceSinglePass=!0),!0===this.wireframe&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=!0),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),!1===this.fog&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData),t){const t=extractFromCache(e.textures),s=extractFromCache(e.images);t.length>0&&(r.textures=t),s.length>0&&(r.images=s)}return r}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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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 r=null;if(null!==t){const e=t.length;r=new Array(e);for(let s=0;s!==e;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,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++}}class MeshBasicMaterial extends Material{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=j,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ji=_generateTables();function _generateTables(){const e=new ArrayBuffer(4),t=new Float32Array(e),r=new Uint32Array(e),s=new Uint32Array(512),o=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(s[e]=0,s[256|e]=32768,o[e]=24,o[256|e]=24):t<-14?(s[e]=1024>>-t-14,s[256|e]=1024>>-t-14|32768,o[e]=-t-1,o[256|e]=-t-1):t<=15?(s[e]=t+15<<10,s[256|e]=t+15<<10|32768,o[e]=13,o[256|e]=13):t<128?(s[e]=31744,s[256|e]=64512,o[e]=24,o[256|e]=24):(s[e]=31744,s[256|e]=64512,o[e]=13,o[256|e]=13)}const l=new Uint32Array(2048),c=new Uint32Array(64),h=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,r=0;for(;!(8388608&t);)t<<=1,r-=8388608;t&=-8388609,r+=947912704,l[e]=t|r}for(let e=1024;e<2048;++e)l[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)c[e]=e<<23;c[31]=1199570944,c[32]=2147483648;for(let e=33;e<63;++e)c[e]=2147483648+(e-32<<23);c[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(h[e]=1024);return{floatView:t,uint32View:r,baseTable:s,shiftTable:o,mantissaTable:l,exponentTable:c,offsetTable:h}}function toHalfFloat(e){Math.abs(e)>65504&&o.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=clamp(e,-65504,65504),Ji.floatView[0]=e;const t=Ji.uint32View[0],r=t>>23&511;return Ji.baseTable[r]+((8388607&t)>>Ji.shiftTable[r])}function fromHalfFloat(e){const t=e>>10;return Ji.uint32View[0]=Ji.mantissaTable[Ji.offsetTable[t]+(1023&e)]+Ji.exponentTable[t],Ji.floatView[0]}const $i={toHalfFloat,fromHalfFloat},Zi=new three_module_Vector3,en=new Vector2;class three_module_BufferAttribute{constructor(e,t,r=!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=r,this.usage=_t,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Me,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return o.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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,r){e*=this.itemSize,r*=t.itemSize;for(let s=0,o=this.itemSize;s<o;s++)this.array[e+s]=t.array[r+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,r=this.count;t<r;t++)en.fromBufferAttribute(this,t),en.applyMatrix3(e),this.setXY(t,en.x,en.y);else if(3===this.itemSize)for(let t=0,r=this.count;t<r;t++)Zi.fromBufferAttribute(this,t),Zi.applyMatrix3(e),this.setXYZ(t,Zi.x,Zi.y,Zi.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)Zi.fromBufferAttribute(this,t),Zi.applyMatrix4(e),this.setXYZ(t,Zi.x,Zi.y,Zi.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)Zi.fromBufferAttribute(this,t),Zi.applyNormalMatrix(e),this.setXYZ(t,Zi.x,Zi.y,Zi.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)Zi.fromBufferAttribute(this,t),Zi.transformDirection(e),this.setXYZ(t,Zi.x,Zi.y,Zi.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=denormalize(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=normalize(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=denormalize(t,this.array)),t}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=denormalize(t,this.array)),t}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=denormalize(t,this.array)),t}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=denormalize(t,this.array)),t}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,s){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=s,this}setXYZW(e,t,r,s,o){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array),o=normalize(o,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=s,this.array[e+3]=o,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==_t&&(e.usage=this.usage),e}}class Uint16BufferAttribute extends three_module_BufferAttribute{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class Uint32BufferAttribute extends three_module_BufferAttribute{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class three_module_Float32BufferAttribute extends three_module_BufferAttribute{constructor(e,t,r){super(new Float32Array(e),t,r)}}let tn=0;const nn=new three_module_Matrix4,rn=new Object3D,sn=new three_module_Vector3,an=new Box3,on=new Box3,ln=new three_module_Vector3;class three_module_BufferGeometry extends EventDispatcher{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:tn++}),this.uuid=generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(arrayNeedsUint32(e)?Uint32BufferAttribute:Uint16BufferAttribute)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(void 0!==r){const t=(new Matrix3).getNormalMatrix(e);r.applyNormalMatrix(t),r.needsUpdate=!0}const s=this.attributes.tangent;return void 0!==s&&(s.transformDirection(e),s.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return nn.makeRotationFromQuaternion(e),this.applyMatrix4(nn),this}rotateX(e){return nn.makeRotationX(e),this.applyMatrix4(nn),this}rotateY(e){return nn.makeRotationY(e),this.applyMatrix4(nn),this}rotateZ(e){return nn.makeRotationZ(e),this.applyMatrix4(nn),this}translate(e,t,r){return nn.makeTranslation(e,t,r),this.applyMatrix4(nn),this}scale(e,t,r){return nn.makeScale(e,t,r),this.applyMatrix4(nn),this}lookAt(e){return rn.lookAt(e),rn.updateMatrix(),this.applyMatrix4(rn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(sn).negate(),this.translate(sn.x,sn.y,sn.z),this}setFromPoints(e){const t=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new three_module_Float32BufferAttribute(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Box3);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return o.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new three_module_Vector3(-1/0,-1/0,-1/0),new three_module_Vector3(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){const r=t[e];an.setFromBufferAttribute(r),this.morphTargetsRelative?(ln.addVectors(this.boundingBox.min,an.min),this.boundingBox.expandByPoint(ln),ln.addVectors(this.boundingBox.max,an.max),this.boundingBox.expandByPoint(ln)):(this.boundingBox.expandByPoint(an.min),this.boundingBox.expandByPoint(an.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&o.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sphere);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return o.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new three_module_Vector3,1/0);if(e){const r=this.boundingSphere.center;if(an.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){const r=t[e];on.setFromBufferAttribute(r),this.morphTargetsRelative?(ln.addVectors(an.min,on.min),an.expandByPoint(ln),ln.addVectors(an.max,on.max),an.expandByPoint(ln)):(an.expandByPoint(on.min),an.expandByPoint(on.max))}an.getCenter(r);let s=0;for(let t=0,o=e.count;t<o;t++)ln.fromBufferAttribute(e,t),s=Math.max(s,r.distanceToSquared(ln));if(t)for(let o=0,l=t.length;o<l;o++){const l=t[o],c=this.morphTargetsRelative;for(let t=0,o=l.count;t<o;t++)ln.fromBufferAttribute(l,t),c&&(sn.fromBufferAttribute(e,t),ln.add(sn)),s=Math.max(s,r.distanceToSquared(ln))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&o.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void o.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const r=e.array,s=t.position.array,l=t.normal.array,c=t.uv.array,h=s.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new three_module_BufferAttribute(new Float32Array(4*h),4));const d=this.getAttribute("tangent").array,p=[],A=[];for(let e=0;e<h;e++)p[e]=new three_module_Vector3,A[e]=new three_module_Vector3;const m=new three_module_Vector3,f=new three_module_Vector3,g=new three_module_Vector3,_=new Vector2,y=new Vector2,x=new Vector2,S=new three_module_Vector3,C=new three_module_Vector3;function handleTriangle(e,t,r){m.fromArray(s,3*e),f.fromArray(s,3*t),g.fromArray(s,3*r),_.fromArray(c,2*e),y.fromArray(c,2*t),x.fromArray(c,2*r),f.sub(m),g.sub(m),y.sub(_),x.sub(_);const o=1/(y.x*x.y-x.x*y.y);isFinite(o)&&(S.copy(f).multiplyScalar(x.y).addScaledVector(g,-y.y).multiplyScalar(o),C.copy(g).multiplyScalar(y.x).addScaledVector(f,-x.x).multiplyScalar(o),p[e].add(S),p[t].add(S),p[r].add(S),A[e].add(C),A[t].add(C),A[r].add(C))}let b=this.groups;0===b.length&&(b=[{start:0,count:r.length}]);for(let e=0,t=b.length;e<t;++e){const t=b[e],s=t.start;for(let e=s,o=s+t.count;e<o;e+=3)handleTriangle(r[e+0],r[e+1],r[e+2])}const I=new three_module_Vector3,T=new three_module_Vector3,B=new three_module_Vector3,U=new three_module_Vector3;function handleVertex(e){B.fromArray(l,3*e),U.copy(B);const t=p[e];I.copy(t),I.sub(B.multiplyScalar(B.dot(t))).normalize(),T.crossVectors(U,t);const r=T.dot(A[e])<0?-1:1;d[4*e]=I.x,d[4*e+1]=I.y,d[4*e+2]=I.z,d[4*e+3]=r}for(let e=0,t=b.length;e<t;++e){const t=b[e],s=t.start;for(let e=s,o=s+t.count;e<o;e+=3)handleVertex(r[e+0]),handleVertex(r[e+1]),handleVertex(r[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let r=this.getAttribute("normal");if(void 0===r)r=new three_module_BufferAttribute(new Float32Array(3*t.count),3),this.setAttribute("normal",r);else for(let e=0,t=r.count;e<t;e++)r.setXYZ(e,0,0,0);const s=new three_module_Vector3,o=new three_module_Vector3,l=new three_module_Vector3,c=new three_module_Vector3,h=new three_module_Vector3,d=new three_module_Vector3,p=new three_module_Vector3,A=new three_module_Vector3;if(e)for(let m=0,f=e.count;m<f;m+=3){const f=e.getX(m+0),g=e.getX(m+1),_=e.getX(m+2);s.fromBufferAttribute(t,f),o.fromBufferAttribute(t,g),l.fromBufferAttribute(t,_),p.subVectors(l,o),A.subVectors(s,o),p.cross(A),c.fromBufferAttribute(r,f),h.fromBufferAttribute(r,g),d.fromBufferAttribute(r,_),c.add(p),h.add(p),d.add(p),r.setXYZ(f,c.x,c.y,c.z),r.setXYZ(g,h.x,h.y,h.z),r.setXYZ(_,d.x,d.y,d.z)}else for(let e=0,c=t.count;e<c;e+=3)s.fromBufferAttribute(t,e+0),o.fromBufferAttribute(t,e+1),l.fromBufferAttribute(t,e+2),p.subVectors(l,o),A.subVectors(s,o),p.cross(A),r.setXYZ(e+0,p.x,p.y,p.z),r.setXYZ(e+1,p.x,p.y,p.z),r.setXYZ(e+2,p.x,p.y,p.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)ln.fromBufferAttribute(e,t),ln.normalize(),e.setXYZ(t,ln.x,ln.y,ln.z)}toNonIndexed(){function convertBufferAttribute(e,t){const r=e.array,s=e.itemSize,o=e.normalized,l=new r.constructor(t.length*s);let c=0,h=0;for(let o=0,d=t.length;o<d;o++){c=e.isInterleavedBufferAttribute?t[o]*e.data.stride+e.offset:t[o]*s;for(let e=0;e<s;e++)l[h++]=r[c++]}return new three_module_BufferAttribute(l,s,o)}if(null===this.index)return o.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new three_module_BufferGeometry,t=this.index.array,r=this.attributes;for(const s in r){const o=convertBufferAttribute(r[s],t);e.setAttribute(s,o)}const s=this.morphAttributes;for(const r in s){const o=[],l=s[r];for(let e=0,r=l.length;e<r;e++){const r=convertBufferAttribute(l[e],t);o.push(r)}e.morphAttributes[r]=o}e.morphTargetsRelative=this.morphTargetsRelative;const l=this.groups;for(let t=0,r=l.length;t<r;t++){const r=l[t];e.addGroup(r.start,r.count,r.materialIndex)}return e}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const r in t)void 0!==t[r]&&(e[r]=t[r]);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 r=this.attributes;for(const t in r){const s=r[t];e.data.attributes[t]=s.toJSON(e.data)}const s={};let o=!1;for(const t in this.morphAttributes){const r=this.morphAttributes[t],l=[];for(let t=0,s=r.length;t<s;t++){const s=r[t];l.push(s.toJSON(e.data))}l.length>0&&(s[t]=l,o=!0)}o&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(e.data.groups=JSON.parse(JSON.stringify(l)));const c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.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 r=e.index;null!==r&&this.setIndex(r.clone(t));const s=e.attributes;for(const e in s){const r=s[e];this.setAttribute(e,r.clone(t))}const o=e.morphAttributes;for(const e in o){const r=[],s=o[e];for(let e=0,o=s.length;e<o;e++)r.push(s[e].clone(t));this.morphAttributes[e]=r}this.morphTargetsRelative=e.morphTargetsRelative;const l=e.groups;for(let e=0,t=l.length;e<t;e++){const t=l[e];this.addGroup(t.start,t.count,t.materialIndex)}const c=e.boundingBox;null!==c&&(this.boundingBox=c.clone());const h=e.boundingSphere;return null!==h&&(this.boundingSphere=h.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const cn=new three_module_Matrix4,hn=new Ray,un=new Sphere,dn=new three_module_Vector3,pn=new three_module_Vector3,An=new three_module_Vector3,mn=new three_module_Vector3,fn=new three_module_Vector3,gn=new three_module_Vector3,_n=new Vector2,vn=new Vector2,yn=new Vector2,En=new three_module_Vector3,xn=new three_module_Vector3,Sn=new three_module_Vector3,Mn=new three_module_Vector3,Cn=new three_module_Vector3;class three_module_Mesh extends Object3D{constructor(e=new three_module_BufferGeometry,t=new MeshBasicMaterial){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){const t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const r=this.geometry,s=r.attributes.position,o=r.morphAttributes.position,l=r.morphTargetsRelative;t.fromBufferAttribute(s,e);const c=this.morphTargetInfluences;if(o&&c){gn.set(0,0,0);for(let r=0,s=o.length;r<s;r++){const s=c[r],h=o[r];0!==s&&(fn.fromBufferAttribute(h,e),l?gn.addScaledVector(fn,s):gn.addScaledVector(fn.sub(t),s))}t.add(gn)}return t}raycast(e,t){const r=this.geometry,s=this.material,o=this.matrixWorld;if(void 0!==s){if(null===r.boundingSphere&&r.computeBoundingSphere(),un.copy(r.boundingSphere),un.applyMatrix4(o),hn.copy(e.ray).recast(e.near),!1===un.containsPoint(hn.origin)){if(null===hn.intersectSphere(un,dn))return;if(hn.origin.distanceToSquared(dn)>(e.far-e.near)**2)return}cn.copy(o).invert(),hn.copy(e.ray).applyMatrix4(cn),null!==r.boundingBox&&!1===hn.intersectsBox(r.boundingBox)||this._computeIntersections(e,t,hn)}}_computeIntersections(e,t,r){let s;const o=this.geometry,l=this.material,c=o.index,h=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,A=o.attributes.normal,m=o.groups,f=o.drawRange;if(null!==c)if(Array.isArray(l))for(let o=0,h=m.length;o<h;o++){const h=m[o],g=l[h.materialIndex];for(let o=Math.max(h.start,f.start),l=Math.min(c.count,Math.min(h.start+h.count,f.start+f.count));o<l;o+=3){s=checkGeometryIntersection(this,g,e,r,d,p,A,c.getX(o),c.getX(o+1),c.getX(o+2)),s&&(s.faceIndex=Math.floor(o/3),s.face.materialIndex=h.materialIndex,t.push(s))}}else{for(let o=Math.max(0,f.start),h=Math.min(c.count,f.start+f.count);o<h;o+=3){s=checkGeometryIntersection(this,l,e,r,d,p,A,c.getX(o),c.getX(o+1),c.getX(o+2)),s&&(s.faceIndex=Math.floor(o/3),t.push(s))}}else if(void 0!==h)if(Array.isArray(l))for(let o=0,c=m.length;o<c;o++){const c=m[o],g=l[c.materialIndex];for(let o=Math.max(c.start,f.start),l=Math.min(h.count,Math.min(c.start+c.count,f.start+f.count));o<l;o+=3){s=checkGeometryIntersection(this,g,e,r,d,p,A,o,o+1,o+2),s&&(s.faceIndex=Math.floor(o/3),s.face.materialIndex=c.materialIndex,t.push(s))}}else{for(let o=Math.max(0,f.start),c=Math.min(h.count,f.start+f.count);o<c;o+=3){s=checkGeometryIntersection(this,l,e,r,d,p,A,o,o+1,o+2),s&&(s.faceIndex=Math.floor(o/3),t.push(s))}}}}function checkGeometryIntersection(e,t,r,s,o,l,c,h,d,m){e.getVertexPosition(h,pn),e.getVertexPosition(d,An),e.getVertexPosition(m,mn);const f=function checkIntersection(e,t,r,s,o,l,c,h){let d;if(d=t.side===A?s.intersectTriangle(c,l,o,!0,h):s.intersectTriangle(o,l,c,t.side===p,h),null===d)return null;Cn.copy(h),Cn.applyMatrix4(e.matrixWorld);const m=r.ray.origin.distanceTo(Cn);return m<r.near||m>r.far?null:{distance:m,point:Cn.clone(),object:e}}(e,t,r,s,pn,An,mn,Mn);if(f){o&&(_n.fromBufferAttribute(o,h),vn.fromBufferAttribute(o,d),yn.fromBufferAttribute(o,m),f.uv=Triangle.getInterpolation(Mn,pn,An,mn,_n,vn,yn,new Vector2)),l&&(_n.fromBufferAttribute(l,h),vn.fromBufferAttribute(l,d),yn.fromBufferAttribute(l,m),f.uv1=Triangle.getInterpolation(Mn,pn,An,mn,_n,vn,yn,new Vector2),f.uv2=f.uv1),c&&(En.fromBufferAttribute(c,h),xn.fromBufferAttribute(c,d),Sn.fromBufferAttribute(c,m),f.normal=Triangle.getInterpolation(Mn,pn,An,mn,En,xn,Sn,new three_module_Vector3),f.normal.dot(s.direction)>0&&f.normal.multiplyScalar(-1));const e={a:h,b:d,c:m,normal:new three_module_Vector3,materialIndex:0};Triangle.getNormal(pn,An,mn,e.normal),f.face=e}return f}class BoxGeometry extends three_module_BufferGeometry{constructor(e=1,t=1,r=1,s=1,o=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:s,heightSegments:o,depthSegments:l};const c=this;s=Math.floor(s),o=Math.floor(o),l=Math.floor(l);const h=[],d=[],p=[],A=[];let m=0,f=0;function buildPlane(e,t,r,s,o,l,g,_,y,x,S){const C=l/y,b=g/x,I=l/2,T=g/2,B=_/2,U=y+1,F=x+1;let O=0,Q=0;const G=new three_module_Vector3;for(let l=0;l<F;l++){const c=l*b-T;for(let h=0;h<U;h++){const m=h*C-I;G[e]=m*s,G[t]=c*o,G[r]=B,d.push(G.x,G.y,G.z),G[e]=0,G[t]=0,G[r]=_>0?1:-1,p.push(G.x,G.y,G.z),A.push(h/y),A.push(1-l/x),O+=1}}for(let e=0;e<x;e++)for(let t=0;t<y;t++){const r=m+t+U*e,s=m+t+U*(e+1),o=m+(t+1)+U*(e+1),l=m+(t+1)+U*e;h.push(r,s,l),h.push(s,o,l),Q+=6}c.addGroup(f,Q,S),f+=Q,m+=O}buildPlane("z","y","x",-1,-1,r,t,e,l,o,0),buildPlane("z","y","x",1,-1,r,t,-e,l,o,1),buildPlane("x","z","y",1,1,e,r,t,s,l,2),buildPlane("x","z","y",1,-1,e,r,-t,s,l,3),buildPlane("x","y","z",1,-1,e,t,r,s,o,4),buildPlane("x","y","z",-1,-1,e,t,-r,s,o,5),this.setIndex(h),this.setAttribute("position",new three_module_Float32BufferAttribute(d,3)),this.setAttribute("normal",new three_module_Float32BufferAttribute(p,3)),this.setAttribute("uv",new three_module_Float32BufferAttribute(A,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new BoxGeometry(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function cloneUniforms(e){const t={};for(const r in e){t[r]={};for(const s in e[r]){const l=e[r][s];l&&(l.isColor||l.isMatrix3||l.isMatrix4||l.isVector2||l.isVector3||l.isVector4||l.isTexture||l.isQuaternion)?l.isRenderTargetTexture?(o.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[r][s]=null):t[r][s]=l.clone():Array.isArray(l)?t[r][s]=l.slice():t[r][s]=l}}return t}function mergeUniforms(e){const t={};for(let r=0;r<e.length;r++){const s=cloneUniforms(e[r]);for(const e in s)t[e]=s[e]}return t}function getUnlitUniformColorSpace(e){return null===e.getRenderTarget()?e.outputColorSpace:Ut.workingColorSpace}const bn={clone:cloneUniforms,merge:mergeUniforms};class ShaderMaterial extends Material{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=cloneUniforms(e.uniforms),this.uniformsGroups=function cloneUniformsGroups(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const r={};for(const e in this.extensions)!0===this.extensions[e]&&(r[e]=!0);return Object.keys(r).length>0&&(t.extensions=r),t}}class Camera extends Object3D{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new three_module_Matrix4,this.projectionMatrix=new three_module_Matrix4,this.projectionMatrixInverse=new three_module_Matrix4,this.coordinateSystem=Et}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){return super.getWorldDirection(e).negate()}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 PerspectiveCamera extends Camera{constructor(e=50,t=1,r=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=s,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*bt*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Ct*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*bt*Math.atan(Math.tan(.5*Ct*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,r,s,o,l){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=r,this.view.offsetY=s,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Ct*this.fov)/this.zoom,r=2*t,s=this.aspect*r,o=-.5*s;const l=this.view;if(null!==this.view&&this.view.enabled){const e=l.fullWidth,c=l.fullHeight;o+=l.offsetX*s/e,t-=l.offsetY*r/c,s*=l.width/e,r*=l.height/c}const c=this.filmOffset;0!==c&&(o+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+s,t,t-r,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 wn=-90;class CubeCamera extends Object3D{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new PerspectiveCamera(wn,1,e,t);s.layers=this.layers,this.add(s);const o=new PerspectiveCamera(wn,1,e,t);o.layers=this.layers,this.add(o);const l=new PerspectiveCamera(wn,1,e,t);l.layers=this.layers,this.add(l);const c=new PerspectiveCamera(wn,1,e,t);c.layers=this.layers,this.add(c);const h=new PerspectiveCamera(wn,1,e,t);h.layers=this.layers,this.add(h);const d=new PerspectiveCamera(wn,1,e,t);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[r,s,o,l,c,h]=t;for(const e of t)this.remove(e);if(e===Et)r.up.set(0,1,0),r.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),l.up.set(0,0,1),l.lookAt(0,-1,0),c.up.set(0,1,0),c.lookAt(0,0,1),h.up.set(0,1,0),h.lookAt(0,0,-1);else{if(e!==xt)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);r.up.set(0,-1,0),r.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),l.up.set(0,0,-1),l.lookAt(0,-1,0),c.up.set(0,-1,0),c.lookAt(0,0,1),h.up.set(0,-1,0),h.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,l,c,h,d,p]=this.children,A=e.getRenderTarget(),m=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,s),e.render(t,o),e.setRenderTarget(r,1,s),e.render(t,l),e.setRenderTarget(r,2,s),e.render(t,c),e.setRenderTarget(r,3,s),e.render(t,h),e.setRenderTarget(r,4,s),e.render(t,d),r.texture.generateMipmaps=_,e.setRenderTarget(r,5,s),e.render(t,p),e.setRenderTarget(A,m,f),e.xr.enabled=g,r.texture.needsPMREMUpdate=!0}}class CubeTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d,p){super(e=void 0!==e?e:[],t=void 0!==t?t:ae,r,s,o,l,c,h,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];void 0!==t.encoding&&(warnOnce("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Ze?tt:et),this.texture=new CubeTexture(s,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:ge}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 r={uniforms:{tEquirect:{value:null}},vertexShader:"\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 <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\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 BoxGeometry(5,5,5),o=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:A,blending:0});o.uniforms.tEquirect.value=t;const l=new three_module_Mesh(s,o),c=t.minFilter;t.minFilter===ve&&(t.minFilter=ge);return new CubeCamera(1,10,this).update(e,l),t.minFilter=c,l.geometry.dispose(),l.material.dispose(),this}clear(e,t,r,s){const o=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,r,s);e.setRenderTarget(o)}}const In=new three_module_Vector3,Tn=new three_module_Vector3,Bn=new Matrix3;class Plane{constructor(e=new three_module_Vector3(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,s){return this.normal.set(e,t,r),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const s=In.subVectors(r,t).cross(Tn.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,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 r=e.delta(In),s=this.normal.dot(r);if(0===s)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/s;return o<0||o>1?null:t.copy(e.start).addScaledVector(r,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<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 r=t||Bn.getNormalMatrix(e),s=this.coplanarPoint(In).applyMatrix4(e),o=this.normal.applyMatrix3(r).normalize();return this.constant=-s.dot(o),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Rn=new Sphere,Ln=new three_module_Vector3;class Frustum{constructor(e=new Plane,t=new Plane,r=new Plane,s=new Plane,o=new Plane,l=new Plane){this.planes=[e,t,r,s,o,l]}set(e,t,r,s,o,l){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(r),c[3].copy(s),c[4].copy(o),c[5].copy(l),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=2e3){const r=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],h=s[3],d=s[4],p=s[5],A=s[6],m=s[7],f=s[8],g=s[9],_=s[10],y=s[11],x=s[12],S=s[13],C=s[14],b=s[15];if(r[0].setComponents(h-o,m-d,y-f,b-x).normalize(),r[1].setComponents(h+o,m+d,y+f,b+x).normalize(),r[2].setComponents(h+l,m+p,y+g,b+S).normalize(),r[3].setComponents(h-l,m-p,y-g,b-S).normalize(),r[4].setComponents(h-c,m-A,y-_,b-C).normalize(),t===Et)r[5].setComponents(h+c,m+A,y+_,b+C).normalize();else{if(t!==xt)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);r[5].setComponents(c,A,_,C).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Rn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Rn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rn)}intersectsSprite(e){return Rn.center.set(0,0,0),Rn.radius=.7071067811865476,Rn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rn)}intersectsSphere(e){const t=this.planes,r=e.center,s=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(r)<s)return!1}return!0}intersectsBox(e){const t=this.planes;for(let r=0;r<6;r++){const s=t[r];if(Ln.x=s.normal.x>0?e.max.x:e.min.x,Ln.y=s.normal.y>0?e.max.y:e.min.y,Ln.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Ln)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function WebGLAnimation(){let e=null,t=!1,r=null,s=null;function onAnimationFrame(t,o){r(t,o),s=e.requestAnimationFrame(onAnimationFrame)}return{start:function(){!0!==t&&null!==r&&(s=e.requestAnimationFrame(onAnimationFrame),t=!0)},stop:function(){e.cancelAnimationFrame(s),t=!1},setAnimationLoop:function(e){r=e},setContext:function(t){e=t}}}function WebGLAttributes(e,t){const r=t.isWebGL2,s=new WeakMap;return{get:function get(e){return e.isInterleavedBufferAttribute&&(e=e.data),s.get(e)},remove:function remove(t){t.isInterleavedBufferAttribute&&(t=t.data);const r=s.get(t);r&&(e.deleteBuffer(r.buffer),s.delete(t))},update:function update(t,o){if(t.isGLBufferAttribute){const e=s.get(t);return void((!e||e.version<t.version)&&s.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const l=s.get(t);if(void 0===l)s.set(t,function createBuffer(t,s){const o=t.array,l=t.usage,c=o.byteLength,h=e.createBuffer();let d;if(e.bindBuffer(s,h),e.bufferData(s,o,l),t.onUploadCallback(),o instanceof Float32Array)d=e.FLOAT;else if(o instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!r)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");d=e.HALF_FLOAT}else d=e.UNSIGNED_SHORT;else if(o instanceof Int16Array)d=e.SHORT;else if(o instanceof Uint32Array)d=e.UNSIGNED_INT;else if(o instanceof Int32Array)d=e.INT;else if(o instanceof Int8Array)d=e.BYTE;else if(o instanceof Uint8Array)d=e.UNSIGNED_BYTE;else{if(!(o instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+o);d=e.UNSIGNED_BYTE}return{buffer:h,type:d,bytesPerElement:o.BYTES_PER_ELEMENT,version:t.version,size:c}}(t,o));else if(l.version<t.version){if(l.size!==t.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function updateBuffer(t,s,o){const l=s.array,c=s._updateRange,h=s.updateRanges;if(e.bindBuffer(o,t),-1===c.count&&0===h.length&&e.bufferSubData(o,0,l),0!==h.length){for(let t=0,s=h.length;t<s;t++){const s=h[t];r?e.bufferSubData(o,s.start*l.BYTES_PER_ELEMENT,l,s.start,s.count):e.bufferSubData(o,s.start*l.BYTES_PER_ELEMENT,l.subarray(s.start,s.start+s.count))}s.clearUpdateRanges()}-1!==c.count&&(r?e.bufferSubData(o,c.offset*l.BYTES_PER_ELEMENT,l,c.offset,c.count):e.bufferSubData(o,c.offset*l.BYTES_PER_ELEMENT,l.subarray(c.offset,c.offset+c.count)),c.count=-1),s.onUploadCallback()}(l.buffer,t,o),l.version=t.version}}}}class PlaneGeometry extends three_module_BufferGeometry{constructor(e=1,t=1,r=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:s};const o=e/2,l=t/2,c=Math.floor(r),h=Math.floor(s),d=c+1,p=h+1,A=e/c,m=t/h,f=[],g=[],_=[],y=[];for(let e=0;e<p;e++){const t=e*m-l;for(let r=0;r<d;r++){const s=r*A-o;g.push(s,-t,0),_.push(0,0,1),y.push(r/c),y.push(1-e/h)}}for(let e=0;e<h;e++)for(let t=0;t<c;t++){const r=t+d*e,s=t+d*(e+1),o=t+1+d*(e+1),l=t+1+d*e;f.push(r,s,l),f.push(s,o,l)}this.setIndex(f),this.setAttribute("position",new three_module_Float32BufferAttribute(g,3)),this.setAttribute("normal",new three_module_Float32BufferAttribute(_,3)),this.setAttribute("uv",new three_module_Float32BufferAttribute(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new PlaneGeometry(e.width,e.height,e.widthSegments,e.heightSegments)}}const Dn={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 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};\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_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\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_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 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:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( 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}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\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, 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 vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\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 vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\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\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\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 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, 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( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, 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:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\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, geometryPosition, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, geometryPosition, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\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 ], geometryNormal );\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( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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 nonPerturbedNormal = 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 = nonPerturbedNormal;\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_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\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\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\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}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn 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_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <cube_uv_reflection_fragment>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\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 <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\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 <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\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 + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\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 <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Un={common:{diffuse:{value:new Color(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Matrix3}},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 Matrix3}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Matrix3}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Matrix3},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Matrix3},normalScale:{value:new Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Matrix3},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Matrix3}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Matrix3}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Matrix3}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Color(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 Color(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0},uvTransform:{value:new Matrix3}},sprite:{diffuse:{value:new Color(16777215)},opacity:{value:1},center:{value:new Vector2(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}}},Pn={basic:{uniforms:mergeUniforms([Un.common,Un.specularmap,Un.envmap,Un.aomap,Un.lightmap,Un.fog]),vertexShader:Dn.meshbasic_vert,fragmentShader:Dn.meshbasic_frag},lambert:{uniforms:mergeUniforms([Un.common,Un.specularmap,Un.envmap,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.fog,Un.lights,{emissive:{value:new Color(0)}}]),vertexShader:Dn.meshlambert_vert,fragmentShader:Dn.meshlambert_frag},phong:{uniforms:mergeUniforms([Un.common,Un.specularmap,Un.envmap,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.fog,Un.lights,{emissive:{value:new Color(0)},specular:{value:new Color(1118481)},shininess:{value:30}}]),vertexShader:Dn.meshphong_vert,fragmentShader:Dn.meshphong_frag},standard:{uniforms:mergeUniforms([Un.common,Un.envmap,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.roughnessmap,Un.metalnessmap,Un.fog,Un.lights,{emissive:{value:new Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Dn.meshphysical_vert,fragmentShader:Dn.meshphysical_frag},toon:{uniforms:mergeUniforms([Un.common,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.gradientmap,Un.fog,Un.lights,{emissive:{value:new Color(0)}}]),vertexShader:Dn.meshtoon_vert,fragmentShader:Dn.meshtoon_frag},matcap:{uniforms:mergeUniforms([Un.common,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.fog,{matcap:{value:null}}]),vertexShader:Dn.meshmatcap_vert,fragmentShader:Dn.meshmatcap_frag},points:{uniforms:mergeUniforms([Un.points,Un.fog]),vertexShader:Dn.points_vert,fragmentShader:Dn.points_frag},dashed:{uniforms:mergeUniforms([Un.common,Un.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Dn.linedashed_vert,fragmentShader:Dn.linedashed_frag},depth:{uniforms:mergeUniforms([Un.common,Un.displacementmap]),vertexShader:Dn.depth_vert,fragmentShader:Dn.depth_frag},normal:{uniforms:mergeUniforms([Un.common,Un.bumpmap,Un.normalmap,Un.displacementmap,{opacity:{value:1}}]),vertexShader:Dn.meshnormal_vert,fragmentShader:Dn.meshnormal_frag},sprite:{uniforms:mergeUniforms([Un.sprite,Un.fog]),vertexShader:Dn.sprite_vert,fragmentShader:Dn.sprite_frag},background:{uniforms:{uvTransform:{value:new Matrix3},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Dn.background_vert,fragmentShader:Dn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Dn.backgroundCube_vert,fragmentShader:Dn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Dn.cube_vert,fragmentShader:Dn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Dn.equirect_vert,fragmentShader:Dn.equirect_frag},distanceRGBA:{uniforms:mergeUniforms([Un.common,Un.displacementmap,{referencePosition:{value:new three_module_Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Dn.distanceRGBA_vert,fragmentShader:Dn.distanceRGBA_frag},shadow:{uniforms:mergeUniforms([Un.lights,Un.fog,{color:{value:new Color(0)},opacity:{value:1}}]),vertexShader:Dn.shadow_vert,fragmentShader:Dn.shadow_frag}};Pn.physical={uniforms:mergeUniforms([Pn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Matrix3},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Matrix3},clearcoatNormalScale:{value:new Vector2(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Matrix3},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Matrix3},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Matrix3},sheen:{value:0},sheenColor:{value:new Color(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Matrix3},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Matrix3},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Matrix3},transmissionSamplerSize:{value:new Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Matrix3},attenuationDistance:{value:0},attenuationColor:{value:new Color(0)},specularColor:{value:new Color(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Matrix3},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Matrix3},anisotropyVector:{value:new Vector2},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Matrix3}}]),vertexShader:Dn.meshphysical_vert,fragmentShader:Dn.meshphysical_frag};const Fn={r:0,b:0,g:0};function WebGLBackground(e,t,r,s,o,l,c){const h=new Color(0);let d,m,f=!0===l?0:1,g=null,_=0,y=null;function setClear(t,r){t.getRGB(Fn,getUnlitUniformColorSpace(e)),s.buffers.color.setClear(Fn.r,Fn.g,Fn.b,r,c)}return{getClearColor:function(){return h},setClearColor:function(e,t=1){h.set(e),f=t,setClear(h,f)},getClearAlpha:function(){return f},setClearAlpha:function(e){f=e,setClear(h,f)},render:function render(l,x){let S=!1,C=!0===x.isScene?x.background:null;if(C&&C.isTexture){C=(x.backgroundBlurriness>0?r:t).get(C)}null===C?setClear(h,f):C&&C.isColor&&(setClear(C,1),S=!0);const b=e.xr.getEnvironmentBlendMode();"additive"===b?s.buffers.color.setClear(0,0,0,1,c):"alpha-blend"===b&&s.buffers.color.setClear(0,0,0,0,c),(e.autoClear||S)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),C&&(C.isCubeTexture||C.mapping===he)?(void 0===m&&(m=new three_module_Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(Pn.backgroundCube.uniforms),vertexShader:Pn.backgroundCube.vertexShader,fragmentShader:Pn.backgroundCube.fragmentShader,side:A,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),o.update(m)),m.material.uniforms.envMap.value=C,m.material.uniforms.flipEnvMap.value=C.isCubeTexture&&!1===C.isRenderTargetTexture?-1:1,m.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,m.material.toneMapped=Ut.getTransfer(C.colorSpace)!==at,g===C&&_===C.version&&y===e.toneMapping||(m.material.needsUpdate=!0,g=C,_=C.version,y=e.toneMapping),m.layers.enableAll(),l.unshift(m,m.geometry,m.material,0,0,null)):C&&C.isTexture&&(void 0===d&&(d=new three_module_Mesh(new PlaneGeometry(2,2),new ShaderMaterial({name:"BackgroundMaterial",uniforms:cloneUniforms(Pn.background.uniforms),vertexShader:Pn.background.vertexShader,fragmentShader:Pn.background.fragmentShader,side:p,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),o.update(d)),d.material.uniforms.t2D.value=C,d.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,d.material.toneMapped=Ut.getTransfer(C.colorSpace)!==at,!0===C.matrixAutoUpdate&&C.updateMatrix(),d.material.uniforms.uvTransform.value.copy(C.matrix),g===C&&_===C.version&&y===e.toneMapping||(d.material.needsUpdate=!0,g=C,_=C.version,y=e.toneMapping),d.layers.enableAll(),l.unshift(d,d.geometry,d.material,0,0,null))}}}function WebGLBindingStates(e,t,r,s){const o=e.getParameter(e.MAX_VERTEX_ATTRIBS),l=s.isWebGL2?null:t.get("OES_vertex_array_object"),c=s.isWebGL2||null!==l,h={},d=createBindingState(null);let p=d,A=!1;function bindVertexArrayObject(t){return s.isWebGL2?e.bindVertexArray(t):l.bindVertexArrayOES(t)}function deleteVertexArrayObject(t){return s.isWebGL2?e.deleteVertexArray(t):l.deleteVertexArrayOES(t)}function createBindingState(e){const t=[],r=[],s=[];for(let e=0;e<o;e++)t[e]=0,r[e]=0,s[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:s,object:e,attributes:{},index:null}}function initAttributes(){const e=p.newAttributes;for(let t=0,r=e.length;t<r;t++)e[t]=0}function enableAttribute(e){enableAttributeAndDivisor(e,0)}function enableAttributeAndDivisor(r,o){const l=p.newAttributes,c=p.enabledAttributes,h=p.attributeDivisors;if(l[r]=1,0===c[r]&&(e.enableVertexAttribArray(r),c[r]=1),h[r]!==o){(s.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[s.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](r,o),h[r]=o}}function disableUnusedAttributes(){const t=p.newAttributes,r=p.enabledAttributes;for(let s=0,o=r.length;s<o;s++)r[s]!==t[s]&&(e.disableVertexAttribArray(s),r[s]=0)}function vertexAttribPointer(t,r,s,o,l,c,h){!0===h?e.vertexAttribIPointer(t,r,s,l,c):e.vertexAttribPointer(t,r,s,o,l,c)}function reset(){resetDefaultState(),A=!0,p!==d&&(p=d,bindVertexArrayObject(p.object))}function resetDefaultState(){d.geometry=null,d.program=null,d.wireframe=!1}return{setup:function setup(o,d,m,f,g){let _=!1;if(c){const t=function getBindingState(t,r,o){const c=!0===o.wireframe;let d=h[t.id];void 0===d&&(d={},h[t.id]=d);let p=d[r.id];void 0===p&&(p={},d[r.id]=p);let A=p[c];void 0===A&&(A=createBindingState(function createVertexArrayObject(){return s.isWebGL2?e.createVertexArray():l.createVertexArrayOES()}()),p[c]=A);return A}(f,m,d);p!==t&&(p=t,bindVertexArrayObject(p.object)),_=function needsUpdate(e,t,r,s){const o=p.attributes,l=t.attributes;let c=0;const h=r.getAttributes();for(const t in h){if(h[t].location>=0){const r=o[t];let s=l[t];if(void 0===s&&("instanceMatrix"===t&&e.instanceMatrix&&(s=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(s=e.instanceColor)),void 0===r)return!0;if(r.attribute!==s)return!0;if(s&&r.data!==s.data)return!0;c++}}return p.attributesNum!==c||p.index!==s}(o,f,m,g),_&&function saveCache(e,t,r,s){const o={},l=t.attributes;let c=0;const h=r.getAttributes();for(const t in h){if(h[t].location>=0){let r=l[t];void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor));const s={};s.attribute=r,r&&r.data&&(s.data=r.data),o[t]=s,c++}}p.attributes=o,p.attributesNum=c,p.index=s}(o,f,m,g)}else{const e=!0===d.wireframe;p.geometry===f.id&&p.program===m.id&&p.wireframe===e||(p.geometry=f.id,p.program=m.id,p.wireframe=e,_=!0)}null!==g&&r.update(g,e.ELEMENT_ARRAY_BUFFER),(_||A)&&(A=!1,function setupVertexAttributes(o,l,c,h){if(!1===s.isWebGL2&&(o.isInstancedMesh||h.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;initAttributes();const d=h.attributes,p=c.getAttributes(),A=l.defaultAttributeValues;for(const t in p){const l=p[t];if(l.location>=0){let c=d[t];if(void 0===c&&("instanceMatrix"===t&&o.instanceMatrix&&(c=o.instanceMatrix),"instanceColor"===t&&o.instanceColor&&(c=o.instanceColor)),void 0!==c){const t=c.normalized,d=c.itemSize,p=r.get(c);if(void 0===p)continue;const A=p.buffer,m=p.type,f=p.bytesPerElement,g=!0===s.isWebGL2&&(m===e.INT||m===e.UNSIGNED_INT||c.gpuType===xe);if(c.isInterleavedBufferAttribute){const r=c.data,s=r.stride,p=c.offset;if(r.isInstancedInterleavedBuffer){for(let e=0;e<l.locationSize;e++)enableAttributeAndDivisor(l.location+e,r.meshPerAttribute);!0!==o.isInstancedMesh&&void 0===h._maxInstanceCount&&(h._maxInstanceCount=r.meshPerAttribute*r.count)}else for(let e=0;e<l.locationSize;e++)enableAttribute(l.location+e);e.bindBuffer(e.ARRAY_BUFFER,A);for(let e=0;e<l.locationSize;e++)vertexAttribPointer(l.location+e,d/l.locationSize,m,t,s*f,(p+d/l.locationSize*e)*f,g)}else{if(c.isInstancedBufferAttribute){for(let e=0;e<l.locationSize;e++)enableAttributeAndDivisor(l.location+e,c.meshPerAttribute);!0!==o.isInstancedMesh&&void 0===h._maxInstanceCount&&(h._maxInstanceCount=c.meshPerAttribute*c.count)}else for(let e=0;e<l.locationSize;e++)enableAttribute(l.location+e);e.bindBuffer(e.ARRAY_BUFFER,A);for(let e=0;e<l.locationSize;e++)vertexAttribPointer(l.location+e,d/l.locationSize,m,t,d*f,d/l.locationSize*e*f,g)}}else if(void 0!==A){const r=A[t];if(void 0!==r)switch(r.length){case 2:e.vertexAttrib2fv(l.location,r);break;case 3:e.vertexAttrib3fv(l.location,r);break;case 4:e.vertexAttrib4fv(l.location,r);break;default:e.vertexAttrib1fv(l.location,r)}}}}disableUnusedAttributes()}(o,d,m,f),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.get(g).buffer))},reset,resetDefaultState,dispose:function dispose(){reset();for(const e in h){const t=h[e];for(const e in t){const r=t[e];for(const e in r)deleteVertexArrayObject(r[e].object),delete r[e];delete t[e]}delete h[e]}},releaseStatesOfGeometry:function releaseStatesOfGeometry(e){if(void 0===h[e.id])return;const t=h[e.id];for(const e in t){const r=t[e];for(const e in r)deleteVertexArrayObject(r[e].object),delete r[e];delete t[e]}delete h[e.id]},releaseStatesOfProgram:function releaseStatesOfProgram(e){for(const t in h){const r=h[t];if(void 0===r[e.id])continue;const s=r[e.id];for(const e in s)deleteVertexArrayObject(s[e].object),delete s[e];delete r[e.id]}},initAttributes,enableAttribute,disableUnusedAttributes}}function WebGLBufferRenderer(e,t,r,s){const l=s.isWebGL2;let c;this.setMode=function setMode(e){c=e},this.render=function render(t,s){e.drawArrays(c,t,s),r.update(s,c,1)},this.renderInstances=function renderInstances(s,h,d){if(0===d)return;let p,A;if(l)p=e,A="drawArraysInstanced";else if(p=t.get("ANGLE_instanced_arrays"),A="drawArraysInstancedANGLE",null===p)return void o.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");p[A](c,s,h,d),r.update(h,c,d)},this.renderMultiDraw=function renderMultiDraw(e,s,o){if(0===o)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<o;t++)this.render(e[t],s[t]);else{l.multiDrawArraysWEBGL(c,e,0,s,0,o);let t=0;for(let e=0;e<o;e++)t+=s[e];r.update(t,c,1)}}}function WebGLCapabilities(e,t,r){let s;function getMaxPrecision(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&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 l="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let c=void 0!==r.precision?r.precision:"highp";const h=getMaxPrecision(c);h!==c&&(o.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=l||t.has("WEBGL_draw_buffers"),p=!0===r.logarithmicDepthBuffer,A=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),f=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),y=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),x=e.getParameter(e.MAX_VARYING_VECTORS),S=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),C=m>0,b=l||t.has("OES_texture_float");return{isWebGL2:l,drawBuffers:d,getMaxAnisotropy:function getMaxAnisotropy(){if(void 0!==s)return s;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");s=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s},getMaxPrecision,precision:c,logarithmicDepthBuffer:p,maxTextures:A,maxVertexTextures:m,maxTextureSize:f,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:S,vertexTextures:C,floatFragmentTextures:b,floatVertexTextures:C&&b,maxSamples:l?e.getParameter(e.MAX_SAMPLES):0}}function WebGLClipping(e){const t=this;let r=null,s=0,o=!1,l=!1;const c=new Plane,h=new Matrix3,d={value:null,needsUpdate:!1};function projectPlanes(e,r,s,o){const l=null!==e?e.length:0;let p=null;if(0!==l){if(p=d.value,!0!==o||null===p){const t=s+4*l,o=r.matrixWorldInverse;h.getNormalMatrix(o),(null===p||p.length<t)&&(p=new Float32Array(t));for(let t=0,r=s;t!==l;++t,r+=4)c.copy(e[t]).applyMatrix4(o,h),c.normal.toArray(p,r),p[r+3]=c.constant}d.value=p,d.needsUpdate=!0}return t.numPlanes=l,t.numIntersection=0,p}this.uniform=d,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const r=0!==e.length||t||0!==s||o;return o=t,s=e.length,r},this.beginShadows=function(){l=!0,projectPlanes(null)},this.endShadows=function(){l=!1},this.setGlobalState=function(e,t){r=projectPlanes(e,t,0)},this.setState=function(c,h,p){const A=c.clippingPlanes,m=c.clipIntersection,f=c.clipShadows,g=e.get(c);if(!o||null===A||0===A.length||l&&!f)l?projectPlanes(null):function resetGlobalState(){d.value!==r&&(d.value=r,d.needsUpdate=s>0);t.numPlanes=s,t.numIntersection=0}();else{const e=l?0:s,t=4*e;let o=g.clippingState||null;d.value=o,o=projectPlanes(A,h,t,p);for(let e=0;e!==t;++e)o[e]=r[e];g.clippingState=o,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=e}}}function WebGLCubeMaps(e){let t=new WeakMap;function mapTextureMapping(e,t){return t===le?e.mapping=ae:t===ce&&(e.mapping=oe),e}function onTextureDispose(e){const r=e.target;r.removeEventListener("dispose",onTextureDispose);const s=t.get(r);void 0!==s&&(t.delete(r),s.dispose())}return{get:function get(r){if(r&&r.isTexture){const s=r.mapping;if(s===le||s===ce){if(t.has(r)){return mapTextureMapping(t.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const o=new WebGLCubeRenderTarget(s.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener("dispose",onTextureDispose),mapTextureMapping(o.texture,r.mapping)}return null}}}return r},dispose:function dispose(){t=new WeakMap}}}class OrthographicCamera extends Camera{constructor(e=-1,t=1,r=1,s=-1,o=.1,l=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=s,this.near=o,this.far=l,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,r,s,o,l){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=r,this.view.offsetY=s,this.view.width=o,this.view.height=l,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),r=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let o=r-e,l=r+e,c=s+t,h=s-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=e*this.view.offsetX,l=o+e*this.view.width,c-=t*this.view.offsetY,h=c-t*this.view.height}this.projectionMatrix.makeOrthographic(o,l,c,h,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 Nn=[.125,.215,.35,.446,.526,.582],On=20,Qn=new OrthographicCamera,kn=new Color;let Gn=null,Vn=0,Hn=0;const zn=(1+Math.sqrt(5))/2,Wn=1/zn,qn=[new three_module_Vector3(1,1,1),new three_module_Vector3(-1,1,1),new three_module_Vector3(1,1,-1),new three_module_Vector3(-1,1,-1),new three_module_Vector3(0,zn,Wn),new three_module_Vector3(0,zn,-Wn),new three_module_Vector3(Wn,0,zn),new three_module_Vector3(-Wn,0,zn),new three_module_Vector3(zn,Wn,0),new three_module_Vector3(-zn,Wn,0)];class PMREMGenerator{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,r=.1,s=100){Gn=this._renderer.getRenderTarget(),Vn=this._renderer.getActiveCubeFace(),Hn=this._renderer.getActiveMipmapLevel(),this._setSize(256);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,r,s,o),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial(),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;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Gn,Vn,Hn),e.scissorTest=!1,_setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ae||e.mapping===oe?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Gn=this._renderer.getRenderTarget(),Vn=this._renderer.getActiveCubeFace(),Hn=this._renderer.getActiveMipmapLevel();const r=t||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,r={magFilter:ge,minFilter:ge,generateMipmaps:!1,type:Ce,format:we,colorSpace:it,depthBuffer:!1},s=_createRenderTarget(e,t,r);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=_createRenderTarget(e,t,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function _createPlanes(e){const t=[],r=[],s=[];let o=e;const l=e-4+1+Nn.length;for(let c=0;c<l;c++){const l=Math.pow(2,o);r.push(l);let h=1/l;c>e-4?h=Nn[c-e+4-1]:0===c&&(h=0),s.push(h);const d=1/(l-2),p=-d,A=1+d,m=[p,p,A,p,A,A,p,p,A,A,p,A],f=6,g=6,_=3,y=2,x=1,S=new Float32Array(_*g*f),C=new Float32Array(y*g*f),b=new Float32Array(x*g*f);for(let e=0;e<f;e++){const t=e%3*2/3-1,r=e>2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0];S.set(s,_*g*e),C.set(m,y*g*e);const o=[e,e,e,e,e,e];b.set(o,x*g*e)}const I=new three_module_BufferGeometry;I.setAttribute("position",new three_module_BufferAttribute(S,_)),I.setAttribute("uv",new three_module_BufferAttribute(C,y)),I.setAttribute("faceIndex",new three_module_BufferAttribute(b,x)),t.push(I),o>4&&o--}return{lodPlanes:t,sizeLods:r,sigmas:s}}(s)),this._blurMaterial=function _getBlurShader(e,t,r){const s=new Float32Array(On),o=new three_module_Vector3(0,1,0),l=new ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:On,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/r,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:s},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:o}},vertexShader:_getCommonVertexShader(),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 <cube_uv_reflection_fragment>\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:0,depthTest:!1,depthWrite:!1});return l}(s,e,t)}return s}_compileMaterial(e){const t=new three_module_Mesh(this._lodPlanes[0],e);this._renderer.compile(t,Qn)}_sceneToCubeUV(e,t,r,s){const o=new PerspectiveCamera(90,1,t,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,p=h.toneMapping;h.getClearColor(kn),h.toneMapping=K,h.autoClear=!1;const m=new MeshBasicMaterial({name:"PMREM.Background",side:A,depthWrite:!1,depthTest:!1}),f=new three_module_Mesh(new BoxGeometry,m);let g=!1;const _=e.background;_?_.isColor&&(m.color.copy(_),e.background=null,g=!0):(m.color.copy(kn),g=!0);for(let t=0;t<6;t++){const r=t%3;0===r?(o.up.set(0,l[t],0),o.lookAt(c[t],0,0)):1===r?(o.up.set(0,0,l[t]),o.lookAt(0,c[t],0)):(o.up.set(0,l[t],0),o.lookAt(0,0,c[t]));const d=this._cubeSize;_setViewport(s,r*d,t>2?d:0,d,d),h.setRenderTarget(s),g&&h.render(f,o),h.render(e,o)}f.geometry.dispose(),f.material.dispose(),h.toneMapping=p,h.autoClear=d,e.background=_}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===ae||e.mapping===oe;s?(null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial());const o=s?this._cubemapMaterial:this._equirectMaterial,l=new three_module_Mesh(this._lodPlanes[0],o);o.uniforms.envMap.value=e;const c=this._cubeSize;_setViewport(t,0,0,3*c,2*c),r.setRenderTarget(t),r.render(l,Qn)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const r=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),s=qn[(t-1)%qn.length];this._blur(e,t-1,t,r,s)}t.autoClear=r}_blur(e,t,r,s,o){const l=this._pingPongRenderTarget;this._halfBlur(e,l,t,r,s,"latitudinal",o),this._halfBlur(l,e,r,r,s,"longitudinal",o)}_halfBlur(e,t,r,s,l,c,h){const d=this._renderer,p=this._blurMaterial;"latitudinal"!==c&&"longitudinal"!==c&&o.error("blur direction must be either latitudinal or longitudinal!");const A=new three_module_Mesh(this._lodPlanes[s],p),m=p.uniforms,f=this._sizeLods[r]-1,g=isFinite(l)?Math.PI/(2*f):2*Math.PI/39,_=l/g,y=isFinite(l)?1+Math.floor(3*_):On;y>On&&o.warn(`sigmaRadians, ${l}, is too large and will clip, as it requested ${y} samples when the maximum is set to 20`);const x=[];let S=0;for(let e=0;e<On;++e){const t=e/_,r=Math.exp(-t*t/2);x.push(r),0===e?S+=r:e<y&&(S+=2*r)}for(let e=0;e<x.length;e++)x[e]=x[e]/S;m.envMap.value=e.texture,m.samples.value=y,m.weights.value=x,m.latitudinal.value="latitudinal"===c,h&&(m.poleAxis.value=h);const{_lodMax:C}=this;m.dTheta.value=g,m.mipInt.value=C-r;const b=this._sizeLods[s];_setViewport(t,3*b*(s>C-4?s-C+4:0),4*(this._cubeSize-b),3*b,2*b),d.setRenderTarget(t),d.render(A,Qn)}}function _createRenderTarget(e,t,r){const s=new WebGLRenderTarget(e,t,r);return s.texture.mapping=he,s.texture.name="PMREM.cubeUv",s.scissorTest=!0,s}function _setViewport(e,t,r,s,o){e.viewport.set(t,r,s,o),e.scissor.set(t,r,s,o)}function _getEquirectMaterial(){return new ShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_getCommonVertexShader(),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 <common>\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:0,depthTest:!1,depthWrite:!1})}function _getCubemapMaterial(){return new ShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_getCommonVertexShader(),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:0,depthTest:!1,depthWrite:!1})}function _getCommonVertexShader(){return"\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"}function WebGLCubeUVMaps(e){let t=new WeakMap,r=null;function onTextureDispose(e){const r=e.target;r.removeEventListener("dispose",onTextureDispose);const s=t.get(r);void 0!==s&&(t.delete(r),s.dispose())}return{get:function get(s){if(s&&s.isTexture){const o=s.mapping,l=o===le||o===ce,c=o===ae||o===oe;if(l||c){if(s.isRenderTargetTexture&&!0===s.needsPMREMUpdate){s.needsPMREMUpdate=!1;let o=t.get(s);return null===r&&(r=new PMREMGenerator(e)),o=l?r.fromEquirectangular(s,o):r.fromCubemap(s,o),t.set(s,o),o.texture}if(t.has(s))return t.get(s).texture;{const o=s.image;if(l&&o&&o.height>0||c&&o&&function isCubeTextureComplete(e){let t=0;const r=6;for(let s=0;s<r;s++)void 0!==e[s]&&t++;return t===r}(o)){null===r&&(r=new PMREMGenerator(e));const o=l?r.fromEquirectangular(s):r.fromCubemap(s);return t.set(s,o),s.addEventListener("dispose",onTextureDispose),o.texture}return null}}}return s},dispose:function dispose(){t=new WeakMap,null!==r&&(r.dispose(),r=null)}}}function WebGLExtensions(e){const t={};function getExtension(r){if(void 0!==t[r])return t[r];let s;switch(r){case"WEBGL_depth_texture":s=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=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":s=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":s=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=e.getExtension(r)}return t[r]=s,s}return{has:function(e){return null!==getExtension(e)},init:function(e){e.isWebGL2?(getExtension("EXT_color_buffer_float"),getExtension("WEBGL_clip_cull_distance")):(getExtension("WEBGL_depth_texture"),getExtension("OES_texture_float"),getExtension("OES_texture_half_float"),getExtension("OES_texture_half_float_linear"),getExtension("OES_standard_derivatives"),getExtension("OES_element_index_uint"),getExtension("OES_vertex_array_object"),getExtension("ANGLE_instanced_arrays")),getExtension("OES_texture_float_linear"),getExtension("EXT_color_buffer_half_float"),getExtension("WEBGL_multisampled_render_to_texture")},get:function(e){const t=getExtension(e);return null===t&&o.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function WebGLGeometries(e,t,r,s){const o={},l=new WeakMap;function onGeometryDispose(e){const c=e.target;null!==c.index&&t.remove(c.index);for(const e in c.attributes)t.remove(c.attributes[e]);for(const e in c.morphAttributes){const r=c.morphAttributes[e];for(let e=0,s=r.length;e<s;e++)t.remove(r[e])}c.removeEventListener("dispose",onGeometryDispose),delete o[c.id];const h=l.get(c);h&&(t.remove(h),l.delete(c)),s.releaseStatesOfGeometry(c),!0===c.isInstancedBufferGeometry&&delete c._maxInstanceCount,r.memory.geometries--}function updateWireframeAttribute(e){const r=[],s=e.index,o=e.attributes.position;let c=0;if(null!==s){const e=s.array;c=s.version;for(let t=0,s=e.length;t<s;t+=3){const s=e[t+0],o=e[t+1],l=e[t+2];r.push(s,o,o,l,l,s)}}else{if(void 0===o)return;{const e=o.array;c=o.version;for(let t=0,s=e.length/3-1;t<s;t+=3){const e=t+0,s=t+1,o=t+2;r.push(e,s,s,o,o,e)}}}const h=new(arrayNeedsUint32(r)?Uint32BufferAttribute:Uint16BufferAttribute)(r,1);h.version=c;const d=l.get(e);d&&t.remove(d),l.set(e,h)}return{get:function get(e,t){return!0===o[t.id]||(t.addEventListener("dispose",onGeometryDispose),o[t.id]=!0,r.memory.geometries++),t},update:function update(r){const s=r.attributes;for(const r in s)t.update(s[r],e.ARRAY_BUFFER);const o=r.morphAttributes;for(const r in o){const s=o[r];for(let r=0,o=s.length;r<o;r++)t.update(s[r],e.ARRAY_BUFFER)}},getWireframeAttribute:function getWireframeAttribute(e){const t=l.get(e);if(t){const r=e.index;null!==r&&t.version<r.version&&updateWireframeAttribute(e)}else updateWireframeAttribute(e);return l.get(e)}}}function WebGLIndexedBufferRenderer(e,t,r,s){const l=s.isWebGL2;let c,h,d;this.setMode=function setMode(e){c=e},this.setIndex=function setIndex(e){h=e.type,d=e.bytesPerElement},this.render=function render(t,s){e.drawElements(c,s,h,t*d),r.update(s,c,1)},this.renderInstances=function renderInstances(s,p,A){if(0===A)return;let m,f;if(l)m=e,f="drawElementsInstanced";else if(m=t.get("ANGLE_instanced_arrays"),f="drawElementsInstancedANGLE",null===m)return void o.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");m[f](c,p,h,s*d,A),r.update(p,c,A)},this.renderMultiDraw=function renderMultiDraw(e,s,o){if(0===o)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<o;t++)this.render(e[t]/d,s[t]);else{l.multiDrawElementsWEBGL(c,s,0,h,e,0,o);let t=0;for(let e=0;e<o;e++)t+=s[e];r.update(t,c,1)}}}function WebGLInfo(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function reset(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function update(r,s,l){switch(t.calls++,s){case e.TRIANGLES:t.triangles+=l*(r/3);break;case e.LINES:t.lines+=l*(r/2);break;case e.LINE_STRIP:t.lines+=l*(r-1);break;case e.LINE_LOOP:t.lines+=l*r;break;case e.POINTS:t.points+=l*r;break;default:o.error("THREE.WebGLInfo: Unknown draw mode:",s)}}}}function numericalSort(e,t){return e[0]-t[0]}function absNumericalSort(e,t){return Math.abs(t[1])-Math.abs(e[1])}function WebGLMorphtargets(e,t,r){const s={},o=new Float32Array(8),l=new WeakMap,c=new Vector4,h=[];for(let e=0;e<8;e++)h[e]=[e,0];return{update:function update(d,p,A){const m=d.morphTargetInfluences;if(!0===t.isWebGL2){const f=p.morphAttributes.position||p.morphAttributes.normal||p.morphAttributes.color,g=void 0!==f?f.length:0;let _=l.get(p);if(void 0===_||_.count!==g){void 0!==_&&_.texture.dispose();const S=void 0!==p.morphAttributes.position,C=void 0!==p.morphAttributes.normal,b=void 0!==p.morphAttributes.color,I=p.morphAttributes.position||[],T=p.morphAttributes.normal||[],B=p.morphAttributes.color||[];let U=0;!0===S&&(U=1),!0===C&&(U=2),!0===b&&(U=3);let F=p.attributes.position.count*U,O=1;F>t.maxTextureSize&&(O=Math.ceil(F/t.maxTextureSize),F=t.maxTextureSize);const Q=new Float32Array(F*O*4*g),G=new DataArrayTexture(Q,F,O,g);G.type=Me,G.needsUpdate=!0;const W=4*U;for(let q=0;q<g;q++){const j=I[q],X=T[q],Y=B[q],K=F*O*4*q;for(let J=0;J<j.count;J++){const $=J*W;!0===S&&(c.fromBufferAttribute(j,J),Q[K+$+0]=c.x,Q[K+$+1]=c.y,Q[K+$+2]=c.z,Q[K+$+3]=0),!0===C&&(c.fromBufferAttribute(X,J),Q[K+$+4]=c.x,Q[K+$+5]=c.y,Q[K+$+6]=c.z,Q[K+$+7]=0),!0===b&&(c.fromBufferAttribute(Y,J),Q[K+$+8]=c.x,Q[K+$+9]=c.y,Q[K+$+10]=c.z,Q[K+$+11]=4===Y.itemSize?c.w:1)}}function disposeTexture(){G.dispose(),l.delete(p),p.removeEventListener("dispose",disposeTexture)}_={count:g,texture:G,size:new Vector2(F,O)},l.set(p,_),p.addEventListener("dispose",disposeTexture)}let y=0;for(let ee=0;ee<m.length;ee++)y+=m[ee];const x=p.morphTargetsRelative?1:1-y;A.getUniforms().setValue(e,"morphTargetBaseInfluence",x),A.getUniforms().setValue(e,"morphTargetInfluences",m),A.getUniforms().setValue(e,"morphTargetsTexture",_.texture,r),A.getUniforms().setValue(e,"morphTargetsTextureSize",_.size)}else{const te=void 0===m?0:m.length;let ie=s[p.id];if(void 0===ie||ie.length!==te){ie=[];for(let oe=0;oe<te;oe++)ie[oe]=[oe,0];s[p.id]=ie}for(let le=0;le<te;le++){const ce=ie[le];ce[0]=le,ce[1]=m[le]}ie.sort(absNumericalSort);for(let he=0;he<8;he++)he<te&&ie[he][1]?(h[he][0]=ie[he][0],h[he][1]=ie[he][1]):(h[he][0]=Number.MAX_SAFE_INTEGER,h[he][1]=0);h.sort(numericalSort);const ne=p.morphAttributes.position,re=p.morphAttributes.normal;let se=0;for(let ue=0;ue<8;ue++){const de=h[ue],pe=de[0],Ae=de[1];pe!==Number.MAX_SAFE_INTEGER&&Ae?(ne&&p.getAttribute("morphTarget"+ue)!==ne[pe]&&p.setAttribute("morphTarget"+ue,ne[pe]),re&&p.getAttribute("morphNormal"+ue)!==re[pe]&&p.setAttribute("morphNormal"+ue,re[pe]),o[ue]=Ae,se+=Ae):(ne&&!0===p.hasAttribute("morphTarget"+ue)&&p.deleteAttribute("morphTarget"+ue),re&&!0===p.hasAttribute("morphNormal"+ue)&&p.deleteAttribute("morphNormal"+ue),o[ue]=0)}const ae=p.morphTargetsRelative?1:1-se;A.getUniforms().setValue(e,"morphTargetBaseInfluence",ae),A.getUniforms().setValue(e,"morphTargetInfluences",o)}}}}function WebGLObjects(e,t,r,s){let o=new WeakMap;function onInstancedMeshDispose(e){const t=e.target;t.removeEventListener("dispose",onInstancedMeshDispose),r.remove(t.instanceMatrix),null!==t.instanceColor&&r.remove(t.instanceColor)}return{update:function update(l){const c=s.render.frame,h=l.geometry,d=t.get(l,h);if(o.get(d)!==c&&(t.update(d),o.set(d,c)),l.isInstancedMesh&&(!1===l.hasEventListener("dispose",onInstancedMeshDispose)&&l.addEventListener("dispose",onInstancedMeshDispose),o.get(l)!==c&&(r.update(l.instanceMatrix,e.ARRAY_BUFFER),null!==l.instanceColor&&r.update(l.instanceColor,e.ARRAY_BUFFER),o.set(l,c))),l.isSkinnedMesh){const e=l.skeleton;o.get(e)!==c&&(e.update(),o.set(e,c))}return d},dispose:function dispose(){o=new WeakMap}}}class DepthTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d,p){if((p=void 0!==p?p:Ie)!==Ie&&p!==Te)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&p===Ie&&(r=Se),void 0===r&&p===Te&&(r=be),super(null,s,o,l,c,h,p,r,d),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==c?c:Ae,this.minFilter=void 0!==h?h:Ae,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}}const jn=new Texture,Xn=new DepthTexture(1,1);Xn.compareFunction=515;const Yn=new DataArrayTexture,Kn=new Data3DTexture,Jn=new CubeTexture,$n=[],Zn=[],er=new Float32Array(16),tr=new Float32Array(9),ir=new Float32Array(4);function flatten(e,t,r){const s=e[0];if(s<=0||s>0)return e;const o=t*r;let l=$n[o];if(void 0===l&&(l=new Float32Array(o),$n[o]=l),0!==t){s.toArray(l,0);for(let s=1,o=0;s!==t;++s)o+=r,e[s].toArray(l,o)}return l}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(let r=0,s=e.length;r<s;r++)if(e[r]!==t[r])return!1;return!0}function copyArray(e,t){for(let r=0,s=t.length;r<s;r++)e[r]=t[r]}function allocTexUnits(e,t){let r=Zn[t];void 0===r&&(r=new Int32Array(t),Zn[t]=r);for(let s=0;s!==t;++s)r[s]=e.allocateTextureUnit();return r}function setValueV1f(e,t){const r=this.cache;r[0]!==t&&(e.uniform1f(this.addr,t),r[0]=t)}function setValueV2f(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y);else{if(arraysEqual(r,t))return;e.uniform2fv(this.addr,t),copyArray(r,t)}}function setValueV3f(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z);else if(void 0!==t.r)r[0]===t.r&&r[1]===t.g&&r[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),r[0]=t.r,r[1]=t.g,r[2]=t.b);else{if(arraysEqual(r,t))return;e.uniform3fv(this.addr,t),copyArray(r,t)}}function setValueV4f(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w);else{if(arraysEqual(r,t))return;e.uniform4fv(this.addr,t),copyArray(r,t)}}function setValueM2(e,t){const r=this.cache,s=t.elements;if(void 0===s){if(arraysEqual(r,t))return;e.uniformMatrix2fv(this.addr,!1,t),copyArray(r,t)}else{if(arraysEqual(r,s))return;ir.set(s),e.uniformMatrix2fv(this.addr,!1,ir),copyArray(r,s)}}function setValueM3(e,t){const r=this.cache,s=t.elements;if(void 0===s){if(arraysEqual(r,t))return;e.uniformMatrix3fv(this.addr,!1,t),copyArray(r,t)}else{if(arraysEqual(r,s))return;tr.set(s),e.uniformMatrix3fv(this.addr,!1,tr),copyArray(r,s)}}function setValueM4(e,t){const r=this.cache,s=t.elements;if(void 0===s){if(arraysEqual(r,t))return;e.uniformMatrix4fv(this.addr,!1,t),copyArray(r,t)}else{if(arraysEqual(r,s))return;er.set(s),e.uniformMatrix4fv(this.addr,!1,er),copyArray(r,s)}}function setValueV1i(e,t){const r=this.cache;r[0]!==t&&(e.uniform1i(this.addr,t),r[0]=t)}function setValueV2i(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y);else{if(arraysEqual(r,t))return;e.uniform2iv(this.addr,t),copyArray(r,t)}}function setValueV3i(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z);else{if(arraysEqual(r,t))return;e.uniform3iv(this.addr,t),copyArray(r,t)}}function setValueV4i(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w);else{if(arraysEqual(r,t))return;e.uniform4iv(this.addr,t),copyArray(r,t)}}function setValueV1ui(e,t){const r=this.cache;r[0]!==t&&(e.uniform1ui(this.addr,t),r[0]=t)}function setValueV2ui(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y);else{if(arraysEqual(r,t))return;e.uniform2uiv(this.addr,t),copyArray(r,t)}}function setValueV3ui(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z);else{if(arraysEqual(r,t))return;e.uniform3uiv(this.addr,t),copyArray(r,t)}}function setValueV4ui(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w);else{if(arraysEqual(r,t))return;e.uniform4uiv(this.addr,t),copyArray(r,t)}}function setValueT1(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o);const l=this.type===e.SAMPLER_2D_SHADOW?Xn:jn;r.setTexture2D(t||l,o)}function setValueT3D1(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o),r.setTexture3D(t||Kn,o)}function setValueT6(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o),r.setTextureCube(t||Jn,o)}function setValueT2DArray1(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o),r.setTexture2DArray(t||Yn,o)}function setValueV1fArray(e,t){e.uniform1fv(this.addr,t)}function setValueV2fArray(e,t){const r=flatten(t,this.size,2);e.uniform2fv(this.addr,r)}function setValueV3fArray(e,t){const r=flatten(t,this.size,3);e.uniform3fv(this.addr,r)}function setValueV4fArray(e,t){const r=flatten(t,this.size,4);e.uniform4fv(this.addr,r)}function setValueM2Array(e,t){const r=flatten(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,r)}function setValueM3Array(e,t){const r=flatten(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,r)}function setValueM4Array(e,t){const r=flatten(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,r)}function setValueV1iArray(e,t){e.uniform1iv(this.addr,t)}function setValueV2iArray(e,t){e.uniform2iv(this.addr,t)}function setValueV3iArray(e,t){e.uniform3iv(this.addr,t)}function setValueV4iArray(e,t){e.uniform4iv(this.addr,t)}function setValueV1uiArray(e,t){e.uniform1uiv(this.addr,t)}function setValueV2uiArray(e,t){e.uniform2uiv(this.addr,t)}function setValueV3uiArray(e,t){e.uniform3uiv(this.addr,t)}function setValueV4uiArray(e,t){e.uniform4uiv(this.addr,t)}function setValueT1Array(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTexture2D(t[e]||jn,l[e])}function setValueT3DArray(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTexture3D(t[e]||Kn,l[e])}function setValueT6Array(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTextureCube(t[e]||Jn,l[e])}function setValueT2DArrayArray(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTexture2DArray(t[e]||Yn,l[e])}class SingleUniform{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.setValue=function getSingularSetter(e){switch(e){case 5126:return setValueV1f;case 35664:return setValueV2f;case 35665:return setValueV3f;case 35666:return setValueV4f;case 35674:return setValueM2;case 35675:return setValueM3;case 35676:return setValueM4;case 5124:case 35670:return setValueV1i;case 35667:case 35671:return setValueV2i;case 35668:case 35672:return setValueV3i;case 35669:case 35673:return setValueV4i;case 5125:return setValueV1ui;case 36294:return setValueV2ui;case 36295:return setValueV3ui;case 36296:return setValueV4ui;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1;case 35679:case 36299:case 36307:return setValueT3D1;case 35680:case 36300:case 36308:case 36293:return setValueT6;case 36289:case 36303:case 36311:case 36292:return setValueT2DArray1}}(t.type)}}class PureArrayUniform{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function getPureArraySetter(e){switch(e){case 5126:return setValueV1fArray;case 35664:return setValueV2fArray;case 35665:return setValueV3fArray;case 35666:return setValueV4fArray;case 35674:return setValueM2Array;case 35675:return setValueM3Array;case 35676:return setValueM4Array;case 5124:case 35670:return setValueV1iArray;case 35667:case 35671:return setValueV2iArray;case 35668:case 35672:return setValueV3iArray;case 35669:case 35673:return setValueV4iArray;case 5125:return setValueV1uiArray;case 36294:return setValueV2uiArray;case 36295:return setValueV3uiArray;case 36296:return setValueV4uiArray;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1Array;case 35679:case 36299:case 36307:return setValueT3DArray;case 35680:case 36300:case 36308:case 36293:return setValueT6Array;case 36289:case 36303:case 36311:case 36292:return setValueT2DArrayArray}}(t.type)}}class StructuredUniform{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,r){const s=this.seq;for(let o=0,l=s.length;o!==l;++o){const l=s[o];l.setValue(e,t[l.id],r)}}}const nr=/(\w+)(\])?(\[|\.)?/g;function addUniform(e,t){e.seq.push(t),e.map[t.id]=t}function parseUniform(e,t,r){const s=e.name,o=s.length;for(nr.lastIndex=0;;){const l=nr.exec(s),c=nr.lastIndex;let h=l[1];const d="]"===l[2],p=l[3];if(d&&(h|=0),void 0===p||"["===p&&c+2===o){addUniform(r,void 0===p?new SingleUniform(h,e,t):new PureArrayUniform(h,e,t));break}{let e=r.map[h];void 0===e&&(e=new StructuredUniform(h),addUniform(r,e)),r=e}}}class WebGLUniforms{constructor(e,t){this.seq=[],this.map={};const r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;++s){const r=e.getActiveUniform(t,s);parseUniform(r,e.getUniformLocation(t,r.name),this)}}setValue(e,t,r,s){const o=this.map[t];void 0!==o&&o.setValue(e,r,s)}setOptional(e,t,r){const s=t[r];void 0!==s&&this.setValue(e,r,s)}static upload(e,t,r,s){for(let o=0,l=t.length;o!==l;++o){const l=t[o],c=r[l.id];!1!==c.needsUpdate&&l.setValue(e,c.value,s)}}static seqWithValue(e,t){const r=[];for(let s=0,o=e.length;s!==o;++s){const o=e[s];o.id in t&&r.push(o)}return r}}function WebGLShader(e,t,r){const s=e.createShader(t);return e.shaderSource(s,r),e.compileShader(s),s}const rr=37297;let sr=0;function getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),o=e.getShaderInfoLog(t).trim();if(s&&""===o)return"";const l=/ERROR: 0:(\d+)/.exec(o);if(l){const s=parseInt(l[1]);return r.toUpperCase()+"\n\n"+o+"\n\n"+function handleSource(e,t){const r=e.split("\n"),s=[],o=Math.max(t-6,0),l=Math.min(t+6,r.length);for(let e=o;e<l;e++){const o=e+1;s.push(`${o===t?">":" "} ${o}: ${r[e]}`)}return s.join("\n")}(e.getShaderSource(t),s)}return o}function getTexelEncodingFunction(e,t){const r=function getEncodingComponents(e){const t=Ut.getPrimaries(Ut.workingColorSpace),r=Ut.getPrimaries(e);let s;switch(t===r?s="":t===lt&&r===ot?s="LinearDisplayP3ToLinearSRGB":t===ot&&r===lt&&(s="LinearSRGBToLinearDisplayP3"),e){case it:case rt:return[s,"LinearTransferOETF"];case tt:case nt:return[s,"sRGBTransferOETF"];default:return o.warn("THREE.WebGLProgram: Unsupported color space:",e),[s,"LinearTransferOETF"]}}(t);return`vec4 ${e}( vec4 value ) { return ${r[0]}( ${r[1]}( value ) ); }`}function getToneMappingFunction(e,t){let r;switch(t){case J:r="Linear";break;case $:r="Reinhard";break;case ee:r="OptimizedCineon";break;case te:r="ACESFilmic";break;case ne:r="AgX";break;case ie:r="Custom";break;default:o.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),r="Linear"}return"vec3 "+e+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}function filterEmptyLine(e){return""!==e}function replaceLightNums(e,t){const r=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,r).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 replaceClippingPlaneNums(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const ar=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(e){return e.replace(ar,includeReplacer)}const or=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function includeReplacer(e,t){let r=Dn[t];if(void 0===r){const e=or.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");r=Dn[e],o.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return resolveIncludes(r)}const lr=/#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 unrollLoops(e){return e.replace(lr,loopReplacer)}function loopReplacer(e,t,r,s){let o="";for(let e=parseInt(t);e<parseInt(r);e++)o+=s.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return o}function generatePrecision(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function WebGLProgram(e,t,r,s){const l=e.getContext(),p=r.defines;let A=r.vertexShader,m=r.fragmentShader;const f=function generateShadowMapTypeDefine(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===c?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===h?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===d&&(t="SHADOWMAP_TYPE_VSM"),t}(r),g=function generateEnvMapTypeDefine(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case ae:case oe:t="ENVMAP_TYPE_CUBE";break;case he:t="ENVMAP_TYPE_CUBE_UV"}return t}(r),_=function generateEnvMapModeDefine(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===oe&&(t="ENVMAP_MODE_REFRACTION");return t}(r),y=function generateEnvMapBlendingDefine(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case j:t="ENVMAP_BLENDING_MULTIPLY";break;case X:t="ENVMAP_BLENDING_MIX";break;case Y:t="ENVMAP_BLENDING_ADD"}return t}(r),x=function generateCubeUVSize(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const r=Math.log2(t)-2,s=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,r),112)),texelHeight:s,maxMip:r}}(r),S=r.isWebGL2?"":function generateExtensions(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(filterEmptyLine).join("\n")}(r),C=function generateVertexExtensions(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(filterEmptyLine).join("\n")}(r),b=function generateDefines(e){const t=[];for(const r in e){const s=e[r];!1!==s&&t.push("#define "+r+" "+s)}return t.join("\n")}(p),I=l.createProgram();let T,B,U=r.glslVersion?"#version "+r.glslVersion+"\n":"";r.isRawShaderMaterial?(T=["#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,b].filter(filterEmptyLine).join("\n"),T.length>0&&(T+="\n"),B=[S,"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,b].filter(filterEmptyLine).join("\n"),B.length>0&&(B+="\n")):(T=[generatePrecision(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,b,r.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",r.batching?"#define USE_BATCHING":"",r.instancing?"#define USE_INSTANCING":"",r.instancingColor?"#define USE_INSTANCING_COLOR":"",r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+_:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.displacementMap?"#define USE_DISPLACEMENTMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.mapUv?"#define MAP_UV "+r.mapUv:"",r.alphaMapUv?"#define ALPHAMAP_UV "+r.alphaMapUv:"",r.lightMapUv?"#define LIGHTMAP_UV "+r.lightMapUv:"",r.aoMapUv?"#define AOMAP_UV "+r.aoMapUv:"",r.emissiveMapUv?"#define EMISSIVEMAP_UV "+r.emissiveMapUv:"",r.bumpMapUv?"#define BUMPMAP_UV "+r.bumpMapUv:"",r.normalMapUv?"#define NORMALMAP_UV "+r.normalMapUv:"",r.displacementMapUv?"#define DISPLACEMENTMAP_UV "+r.displacementMapUv:"",r.metalnessMapUv?"#define METALNESSMAP_UV "+r.metalnessMapUv:"",r.roughnessMapUv?"#define ROUGHNESSMAP_UV "+r.roughnessMapUv:"",r.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+r.anisotropyMapUv:"",r.clearcoatMapUv?"#define CLEARCOATMAP_UV "+r.clearcoatMapUv:"",r.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+r.clearcoatNormalMapUv:"",r.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+r.clearcoatRoughnessMapUv:"",r.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+r.iridescenceMapUv:"",r.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+r.iridescenceThicknessMapUv:"",r.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+r.sheenColorMapUv:"",r.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+r.sheenRoughnessMapUv:"",r.specularMapUv?"#define SPECULARMAP_UV "+r.specularMapUv:"",r.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+r.specularColorMapUv:"",r.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+r.specularIntensityMapUv:"",r.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+r.transmissionMapUv:"",r.thicknessMapUv?"#define THICKNESSMAP_UV "+r.thicknessMapUv:"",r.vertexTangents&&!1===r.flatShading?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&!1===r.flatShading?"#define USE_MORPHNORMALS":"",r.morphColors&&r.isWebGL2?"#define USE_MORPHCOLORS":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+r.morphTextureStride:"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_COUNT "+r.morphTargetsCount:"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+f:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.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(filterEmptyLine).join("\n"),B=[S,generatePrecision(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,b,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+g:"",r.envMap?"#define "+_:"",r.envMap?"#define "+y:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.maxMip+".0":"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoat?"#define USE_CLEARCOAT":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescence?"#define USE_IRIDESCENCE":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaTest?"#define USE_ALPHATEST":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.sheen?"#define USE_SHEEN":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.vertexTangents&&!1===r.flatShading?"#define USE_TANGENT":"",r.vertexColors||r.instancingColor?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+f:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",r.toneMapping!==K?"#define TONE_MAPPING":"",r.toneMapping!==K?Dn.tonemapping_pars_fragment:"",r.toneMapping!==K?getToneMappingFunction("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",r.opaque?"#define OPAQUE":"",Dn.colorspace_pars_fragment,getTexelEncodingFunction("linearToOutputTexel",r.outputColorSpace),r.useDepthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(filterEmptyLine).join("\n")),A=resolveIncludes(A),A=replaceLightNums(A,r),A=replaceClippingPlaneNums(A,r),m=resolveIncludes(m),m=replaceLightNums(m,r),m=replaceClippingPlaneNums(m,r),A=unrollLoops(A),m=unrollLoops(m),r.isWebGL2&&!0!==r.isRawShaderMaterial&&(U="#version 300 es\n",T=[C,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+T,B=["precision mediump sampler2DArray;","#define varying in",r.glslVersion===vt?"":"layout(location = 0) out highp vec4 pc_fragColor;",r.glslVersion===vt?"":"#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"+B);const F=U+T+A,O=U+B+m,Q=WebGLShader(l,l.VERTEX_SHADER,F),G=WebGLShader(l,l.FRAGMENT_SHADER,O);function onFirstUse(t){if(e.debug.checkShaderErrors){const r=l.getProgramInfoLog(I).trim(),s=l.getShaderInfoLog(Q).trim(),c=l.getShaderInfoLog(G).trim();let h=!0,d=!0;if(!1===l.getProgramParameter(I,l.LINK_STATUS))if(h=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(l,I,Q,G);else{const e=getShaderErrors(l,Q,"vertex"),t=getShaderErrors(l,G,"fragment");o.error("THREE.WebGLProgram: Shader Error "+l.getError()+" - VALIDATE_STATUS "+l.getProgramParameter(I,l.VALIDATE_STATUS)+"\n\nProgram Info Log: "+r+"\n"+e+"\n"+t)}else""!==r?o.warn("THREE.WebGLProgram: Program Info Log:",r):""!==s&&""!==c||(d=!1);d&&(t.diagnostics={runnable:h,programLog:r,vertexShader:{log:s,prefix:T},fragmentShader:{log:c,prefix:B}})}l.deleteShader(Q),l.deleteShader(G),W=new WebGLUniforms(l,I),q=function fetchAttributeLocations(e,t){const r={},s=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){const s=e.getActiveAttrib(t,o),l=s.name;let c=1;s.type===e.FLOAT_MAT2&&(c=2),s.type===e.FLOAT_MAT3&&(c=3),s.type===e.FLOAT_MAT4&&(c=4),r[l]={type:s.type,location:e.getAttribLocation(t,l),locationSize:c}}return r}(l,I)}let W,q;l.attachShader(I,Q),l.attachShader(I,G),void 0!==r.index0AttributeName?l.bindAttribLocation(I,0,r.index0AttributeName):!0===r.morphTargets&&l.bindAttribLocation(I,0,"position"),l.linkProgram(I),this.getUniforms=function(){return void 0===W&&onFirstUse(this),W},this.getAttributes=function(){return void 0===q&&onFirstUse(this),q};let J=!1===r.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===J&&(J=l.getProgramParameter(I,rr)),J},this.destroy=function(){s.releaseStatesOfProgram(this),l.deleteProgram(I),this.program=void 0},this.type=r.shaderType,this.name=r.shaderName,this.id=sr++,this.cacheKey=t,this.usedTimes=1,this.program=I,this.vertexShader=Q,this.fragmentShader=G,this}let cr=0;class WebGLShaderCache{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,s=this._getShaderStage(t),o=this._getShaderStage(r),l=this._getShaderCacheForMaterial(e);return!1===l.has(s)&&(l.add(s),s.usedTimes++),!1===l.has(o)&&(l.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return void 0===r&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return void 0===r&&(r=new WebGLShaderStage(e),t.set(e,r)),r}}class WebGLShaderStage{constructor(e){this.id=cr++,this.code=e,this.usedTimes=0}}function WebGLPrograms(e,t,r,s,l,c,h){const d=new Layers,p=new WebGLShaderCache,f=[],g=l.isWebGL2,_=l.logarithmicDepthBuffer,y=l.vertexTextures;let x=l.precision;const S={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function getChannel(e){return 0===e?"uv":`uv${e}`}return{getParameters:function getParameters(c,d,f,C,b){const I=C.fog,T=b.geometry,B=c.isMeshStandardMaterial?C.environment:null,U=(c.isMeshStandardMaterial?r:t).get(c.envMap||B),F=U&&U.mapping===he?U.image.height:null,O=S[c.type];null!==c.precision&&(x=l.getMaxPrecision(c.precision),x!==c.precision&&o.warn("THREE.WebGLProgram.getParameters:",c.precision,"not supported, using",x,"instead."));const Q=T.morphAttributes.position||T.morphAttributes.normal||T.morphAttributes.color,G=void 0!==Q?Q.length:0;let W,q,j,X,Y=0;if(void 0!==T.morphAttributes.position&&(Y=1),void 0!==T.morphAttributes.normal&&(Y=2),void 0!==T.morphAttributes.color&&(Y=3),O){const e=Pn[O];W=e.vertexShader,q=e.fragmentShader}else W=c.vertexShader,q=c.fragmentShader,p.update(c),j=p.getVertexShaderID(c),X=p.getFragmentShaderID(c);const J=e.getRenderTarget(),$=!0===b.isInstancedMesh,ee=!0===b.isBatchedMesh,te=!!c.map,ie=!!c.matcap,ne=!!U,re=!!c.aoMap,se=!!c.lightMap,ae=!!c.bumpMap,oe=!!c.normalMap,le=!!c.displacementMap,ce=!!c.emissiveMap,ue=!!c.metalnessMap,de=!!c.roughnessMap,pe=c.anisotropy>0,Ae=c.clearcoat>0,me=c.iridescence>0,fe=c.sheen>0,ge=c.transmission>0,_e=pe&&!!c.anisotropyMap,ve=Ae&&!!c.clearcoatMap,ye=Ae&&!!c.clearcoatNormalMap,Ee=Ae&&!!c.clearcoatRoughnessMap,xe=me&&!!c.iridescenceMap,Se=me&&!!c.iridescenceThicknessMap,Me=fe&&!!c.sheenColorMap,Ce=fe&&!!c.sheenRoughnessMap,be=!!c.specularMap,we=!!c.specularColorMap,Ie=!!c.specularIntensityMap,Te=ge&&!!c.transmissionMap,Be=ge&&!!c.thicknessMap,Re=!!c.gradientMap,Le=!!c.alphaMap,De=c.alphaTest>0,Ue=!!c.alphaHash,Pe=!!c.extensions,Fe=!!T.attributes.uv1,Ne=!!T.attributes.uv2,Oe=!!T.attributes.uv3;let Qe=K;return c.toneMapped&&(null!==J&&!0!==J.isXRRenderTarget||(Qe=e.toneMapping)),{isWebGL2:g,shaderID:O,shaderType:c.type,shaderName:c.name,vertexShader:W,fragmentShader:q,defines:c.defines,customVertexShaderID:j,customFragmentShaderID:X,isRawShaderMaterial:!0===c.isRawShaderMaterial,glslVersion:c.glslVersion,precision:x,batching:ee,instancing:$,instancingColor:$&&null!==b.instanceColor,supportsVertexTextures:y,outputColorSpace:null===J?e.outputColorSpace:!0===J.isXRRenderTarget?J.texture.colorSpace:it,map:te,matcap:ie,envMap:ne,envMapMode:ne&&U.mapping,envMapCubeUVHeight:F,aoMap:re,lightMap:se,bumpMap:ae,normalMap:oe,displacementMap:y&&le,emissiveMap:ce,normalMapObjectSpace:oe&&1===c.normalMapType,normalMapTangentSpace:oe&&0===c.normalMapType,metalnessMap:ue,roughnessMap:de,anisotropy:pe,anisotropyMap:_e,clearcoat:Ae,clearcoatMap:ve,clearcoatNormalMap:ye,clearcoatRoughnessMap:Ee,iridescence:me,iridescenceMap:xe,iridescenceThicknessMap:Se,sheen:fe,sheenColorMap:Me,sheenRoughnessMap:Ce,specularMap:be,specularColorMap:we,specularIntensityMap:Ie,transmission:ge,transmissionMap:Te,thicknessMap:Be,gradientMap:Re,opaque:!1===c.transparent&&1===c.blending,alphaMap:Le,alphaTest:De,alphaHash:Ue,combine:c.combine,mapUv:te&&getChannel(c.map.channel),aoMapUv:re&&getChannel(c.aoMap.channel),lightMapUv:se&&getChannel(c.lightMap.channel),bumpMapUv:ae&&getChannel(c.bumpMap.channel),normalMapUv:oe&&getChannel(c.normalMap.channel),displacementMapUv:le&&getChannel(c.displacementMap.channel),emissiveMapUv:ce&&getChannel(c.emissiveMap.channel),metalnessMapUv:ue&&getChannel(c.metalnessMap.channel),roughnessMapUv:de&&getChannel(c.roughnessMap.channel),anisotropyMapUv:_e&&getChannel(c.anisotropyMap.channel),clearcoatMapUv:ve&&getChannel(c.clearcoatMap.channel),clearcoatNormalMapUv:ye&&getChannel(c.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ee&&getChannel(c.clearcoatRoughnessMap.channel),iridescenceMapUv:xe&&getChannel(c.iridescenceMap.channel),iridescenceThicknessMapUv:Se&&getChannel(c.iridescenceThicknessMap.channel),sheenColorMapUv:Me&&getChannel(c.sheenColorMap.channel),sheenRoughnessMapUv:Ce&&getChannel(c.sheenRoughnessMap.channel),specularMapUv:be&&getChannel(c.specularMap.channel),specularColorMapUv:we&&getChannel(c.specularColorMap.channel),specularIntensityMapUv:Ie&&getChannel(c.specularIntensityMap.channel),transmissionMapUv:Te&&getChannel(c.transmissionMap.channel),thicknessMapUv:Be&&getChannel(c.thicknessMap.channel),alphaMapUv:Le&&getChannel(c.alphaMap.channel),vertexTangents:!!T.attributes.tangent&&(oe||pe),vertexColors:c.vertexColors,vertexAlphas:!0===c.vertexColors&&!!T.attributes.color&&4===T.attributes.color.itemSize,vertexUv1s:Fe,vertexUv2s:Ne,vertexUv3s:Oe,pointsUvs:!0===b.isPoints&&!!T.attributes.uv&&(te||Le),fog:!!I,useFog:!0===c.fog,fogExp2:I&&I.isFogExp2,flatShading:!0===c.flatShading,sizeAttenuation:!0===c.sizeAttenuation,logarithmicDepthBuffer:_,skinning:!0===b.isSkinnedMesh,morphTargets:void 0!==T.morphAttributes.position,morphNormals:void 0!==T.morphAttributes.normal,morphColors:void 0!==T.morphAttributes.color,morphTargetsCount:G,morphTextureStride:Y,numDirLights:d.directional.length,numPointLights:d.point.length,numSpotLights:d.spot.length,numSpotLightMaps:d.spotLightMap.length,numRectAreaLights:d.rectArea.length,numHemiLights:d.hemi.length,numDirLightShadows:d.directionalShadowMap.length,numPointLightShadows:d.pointShadowMap.length,numSpotLightShadows:d.spotShadowMap.length,numSpotLightShadowsWithMaps:d.numSpotLightShadowsWithMaps,numLightProbes:d.numLightProbes,numClippingPlanes:h.numPlanes,numClipIntersection:h.numIntersection,dithering:c.dithering,shadowMapEnabled:e.shadowMap.enabled&&f.length>0,shadowMapType:e.shadowMap.type,toneMapping:Qe,useLegacyLights:e._useLegacyLights,decodeVideoTexture:te&&!0===c.map.isVideoTexture&&Ut.getTransfer(c.map.colorSpace)===at,premultipliedAlpha:c.premultipliedAlpha,doubleSided:c.side===m,flipSided:c.side===A,useDepthPacking:c.depthPacking>=0,depthPacking:c.depthPacking||0,index0AttributeName:c.index0AttributeName,extensionDerivatives:Pe&&!0===c.extensions.derivatives,extensionFragDepth:Pe&&!0===c.extensions.fragDepth,extensionDrawBuffers:Pe&&!0===c.extensions.drawBuffers,extensionShaderTextureLOD:Pe&&!0===c.extensions.shaderTextureLOD,extensionClipCullDistance:Pe&&c.extensions.clipCullDistance&&s.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:g||s.has("EXT_frag_depth"),rendererExtensionDrawBuffers:g||s.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:g||s.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:s.has("KHR_parallel_shader_compile"),customProgramCacheKey:c.customProgramCacheKey()}},getProgramCacheKey:function getProgramCacheKey(t){const r=[];if(t.shaderID?r.push(t.shaderID):(r.push(t.customVertexShaderID),r.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)r.push(e),r.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function getProgramCacheKeyParameters(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.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(r,t),function getProgramCacheKeyBooleans(e,t){d.disableAll(),t.isWebGL2&&d.enable(0);t.supportsVertexTextures&&d.enable(1);t.instancing&&d.enable(2);t.instancingColor&&d.enable(3);t.matcap&&d.enable(4);t.envMap&&d.enable(5);t.normalMapObjectSpace&&d.enable(6);t.normalMapTangentSpace&&d.enable(7);t.clearcoat&&d.enable(8);t.iridescence&&d.enable(9);t.alphaTest&&d.enable(10);t.vertexColors&&d.enable(11);t.vertexAlphas&&d.enable(12);t.vertexUv1s&&d.enable(13);t.vertexUv2s&&d.enable(14);t.vertexUv3s&&d.enable(15);t.vertexTangents&&d.enable(16);t.anisotropy&&d.enable(17);t.alphaHash&&d.enable(18);t.batching&&d.enable(19);e.push(d.mask),d.disableAll(),t.fog&&d.enable(0);t.useFog&&d.enable(1);t.flatShading&&d.enable(2);t.logarithmicDepthBuffer&&d.enable(3);t.skinning&&d.enable(4);t.morphTargets&&d.enable(5);t.morphNormals&&d.enable(6);t.morphColors&&d.enable(7);t.premultipliedAlpha&&d.enable(8);t.shadowMapEnabled&&d.enable(9);t.useLegacyLights&&d.enable(10);t.doubleSided&&d.enable(11);t.flipSided&&d.enable(12);t.useDepthPacking&&d.enable(13);t.dithering&&d.enable(14);t.transmission&&d.enable(15);t.sheen&&d.enable(16);t.opaque&&d.enable(17);t.pointsUvs&&d.enable(18);t.decodeVideoTexture&&d.enable(19);e.push(d.mask)}(r,t),r.push(e.outputColorSpace)),r.push(t.customProgramCacheKey),r.join()},getUniforms:function getUniforms(e){const t=S[e.type];let r;if(t){const e=Pn[t];r=bn.clone(e.uniforms)}else r=e.uniforms;return r},acquireProgram:function acquireProgram(t,r){let s;for(let e=0,t=f.length;e<t;e++){const t=f[e];if(t.cacheKey===r){s=t,++s.usedTimes;break}}return void 0===s&&(s=new WebGLProgram(e,r,t,c),f.push(s)),s},releaseProgram:function releaseProgram(e){if(0==--e.usedTimes){const t=f.indexOf(e);f[t]=f[f.length-1],f.pop(),e.destroy()}},releaseShaderCache:function releaseShaderCache(e){p.remove(e)},programs:f,dispose:function dispose(){p.dispose()}}}function WebGLProperties(){let e=new WeakMap;return{get:function get(t){let r=e.get(t);return void 0===r&&(r={},e.set(t,r)),r},remove:function remove(t){e.delete(t)},update:function update(t,r,s){e.get(t)[r]=s},dispose:function dispose(){e=new WeakMap}}}function painterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function reversePainterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function WebGLRenderList(){const e=[];let t=0;const r=[],s=[],o=[];function getNextRenderItem(r,s,o,l,c,h){let d=e[t];return void 0===d?(d={id:r.id,object:r,geometry:s,material:o,groupOrder:l,renderOrder:r.renderOrder,z:c,group:h},e[t]=d):(d.id=r.id,d.object=r,d.geometry=s,d.material=o,d.groupOrder=l,d.renderOrder=r.renderOrder,d.z=c,d.group=h),t++,d}return{opaque:r,transmissive:s,transparent:o,init:function init(){t=0,r.length=0,s.length=0,o.length=0},push:function push(e,t,l,c,h,d){const p=getNextRenderItem(e,t,l,c,h,d);l.transmission>0?s.push(p):!0===l.transparent?o.push(p):r.push(p)},unshift:function unshift(e,t,l,c,h,d){const p=getNextRenderItem(e,t,l,c,h,d);l.transmission>0?s.unshift(p):!0===l.transparent?o.unshift(p):r.unshift(p)},finish:function finish(){for(let r=t,s=e.length;r<s;r++){const t=e[r];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function sort(e,t){r.length>1&&r.sort(e||painterSortStable),s.length>1&&s.sort(t||reversePainterSortStable),o.length>1&&o.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(){let e=new WeakMap;return{get:function get(t,r){const s=e.get(t);let o;return void 0===s?(o=new WebGLRenderList,e.set(t,[o])):r>=s.length?(o=new WebGLRenderList,s.push(o)):o=s[r],o},dispose:function dispose(){e=new WeakMap}}}function UniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let r;switch(t.type){case"DirectionalLight":r={direction:new three_module_Vector3,color:new Color};break;case"SpotLight":r={position:new three_module_Vector3,direction:new three_module_Vector3,color:new Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new three_module_Vector3,color:new Color,distance:0,decay:0};break;case"HemisphereLight":r={direction:new three_module_Vector3,skyColor:new Color,groundColor:new Color};break;case"RectAreaLight":r={color:new Color,position:new three_module_Vector3,halfWidth:new three_module_Vector3,halfHeight:new three_module_Vector3}}return e[t.id]=r,r}}}let hr=0;function shadowCastingAndTexturingLightsFirst(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function WebGLLights(e,t){const r=new UniformsCache,s=function ShadowUniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let r;switch(t.type){case"DirectionalLight":case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=r,r}}}(),l={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-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,numLightProbes:0};for(let e=0;e<9;e++)l.probe.push(new three_module_Vector3);const c=new three_module_Vector3,h=new three_module_Matrix4,d=new three_module_Matrix4;return{setup:function setup(c,h){let d=0,p=0,A=0;for(let e=0;e<9;e++)l.probe[e].set(0,0,0);let m=0,f=0,g=0,_=0,y=0,x=0,S=0,C=0,b=0,I=0,T=0;c.sort(shadowCastingAndTexturingLightsFirst);const B=!0===h?Math.PI:1;for(let e=0,t=c.length;e<t;e++){const t=c[e],o=t.color,h=t.intensity,U=t.distance,F=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)d+=o.r*h*B,p+=o.g*h*B,A+=o.b*h*B;else if(t.isLightProbe){for(let e=0;e<9;e++)l.probe[e].addScaledVector(t.sh.coefficients[e],h);T++}else if(t.isDirectionalLight){const e=r.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*B),t.castShadow){const e=t.shadow,r=s.get(t);r.shadowBias=e.bias,r.shadowNormalBias=e.normalBias,r.shadowRadius=e.radius,r.shadowMapSize=e.mapSize,l.directionalShadow[m]=r,l.directionalShadowMap[m]=F,l.directionalShadowMatrix[m]=t.shadow.matrix,x++}l.directional[m]=e,m++}else if(t.isSpotLight){const e=r.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(o).multiplyScalar(h*B),e.distance=U,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,l.spot[g]=e;const c=t.shadow;if(t.map&&(l.spotLightMap[b]=t.map,b++,c.updateMatrices(t),t.castShadow&&I++),l.spotLightMatrix[g]=c.matrix,t.castShadow){const e=s.get(t);e.shadowBias=c.bias,e.shadowNormalBias=c.normalBias,e.shadowRadius=c.radius,e.shadowMapSize=c.mapSize,l.spotShadow[g]=e,l.spotShadowMap[g]=F,C++}g++}else if(t.isRectAreaLight){const e=r.get(t);e.color.copy(o).multiplyScalar(h),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),l.rectArea[_]=e,_++}else if(t.isPointLight){const e=r.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*B),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,r=s.get(t);r.shadowBias=e.bias,r.shadowNormalBias=e.normalBias,r.shadowRadius=e.radius,r.shadowMapSize=e.mapSize,r.shadowCameraNear=e.camera.near,r.shadowCameraFar=e.camera.far,l.pointShadow[f]=r,l.pointShadowMap[f]=F,l.pointShadowMatrix[f]=t.shadow.matrix,S++}l.point[f]=e,f++}else if(t.isHemisphereLight){const e=r.get(t);e.skyColor.copy(t.color).multiplyScalar(h*B),e.groundColor.copy(t.groundColor).multiplyScalar(h*B),l.hemi[y]=e,y++}}_>0&&(t.isWebGL2?!0===e.has("OES_texture_float_linear")?(l.rectAreaLTC1=Un.LTC_FLOAT_1,l.rectAreaLTC2=Un.LTC_FLOAT_2):(l.rectAreaLTC1=Un.LTC_HALF_1,l.rectAreaLTC2=Un.LTC_HALF_2):!0===e.has("OES_texture_float_linear")?(l.rectAreaLTC1=Un.LTC_FLOAT_1,l.rectAreaLTC2=Un.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(l.rectAreaLTC1=Un.LTC_HALF_1,l.rectAreaLTC2=Un.LTC_HALF_2):o.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),l.ambient[0]=d,l.ambient[1]=p,l.ambient[2]=A;const U=l.hash;U.directionalLength===m&&U.pointLength===f&&U.spotLength===g&&U.rectAreaLength===_&&U.hemiLength===y&&U.numDirectionalShadows===x&&U.numPointShadows===S&&U.numSpotShadows===C&&U.numSpotMaps===b&&U.numLightProbes===T||(l.directional.length=m,l.spot.length=g,l.rectArea.length=_,l.point.length=f,l.hemi.length=y,l.directionalShadow.length=x,l.directionalShadowMap.length=x,l.pointShadow.length=S,l.pointShadowMap.length=S,l.spotShadow.length=C,l.spotShadowMap.length=C,l.directionalShadowMatrix.length=x,l.pointShadowMatrix.length=S,l.spotLightMatrix.length=C+b-I,l.spotLightMap.length=b,l.numSpotLightShadowsWithMaps=I,l.numLightProbes=T,U.directionalLength=m,U.pointLength=f,U.spotLength=g,U.rectAreaLength=_,U.hemiLength=y,U.numDirectionalShadows=x,U.numPointShadows=S,U.numSpotShadows=C,U.numSpotMaps=b,U.numLightProbes=T,l.version=hr++)},setupView:function setupView(e,t){let r=0,s=0,o=0,p=0,A=0;const m=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){const f=e[t];if(f.isDirectionalLight){const e=l.directional[r];e.direction.setFromMatrixPosition(f.matrixWorld),c.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(c),e.direction.transformDirection(m),r++}else if(f.isSpotLight){const e=l.spot[o];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(m),e.direction.setFromMatrixPosition(f.matrixWorld),c.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(c),e.direction.transformDirection(m),o++}else if(f.isRectAreaLight){const e=l.rectArea[p];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(m),d.identity(),h.copy(f.matrixWorld),h.premultiply(m),d.extractRotation(h),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(d),e.halfHeight.applyMatrix4(d),p++}else if(f.isPointLight){const e=l.point[s];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(m),s++}else if(f.isHemisphereLight){const e=l.hemi[A];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(m),A++}}},state:l}}function WebGLRenderState(e,t){const r=new WebGLLights(e,t),s=[],o=[];return{init:function init(){s.length=0,o.length=0},state:{lightsArray:s,shadowsArray:o,lights:r},setupLights:function setupLights(e){r.setup(s,e)},setupLightsView:function setupLightsView(e){r.setupView(s,e)},pushLight:function pushLight(e){s.push(e)},pushShadow:function pushShadow(e){o.push(e)}}}function WebGLRenderStates(e,t){let r=new WeakMap;return{get:function get(s,o=0){const l=r.get(s);let c;return void 0===l?(c=new WebGLRenderState(e,t),r.set(s,[c])):o>=l.length?(c=new WebGLRenderState(e,t),l.push(c)):c=l[o],c},dispose:function dispose(){r=new WeakMap}}}class MeshDepthMaterial extends Material{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 MeshDistanceMaterial extends Material{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 WebGLShadowMap(e,t,r){let s=new Frustum;const l=new Vector2,h=new Vector2,f=new Vector4,g=new MeshDepthMaterial({depthPacking:3201}),_=new MeshDistanceMaterial,y={},x=r.maxTextureSize,S={[p]:A,[A]:p,[m]:m},C=new ShaderMaterial({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Vector2},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 <packing>\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}"}),b=C.clone();b.defines.HORIZONTAL_PASS=1;const I=new three_module_BufferGeometry;I.setAttribute("position",new three_module_BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const T=new three_module_Mesh(I,C),B=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=c;let U=this.type;function VSMPass(r,s){const o=t.update(T);C.defines.VSM_SAMPLES!==r.blurSamples&&(C.defines.VSM_SAMPLES=r.blurSamples,b.defines.VSM_SAMPLES=r.blurSamples,C.needsUpdate=!0,b.needsUpdate=!0),null===r.mapPass&&(r.mapPass=new WebGLRenderTarget(l.x,l.y)),C.uniforms.shadow_pass.value=r.map.texture,C.uniforms.resolution.value=r.mapSize,C.uniforms.radius.value=r.radius,e.setRenderTarget(r.mapPass),e.clear(),e.renderBufferDirect(s,null,o,C,T,null),b.uniforms.shadow_pass.value=r.mapPass.texture,b.uniforms.resolution.value=r.mapSize,b.uniforms.radius.value=r.radius,e.setRenderTarget(r.map),e.clear(),e.renderBufferDirect(s,null,o,b,T,null)}function getDepthMaterial(t,r,s,o){let l=null;const c=!0===s.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==c)l=c;else if(l=!0===s.isPointLight?_:g,e.localClippingEnabled&&!0===r.clipShadows&&Array.isArray(r.clippingPlanes)&&0!==r.clippingPlanes.length||r.displacementMap&&0!==r.displacementScale||r.alphaMap&&r.alphaTest>0||r.map&&r.alphaTest>0){const e=l.uuid,t=r.uuid;let s=y[e];void 0===s&&(s={},y[e]=s);let o=s[t];void 0===o&&(o=l.clone(),s[t]=o,r.addEventListener("dispose",onMaterialDispose)),l=o}if(l.visible=r.visible,l.wireframe=r.wireframe,l.side=o===d?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:S[r.side],l.alphaMap=r.alphaMap,l.alphaTest=r.alphaTest,l.map=r.map,l.clipShadows=r.clipShadows,l.clippingPlanes=r.clippingPlanes,l.clipIntersection=r.clipIntersection,l.displacementMap=r.displacementMap,l.displacementScale=r.displacementScale,l.displacementBias=r.displacementBias,l.wireframeLinewidth=r.wireframeLinewidth,l.linewidth=r.linewidth,!0===s.isPointLight&&!0===l.isMeshDistanceMaterial){e.properties.get(l).light=s}return l}function renderObject(r,o,l,c,h){if(!1===r.visible)return;if(r.layers.test(o.layers)&&(r.isMesh||r.isLine||r.isPoints)&&(r.castShadow||r.receiveShadow&&h===d)&&(!r.frustumCulled||s.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(l.matrixWorldInverse,r.matrixWorld);const s=t.update(r),d=r.material;if(Array.isArray(d)){const t=s.groups;for(let p=0,A=t.length;p<A;p++){const A=t[p],m=d[A.materialIndex];if(m&&m.visible){const t=getDepthMaterial(r,m,c,h);r.onBeforeShadow(e,r,o,l,s,t,A),e.renderBufferDirect(l,null,s,t,r,A),r.onAfterShadow(e,r,o,l,s,t,A)}}}else if(d.visible){const t=getDepthMaterial(r,d,c,h);r.onBeforeShadow(e,r,o,l,s,t,null),e.renderBufferDirect(l,null,s,t,r,null),r.onAfterShadow(e,r,o,l,s,t,null)}}const p=r.children;for(let e=0,t=p.length;e<t;e++)renderObject(p[e],o,l,c,h)}function onMaterialDispose(e){e.target.removeEventListener("dispose",onMaterialDispose);for(const t in y){const r=y[t],s=e.target.uuid;if(s in r){r[s].dispose(),delete r[s]}}}this.render=function(t,r,c){if(!1===B.enabled)return;if(!1===B.autoUpdate&&!1===B.needsUpdate)return;if(0===t.length)return;const p=e.getRenderTarget(),A=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.state;g.setBlending(0),g.buffers.color.setClear(1,1,1,1),g.buffers.depth.setTest(!0),g.setScissorTest(!1);const _=U!==d&&this.type===d,y=U===d&&this.type!==d;for(let p=0,A=t.length;p<A;p++){const A=t[p],m=A.shadow;if(void 0===m){o.warn("THREE.WebGLShadowMap:",A,"has no shadow.");continue}if(!1===m.autoUpdate&&!1===m.needsUpdate)continue;l.copy(m.mapSize);const S=m.getFrameExtents();if(l.multiply(S),h.copy(m.mapSize),(l.x>x||l.y>x)&&(l.x>x&&(h.x=Math.floor(x/S.x),l.x=h.x*S.x,m.mapSize.x=h.x),l.y>x&&(h.y=Math.floor(x/S.y),l.y=h.y*S.y,m.mapSize.y=h.y)),null===m.map||!0===_||!0===y){const e=this.type!==d?{minFilter:Ae,magFilter:Ae}:{};null!==m.map&&m.map.dispose(),m.map=new WebGLRenderTarget(l.x,l.y,e),m.map.texture.name=A.name+".shadowMap",m.camera.updateProjectionMatrix()}e.setRenderTarget(m.map),e.clear();const C=m.getViewportCount();for(let e=0;e<C;e++){const t=m.getViewport(e);f.set(h.x*t.x,h.y*t.y,h.x*t.z,h.y*t.w),g.viewport(f),m.updateMatrices(A,e),s=m.getFrustum(),renderObject(r,c,m.camera,A,this.type)}!0!==m.isPointLightShadow&&this.type===d&&VSMPass(m,c),m.needsUpdate=!1}U=this.type,B.needsUpdate=!1,e.setRenderTarget(p,A,m)}}function WebGLState(e,t,r){const s=r.isWebGL2;const l=new function ColorBuffer(){let t=!1;const r=new Vector4;let s=null;const o=new Vector4(0,0,0,0);return{setMask:function(r){s===r||t||(e.colorMask(r,r,r,r),s=r)},setLocked:function(e){t=e},setClear:function(t,s,l,c,h){!0===h&&(t*=c,s*=c,l*=c),r.set(t,s,l,c),!1===o.equals(r)&&(e.clearColor(t,s,l,c),o.copy(r))},reset:function(){t=!1,s=null,o.set(-1,0,0,0)}}},c=new function DepthBuffer(){let t=!1,r=null,s=null,o=null;return{setTest:function(t){t?enable(e.DEPTH_TEST):disable(e.DEPTH_TEST)},setMask:function(s){r===s||t||(e.depthMask(s),r=s)},setFunc:function(t){if(s!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}s=t}},setLocked:function(e){t=e},setClear:function(t){o!==t&&(e.clearDepth(t),o=t)},reset:function(){t=!1,r=null,s=null,o=null}}},h=new function StencilBuffer(){let t=!1,r=null,s=null,o=null,l=null,c=null,h=null,d=null,p=null;return{setTest:function(r){t||(r?enable(e.STENCIL_TEST):disable(e.STENCIL_TEST))},setMask:function(s){r===s||t||(e.stencilMask(s),r=s)},setFunc:function(t,r,c){s===t&&o===r&&l===c||(e.stencilFunc(t,r,c),s=t,o=r,l=c)},setOp:function(t,r,s){c===t&&h===r&&d===s||(e.stencilOp(t,r,s),c=t,h=r,d=s)},setLocked:function(e){t=e},setClear:function(t){p!==t&&(e.clearStencil(t),p=t)},reset:function(){t=!1,r=null,s=null,o=null,l=null,c=null,h=null,d=null,p=null}}},d=new WeakMap,p=new WeakMap;let j={},X={},Y=new WeakMap,K=[],J=null,$=!1,ee=null,te=null,ie=null,ne=null,re=null,se=null,ae=null,oe=new Color(0,0,0),le=0,ce=!1,he=null,ue=null,de=null,pe=null,Ae=null;const me=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let fe=!1,ge=0;const _e=e.getParameter(e.VERSION);-1!==_e.indexOf("WebGL")?(ge=parseFloat(/^WebGL (\d)/.exec(_e)[1]),fe=ge>=1):-1!==_e.indexOf("OpenGL ES")&&(ge=parseFloat(/^OpenGL ES (\d)/.exec(_e)[1]),fe=ge>=2);let ve=null,ye={};const Ee=e.getParameter(e.SCISSOR_BOX),xe=e.getParameter(e.VIEWPORT),Se=(new Vector4).fromArray(Ee),Me=(new Vector4).fromArray(xe);function createTexture(t,r,o,l){const c=new Uint8Array(4),h=e.createTexture();e.bindTexture(t,h),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let h=0;h<o;h++)!s||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(r+h,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,c):e.texImage3D(r,0,e.RGBA,1,1,l,0,e.RGBA,e.UNSIGNED_BYTE,c);return h}const Ce={};function enable(t){!0!==j[t]&&(e.enable(t),j[t]=!0)}function disable(t){!1!==j[t]&&(e.disable(t),j[t]=!1)}Ce[e.TEXTURE_2D]=createTexture(e.TEXTURE_2D,e.TEXTURE_2D,1),Ce[e.TEXTURE_CUBE_MAP]=createTexture(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),s&&(Ce[e.TEXTURE_2D_ARRAY]=createTexture(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),Ce[e.TEXTURE_3D]=createTexture(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),h.setClear(0),enable(e.DEPTH_TEST),c.setFunc(3),setFlipSided(!1),setCullFace(1),enable(e.CULL_FACE),setBlending(0);const be={[f]:e.FUNC_ADD,[g]:e.FUNC_SUBTRACT,[_]:e.FUNC_REVERSE_SUBTRACT};if(s)be[103]=e.MIN,be[104]=e.MAX;else{const e=t.get("EXT_blend_minmax");null!==e&&(be[103]=e.MIN_EXT,be[104]=e.MAX_EXT)}const we={[y]:e.ZERO,[x]:e.ONE,[S]:e.SRC_COLOR,[b]:e.SRC_ALPHA,[O]:e.SRC_ALPHA_SATURATE,[U]:e.DST_COLOR,[T]:e.DST_ALPHA,[C]:e.ONE_MINUS_SRC_COLOR,[I]:e.ONE_MINUS_SRC_ALPHA,[F]:e.ONE_MINUS_DST_COLOR,[B]:e.ONE_MINUS_DST_ALPHA,[Q]:e.CONSTANT_COLOR,[G]:e.ONE_MINUS_CONSTANT_COLOR,[W]:e.CONSTANT_ALPHA,[q]:e.ONE_MINUS_CONSTANT_ALPHA};function setBlending(t,r,s,l,c,h,d,p,A,m){if(0!==t){if(!1===$&&(enable(e.BLEND),$=!0),5===t)c=c||r,h=h||s,d=d||l,r===te&&c===re||(e.blendEquationSeparate(be[r],be[c]),te=r,re=c),s===ie&&l===ne&&h===se&&d===ae||(e.blendFuncSeparate(we[s],we[l],we[h],we[d]),ie=s,ne=l,se=h,ae=d),!1!==p.equals(oe)&&A===le||(e.blendColor(p.r,p.g,p.b,A),oe.copy(p),le=A),ee=t,ce=!1;else if(t!==ee||m!==ce){if(te===f&&re===f||(e.blendEquation(e.FUNC_ADD),te=f,re=f),m)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:o.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:o.error("THREE.WebGLState: Invalid blending: ",t)}ie=null,ne=null,se=null,ae=null,oe.set(0,0,0),le=0,ee=t,ce=m}}else!0===$&&(disable(e.BLEND),$=!1)}function setFlipSided(t){he!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),he=t)}function setCullFace(t){0!==t?(enable(e.CULL_FACE),t!==ue&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):disable(e.CULL_FACE),ue=t}function setPolygonOffset(t,r,s){t?(enable(e.POLYGON_OFFSET_FILL),pe===r&&Ae===s||(e.polygonOffset(r,s),pe=r,Ae=s)):disable(e.POLYGON_OFFSET_FILL)}return{buffers:{color:l,depth:c,stencil:h},enable,disable,bindFramebuffer:function bindFramebuffer(t,r){return X[t]!==r&&(e.bindFramebuffer(t,r),X[t]=r,s&&(t===e.DRAW_FRAMEBUFFER&&(X[e.FRAMEBUFFER]=r),t===e.FRAMEBUFFER&&(X[e.DRAW_FRAMEBUFFER]=r)),!0)},drawBuffers:function drawBuffers(s,o){let l=K,c=!1;if(s)if(l=Y.get(o),void 0===l&&(l=[],Y.set(o,l)),s.isWebGLMultipleRenderTargets){const t=s.texture;if(l.length!==t.length||l[0]!==e.COLOR_ATTACHMENT0){for(let r=0,s=t.length;r<s;r++)l[r]=e.COLOR_ATTACHMENT0+r;l.length=t.length,c=!0}}else l[0]!==e.COLOR_ATTACHMENT0&&(l[0]=e.COLOR_ATTACHMENT0,c=!0);else l[0]!==e.BACK&&(l[0]=e.BACK,c=!0);c&&(r.isWebGL2?e.drawBuffers(l):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(l))},useProgram:function useProgram(t){return J!==t&&(e.useProgram(t),J=t,!0)},setBlending,setMaterial:function setMaterial(t,r){t.side===m?disable(e.CULL_FACE):enable(e.CULL_FACE);let s=t.side===A;r&&(s=!s),setFlipSided(s),1===t.blending&&!1===t.transparent?setBlending(0):setBlending(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),c.setFunc(t.depthFunc),c.setTest(t.depthTest),c.setMask(t.depthWrite),l.setMask(t.colorWrite);const o=t.stencilWrite;h.setTest(o),o&&(h.setMask(t.stencilWriteMask),h.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),h.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),setPolygonOffset(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?enable(e.SAMPLE_ALPHA_TO_COVERAGE):disable(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided,setCullFace,setLineWidth:function setLineWidth(t){t!==de&&(fe&&e.lineWidth(t),de=t)},setPolygonOffset,setScissorTest:function setScissorTest(t){t?enable(e.SCISSOR_TEST):disable(e.SCISSOR_TEST)},activeTexture:function activeTexture(t){void 0===t&&(t=e.TEXTURE0+me-1),ve!==t&&(e.activeTexture(t),ve=t)},bindTexture:function bindTexture(t,r,s){void 0===s&&(s=null===ve?e.TEXTURE0+me-1:ve);let o=ye[s];void 0===o&&(o={type:void 0,texture:void 0},ye[s]=o),o.type===t&&o.texture===r||(ve!==s&&(e.activeTexture(s),ve=s),e.bindTexture(t,r||Ce[t]),o.type=t,o.texture=r)},unbindTexture:function unbindTexture(){const t=ye[ve];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function compressedTexImage2D(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},compressedTexImage3D:function compressedTexImage3D(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texImage2D:function texImage2D(){try{e.texImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texImage3D:function texImage3D(){try{e.texImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},updateUBOMapping:function updateUBOMapping(t,r){let s=p.get(r);void 0===s&&(s=new WeakMap,p.set(r,s));let o=s.get(t);void 0===o&&(o=e.getUniformBlockIndex(r,t.name),s.set(t,o))},uniformBlockBinding:function uniformBlockBinding(t,r){const s=p.get(r).get(t);d.get(r)!==s&&(e.uniformBlockBinding(r,s,t.__bindingPointIndex),d.set(r,s))},texStorage2D:function texStorage2D(){try{e.texStorage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texStorage3D:function texStorage3D(){try{e.texStorage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texSubImage2D:function texSubImage2D(){try{e.texSubImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texSubImage3D:function texSubImage3D(){try{e.texSubImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function compressedTexSubImage2D(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function compressedTexSubImage3D(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},scissor:function scissor(t){!1===Se.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),Se.copy(t))},viewport:function viewport(t){!1===Me.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),Me.copy(t))},reset:function reset(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),!0===s&&(e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),j={},ve=null,ye={},X={},Y=new WeakMap,K=[],J=null,$=!1,ee=null,te=null,ie=null,ne=null,re=null,se=null,ae=null,oe=new Color(0,0,0),le=0,ce=!1,he=null,ue=null,de=null,pe=null,Ae=null,Se.set(0,0,e.canvas.width,e.canvas.height),Me.set(0,0,e.canvas.width,e.canvas.height),l.reset(),c.reset(),h.reset()}}}function WebGLTextures(e,t,r,s,l,c,h){const d=l.isWebGL2,p=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,A="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap;let f;const g=new WeakMap;let _=!1;try{_="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function createCanvas(e,t){return _?new OffscreenCanvas(e,t):createElementNS("canvas")}function resizeImage(e,t,r,s){let l=1;if((e.width>s||e.height>s)&&(l=s/Math.max(e.width,e.height)),l<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const s=t?floorPowerOfTwo:Math.floor,c=s(l*e.width),h=s(l*e.height);void 0===f&&(f=createCanvas(c,h));const d=r?createCanvas(c,h):f;d.width=c,d.height=h;return d.getContext("2d").drawImage(e,0,0,c,h),o.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+c+"x"+h+")."),d}return"data"in e&&o.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function isPowerOfTwo$1(e){return isPowerOfTwo(e.width)&&isPowerOfTwo(e.height)}function textureNeedsGenerateMipmaps(e,t){return e.generateMipmaps&&t&&e.minFilter!==Ae&&e.minFilter!==ge}function generateMipmap(t){e.generateMipmap(t)}function getInternalFormat(r,s,l,c,h=!1){if(!1===d)return s;if(null!==r){if(void 0!==e[r])return e[r];o.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+r+"'")}let p=s;if(s===e.RED&&(l===e.FLOAT&&(p=e.R32F),l===e.HALF_FLOAT&&(p=e.R16F),l===e.UNSIGNED_BYTE&&(p=e.R8)),s===e.RED_INTEGER&&(l===e.UNSIGNED_BYTE&&(p=e.R8UI),l===e.UNSIGNED_SHORT&&(p=e.R16UI),l===e.UNSIGNED_INT&&(p=e.R32UI),l===e.BYTE&&(p=e.R8I),l===e.SHORT&&(p=e.R16I),l===e.INT&&(p=e.R32I)),s===e.RG&&(l===e.FLOAT&&(p=e.RG32F),l===e.HALF_FLOAT&&(p=e.RG16F),l===e.UNSIGNED_BYTE&&(p=e.RG8)),s===e.RGBA){const t=h?st:Ut.getTransfer(c);l===e.FLOAT&&(p=e.RGBA32F),l===e.HALF_FLOAT&&(p=e.RGBA16F),l===e.UNSIGNED_BYTE&&(p=t===at?e.SRGB8_ALPHA8:e.RGBA8),l===e.UNSIGNED_SHORT_4_4_4_4&&(p=e.RGBA4),l===e.UNSIGNED_SHORT_5_5_5_1&&(p=e.RGB5_A1)}return p!==e.R16F&&p!==e.R32F&&p!==e.RG16F&&p!==e.RG32F&&p!==e.RGBA16F&&p!==e.RGBA32F||t.get("EXT_color_buffer_float"),p}function getMipLevels(e,t,r){return!0===textureNeedsGenerateMipmaps(e,r)||e.isFramebufferTexture&&e.minFilter!==Ae&&e.minFilter!==ge?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 filterFallback(t){return t===Ae||t===me||t===fe?e.NEAREST:e.LINEAR}function onTextureDispose(e){const t=e.target;t.removeEventListener("dispose",onTextureDispose),function deallocateTexture(e){const t=s.get(e);if(void 0===t.__webglInit)return;const r=e.source,o=g.get(r);if(o){const s=o[t.__cacheKey];s.usedTimes--,0===s.usedTimes&&deleteTexture(e),0===Object.keys(o).length&&g.delete(r)}s.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function onRenderTargetDispose(t){const r=t.target;r.removeEventListener("dispose",onRenderTargetDispose),function deallocateRenderTarget(t){const r=t.texture,o=s.get(t),l=s.get(r);void 0!==l.__webglTexture&&(e.deleteTexture(l.__webglTexture),h.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(o.__webglFramebuffer[t]))for(let r=0;r<o.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(o.__webglFramebuffer[t][r]);else e.deleteFramebuffer(o.__webglFramebuffer[t]);o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer[t])}else{if(Array.isArray(o.__webglFramebuffer))for(let t=0;t<o.__webglFramebuffer.length;t++)e.deleteFramebuffer(o.__webglFramebuffer[t]);else e.deleteFramebuffer(o.__webglFramebuffer);if(o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer),o.__webglMultisampledFramebuffer&&e.deleteFramebuffer(o.__webglMultisampledFramebuffer),o.__webglColorRenderbuffer)for(let t=0;t<o.__webglColorRenderbuffer.length;t++)o.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(o.__webglColorRenderbuffer[t]);o.__webglDepthRenderbuffer&&e.deleteRenderbuffer(o.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,o=r.length;t<o;t++){const o=s.get(r[t]);o.__webglTexture&&(e.deleteTexture(o.__webglTexture),h.memory.textures--),s.remove(r[t])}s.remove(r),s.remove(t)}(r)}function deleteTexture(t){const r=s.get(t);e.deleteTexture(r.__webglTexture);const o=t.source;delete g.get(o)[r.__cacheKey],h.memory.textures--}let y=0;function setTexture2D(t,l){const c=s.get(t);if(t.isVideoTexture&&function updateVideoTexture(e){const t=h.render.frame;m.get(e)!==t&&(m.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&c.__version!==t.version){const e=t.image;if(null===e)o.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void uploadTexture(c,t,l);o.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}r.bindTexture(e.TEXTURE_2D,c.__webglTexture,e.TEXTURE0+l)}const x={[ue]:e.REPEAT,[de]:e.CLAMP_TO_EDGE,[pe]:e.MIRRORED_REPEAT},S={[Ae]:e.NEAREST,[me]:e.NEAREST_MIPMAP_NEAREST,[fe]:e.NEAREST_MIPMAP_LINEAR,[ge]:e.LINEAR,[_e]:e.LINEAR_MIPMAP_NEAREST,[ve]:e.LINEAR_MIPMAP_LINEAR},C={[ht]:e.NEVER,[gt]:e.ALWAYS,[ut]:e.LESS,[pt]:e.LEQUAL,[dt]:e.EQUAL,[ft]:e.GEQUAL,[At]:e.GREATER,[mt]:e.NOTEQUAL};function setTextureParameters(r,c,h){if(h?(e.texParameteri(r,e.TEXTURE_WRAP_S,x[c.wrapS]),e.texParameteri(r,e.TEXTURE_WRAP_T,x[c.wrapT]),r!==e.TEXTURE_3D&&r!==e.TEXTURE_2D_ARRAY||e.texParameteri(r,e.TEXTURE_WRAP_R,x[c.wrapR]),e.texParameteri(r,e.TEXTURE_MAG_FILTER,S[c.magFilter]),e.texParameteri(r,e.TEXTURE_MIN_FILTER,S[c.minFilter])):(e.texParameteri(r,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(r,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),r!==e.TEXTURE_3D&&r!==e.TEXTURE_2D_ARRAY||e.texParameteri(r,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),c.wrapS===de&&c.wrapT===de||o.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(r,e.TEXTURE_MAG_FILTER,filterFallback(c.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,filterFallback(c.minFilter)),c.minFilter!==Ae&&c.minFilter!==ge&&o.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),c.compareFunction&&(e.texParameteri(r,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(r,e.TEXTURE_COMPARE_FUNC,C[c.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const o=t.get("EXT_texture_filter_anisotropic");if(c.magFilter===Ae)return;if(c.minFilter!==fe&&c.minFilter!==ve)return;if(c.type===Me&&!1===t.has("OES_texture_float_linear"))return;if(!1===d&&c.type===Ce&&!1===t.has("OES_texture_half_float_linear"))return;(c.anisotropy>1||s.get(c).__currentAnisotropy)&&(e.texParameterf(r,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(c.anisotropy,l.getMaxAnisotropy())),s.get(c).__currentAnisotropy=c.anisotropy)}}function initTexture(t,r){let s=!1;void 0===t.__webglInit&&(t.__webglInit=!0,r.addEventListener("dispose",onTextureDispose));const o=r.source;let l=g.get(o);void 0===l&&(l={},g.set(o,l));const c=function getTextureCacheKey(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()}(r);if(c!==t.__cacheKey){void 0===l[c]&&(l[c]={texture:e.createTexture(),usedTimes:0},h.memory.textures++,s=!0),l[c].usedTimes++;const o=l[t.__cacheKey];void 0!==o&&(l[t.__cacheKey].usedTimes--,0===o.usedTimes&&deleteTexture(r)),t.__cacheKey=c,t.__webglTexture=l[c].texture}return s}function uploadTexture(t,h,p){let A=e.TEXTURE_2D;(h.isDataArrayTexture||h.isCompressedArrayTexture)&&(A=e.TEXTURE_2D_ARRAY),h.isData3DTexture&&(A=e.TEXTURE_3D);const m=initTexture(t,h),f=h.source;r.bindTexture(A,t.__webglTexture,e.TEXTURE0+p);const g=s.get(f);if(f.version!==g.__version||!0===m){r.activeTexture(e.TEXTURE0+p);const t=Ut.getPrimaries(Ut.workingColorSpace),s=h.colorSpace===et?null:Ut.getPrimaries(h.colorSpace),_=h.colorSpace===et||t===s?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,h.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,h.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,_);const y=function textureNeedsPowerOfTwo(e){return!d&&(e.wrapS!==de||e.wrapT!==de||e.minFilter!==Ae&&e.minFilter!==ge)}(h)&&!1===isPowerOfTwo$1(h.image);let x=resizeImage(h.image,y,!1,l.maxTextureSize);x=verifyColorSpace(h,x);const S=isPowerOfTwo$1(x)||d,C=c.convert(h.format,h.colorSpace);let b,I=c.convert(h.type),T=getInternalFormat(h.internalFormat,C,I,h.colorSpace,h.isVideoTexture);setTextureParameters(A,h,S);const B=h.mipmaps,U=d&&!0!==h.isVideoTexture&&T!==Oe,F=void 0===g.__version||!0===m,O=getMipLevels(h,x,S);if(h.isDepthTexture)T=e.DEPTH_COMPONENT,d?T=h.type===Me?e.DEPTH_COMPONENT32F:h.type===Se?e.DEPTH_COMPONENT24:h.type===be?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:h.type===Me&&o.error("WebGLRenderer: Floating point depth texture requires WebGL2."),h.format===Ie&&T===e.DEPTH_COMPONENT&&h.type!==Ee&&h.type!==Se&&(o.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),h.type=Se,I=c.convert(h.type)),h.format===Te&&T===e.DEPTH_COMPONENT&&(T=e.DEPTH_STENCIL,h.type!==be&&(o.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),h.type=be,I=c.convert(h.type))),F&&(U?r.texStorage2D(e.TEXTURE_2D,1,T,x.width,x.height):r.texImage2D(e.TEXTURE_2D,0,T,x.width,x.height,0,C,I,null));else if(h.isDataTexture)if(B.length>0&&S){U&&F&&r.texStorage2D(e.TEXTURE_2D,O,T,B[0].width,B[0].height);for(let t=0,s=B.length;t<s;t++)b=B[t],U?r.texSubImage2D(e.TEXTURE_2D,t,0,0,b.width,b.height,C,I,b.data):r.texImage2D(e.TEXTURE_2D,t,T,b.width,b.height,0,C,I,b.data);h.generateMipmaps=!1}else U?(F&&r.texStorage2D(e.TEXTURE_2D,O,T,x.width,x.height),r.texSubImage2D(e.TEXTURE_2D,0,0,0,x.width,x.height,C,I,x.data)):r.texImage2D(e.TEXTURE_2D,0,T,x.width,x.height,0,C,I,x.data);else if(h.isCompressedTexture)if(h.isCompressedArrayTexture){U&&F&&r.texStorage3D(e.TEXTURE_2D_ARRAY,O,T,B[0].width,B[0].height,x.depth);for(let t=0,s=B.length;t<s;t++)b=B[t],h.format!==we?null!==C?U?r.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,b.width,b.height,x.depth,C,b.data,0,0):r.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,T,b.width,b.height,x.depth,0,b.data,0,0):o.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):U?r.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,b.width,b.height,x.depth,C,I,b.data):r.texImage3D(e.TEXTURE_2D_ARRAY,t,T,b.width,b.height,x.depth,0,C,I,b.data)}else{U&&F&&r.texStorage2D(e.TEXTURE_2D,O,T,B[0].width,B[0].height);for(let t=0,s=B.length;t<s;t++)b=B[t],h.format!==we?null!==C?U?r.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,b.width,b.height,C,b.data):r.compressedTexImage2D(e.TEXTURE_2D,t,T,b.width,b.height,0,b.data):o.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):U?r.texSubImage2D(e.TEXTURE_2D,t,0,0,b.width,b.height,C,I,b.data):r.texImage2D(e.TEXTURE_2D,t,T,b.width,b.height,0,C,I,b.data)}else if(h.isDataArrayTexture)U?(F&&r.texStorage3D(e.TEXTURE_2D_ARRAY,O,T,x.width,x.height,x.depth),r.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,x.width,x.height,x.depth,C,I,x.data)):r.texImage3D(e.TEXTURE_2D_ARRAY,0,T,x.width,x.height,x.depth,0,C,I,x.data);else if(h.isData3DTexture)U?(F&&r.texStorage3D(e.TEXTURE_3D,O,T,x.width,x.height,x.depth),r.texSubImage3D(e.TEXTURE_3D,0,0,0,0,x.width,x.height,x.depth,C,I,x.data)):r.texImage3D(e.TEXTURE_3D,0,T,x.width,x.height,x.depth,0,C,I,x.data);else if(h.isFramebufferTexture){if(F)if(U)r.texStorage2D(e.TEXTURE_2D,O,T,x.width,x.height);else{let t=x.width,s=x.height;for(let o=0;o<O;o++)r.texImage2D(e.TEXTURE_2D,o,T,t,s,0,C,I,null),t>>=1,s>>=1}}else if(B.length>0&&S){U&&F&&r.texStorage2D(e.TEXTURE_2D,O,T,B[0].width,B[0].height);for(let t=0,s=B.length;t<s;t++)b=B[t],U?r.texSubImage2D(e.TEXTURE_2D,t,0,0,C,I,b):r.texImage2D(e.TEXTURE_2D,t,T,C,I,b);h.generateMipmaps=!1}else U?(F&&r.texStorage2D(e.TEXTURE_2D,O,T,x.width,x.height),r.texSubImage2D(e.TEXTURE_2D,0,0,0,C,I,x)):r.texImage2D(e.TEXTURE_2D,0,T,C,I,x);textureNeedsGenerateMipmaps(h,S)&&generateMipmap(A),g.__version=f.version,h.onUpdate&&h.onUpdate(h)}t.__version=h.version}function setupFrameBufferTexture(t,o,l,h,d,A){const m=c.convert(l.format,l.colorSpace),f=c.convert(l.type),g=getInternalFormat(l.internalFormat,m,f,l.colorSpace);if(!s.get(o).__hasExternalTextures){const t=Math.max(1,o.width>>A),s=Math.max(1,o.height>>A);d===e.TEXTURE_3D||d===e.TEXTURE_2D_ARRAY?r.texImage3D(d,A,g,t,s,o.depth,0,m,f,null):r.texImage2D(d,A,g,t,s,0,m,f,null)}r.bindFramebuffer(e.FRAMEBUFFER,t),useMultisampledRTT(o)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,h,d,s.get(l).__webglTexture,0,getRenderTargetSamples(o)):(d===e.TEXTURE_2D||d>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&d<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,h,d,s.get(l).__webglTexture,A),r.bindFramebuffer(e.FRAMEBUFFER,null)}function setupRenderBufferStorage(t,r,s){if(e.bindRenderbuffer(e.RENDERBUFFER,t),r.depthBuffer&&!r.stencilBuffer){let o=!0===d?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(s||useMultisampledRTT(r)){const t=r.depthTexture;t&&t.isDepthTexture&&(t.type===Me?o=e.DEPTH_COMPONENT32F:t.type===Se&&(o=e.DEPTH_COMPONENT24));const s=getRenderTargetSamples(r);useMultisampledRTT(r)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,s,o,r.width,r.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,s,o,r.width,r.height)}else e.renderbufferStorage(e.RENDERBUFFER,o,r.width,r.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(r.depthBuffer&&r.stencilBuffer){const o=getRenderTargetSamples(r);s&&!1===useMultisampledRTT(r)?e.renderbufferStorageMultisample(e.RENDERBUFFER,o,e.DEPTH24_STENCIL8,r.width,r.height):useMultisampledRTT(r)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,o,e.DEPTH24_STENCIL8,r.width,r.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,r.width,r.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===r.isWebGLMultipleRenderTargets?r.texture:[r.texture];for(let o=0;o<t.length;o++){const l=t[o],h=c.convert(l.format,l.colorSpace),d=c.convert(l.type),A=getInternalFormat(l.internalFormat,h,d,l.colorSpace),m=getRenderTargetSamples(r);s&&!1===useMultisampledRTT(r)?e.renderbufferStorageMultisample(e.RENDERBUFFER,m,A,r.width,r.height):useMultisampledRTT(r)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,m,A,r.width,r.height):e.renderbufferStorage(e.RENDERBUFFER,A,r.width,r.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function setupDepthRenderbuffer(t){const o=s.get(t),l=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!o.__autoAllocateDepthBuffer){if(l)throw new Error("target.depthTexture not supported in Cube render targets");!function setupDepthTexture(t,o){if(o&&o.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(r.bindFramebuffer(e.FRAMEBUFFER,t),!o.depthTexture||!o.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");s.get(o.depthTexture).__webglTexture&&o.depthTexture.image.width===o.width&&o.depthTexture.image.height===o.height||(o.depthTexture.image.width=o.width,o.depthTexture.image.height=o.height,o.depthTexture.needsUpdate=!0),setTexture2D(o.depthTexture,0);const l=s.get(o.depthTexture).__webglTexture,c=getRenderTargetSamples(o);if(o.depthTexture.format===Ie)useMultisampledRTT(o)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,l,0,c):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,l,0);else{if(o.depthTexture.format!==Te)throw new Error("Unknown depthTexture format");useMultisampledRTT(o)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,l,0,c):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,l,0)}}(o.__webglFramebuffer,t)}else if(l){o.__webglDepthbuffer=[];for(let s=0;s<6;s++)r.bindFramebuffer(e.FRAMEBUFFER,o.__webglFramebuffer[s]),o.__webglDepthbuffer[s]=e.createRenderbuffer(),setupRenderBufferStorage(o.__webglDepthbuffer[s],t,!1)}else r.bindFramebuffer(e.FRAMEBUFFER,o.__webglFramebuffer),o.__webglDepthbuffer=e.createRenderbuffer(),setupRenderBufferStorage(o.__webglDepthbuffer,t,!1);r.bindFramebuffer(e.FRAMEBUFFER,null)}function getRenderTargetSamples(e){return Math.min(l.maxSamples,e.samples)}function useMultisampledRTT(e){const r=s.get(e);return d&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==r.__useRenderToTexture}function verifyColorSpace(e,r){const s=e.colorSpace,l=e.format,c=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===yt||s!==it&&s!==et&&(Ut.getTransfer(s)===at?!1===d?!0===t.has("EXT_sRGB")&&l===we?(e.format=yt,e.minFilter=ge,e.generateMipmaps=!1):r=ImageUtils.sRGBToLinear(r):l===we&&c===ye||o.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):o.error("THREE.WebGLTextures: Unsupported texture color space:",s)),r}this.allocateTextureUnit=function allocateTextureUnit(){const e=y;return e>=l.maxTextures&&o.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l.maxTextures),y+=1,e},this.resetTextureUnits=function resetTextureUnits(){y=0},this.setTexture2D=setTexture2D,this.setTexture2DArray=function setTexture2DArray(t,o){const l=s.get(t);t.version>0&&l.__version!==t.version?uploadTexture(l,t,o):r.bindTexture(e.TEXTURE_2D_ARRAY,l.__webglTexture,e.TEXTURE0+o)},this.setTexture3D=function setTexture3D(t,o){const l=s.get(t);t.version>0&&l.__version!==t.version?uploadTexture(l,t,o):r.bindTexture(e.TEXTURE_3D,l.__webglTexture,e.TEXTURE0+o)},this.setTextureCube=function setTextureCube(t,h){const p=s.get(t);t.version>0&&p.__version!==t.version?function uploadCubeTexture(t,h,p){if(6!==h.image.length)return;const A=initTexture(t,h),m=h.source;r.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+p);const f=s.get(m);if(m.version!==f.__version||!0===A){r.activeTexture(e.TEXTURE0+p);const t=Ut.getPrimaries(Ut.workingColorSpace),s=h.colorSpace===et?null:Ut.getPrimaries(h.colorSpace),g=h.colorSpace===et||t===s?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,h.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,h.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,g);const _=h.isCompressedTexture||h.image[0].isCompressedTexture,y=h.image[0]&&h.image[0].isDataTexture,x=[];for(let e=0;e<6;e++)x[e]=_||y?y?h.image[e].image:h.image[e]:resizeImage(h.image[e],!1,!0,l.maxCubemapSize),x[e]=verifyColorSpace(h,x[e]);const S=x[0],C=isPowerOfTwo$1(S)||d,b=c.convert(h.format,h.colorSpace),I=c.convert(h.type),T=getInternalFormat(h.internalFormat,b,I,h.colorSpace),B=d&&!0!==h.isVideoTexture,U=void 0===f.__version||!0===A;let F,O=getMipLevels(h,S,C);if(setTextureParameters(e.TEXTURE_CUBE_MAP,h,C),_){B&&U&&r.texStorage2D(e.TEXTURE_CUBE_MAP,O,T,S.width,S.height);for(let t=0;t<6;t++){F=x[t].mipmaps;for(let s=0;s<F.length;s++){const l=F[s];h.format!==we?null!==b?B?r.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,0,0,l.width,l.height,b,l.data):r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,T,l.width,l.height,0,l.data):o.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,0,0,l.width,l.height,b,I,l.data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,T,l.width,l.height,0,b,I,l.data)}}}else{F=h.mipmaps,B&&U&&(F.length>0&&O++,r.texStorage2D(e.TEXTURE_CUBE_MAP,O,T,x[0].width,x[0].height));for(let t=0;t<6;t++)if(y){B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,x[t].width,x[t].height,b,I,x[t].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,x[t].width,x[t].height,0,b,I,x[t].data);for(let s=0;s<F.length;s++){const o=F[s].image[t].image;B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,0,0,o.width,o.height,b,I,o.data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,T,o.width,o.height,0,b,I,o.data)}}else{B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,b,I,x[t]):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,b,I,x[t]);for(let s=0;s<F.length;s++){const o=F[s];B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,0,0,b,I,o.image[t]):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,T,b,I,o.image[t])}}}textureNeedsGenerateMipmaps(h,C)&&generateMipmap(e.TEXTURE_CUBE_MAP),f.__version=m.version,h.onUpdate&&h.onUpdate(h)}t.__version=h.version}(p,t,h):r.bindTexture(e.TEXTURE_CUBE_MAP,p.__webglTexture,e.TEXTURE0+h)},this.rebindTextures=function rebindTextures(t,r,o){const l=s.get(t);void 0!==r&&setupFrameBufferTexture(l.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==o&&setupDepthRenderbuffer(t)},this.setupRenderTarget=function setupRenderTarget(t){const p=t.texture,A=s.get(t),m=s.get(p);t.addEventListener("dispose",onRenderTargetDispose),!0!==t.isWebGLMultipleRenderTargets&&(void 0===m.__webglTexture&&(m.__webglTexture=e.createTexture()),m.__version=p.version,h.memory.textures++);const f=!0===t.isWebGLCubeRenderTarget,g=!0===t.isWebGLMultipleRenderTargets,_=isPowerOfTwo$1(t)||d;if(f){A.__webglFramebuffer=[];for(let t=0;t<6;t++)if(d&&p.mipmaps&&p.mipmaps.length>0){A.__webglFramebuffer[t]=[];for(let r=0;r<p.mipmaps.length;r++)A.__webglFramebuffer[t][r]=e.createFramebuffer()}else A.__webglFramebuffer[t]=e.createFramebuffer()}else{if(d&&p.mipmaps&&p.mipmaps.length>0){A.__webglFramebuffer=[];for(let t=0;t<p.mipmaps.length;t++)A.__webglFramebuffer[t]=e.createFramebuffer()}else A.__webglFramebuffer=e.createFramebuffer();if(g)if(l.drawBuffers){const r=t.texture;for(let t=0,o=r.length;t<o;t++){const o=s.get(r[t]);void 0===o.__webglTexture&&(o.__webglTexture=e.createTexture(),h.memory.textures++)}}else o.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(d&&t.samples>0&&!1===useMultisampledRTT(t)){const s=g?p:[p];A.__webglMultisampledFramebuffer=e.createFramebuffer(),A.__webglColorRenderbuffer=[],r.bindFramebuffer(e.FRAMEBUFFER,A.__webglMultisampledFramebuffer);for(let r=0;r<s.length;r++){const o=s[r];A.__webglColorRenderbuffer[r]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,A.__webglColorRenderbuffer[r]);const l=c.convert(o.format,o.colorSpace),h=c.convert(o.type),d=getInternalFormat(o.internalFormat,l,h,o.colorSpace,!0===t.isXRRenderTarget),p=getRenderTargetSamples(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,p,d,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+r,e.RENDERBUFFER,A.__webglColorRenderbuffer[r])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(A.__webglDepthRenderbuffer=e.createRenderbuffer(),setupRenderBufferStorage(A.__webglDepthRenderbuffer,t,!0)),r.bindFramebuffer(e.FRAMEBUFFER,null)}}if(f){r.bindTexture(e.TEXTURE_CUBE_MAP,m.__webglTexture),setTextureParameters(e.TEXTURE_CUBE_MAP,p,_);for(let r=0;r<6;r++)if(d&&p.mipmaps&&p.mipmaps.length>0)for(let s=0;s<p.mipmaps.length;s++)setupFrameBufferTexture(A.__webglFramebuffer[r][s],t,p,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+r,s);else setupFrameBufferTexture(A.__webglFramebuffer[r],t,p,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0);textureNeedsGenerateMipmaps(p,_)&&generateMipmap(e.TEXTURE_CUBE_MAP),r.unbindTexture()}else if(g){const o=t.texture;for(let l=0,c=o.length;l<c;l++){const c=o[l],h=s.get(c);r.bindTexture(e.TEXTURE_2D,h.__webglTexture),setTextureParameters(e.TEXTURE_2D,c,_),setupFrameBufferTexture(A.__webglFramebuffer,t,c,e.COLOR_ATTACHMENT0+l,e.TEXTURE_2D,0),textureNeedsGenerateMipmaps(c,_)&&generateMipmap(e.TEXTURE_2D)}r.unbindTexture()}else{let s=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(d?s=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:o.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),r.bindTexture(s,m.__webglTexture),setTextureParameters(s,p,_),d&&p.mipmaps&&p.mipmaps.length>0)for(let r=0;r<p.mipmaps.length;r++)setupFrameBufferTexture(A.__webglFramebuffer[r],t,p,e.COLOR_ATTACHMENT0,s,r);else setupFrameBufferTexture(A.__webglFramebuffer,t,p,e.COLOR_ATTACHMENT0,s,0);textureNeedsGenerateMipmaps(p,_)&&generateMipmap(s),r.unbindTexture()}t.depthBuffer&&setupDepthRenderbuffer(t)},this.updateRenderTargetMipmap=function updateRenderTargetMipmap(t){const o=isPowerOfTwo$1(t)||d,l=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let c=0,h=l.length;c<h;c++){const h=l[c];if(textureNeedsGenerateMipmaps(h,o)){const o=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,l=s.get(h).__webglTexture;r.bindTexture(o,l),generateMipmap(o),r.unbindTexture()}}},this.updateMultisampleRenderTarget=function updateMultisampleRenderTarget(t){if(d&&t.samples>0&&!1===useMultisampledRTT(t)){const o=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],l=t.width,c=t.height;let h=e.COLOR_BUFFER_BIT;const d=[],p=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,m=s.get(t),f=!0===t.isWebGLMultipleRenderTargets;if(f)for(let t=0;t<o.length;t++)r.bindFramebuffer(e.FRAMEBUFFER,m.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),r.bindFramebuffer(e.FRAMEBUFFER,m.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);r.bindFramebuffer(e.READ_FRAMEBUFFER,m.__webglMultisampledFramebuffer),r.bindFramebuffer(e.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let r=0;r<o.length;r++){d.push(e.COLOR_ATTACHMENT0+r),t.depthBuffer&&d.push(p);const g=void 0!==m.__ignoreDepthValues&&m.__ignoreDepthValues;if(!1===g&&(t.depthBuffer&&(h|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(h|=e.STENCIL_BUFFER_BIT)),f&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,m.__webglColorRenderbuffer[r]),!0===g&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[p]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[p])),f){const t=s.get(o[r]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,l,c,0,0,l,c,h,e.NEAREST),A&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,d)}if(r.bindFramebuffer(e.READ_FRAMEBUFFER,null),r.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),f)for(let t=0;t<o.length;t++){r.bindFramebuffer(e.FRAMEBUFFER,m.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,m.__webglColorRenderbuffer[t]);const l=s.get(o[t]).__webglTexture;r.bindFramebuffer(e.FRAMEBUFFER,m.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,l,0)}r.bindFramebuffer(e.DRAW_FRAMEBUFFER,m.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=setupDepthRenderbuffer,this.setupFrameBufferTexture=setupFrameBufferTexture,this.useMultisampledRTT=useMultisampledRTT}function WebGLUtils(e,t,r){const s=r.isWebGL2;return{convert:function convert(r,o=et){let l;const c=Ut.getTransfer(o);if(r===ye)return e.UNSIGNED_BYTE;if(1017===r)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===r)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===r)return e.BYTE;if(1011===r)return e.SHORT;if(r===Ee)return e.UNSIGNED_SHORT;if(r===xe)return e.INT;if(r===Se)return e.UNSIGNED_INT;if(r===Me)return e.FLOAT;if(r===Ce)return s?e.HALF_FLOAT:(l=t.get("OES_texture_half_float"),null!==l?l.HALF_FLOAT_OES:null);if(1021===r)return e.ALPHA;if(r===we)return e.RGBA;if(1024===r)return e.LUMINANCE;if(1025===r)return e.LUMINANCE_ALPHA;if(r===Ie)return e.DEPTH_COMPONENT;if(r===Te)return e.DEPTH_STENCIL;if(r===yt)return l=t.get("EXT_sRGB"),null!==l?l.SRGB_ALPHA_EXT:null;if(r===Be)return e.RED;if(1029===r)return e.RED_INTEGER;if(r===Re)return e.RG;if(1031===r)return e.RG_INTEGER;if(1033===r)return e.RGBA_INTEGER;if(r===Le||r===De||r===Ue||r===Pe)if(c===at){if(l=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===l)return null;if(r===Le)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===De)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===Ue)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Pe)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(l=t.get("WEBGL_compressed_texture_s3tc"),null===l)return null;if(r===Le)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===De)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Ue)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Pe)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(r===Fe||35841===r||r===Ne||35843===r){if(l=t.get("WEBGL_compressed_texture_pvrtc"),null===l)return null;if(r===Fe)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===r)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Ne)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===r)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===Oe)return l=t.get("WEBGL_compressed_texture_etc1"),null!==l?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===Qe||r===ke){if(l=t.get("WEBGL_compressed_texture_etc"),null===l)return null;if(r===Qe)return c===at?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(r===ke)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}if(r===Ge||37809===r||37810===r||37811===r||r===Ve||37813===r||37814===r||37815===r||37816===r||37817===r||37818===r||37819===r||37820===r||37821===r){if(l=t.get("WEBGL_compressed_texture_astc"),null===l)return null;if(r===Ge)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Ve)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===r)return c===at?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}if(r===He||36494===r||36495===r){if(l=t.get("EXT_texture_compression_bptc"),null===l)return null;if(r===He)return c===at?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(36494===r)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(36495===r)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===r||36284===r||36285===r||36286===r){if(l=t.get("EXT_texture_compression_rgtc"),null===l)return null;if(r===He)return l.COMPRESSED_RED_RGTC1_EXT;if(36284===r)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===r)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===r)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return r===be?s?e.UNSIGNED_INT_24_8:(l=t.get("WEBGL_depth_texture"),null!==l?l.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[r]?e[r]:null}}}class ArrayCamera extends PerspectiveCamera{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class three_module_Group extends Object3D{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ur={type:"move"};class WebXRController{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new three_module_Group,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new three_module_Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new three_module_Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new three_module_Vector3),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new three_module_Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new three_module_Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new three_module_Vector3),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,r){let s=null,o=null,l=null;const c=this._targetRay,h=this._grip,d=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(d&&e.hand){l=!0;for(const s of e.hand.values()){const e=t.getJointPose(s,r),o=this._getHandJoint(d,s);null!==e&&(o.matrix.fromArray(e.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,o.jointRadius=e.radius),o.visible=null!==e}const s=d.joints["index-finger-tip"],o=d.joints["thumb-tip"],c=s.position.distanceTo(o.position),h=.02,p=.005;d.inputState.pinching&&c>h+p?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!d.inputState.pinching&&c<=h-p&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==h&&e.gripSpace&&(o=t.getPose(e.gripSpace,r),null!==o&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));null!==c&&(s=t.getPose(e.targetRaySpace,r),null===s&&null!==o&&(s=o),null!==s&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(ur)))}return null!==c&&(c.visible=null!==s),null!==h&&(h.visible=null!==o),null!==d&&(d.visible=null!==l),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const r=new three_module_Group;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class WebXRManager extends EventDispatcher{constructor(e,t){super();const r=this;let s=null,l=1,c=null,h="local-floor",d=1,p=null,A=null,m=null,f=null,g=null,_=null;const y=t.getContextAttributes();let x=null,S=null;const C=[],b=[],I=new Vector2;let T=null;const B=new PerspectiveCamera;B.layers.enable(1),B.viewport=new Vector4;const U=new PerspectiveCamera;U.layers.enable(2),U.viewport=new Vector4;const F=[B,U],O=new ArrayCamera;O.layers.enable(1),O.layers.enable(2);let Q=null,G=null;function onSessionEvent(e){const t=b.indexOf(e.inputSource);if(-1===t)return;const r=C[t];void 0!==r&&(r.update(e.inputSource,e.frame,p||c),r.dispatchEvent({type:e.type,data:e.inputSource}))}function onSessionEnd(){s.removeEventListener("select",onSessionEvent),s.removeEventListener("selectstart",onSessionEvent),s.removeEventListener("selectend",onSessionEvent),s.removeEventListener("squeeze",onSessionEvent),s.removeEventListener("squeezestart",onSessionEvent),s.removeEventListener("squeezeend",onSessionEvent),s.removeEventListener("end",onSessionEnd),s.removeEventListener("inputsourceschange",onInputSourcesChange);for(let e=0;e<C.length;e++){const t=b[e];null!==t&&(b[e]=null,C[e].disconnect(t))}Q=null,G=null,e.setRenderTarget(x),g=null,f=null,m=null,s=null,S=null,X.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(I.width,I.height,!1),r.dispatchEvent({type:"sessionend"})}function onInputSourcesChange(e){for(let t=0;t<e.removed.length;t++){const r=e.removed[t],s=b.indexOf(r);s>=0&&(b[s]=null,C[s].disconnect(r))}for(let t=0;t<e.added.length;t++){const r=e.added[t];let s=b.indexOf(r);if(-1===s){for(let e=0;e<C.length;e++){if(e>=b.length){b.push(r),s=e;break}if(null===b[e]){b[e]=r,s=e;break}}if(-1===s)break}const o=C[s];o&&o.connect(r)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=C[e];return void 0===t&&(t=new WebXRController,C[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=C[e];return void 0===t&&(t=new WebXRController,C[e]=t),t.getGripSpace()},this.getHand=function(e){let t=C[e];return void 0===t&&(t=new WebXRController,C[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){l=e,!0===r.isPresenting&&o.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){h=e,!0===r.isPresenting&&o.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return p||c},this.setReferenceSpace=function(e){p=e},this.getBaseLayer=function(){return null!==f?f:g},this.getBinding=function(){return m},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(o){if(s=o,null!==s){if(x=e.getRenderTarget(),s.addEventListener("select",onSessionEvent),s.addEventListener("selectstart",onSessionEvent),s.addEventListener("selectend",onSessionEvent),s.addEventListener("squeeze",onSessionEvent),s.addEventListener("squeezestart",onSessionEvent),s.addEventListener("squeezeend",onSessionEvent),s.addEventListener("end",onSessionEnd),s.addEventListener("inputsourceschange",onInputSourcesChange),!0!==y.xrCompatible&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(I),void 0===s.renderState.layers||!1===e.capabilities.isWebGL2){const r={antialias:void 0!==s.renderState.layers||y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:l};g=new XRWebGLLayer(s,t,r),s.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),S=new WebGLRenderTarget(g.framebufferWidth,g.framebufferHeight,{format:we,type:ye,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let r=null,o=null,c=null;y.depth&&(c=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,r=y.stencil?Te:Ie,o=y.stencil?be:Se);const h={colorFormat:t.RGBA8,depthFormat:c,scaleFactor:l};m=new XRWebGLBinding(s,t),f=m.createProjectionLayer(h),s.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),S=new WebGLRenderTarget(f.textureWidth,f.textureHeight,{format:we,type:ye,depthTexture:new DepthTexture(f.textureWidth,f.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,r),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});e.properties.get(S).__ignoreDepthValues=f.ignoreDepthValues}S.isXRRenderTarget=!0,this.setFoveation(d),p=null,c=await s.requestReferenceSpace(h),X.setContext(s),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==s)return s.environmentBlendMode};const W=new three_module_Vector3,q=new three_module_Vector3;function updateCamera(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===s)return;O.near=U.near=B.near=e.near,O.far=U.far=B.far=e.far,Q===O.near&&G===O.far||(s.updateRenderState({depthNear:O.near,depthFar:O.far}),Q=O.near,G=O.far);const t=e.parent,r=O.cameras;updateCamera(O,t);for(let e=0;e<r.length;e++)updateCamera(r[e],t);2===r.length?function setProjectionFromUnion(e,t,r){W.setFromMatrixPosition(t.matrixWorld),q.setFromMatrixPosition(r.matrixWorld);const s=W.distanceTo(q),o=t.projectionMatrix.elements,l=r.projectionMatrix.elements,c=o[14]/(o[10]-1),h=o[14]/(o[10]+1),d=(o[9]+1)/o[5],p=(o[9]-1)/o[5],A=(o[8]-1)/o[0],m=(l[8]+1)/l[0],f=c*A,g=c*m,_=s/(-A+m),y=_*-A;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(y),e.translateZ(_),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const x=c+_,S=h+_,C=f-y,b=g+(s-y),I=d*h/S*x,T=p*h/S*x;e.projectionMatrix.makePerspective(C,b,I,T,x,S),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(O,B,U):O.projectionMatrix.copy(B.projectionMatrix),function updateUserCamera(e,t,r){null===r?e.matrix.copy(t.matrixWorld):(e.matrix.copy(r.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*bt*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,O,t)},this.getCamera=function(){return O},this.getFoveation=function(){if(null!==f||null!==g)return d},this.setFoveation=function(e){d=e,null!==f&&(f.fixedFoveation=e),null!==g&&void 0!==g.fixedFoveation&&(g.fixedFoveation=e)};let j=null;const X=new WebGLAnimation;X.setAnimationLoop((function onAnimationFrame(t,s){if(A=s.getViewerPose(p||c),_=s,null!==A){const t=A.views;null!==g&&(e.setRenderTargetFramebuffer(S,g.framebuffer),e.setRenderTarget(S));let r=!1;t.length!==O.cameras.length&&(O.cameras.length=0,r=!0);for(let s=0;s<t.length;s++){const o=t[s];let l=null;if(null!==g)l=g.getViewport(o);else{const t=m.getViewSubImage(f,o);l=t.viewport,0===s&&(e.setRenderTargetTextures(S,t.colorTexture,f.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(S))}let c=F[s];void 0===c&&(c=new PerspectiveCamera,c.layers.enable(s),c.viewport=new Vector4,F[s]=c),c.matrix.fromArray(o.transform.matrix),c.matrix.decompose(c.position,c.quaternion,c.scale),c.projectionMatrix.fromArray(o.projectionMatrix),c.projectionMatrixInverse.copy(c.projectionMatrix).invert(),c.viewport.set(l.x,l.y,l.width,l.height),0===s&&(O.matrix.copy(c.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),!0===r&&O.cameras.push(c)}}for(let e=0;e<C.length;e++){const t=b[e],r=C[e];null!==t&&void 0!==r&&r.update(t,s,p||c)}j&&j(t,s),s.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:s}),_=null})),this.setAnimationLoop=function(e){j=e},this.dispose=function(){}}}function WebGLMaterials(e,t){function refreshTransformUniform(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function refreshUniformsCommon(r,s){r.opacity.value=s.opacity,s.color&&r.diffuse.value.copy(s.color),s.emissive&&r.emissive.value.copy(s.emissive).multiplyScalar(s.emissiveIntensity),s.map&&(r.map.value=s.map,refreshTransformUniform(s.map,r.mapTransform)),s.alphaMap&&(r.alphaMap.value=s.alphaMap,refreshTransformUniform(s.alphaMap,r.alphaMapTransform)),s.bumpMap&&(r.bumpMap.value=s.bumpMap,refreshTransformUniform(s.bumpMap,r.bumpMapTransform),r.bumpScale.value=s.bumpScale,s.side===A&&(r.bumpScale.value*=-1)),s.normalMap&&(r.normalMap.value=s.normalMap,refreshTransformUniform(s.normalMap,r.normalMapTransform),r.normalScale.value.copy(s.normalScale),s.side===A&&r.normalScale.value.negate()),s.displacementMap&&(r.displacementMap.value=s.displacementMap,refreshTransformUniform(s.displacementMap,r.displacementMapTransform),r.displacementScale.value=s.displacementScale,r.displacementBias.value=s.displacementBias),s.emissiveMap&&(r.emissiveMap.value=s.emissiveMap,refreshTransformUniform(s.emissiveMap,r.emissiveMapTransform)),s.specularMap&&(r.specularMap.value=s.specularMap,refreshTransformUniform(s.specularMap,r.specularMapTransform)),s.alphaTest>0&&(r.alphaTest.value=s.alphaTest);const o=t.get(s).envMap;if(o&&(r.envMap.value=o,r.flipEnvMap.value=o.isCubeTexture&&!1===o.isRenderTargetTexture?-1:1,r.reflectivity.value=s.reflectivity,r.ior.value=s.ior,r.refractionRatio.value=s.refractionRatio),s.lightMap){r.lightMap.value=s.lightMap;const t=!0===e._useLegacyLights?Math.PI:1;r.lightMapIntensity.value=s.lightMapIntensity*t,refreshTransformUniform(s.lightMap,r.lightMapTransform)}s.aoMap&&(r.aoMap.value=s.aoMap,r.aoMapIntensity.value=s.aoMapIntensity,refreshTransformUniform(s.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function refreshFogUniforms(t,r){r.color.getRGB(t.fogColor.value,getUnlitUniformColorSpace(e)),r.isFog?(t.fogNear.value=r.near,t.fogFar.value=r.far):r.isFogExp2&&(t.fogDensity.value=r.density)},refreshMaterialUniforms:function refreshMaterialUniforms(e,r,s,o,l){r.isMeshBasicMaterial||r.isMeshLambertMaterial?refreshUniformsCommon(e,r):r.isMeshToonMaterial?(refreshUniformsCommon(e,r),function refreshUniformsToon(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(refreshUniformsCommon(e,r),function refreshUniformsPhong(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(refreshUniformsCommon(e,r),function refreshUniformsStandard(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,refreshTransformUniform(r.metalnessMap,e.metalnessMapTransform));e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,refreshTransformUniform(r.roughnessMap,e.roughnessMapTransform));const s=t.get(r).envMap;s&&(e.envMapIntensity.value=r.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function refreshUniformsPhysical(e,t,r){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,refreshTransformUniform(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,refreshTransformUniform(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,refreshTransformUniform(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,refreshTransformUniform(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,refreshTransformUniform(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===A&&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,refreshTransformUniform(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,refreshTransformUniform(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,refreshTransformUniform(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,refreshTransformUniform(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,refreshTransformUniform(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,refreshTransformUniform(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,refreshTransformUniform(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,l)):r.isMeshMatcapMaterial?(refreshUniformsCommon(e,r),function refreshUniformsMatcap(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?refreshUniformsCommon(e,r):r.isMeshDistanceMaterial?(refreshUniformsCommon(e,r),function refreshUniformsDistance(e,r){const s=t.get(r).light;e.referencePosition.value.setFromMatrixPosition(s.matrixWorld),e.nearDistance.value=s.shadow.camera.near,e.farDistance.value=s.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?refreshUniformsCommon(e,r):r.isLineBasicMaterial?(!function refreshUniformsLine(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,refreshTransformUniform(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function refreshUniformsDash(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function refreshUniformsPoints(e,t,r,s){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*s,t.map&&(e.map.value=t.map,refreshTransformUniform(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,refreshTransformUniform(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,o):r.isSpriteMaterial?function refreshUniformsSprites(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,refreshTransformUniform(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,refreshTransformUniform(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 WebGLUniformsGroups(e,t,r,s){let l={},c={},h=[];const d=r.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function hasUniformChanged(e,t,r,s){const o=e.value,l=t+"_"+r;if(void 0===s[l])return s[l]="number"==typeof o||"boolean"==typeof o?o:o.clone(),!0;{const e=s[l];if("number"==typeof o||"boolean"==typeof o){if(e!==o)return s[l]=o,!0}else if(!1===e.equals(o))return e.copy(o),!0}return!1}function getUniformSize(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?o.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):o.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function onUniformsGroupsDispose(t){const r=t.target;r.removeEventListener("dispose",onUniformsGroupsDispose);const s=h.indexOf(r.__bindingPointIndex);h.splice(s,1),e.deleteBuffer(l[r.id]),delete l[r.id],delete c[r.id]}return{bind:function bind(e,t){const r=t.program;s.uniformBlockBinding(e,r)},update:function update(r,p){let A=l[r.id];void 0===A&&(!function prepareUniformsGroup(e){const t=e.uniforms;let r=0;const s=16;for(let e=0,o=t.length;e<o;e++){const o=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=o.length;e<t;e++){const t=o[e],l=Array.isArray(t.value)?t.value:[t.value];for(let e=0,o=l.length;e<o;e++){const o=getUniformSize(l[e]),c=r%s;0!==c&&s-c<o.boundary&&(r+=s-c),t.__data=new Float32Array(o.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=r,r+=o.storage}}}const o=r%s;o>0&&(r+=s-o);return e.__size=r,e.__cache={},this}(r),A=function createBuffer(t){const r=function allocateBindingPointIndex(){for(let e=0;e<d;e++)if(-1===h.indexOf(e))return h.push(e),e;return o.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=r;const s=e.createBuffer(),l=t.__size,c=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,s),e.bufferData(e.UNIFORM_BUFFER,l,c),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,r,s),s}(r),l[r.id]=A,r.addEventListener("dispose",onUniformsGroupsDispose));const m=p.program;s.updateUBOMapping(r,m);const f=t.render.frame;c[r.id]!==f&&(!function updateBufferData(t){const r=l[t.id],s=t.uniforms,o=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,r);for(let t=0,r=s.length;t<r;t++){const r=Array.isArray(s[t])?s[t]:[s[t]];for(let s=0,l=r.length;s<l;s++){const l=r[s];if(!0===hasUniformChanged(l,t,s,o)){const t=l.__offset,r=Array.isArray(l.value)?l.value:[l.value];let s=0;for(let o=0;o<r.length;o++){const c=r[o],h=getUniformSize(c);"number"==typeof c||"boolean"==typeof c?(l.__data[0]=c,e.bufferSubData(e.UNIFORM_BUFFER,t+s,l.__data)):c.isMatrix3?(l.__data[0]=c.elements[0],l.__data[1]=c.elements[1],l.__data[2]=c.elements[2],l.__data[3]=0,l.__data[4]=c.elements[3],l.__data[5]=c.elements[4],l.__data[6]=c.elements[5],l.__data[7]=0,l.__data[8]=c.elements[6],l.__data[9]=c.elements[7],l.__data[10]=c.elements[8],l.__data[11]=0):(c.toArray(l.__data,s),s+=h.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,l.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(r),c[r.id]=f)},dispose:function dispose(){for(const t in l)e.deleteBuffer(l[t]);h=[],l={},c={}}}}class WebGLRenderer{constructor(e={}){const{canvas:t=createCanvasElement(),context:r=null,depth:s=!0,stencil:c=!0,alpha:h=!1,antialias:d=!1,premultipliedAlpha:f=!0,preserveDrawingBuffer:g=!1,powerPreference:_="default",failIfMajorPerformanceCaveat:y=!1}=e;let x;this.isWebGLRenderer=!0,x=null!==r?r.getContextAttributes().alpha:h;const S=new Uint32Array(4),C=new Int32Array(4);let b=null,I=null;const T=[],B=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=tt,this._useLegacyLights=!1,this.toneMapping=K,this.toneMappingExposure=1;const U=this;let F=!1,O=0,Q=0,G=null,W=-1,q=null;const j=new Vector4,X=new Vector4;let Y=null;const J=new Color(0);let $=0,ee=t.width,te=t.height,ie=1,ne=null,re=null;const se=new Vector4(0,0,ee,te),ae=new Vector4(0,0,ee,te);let oe=!1;const le=new Frustum;let ce=!1,he=!1,ue=null;const de=new three_module_Matrix4,pe=new Vector2,Ae=new three_module_Vector3,me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function getTargetPixelRatio(){return null===G?ie:1}let fe,ge,_e,xe,Ie,Te,Be,Re,Le,De,Ue,Pe,Fe,Ne,Oe,Qe,ke,Ge,Ve,He,ze,We,qe,je,Xe=r;function getContext(e,r){for(let s=0;s<e.length;s++){const o=e[s],l=t.getContext(o,r);if(null!==l)return l}return null}try{const e={alpha:!0,depth:s,stencil:c,antialias:d,premultipliedAlpha:f,preserveDrawingBuffer:g,powerPreference:_,failIfMajorPerformanceCaveat:y};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${l}`),t.addEventListener("webglcontextlost",onContextLost,!1),t.addEventListener("webglcontextrestored",onContextRestore,!1),t.addEventListener("webglcontextcreationerror",onContextCreationError,!1),null===Xe){const t=["webgl2","webgl","experimental-webgl"];if(!0===U.isWebGL1Renderer&&t.shift(),Xe=getContext(t,e),null===Xe)throw getContext(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!=typeof WebGLRenderingContext&&Xe instanceof WebGLRenderingContext&&o.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===Xe.getShaderPrecisionFormat&&(Xe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw o.error("THREE.WebGLRenderer: "+e.message),e}function initGLContext(){fe=new WebGLExtensions(Xe),ge=new WebGLCapabilities(Xe,fe,e),fe.init(ge),We=new WebGLUtils(Xe,fe,ge),_e=new WebGLState(Xe,fe,ge),xe=new WebGLInfo(Xe),Ie=new WebGLProperties,Te=new WebGLTextures(Xe,fe,_e,Ie,ge,We,xe),Be=new WebGLCubeMaps(U),Re=new WebGLCubeUVMaps(U),Le=new WebGLAttributes(Xe,ge),qe=new WebGLBindingStates(Xe,fe,Le,ge),De=new WebGLGeometries(Xe,Le,xe,qe),Ue=new WebGLObjects(Xe,De,Le,xe),Ve=new WebGLMorphtargets(Xe,ge,Te),Qe=new WebGLClipping(Ie),Pe=new WebGLPrograms(U,Be,Re,fe,ge,qe,Qe),Fe=new WebGLMaterials(U,Ie),Ne=new WebGLRenderLists,Oe=new WebGLRenderStates(fe,ge),Ge=new WebGLBackground(U,Be,Re,_e,Ue,x,f),ke=new WebGLShadowMap(U,Ue,ge),je=new WebGLUniformsGroups(Xe,xe,ge,_e),He=new WebGLBufferRenderer(Xe,fe,xe,ge),ze=new WebGLIndexedBufferRenderer(Xe,fe,xe,ge),xe.programs=Pe.programs,U.capabilities=ge,U.extensions=fe,U.properties=Ie,U.renderLists=Ne,U.shadowMap=ke,U.state=_e,U.info=xe}initGLContext();const Ye=new WebXRManager(U,Xe);function onContextLost(e){e.preventDefault(),o.log("THREE.WebGLRenderer: Context Lost."),F=!0}function onContextRestore(){o.log("THREE.WebGLRenderer: Context Restored."),F=!1;const e=xe.autoReset,t=ke.enabled,r=ke.autoUpdate,s=ke.needsUpdate,l=ke.type;initGLContext(),xe.autoReset=e,ke.enabled=t,ke.autoUpdate=r,ke.needsUpdate=s,ke.type=l}function onContextCreationError(e){o.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function onMaterialDispose(e){const t=e.target;t.removeEventListener("dispose",onMaterialDispose),function deallocateMaterial(e){(function releaseMaterialProgramReferences(e){const t=Ie.get(e).programs;void 0!==t&&(t.forEach((function(e){Pe.releaseProgram(e)})),e.isShaderMaterial&&Pe.releaseShaderCache(e))})(e),Ie.remove(e)}(t)}function prepareMaterial(e,t,r){!0===e.transparent&&e.side===m&&!1===e.forceSinglePass?(e.side=A,e.needsUpdate=!0,getProgram(e,t,r),e.side=p,e.needsUpdate=!0,getProgram(e,t,r),e.side=m):getProgram(e,t,r)}this.xr=Ye,this.getContext=function(){return Xe},this.getContextAttributes=function(){return Xe.getContextAttributes()},this.forceContextLoss=function(){const e=fe.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=fe.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(e){void 0!==e&&(ie=e,this.setSize(ee,te,!1))},this.getSize=function(e){return e.set(ee,te)},this.setSize=function(e,r,s=!0){Ye.isPresenting?o.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(ee=e,te=r,t.width=Math.floor(e*ie),t.height=Math.floor(r*ie),!0===s&&(t.style.width=e+"px",t.style.height=r+"px"),this.setViewport(0,0,e,r))},this.getDrawingBufferSize=function(e){return e.set(ee*ie,te*ie).floor()},this.setDrawingBufferSize=function(e,r,s){ee=e,te=r,ie=s,t.width=Math.floor(e*s),t.height=Math.floor(r*s),this.setViewport(0,0,e,r)},this.getCurrentViewport=function(e){return e.copy(j)},this.getViewport=function(e){return e.copy(se)},this.setViewport=function(e,t,r,s){e.isVector4?se.set(e.x,e.y,e.z,e.w):se.set(e,t,r,s),_e.viewport(j.copy(se).multiplyScalar(ie).floor())},this.getScissor=function(e){return e.copy(ae)},this.setScissor=function(e,t,r,s){e.isVector4?ae.set(e.x,e.y,e.z,e.w):ae.set(e,t,r,s),_e.scissor(X.copy(ae).multiplyScalar(ie).floor())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){_e.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ne=e},this.setTransparentSort=function(e){re=e},this.getClearColor=function(e){return e.copy(Ge.getClearColor())},this.setClearColor=function(){Ge.setClearColor.apply(Ge,arguments)},this.getClearAlpha=function(){return Ge.getClearAlpha()},this.setClearAlpha=function(){Ge.setClearAlpha.apply(Ge,arguments)},this.clear=function(e=!0,t=!0,r=!0){let s=0;if(e){let e=!1;if(null!==G){const t=G.texture.format;e=1033===t||1031===t||1029===t}if(e){const e=G.texture.type,t=e===ye||e===Se||e===Ee||e===be||1017===e||1018===e,r=Ge.getClearColor(),s=Ge.getClearAlpha(),o=r.r,l=r.g,c=r.b;t?(S[0]=o,S[1]=l,S[2]=c,S[3]=s,Xe.clearBufferuiv(Xe.COLOR,0,S)):(C[0]=o,C[1]=l,C[2]=c,C[3]=s,Xe.clearBufferiv(Xe.COLOR,0,C))}else s|=Xe.COLOR_BUFFER_BIT}t&&(s|=Xe.DEPTH_BUFFER_BIT),r&&(s|=Xe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Xe.clear(s)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",onContextLost,!1),t.removeEventListener("webglcontextrestored",onContextRestore,!1),t.removeEventListener("webglcontextcreationerror",onContextCreationError,!1),Ne.dispose(),Oe.dispose(),Ie.dispose(),Be.dispose(),Re.dispose(),Ue.dispose(),qe.dispose(),je.dispose(),Pe.dispose(),Ye.dispose(),Ye.removeEventListener("sessionstart",onXRSessionStart),Ye.removeEventListener("sessionend",onXRSessionEnd),ue&&(ue.dispose(),ue=null),Je.stop()},this.renderBufferDirect=function(e,t,r,s,l,c){null===t&&(t=me);const h=l.isMesh&&l.matrixWorld.determinant()<0,d=function setProgram(e,t,r,s,l){!0!==t.isScene&&(t=me);Te.resetTextureUnits();const c=t.fog,h=s.isMeshStandardMaterial?t.environment:null,d=null===G?U.outputColorSpace:!0===G.isXRRenderTarget?G.texture.colorSpace:it,p=(s.isMeshStandardMaterial?Re:Be).get(s.envMap||h),A=!0===s.vertexColors&&!!r.attributes.color&&4===r.attributes.color.itemSize,m=!!r.attributes.tangent&&(!!s.normalMap||s.anisotropy>0),f=!!r.morphAttributes.position,g=!!r.morphAttributes.normal,_=!!r.morphAttributes.color;let y=K;s.toneMapped&&(null!==G&&!0!==G.isXRRenderTarget||(y=U.toneMapping));const x=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,S=void 0!==x?x.length:0,C=Ie.get(s),b=I.state.lights;if(!0===ce&&(!0===he||e!==q)){const t=e===q&&s.id===W;Qe.setState(s,e,t)}let T=!1;s.version===C.__version?C.needsLights&&C.lightsStateVersion!==b.state.version||C.outputColorSpace!==d||l.isBatchedMesh&&!1===C.batching?T=!0:l.isBatchedMesh||!0!==C.batching?l.isInstancedMesh&&!1===C.instancing?T=!0:l.isInstancedMesh||!0!==C.instancing?l.isSkinnedMesh&&!1===C.skinning?T=!0:l.isSkinnedMesh||!0!==C.skinning?l.isInstancedMesh&&!0===C.instancingColor&&null===l.instanceColor||l.isInstancedMesh&&!1===C.instancingColor&&null!==l.instanceColor||C.envMap!==p||!0===s.fog&&C.fog!==c?T=!0:void 0===C.numClippingPlanes||C.numClippingPlanes===Qe.numPlanes&&C.numIntersection===Qe.numIntersection?(C.vertexAlphas!==A||C.vertexTangents!==m||C.morphTargets!==f||C.morphNormals!==g||C.morphColors!==_||C.toneMapping!==y||!0===ge.isWebGL2&&C.morphTargetsCount!==S)&&(T=!0):T=!0:T=!0:T=!0:T=!0:(T=!0,C.__version=s.version);let B=C.currentProgram;!0===T&&(B=getProgram(s,t,l));let F=!1,O=!1,Q=!1;const j=B.getUniforms(),X=C.uniforms;_e.useProgram(B.program)&&(F=!0,O=!0,Q=!0);s.id!==W&&(W=s.id,O=!0);if(F||q!==e){j.setValue(Xe,"projectionMatrix",e.projectionMatrix),j.setValue(Xe,"viewMatrix",e.matrixWorldInverse);const t=j.map.cameraPosition;void 0!==t&&t.setValue(Xe,Ae.setFromMatrixPosition(e.matrixWorld)),ge.logarithmicDepthBuffer&&j.setValue(Xe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(s.isMeshPhongMaterial||s.isMeshToonMaterial||s.isMeshLambertMaterial||s.isMeshBasicMaterial||s.isMeshStandardMaterial||s.isShaderMaterial)&&j.setValue(Xe,"isOrthographic",!0===e.isOrthographicCamera),q!==e&&(q=e,O=!0,Q=!0)}if(l.isSkinnedMesh){j.setOptional(Xe,l,"bindMatrix"),j.setOptional(Xe,l,"bindMatrixInverse");const e=l.skeleton;e&&(ge.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),j.setValue(Xe,"boneTexture",e.boneTexture,Te)):o.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}l.isBatchedMesh&&(j.setOptional(Xe,l,"batchingTexture"),j.setValue(Xe,"batchingTexture",l._matricesTexture,Te));const Y=r.morphAttributes;(void 0!==Y.position||void 0!==Y.normal||void 0!==Y.color&&!0===ge.isWebGL2)&&Ve.update(l,r,B);(O||C.receiveShadow!==l.receiveShadow)&&(C.receiveShadow=l.receiveShadow,j.setValue(Xe,"receiveShadow",l.receiveShadow));s.isMeshGouraudMaterial&&null!==s.envMap&&(X.envMap.value=p,X.flipEnvMap.value=p.isCubeTexture&&!1===p.isRenderTargetTexture?-1:1);O&&(j.setValue(Xe,"toneMappingExposure",U.toneMappingExposure),C.needsLights&&function markUniformsLightsNeedsUpdate(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(X,Q),c&&!0===s.fog&&Fe.refreshFogUniforms(X,c),Fe.refreshMaterialUniforms(X,s,ie,te,ue),WebGLUniforms.upload(Xe,getUniformList(C),X,Te));s.isShaderMaterial&&!0===s.uniformsNeedUpdate&&(WebGLUniforms.upload(Xe,getUniformList(C),X,Te),s.uniformsNeedUpdate=!1);s.isSpriteMaterial&&j.setValue(Xe,"center",l.center);if(j.setValue(Xe,"modelViewMatrix",l.modelViewMatrix),j.setValue(Xe,"normalMatrix",l.normalMatrix),j.setValue(Xe,"modelMatrix",l.matrixWorld),s.isShaderMaterial||s.isRawShaderMaterial){const e=s.uniformsGroups;for(let t=0,r=e.length;t<r;t++)if(ge.isWebGL2){const r=e[t];je.update(r,B),je.bind(r,B)}else o.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return B}(e,t,r,s,l);_e.setMaterial(s,h);let p=r.index,A=1;if(!0===s.wireframe){if(p=De.getWireframeAttribute(r),void 0===p)return;A=2}const m=r.drawRange,f=r.attributes.position;let g=m.start*A,_=(m.start+m.count)*A;null!==c&&(g=Math.max(g,c.start*A),_=Math.min(_,(c.start+c.count)*A)),null!==p?(g=Math.max(g,0),_=Math.min(_,p.count)):null!=f&&(g=Math.max(g,0),_=Math.min(_,f.count));const y=_-g;if(y<0||y===1/0)return;let x;qe.setup(l,s,d,r,p);let S=He;if(null!==p&&(x=Le.get(p),S=ze,S.setIndex(x)),l.isMesh)!0===s.wireframe?(_e.setLineWidth(s.wireframeLinewidth*getTargetPixelRatio()),S.setMode(Xe.LINES)):S.setMode(Xe.TRIANGLES);else if(l.isLine){let e=s.linewidth;void 0===e&&(e=1),_e.setLineWidth(e*getTargetPixelRatio()),l.isLineSegments?S.setMode(Xe.LINES):l.isLineLoop?S.setMode(Xe.LINE_LOOP):S.setMode(Xe.LINE_STRIP)}else l.isPoints?S.setMode(Xe.POINTS):l.isSprite&&S.setMode(Xe.TRIANGLES);if(l.isBatchedMesh)S.renderMultiDraw(l._multiDrawStarts,l._multiDrawCounts,l._multiDrawCount);else if(l.isInstancedMesh)S.renderInstances(g,y,l.count);else if(r.isInstancedBufferGeometry){const e=void 0!==r._maxInstanceCount?r._maxInstanceCount:1/0,t=Math.min(r.instanceCount,e);S.renderInstances(g,y,t)}else S.render(g,y)},this.compile=function(e,t,r=null){null===r&&(r=e),I=Oe.get(r),I.init(),B.push(I),r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(I.pushLight(e),e.castShadow&&I.pushShadow(e))})),e!==r&&e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(I.pushLight(e),e.castShadow&&I.pushShadow(e))})),I.setupLights(U._useLegacyLights);const s=new Set;return e.traverse((function(e){const t=e.material;if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++){const l=t[o];prepareMaterial(l,r,e),s.add(l)}else prepareMaterial(t,r,e),s.add(t)})),B.pop(),I=null,s},this.compileAsync=function(e,t,r=null){const s=this.compile(e,t,r);return new Promise((t=>{function checkMaterialsReady(){s.forEach((function(e){Ie.get(e).currentProgram.isReady()&&s.delete(e)})),0!==s.size?setTimeout(checkMaterialsReady,10):t(e)}null!==fe.get("KHR_parallel_shader_compile")?checkMaterialsReady():setTimeout(checkMaterialsReady,10)}))};let Ke=null;function onXRSessionStart(){Je.stop()}function onXRSessionEnd(){Je.start()}const Je=new WebGLAnimation;function projectObject(e,t,r,s){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)I.pushLight(e),e.castShadow&&I.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||le.intersectsSprite(e)){s&&Ae.setFromMatrixPosition(e.matrixWorld).applyMatrix4(de);const t=Ue.update(e),o=e.material;o.visible&&b.push(e,t,o,r,Ae.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||le.intersectsObject(e))){const t=Ue.update(e),o=e.material;if(s&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),Ae.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),Ae.copy(t.boundingSphere.center)),Ae.applyMatrix4(e.matrixWorld).applyMatrix4(de)),Array.isArray(o)){const s=t.groups;for(let l=0,c=s.length;l<c;l++){const c=s[l],h=o[c.materialIndex];h&&h.visible&&b.push(e,t,h,r,Ae.z,c)}}else o.visible&&b.push(e,t,o,r,Ae.z,null)}const o=e.children;for(let e=0,l=o.length;e<l;e++)projectObject(o[e],t,r,s)}function renderScene(e,t,r,s){const o=e.opaque,l=e.transmissive,c=e.transparent;I.setupLightsView(r),!0===ce&&Qe.setGlobalState(U.clippingPlanes,r),l.length>0&&function renderTransmissionPass(e,t,r,s){const o=!0===r.isScene?r.overrideMaterial:null;if(null!==o)return;const l=ge.isWebGL2;null===ue&&(ue=new WebGLRenderTarget(1,1,{generateMipmaps:!0,type:fe.has("EXT_color_buffer_half_float")?Ce:ye,minFilter:ve,samples:l?4:0}));U.getDrawingBufferSize(pe),l?ue.setSize(pe.x,pe.y):ue.setSize(floorPowerOfTwo(pe.x),floorPowerOfTwo(pe.y));const c=U.getRenderTarget();U.setRenderTarget(ue),U.getClearColor(J),$=U.getClearAlpha(),$<1&&U.setClearColor(16777215,.5);U.clear();const h=U.toneMapping;U.toneMapping=K,renderObjects(e,r,s),Te.updateMultisampleRenderTarget(ue),Te.updateRenderTargetMipmap(ue);let d=!1;for(let e=0,o=t.length;e<o;e++){const o=t[e],l=o.object,c=o.geometry,h=o.material,p=o.group;if(h.side===m&&l.layers.test(s.layers)){const e=h.side;h.side=A,h.needsUpdate=!0,renderObject(l,r,s,c,h,p),h.side=e,h.needsUpdate=!0,d=!0}}!0===d&&(Te.updateMultisampleRenderTarget(ue),Te.updateRenderTargetMipmap(ue));U.setRenderTarget(c),U.setClearColor(J,$),U.toneMapping=h}(o,l,t,r),s&&_e.viewport(j.copy(s)),o.length>0&&renderObjects(o,t,r),l.length>0&&renderObjects(l,t,r),c.length>0&&renderObjects(c,t,r),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function renderObjects(e,t,r){const s=!0===t.isScene?t.overrideMaterial:null;for(let o=0,l=e.length;o<l;o++){const l=e[o],c=l.object,h=l.geometry,d=null===s?l.material:s,p=l.group;c.layers.test(r.layers)&&renderObject(c,t,r,h,d,p)}}function renderObject(e,t,r,s,o,l){e.onBeforeRender(U,t,r,s,o,l),e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),o.onBeforeRender(U,t,r,s,e,l),!0===o.transparent&&o.side===m&&!1===o.forceSinglePass?(o.side=A,o.needsUpdate=!0,U.renderBufferDirect(r,t,s,o,e,l),o.side=p,o.needsUpdate=!0,U.renderBufferDirect(r,t,s,o,e,l),o.side=m):U.renderBufferDirect(r,t,s,o,e,l),e.onAfterRender(U,t,r,s,o,l)}function getProgram(e,t,r){!0!==t.isScene&&(t=me);const s=Ie.get(e),o=I.state.lights,l=I.state.shadowsArray,c=o.state.version,h=Pe.getParameters(e,o.state,l,t,r),d=Pe.getProgramCacheKey(h);let p=s.programs;s.environment=e.isMeshStandardMaterial?t.environment:null,s.fog=t.fog,s.envMap=(e.isMeshStandardMaterial?Re:Be).get(e.envMap||s.environment),void 0===p&&(e.addEventListener("dispose",onMaterialDispose),p=new Map,s.programs=p);let A=p.get(d);if(void 0!==A){if(s.currentProgram===A&&s.lightsStateVersion===c)return updateCommonMaterialProperties(e,h),A}else h.uniforms=Pe.getUniforms(e),e.onBuild(r,h,U),e.onBeforeCompile(h,U),A=Pe.acquireProgram(h,d),p.set(d,A),s.uniforms=h.uniforms;const m=s.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(m.clippingPlanes=Qe.uniform),updateCommonMaterialProperties(e,h),s.needsLights=function materialNeedsLights(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),s.lightsStateVersion=c,s.needsLights&&(m.ambientLightColor.value=o.state.ambient,m.lightProbe.value=o.state.probe,m.directionalLights.value=o.state.directional,m.directionalLightShadows.value=o.state.directionalShadow,m.spotLights.value=o.state.spot,m.spotLightShadows.value=o.state.spotShadow,m.rectAreaLights.value=o.state.rectArea,m.ltc_1.value=o.state.rectAreaLTC1,m.ltc_2.value=o.state.rectAreaLTC2,m.pointLights.value=o.state.point,m.pointLightShadows.value=o.state.pointShadow,m.hemisphereLights.value=o.state.hemi,m.directionalShadowMap.value=o.state.directionalShadowMap,m.directionalShadowMatrix.value=o.state.directionalShadowMatrix,m.spotShadowMap.value=o.state.spotShadowMap,m.spotLightMatrix.value=o.state.spotLightMatrix,m.spotLightMap.value=o.state.spotLightMap,m.pointShadowMap.value=o.state.pointShadowMap,m.pointShadowMatrix.value=o.state.pointShadowMatrix),s.currentProgram=A,s.uniformsList=null,A}function getUniformList(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=WebGLUniforms.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function updateCommonMaterialProperties(e,t){const r=Ie.get(e);r.outputColorSpace=t.outputColorSpace,r.batching=t.batching,r.instancing=t.instancing,r.instancingColor=t.instancingColor,r.skinning=t.skinning,r.morphTargets=t.morphTargets,r.morphNormals=t.morphNormals,r.morphColors=t.morphColors,r.morphTargetsCount=t.morphTargetsCount,r.numClippingPlanes=t.numClippingPlanes,r.numIntersection=t.numClipIntersection,r.vertexAlphas=t.vertexAlphas,r.vertexTangents=t.vertexTangents,r.toneMapping=t.toneMapping}Je.setAnimationLoop((function onAnimationFrame(e){Ke&&Ke(e)})),"undefined"!=typeof self&&Je.setContext(self),this.setAnimationLoop=function(e){Ke=e,Ye.setAnimationLoop(e),null===e?Je.stop():Je.start()},Ye.addEventListener("sessionstart",onXRSessionStart),Ye.addEventListener("sessionend",onXRSessionEnd),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void o.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===F)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Ye.enabled&&!0===Ye.isPresenting&&(!0===Ye.cameraAutoUpdate&&Ye.updateCamera(t),t=Ye.getCamera()),!0===e.isScene&&e.onBeforeRender(U,e,t,G),I=Oe.get(e,B.length),I.init(),B.push(I),de.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),le.setFromProjectionMatrix(de),he=this.localClippingEnabled,ce=Qe.init(this.clippingPlanes,he),b=Ne.get(e,T.length),b.init(),T.push(b),projectObject(e,t,0,U.sortObjects),b.finish(),!0===U.sortObjects&&b.sort(ne,re),this.info.render.frame++,!0===ce&&Qe.beginShadows();const r=I.state.shadowsArray;if(ke.render(r,e,t),!0===ce&&Qe.endShadows(),!0===this.info.autoReset&&this.info.reset(),Ge.render(b,e),I.setupLights(U._useLegacyLights),t.isArrayCamera){const r=t.cameras;for(let t=0,s=r.length;t<s;t++){const s=r[t];renderScene(b,e,s,s.viewport)}}else renderScene(b,e,t);null!==G&&(Te.updateMultisampleRenderTarget(G),Te.updateRenderTargetMipmap(G)),!0===e.isScene&&e.onAfterRender(U,e,t),qe.resetDefaultState(),W=-1,q=null,B.pop(),I=B.length>0?B[B.length-1]:null,T.pop(),b=T.length>0?T[T.length-1]:null},this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return Q},this.getRenderTarget=function(){return G},this.setRenderTargetTextures=function(e,t,r){Ie.get(e.texture).__webglTexture=t,Ie.get(e.depthTexture).__webglTexture=r;const s=Ie.get(e);s.__hasExternalTextures=!0,s.__hasExternalTextures&&(s.__autoAllocateDepthBuffer=void 0===r,s.__autoAllocateDepthBuffer||!0===fe.has("WEBGL_multisampled_render_to_texture")&&(o.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),s.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const r=Ie.get(e);r.__webglFramebuffer=t,r.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,r=0){G=e,O=t,Q=r;let s=!0,o=null,l=!1,c=!1;if(e){const h=Ie.get(e);void 0!==h.__useDefaultFramebuffer?(_e.bindFramebuffer(Xe.FRAMEBUFFER,null),s=!1):void 0===h.__webglFramebuffer?Te.setupRenderTarget(e):h.__hasExternalTextures&&Te.rebindTextures(e,Ie.get(e.texture).__webglTexture,Ie.get(e.depthTexture).__webglTexture);const d=e.texture;(d.isData3DTexture||d.isDataArrayTexture||d.isCompressedArrayTexture)&&(c=!0);const p=Ie.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(o=Array.isArray(p[t])?p[t][r]:p[t],l=!0):o=ge.isWebGL2&&e.samples>0&&!1===Te.useMultisampledRTT(e)?Ie.get(e).__webglMultisampledFramebuffer:Array.isArray(p)?p[r]:p,j.copy(e.viewport),X.copy(e.scissor),Y=e.scissorTest}else j.copy(se).multiplyScalar(ie).floor(),X.copy(ae).multiplyScalar(ie).floor(),Y=oe;if(_e.bindFramebuffer(Xe.FRAMEBUFFER,o)&&ge.drawBuffers&&s&&_e.drawBuffers(e,o),_e.viewport(j),_e.scissor(X),_e.setScissorTest(Y),l){const s=Ie.get(e.texture);Xe.framebufferTexture2D(Xe.FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,Xe.TEXTURE_CUBE_MAP_POSITIVE_X+t,s.__webglTexture,r)}else if(c){const s=Ie.get(e.texture),o=t||0;Xe.framebufferTextureLayer(Xe.FRAMEBUFFER,Xe.COLOR_ATTACHMENT0,s.__webglTexture,r||0,o)}W=-1},this.readRenderTargetPixels=function(e,t,r,s,l,c,h){if(!e||!e.isWebGLRenderTarget)return void o.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let d=Ie.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==h&&(d=d[h]),d){_e.bindFramebuffer(Xe.FRAMEBUFFER,d);try{const h=e.texture,d=h.format,p=h.type;if(d!==we&&We.convert(d)!==Xe.getParameter(Xe.IMPLEMENTATION_COLOR_READ_FORMAT))return void o.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const A=p===Ce&&(fe.has("EXT_color_buffer_half_float")||ge.isWebGL2&&fe.has("EXT_color_buffer_float"));if(!(p===ye||We.convert(p)===Xe.getParameter(Xe.IMPLEMENTATION_COLOR_READ_TYPE)||p===Me&&(ge.isWebGL2||fe.has("OES_texture_float")||fe.has("WEBGL_color_buffer_float"))||A))return void o.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-s&&r>=0&&r<=e.height-l&&Xe.readPixels(t,r,s,l,We.convert(d),We.convert(p),c)}finally{const e=null!==G?Ie.get(G).__webglFramebuffer:null;_e.bindFramebuffer(Xe.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,r=0){const s=Math.pow(2,-r),o=Math.floor(t.image.width*s),l=Math.floor(t.image.height*s);Te.setTexture2D(t,0),Xe.copyTexSubImage2D(Xe.TEXTURE_2D,r,0,0,e.x,e.y,o,l),_e.unbindTexture()},this.copyTextureToTexture=function(e,t,r,s=0){const o=t.image.width,l=t.image.height,c=We.convert(r.format),h=We.convert(r.type);Te.setTexture2D(r,0),Xe.pixelStorei(Xe.UNPACK_FLIP_Y_WEBGL,r.flipY),Xe.pixelStorei(Xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),Xe.pixelStorei(Xe.UNPACK_ALIGNMENT,r.unpackAlignment),t.isDataTexture?Xe.texSubImage2D(Xe.TEXTURE_2D,s,e.x,e.y,o,l,c,h,t.image.data):t.isCompressedTexture?Xe.compressedTexSubImage2D(Xe.TEXTURE_2D,s,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,c,t.mipmaps[0].data):Xe.texSubImage2D(Xe.TEXTURE_2D,s,e.x,e.y,c,h,t.image),0===s&&r.generateMipmaps&&Xe.generateMipmap(Xe.TEXTURE_2D),_e.unbindTexture()},this.copyTextureToTexture3D=function(e,t,r,s,l=0){if(U.isWebGL1Renderer)return void o.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const c=e.max.x-e.min.x+1,h=e.max.y-e.min.y+1,d=e.max.z-e.min.z+1,p=We.convert(s.format),A=We.convert(s.type);let m;if(s.isData3DTexture)Te.setTexture3D(s,0),m=Xe.TEXTURE_3D;else{if(!s.isDataArrayTexture&&!s.isCompressedArrayTexture)return void o.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Te.setTexture2DArray(s,0),m=Xe.TEXTURE_2D_ARRAY}Xe.pixelStorei(Xe.UNPACK_FLIP_Y_WEBGL,s.flipY),Xe.pixelStorei(Xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),Xe.pixelStorei(Xe.UNPACK_ALIGNMENT,s.unpackAlignment);const f=Xe.getParameter(Xe.UNPACK_ROW_LENGTH),g=Xe.getParameter(Xe.UNPACK_IMAGE_HEIGHT),_=Xe.getParameter(Xe.UNPACK_SKIP_PIXELS),y=Xe.getParameter(Xe.UNPACK_SKIP_ROWS),x=Xe.getParameter(Xe.UNPACK_SKIP_IMAGES),S=r.isCompressedTexture?r.mipmaps[l]:r.image;Xe.pixelStorei(Xe.UNPACK_ROW_LENGTH,S.width),Xe.pixelStorei(Xe.UNPACK_IMAGE_HEIGHT,S.height),Xe.pixelStorei(Xe.UNPACK_SKIP_PIXELS,e.min.x),Xe.pixelStorei(Xe.UNPACK_SKIP_ROWS,e.min.y),Xe.pixelStorei(Xe.UNPACK_SKIP_IMAGES,e.min.z),r.isDataTexture||r.isData3DTexture?Xe.texSubImage3D(m,l,t.x,t.y,t.z,c,h,d,p,A,S.data):r.isCompressedArrayTexture?(o.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Xe.compressedTexSubImage3D(m,l,t.x,t.y,t.z,c,h,d,p,S.data)):Xe.texSubImage3D(m,l,t.x,t.y,t.z,c,h,d,p,A,S),Xe.pixelStorei(Xe.UNPACK_ROW_LENGTH,f),Xe.pixelStorei(Xe.UNPACK_IMAGE_HEIGHT,g),Xe.pixelStorei(Xe.UNPACK_SKIP_PIXELS,_),Xe.pixelStorei(Xe.UNPACK_SKIP_ROWS,y),Xe.pixelStorei(Xe.UNPACK_SKIP_IMAGES,x),0===l&&s.generateMipmaps&&Xe.generateMipmap(m),_e.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Te.setTextureCube(e,0):e.isData3DTexture?Te.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Te.setTexture2DArray(e,0):Te.setTexture2D(e,0),_e.unbindTexture()},this.resetState=function(){O=0,Q=0,G=null,_e.reset(),qe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Et}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===nt?"display-p3":"srgb",t.unpackColorSpace=Ut.workingColorSpace===rt?"display-p3":"srgb"}get outputEncoding(){return o.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===tt?Ze:3e3}set outputEncoding(e){o.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ze?tt:it}get useLegacyLights(){return o.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){o.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 WebGL1Renderer extends WebGLRenderer{}).prototype.isWebGL1Renderer=!0;class Scene extends Object3D{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"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 three_module_InterleavedBuffer{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=_t,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=generateUUID()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return o.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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,r){e*=this.stride,r*=t.stride;for(let s=0,o=this.stride;s<o;s++)this.array[e+s]=t.array[r+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const dr=new three_module_Vector3;class three_module_InterleavedBufferAttribute{constructor(e,t,r,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,r=this.data.count;t<r;t++)dr.fromBufferAttribute(this,t),dr.applyMatrix4(e),this.setXYZ(t,dr.x,dr.y,dr.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)dr.fromBufferAttribute(this,t),dr.applyNormalMatrix(e),this.setXYZ(t,dr.x,dr.y,dr.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)dr.fromBufferAttribute(this,t),dr.transformDirection(e),this.setXYZ(t,dr.x,dr.y,dr.z);return this}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=denormalize(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=denormalize(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=denormalize(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=denormalize(t,this.array)),t}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=s,this}setXYZW(e,t,r,s,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array),o=normalize(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=s,this.data.array[e+3]=o,this}clone(e){if(void 0===e){o.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return new three_module_BufferAttribute(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new three_module_InterleavedBufferAttribute(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){o.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const pr=new three_module_Vector3,Ar=new Vector4,mr=new Vector4,fr=new three_module_Vector3,gr=new three_module_Matrix4,_r=new three_module_Vector3,vr=new Sphere,yr=new three_module_Matrix4,Er=new Ray;class SkinnedMesh extends three_module_Mesh{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=re,this.bindMatrix=new three_module_Matrix4,this.bindMatrixInverse=new three_module_Matrix4,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new Box3),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,_r),this.boundingBox.expandByPoint(_r)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Sphere),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,_r),this.boundingSphere.expandByPoint(_r)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const r=this.material,s=this.matrixWorld;void 0!==r&&(null===this.boundingSphere&&this.computeBoundingSphere(),vr.copy(this.boundingSphere),vr.applyMatrix4(s),!1!==e.ray.intersectsSphere(vr)&&(yr.copy(s).invert(),Er.copy(e.ray).applyMatrix4(yr),null!==this.boundingBox&&!1===Er.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,Er)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Vector4,t=this.geometry.attributes.skinWeight;for(let r=0,s=t.count;r<s;r++){e.fromBufferAttribute(t,r);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(r,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===re?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():o.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const r=this.skeleton,s=this.geometry;Ar.fromBufferAttribute(s.attributes.skinIndex,e),mr.fromBufferAttribute(s.attributes.skinWeight,e),pr.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const s=mr.getComponent(e);if(0!==s){const o=Ar.getComponent(e);gr.multiplyMatrices(r.bones[o].matrixWorld,r.boneInverses[o]),t.addScaledVector(fr.copy(pr).applyMatrix4(gr),s)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return o.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class Bone extends Object3D{constructor(){super(),this.isBone=!0,this.type="Bone"}}class DataTexture extends Texture{constructor(e=null,t=1,r=1,s,o,l,c,h,d=Ae,p=Ae,A,m){super(null,l,c,h,d,p,s,o,A,m),this.isDataTexture=!0,this.image={data:e,width:t,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const xr=new three_module_Matrix4,Sr=new three_module_Matrix4;class Skeleton{constructor(e=[],t=[]){this.uuid=generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){o.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new three_module_Matrix4)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new three_module_Matrix4;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,r=this.boneMatrices,s=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const o=e[s]?e[s].matrixWorld:Sr;xr.multiplyMatrices(o,t[s]),xr.toArray(r,16*s)}null!==s&&(s.needsUpdate=!0)}clone(){return new Skeleton(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const r=new DataTexture(t,e,e,we,Me);return r.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=r,this}getBoneByName(e){for(let t=0,r=this.bones.length;t<r;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let r=0,s=e.bones.length;r<s;r++){const s=e.bones[r];let l=t[s];void 0===l&&(o.warn("THREE.Skeleton: No bone found with UUID:",s),l=new Bone),this.bones.push(l),this.boneInverses.push((new three_module_Matrix4).fromArray(e.boneInverses[r]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,r=this.boneInverses;for(let s=0,o=t.length;s<o;s++){const o=t[s];e.bones.push(o.uuid);const l=r[s];e.boneInverses.push(l.toArray())}return e}}class three_module_InstancedBufferAttribute extends three_module_BufferAttribute{constructor(e,t,r,s=1){super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Mr=new three_module_Matrix4,Cr=new three_module_Matrix4,br=[],wr=new Box3,Ir=new three_module_Matrix4,Tr=new three_module_Mesh,Br=new Sphere;class InstancedMesh extends three_module_Mesh{constructor(e,t,r){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new three_module_InstancedBufferAttribute(new Float32Array(16*r),16),this.instanceColor=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<r;e++)this.setMatrixAt(e,Ir)}computeBoundingBox(){const e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Box3),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,Mr),wr.copy(e.boundingBox).applyMatrix4(Mr),this.boundingBox.union(wr)}computeBoundingSphere(){const e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new Sphere),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,Mr),Br.copy(e.boundingSphere).applyMatrix4(Mr),this.boundingSphere.union(Br)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const r=this.matrixWorld,s=this.count;if(Tr.geometry=this.geometry,Tr.material=this.material,void 0!==Tr.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Br.copy(this.boundingSphere),Br.applyMatrix4(r),!1!==e.ray.intersectsSphere(Br)))for(let o=0;o<s;o++){this.getMatrixAt(o,Mr),Cr.multiplyMatrices(r,Mr),Tr.matrixWorld=Cr,Tr.raycast(e,br);for(let e=0,r=br.length;e<r;e++){const r=br[e];r.instanceId=o,r.object=this,t.push(r)}br.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new three_module_InstancedBufferAttribute(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class LineBasicMaterial extends Material{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Color(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Rr=new three_module_Vector3,Lr=new three_module_Vector3,Dr=new three_module_Matrix4,Ur=new Ray,Pr=new Sphere;class Line extends Object3D{constructor(e=new three_module_BufferGeometry,t=new LineBasicMaterial){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,r=[0];for(let e=1,s=t.count;e<s;e++)Rr.fromBufferAttribute(t,e-1),Lr.fromBufferAttribute(t,e),r[e]=r[e-1],r[e]+=Rr.distanceTo(Lr);e.setAttribute("lineDistance",new three_module_Float32BufferAttribute(r,1))}else o.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const r=this.geometry,s=this.matrixWorld,o=e.params.Line.threshold,l=r.drawRange;if(null===r.boundingSphere&&r.computeBoundingSphere(),Pr.copy(r.boundingSphere),Pr.applyMatrix4(s),Pr.radius+=o,!1===e.ray.intersectsSphere(Pr))return;Dr.copy(s).invert(),Ur.copy(e.ray).applyMatrix4(Dr);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,d=new three_module_Vector3,p=new three_module_Vector3,A=new three_module_Vector3,m=new three_module_Vector3,f=this.isLineSegments?2:1,g=r.index,_=r.attributes.position;if(null!==g){for(let r=Math.max(0,l.start),s=Math.min(g.count,l.start+l.count)-1;r<s;r+=f){const s=g.getX(r),o=g.getX(r+1);d.fromBufferAttribute(_,s),p.fromBufferAttribute(_,o);if(Ur.distanceSqToSegment(d,p,m,A)>h)continue;m.applyMatrix4(this.matrixWorld);const l=e.ray.origin.distanceTo(m);l<e.near||l>e.far||t.push({distance:l,point:A.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}else{for(let r=Math.max(0,l.start),s=Math.min(_.count,l.start+l.count)-1;r<s;r+=f){d.fromBufferAttribute(_,r),p.fromBufferAttribute(_,r+1);if(Ur.distanceSqToSegment(d,p,m,A)>h)continue;m.applyMatrix4(this.matrixWorld);const s=e.ray.origin.distanceTo(m);s<e.near||s>e.far||t.push({distance:s,point:A.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){const t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const Fr=new three_module_Vector3,Nr=new three_module_Vector3;class LineSegments extends Line{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,r=[];for(let e=0,s=t.count;e<s;e+=2)Fr.fromBufferAttribute(t,e),Nr.fromBufferAttribute(t,e+1),r[e]=0===e?0:r[e-1],r[e+1]=r[e]+Fr.distanceTo(Nr);e.setAttribute("lineDistance",new three_module_Float32BufferAttribute(r,1))}else o.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class LineLoop extends Line{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class PointsMaterial extends Material{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Or=new three_module_Matrix4,Qr=new Ray,kr=new Sphere,Gr=new three_module_Vector3;class Points extends Object3D{constructor(e=new three_module_BufferGeometry,t=new PointsMaterial){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const r=this.geometry,s=this.matrixWorld,o=e.params.Points.threshold,l=r.drawRange;if(null===r.boundingSphere&&r.computeBoundingSphere(),kr.copy(r.boundingSphere),kr.applyMatrix4(s),kr.radius+=o,!1===e.ray.intersectsSphere(kr))return;Or.copy(s).invert(),Qr.copy(e.ray).applyMatrix4(Or);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,d=r.index,p=r.attributes.position;if(null!==d){for(let r=Math.max(0,l.start),o=Math.min(d.count,l.start+l.count);r<o;r++){const o=d.getX(r);Gr.fromBufferAttribute(p,o),testPoint(Gr,o,h,s,e,t,this)}}else{for(let r=Math.max(0,l.start),o=Math.min(p.count,l.start+l.count);r<o;r++)Gr.fromBufferAttribute(p,r),testPoint(Gr,r,h,s,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){const t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function testPoint(e,t,r,s,o,l,c){const h=Qr.distanceSqToPoint(e);if(h<r){const r=new three_module_Vector3;Qr.closestPointToPoint(e,r),r.applyMatrix4(s);const d=o.ray.origin.distanceTo(r);if(d<o.near||d>o.far)return;l.push({distance:d,distanceToRay:Math.sqrt(h),point:r,index:t,face:null,object:c})}}class VideoTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d){super(e,t,r,s,o,l,c,h,d),this.isVideoTexture=!0,this.minFilter=void 0!==l?l:ge,this.magFilter=void 0!==o?o:ge,this.generateMipmaps=!1;const p=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function updateVideo(){p.needsUpdate=!0,e.requestVideoFrameCallback(updateVideo)}))}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 CompressedTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d,p,A,m){super(null,l,c,h,d,p,s,o,A,m),this.isCompressedTexture=!0,this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class CompressedArrayTexture extends CompressedTexture{constructor(e,t,r,s,o,l){super(e,t,r,o,l),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=de}}class CompressedCubeTexture extends CompressedTexture{constructor(e,t,r){super(void 0,e[0].width,e[0].height,t,r,ae),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class CanvasTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d){super(e,t,r,s,o,l,c,h,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class SphereGeometry extends three_module_BufferGeometry{constructor(e=1,t=32,r=16,s=0,o=2*Math.PI,l=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:s,phiLength:o,thetaStart:l,thetaLength:c},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));const h=Math.min(l+c,Math.PI);let d=0;const p=[],A=new three_module_Vector3,m=new three_module_Vector3,f=[],g=[],_=[],y=[];for(let f=0;f<=r;f++){const x=[],S=f/r;let C=0;0===f&&0===l?C=.5/t:f===r&&h===Math.PI&&(C=-.5/t);for(let r=0;r<=t;r++){const h=r/t;A.x=-e*Math.cos(s+h*o)*Math.sin(l+S*c),A.y=e*Math.cos(l+S*c),A.z=e*Math.sin(s+h*o)*Math.sin(l+S*c),g.push(A.x,A.y,A.z),m.copy(A).normalize(),_.push(m.x,m.y,m.z),y.push(h+C,1-S),x.push(d++)}p.push(x)}for(let e=0;e<r;e++)for(let s=0;s<t;s++){const t=p[e][s+1],o=p[e][s],c=p[e+1][s],d=p[e+1][s+1];(0!==e||l>0)&&f.push(t,o,d),(e!==r-1||h<Math.PI)&&f.push(o,c,d)}this.setIndex(f),this.setAttribute("position",new three_module_Float32BufferAttribute(g,3)),this.setAttribute("normal",new three_module_Float32BufferAttribute(_,3)),this.setAttribute("uv",new three_module_Float32BufferAttribute(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new SphereGeometry(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class MeshStandardMaterial extends Material{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Color(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.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.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,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 MeshPhysicalMaterial extends MeshStandardMaterial{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Vector2(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return clamp(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Color(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Color(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Color(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=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}}function convertArray(e,t,r){return!e||!r&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function getKeyframeOrder(e){const t=e.length,r=new Array(t);for(let e=0;e!==t;++e)r[e]=e;return r.sort((function compareTime(t,r){return e[t]-e[r]})),r}function sortedArray(e,t,r){const s=e.length,o=new e.constructor(s);for(let l=0,c=0;c!==s;++l){const s=r[l]*t;for(let r=0;r!==t;++r)o[c++]=e[s+r]}return o}function flattenJSON(e,t,r,s){let o=1,l=e[0];for(;void 0!==l&&void 0===l[s];)l=e[o++];if(void 0===l)return;let c=l[s];if(void 0!==c)if(Array.isArray(c))do{c=l[s],void 0!==c&&(t.push(l.time),r.push.apply(r,c)),l=e[o++]}while(void 0!==l);else if(void 0!==c.toArray)do{c=l[s],void 0!==c&&(t.push(l.time),c.toArray(r,r.length)),l=e[o++]}while(void 0!==l);else do{c=l[s],void 0!==c&&(t.push(l.time),r.push(c)),l=e[o++]}while(void 0!==l)}class Interpolant{constructor(e,t,r,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==s?s:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let r=this._cachedIndex,s=t[r],o=t[r-1];e:{t:{let l;i:{n:if(!(e<s)){for(let l=r+2;;){if(void 0===s){if(e<o)break n;return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===l)break;if(o=s,s=t[++r],e<s)break t}l=t.length;break i}if(e>=o)break e;{const c=t[1];e<c&&(r=2,o=c);for(let l=r-2;;){if(void 0===o)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(s=o,o=t[--r-1],e>=o)break t}l=r,r=0}}for(;r<l;){const s=r+l>>>1;e<t[s]?l=s:r=s+1}if(s=t[r],o=t[r-1],void 0===o)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===s)return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,o,s)}return this.interpolate_(r,o,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,o=e*s;for(let e=0;e!==s;++e)t[e]=r[o+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class CubicInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ye,endingEnd:Ye}}intervalChanged_(e,t,r){const s=this.parameterPositions;let o=e-2,l=e+1,c=s[o],h=s[l];if(void 0===c)switch(this.getSettings_().endingStart){case Ke:o=e,c=2*t-r;break;case Je:o=s.length-2,c=t+s[o]-s[o+1];break;default:o=e,c=r}if(void 0===h)switch(this.getSettings_().endingEnd){case Ke:l=e,h=2*r-t;break;case Je:l=1,h=r+s[1]-s[0];break;default:l=e-1,h=t}const d=.5*(r-t),p=this.valueSize;this._weightPrev=d/(t-c),this._weightNext=d/(h-r),this._offsetPrev=o*p,this._offsetNext=l*p}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=e*c,d=h-c,p=this._offsetPrev,A=this._offsetNext,m=this._weightPrev,f=this._weightNext,g=(r-t)/(s-t),_=g*g,y=_*g,x=-m*y+2*m*_-m*g,S=(1+m)*y+(-1.5-2*m)*_+(-.5+m)*g+1,C=(-1-f)*y+(1.5+f)*_+.5*g,b=f*y-f*_;for(let e=0;e!==c;++e)o[e]=x*l[p+e]+S*l[d+e]+C*l[h+e]+b*l[A+e];return o}}class LinearInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=e*c,d=h-c,p=(r-t)/(s-t),A=1-p;for(let e=0;e!==c;++e)o[e]=l[d+e]*A+l[h+e]*p;return o}}class DiscreteInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class KeyframeTrack{constructor(e,t,r,s){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=convertArray(t,this.TimeBufferType),this.values=convertArray(r,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:convertArray(e.times,Array),values:convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(r.interpolation=t)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new LinearInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new CubicInterpolant(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case qe:t=this.InterpolantFactoryMethodDiscrete;break;case je:t=this.InterpolantFactoryMethodLinear;break;case Xe:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return o.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return qe;case this.InterpolantFactoryMethodLinear:return je;case this.InterpolantFactoryMethodSmooth:return Xe}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let r=0,s=t.length;r!==s;++r)t[r]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let r=0,s=t.length;r!==s;++r)t[r]*=e}return this}trim(e,t){const r=this.times,s=r.length;let o=0,l=s-1;for(;o!==s&&r[o]<e;)++o;for(;-1!==l&&r[l]>t;)--l;if(++l,0!==o||l!==s){o>=l&&(l=Math.max(l,1),o=l-1);const e=this.getValueSize();this.times=r.slice(o,l),this.values=this.values.slice(o*e,l*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(o.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,s=this.values,l=r.length;0===l&&(o.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let c=null;for(let t=0;t!==l;t++){const s=r[t];if("number"==typeof s&&isNaN(s)){o.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,s),e=!1;break}if(null!==c&&c>s){o.error("THREE.KeyframeTrack: Out of order keys.",this,t,s,c),e=!1;break}c=s}if(void 0!==s&&isTypedArray(s))for(let t=0,r=s.length;t!==r;++t){const r=s[t];if(isNaN(r)){o.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,r),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),r=this.getValueSize(),s=this.getInterpolation()===Xe,o=e.length-1;let l=1;for(let c=1;c<o;++c){let o=!1;const h=e[c];if(h!==e[c+1]&&(1!==c||h!==e[0]))if(s)o=!0;else{const e=c*r,s=e-r,l=e+r;for(let c=0;c!==r;++c){const r=t[e+c];if(r!==t[s+c]||r!==t[l+c]){o=!0;break}}}if(o){if(c!==l){e[l]=e[c];const s=c*r,o=l*r;for(let e=0;e!==r;++e)t[o+e]=t[s+e]}++l}}if(o>0){e[l]=e[o];for(let e=o*r,s=l*r,c=0;c!==r;++c)t[s+c]=t[e+c];++l}return l!==e.length?(this.times=e.slice(0,l),this.values=t.slice(0,l*r)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),r=new(0,this.constructor)(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}KeyframeTrack.prototype.TimeBufferType=Float32Array,KeyframeTrack.prototype.ValueBufferType=Float32Array,KeyframeTrack.prototype.DefaultInterpolation=je;class BooleanKeyframeTrack extends KeyframeTrack{}BooleanKeyframeTrack.prototype.ValueTypeName="bool",BooleanKeyframeTrack.prototype.ValueBufferType=Array,BooleanKeyframeTrack.prototype.DefaultInterpolation=qe,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class ColorKeyframeTrack extends KeyframeTrack{}ColorKeyframeTrack.prototype.ValueTypeName="color";class NumberKeyframeTrack extends KeyframeTrack{}NumberKeyframeTrack.prototype.ValueTypeName="number";class QuaternionLinearInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=(r-t)/(s-t);let d=e*c;for(let e=d+c;d!==e;d+=4)three_module_Quaternion.slerpFlat(o,0,l,d-c,l,d,h);return o}}class three_module_QuaternionKeyframeTrack extends KeyframeTrack{InterpolantFactoryMethodLinear(e){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)}}three_module_QuaternionKeyframeTrack.prototype.ValueTypeName="quaternion",three_module_QuaternionKeyframeTrack.prototype.DefaultInterpolation=je,three_module_QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class StringKeyframeTrack extends KeyframeTrack{}StringKeyframeTrack.prototype.ValueTypeName="string",StringKeyframeTrack.prototype.ValueBufferType=Array,StringKeyframeTrack.prototype.DefaultInterpolation=qe,StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class three_module_VectorKeyframeTrack extends KeyframeTrack{}three_module_VectorKeyframeTrack.prototype.ValueTypeName="vector";class three_module_AnimationClip{constructor(e,t=-1,r,s=2500){this.name=e,this.tracks=r,this.duration=t,this.blendMode=s,this.uuid=generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,s=1/(e.fps||1);for(let e=0,o=r.length;e!==o;++e)t.push(parseKeyframeTrack(r[e]).scale(s));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){const t=[],r=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,s=r.length;e!==s;++e)t.push(KeyframeTrack.toJSON(r[e]));return s}static CreateFromMorphTargetSequence(e,t,r,s){const o=t.length,l=[];for(let e=0;e<o;e++){let c=[],h=[];c.push((e+o-1)%o,e,(e+1)%o),h.push(0,1,0);const d=getKeyframeOrder(c);c=sortedArray(c,1,d),h=sortedArray(h,1,d),s||0!==c[0]||(c.push(o),h.push(h[0])),l.push(new NumberKeyframeTrack(".morphTargetInfluences["+t[e].name+"]",c,h).scale(1/r))}return new this(e,-1,l)}static findByName(e,t){let r=e;if(!Array.isArray(e)){const t=e;r=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<r.length;e++)if(r[e].name===t)return r[e];return null}static CreateClipsFromMorphTargetSequences(e,t,r){const s={},o=/^([\w-]*?)([\d]+)$/;for(let t=0,r=e.length;t<r;t++){const r=e[t],l=r.name.match(o);if(l&&l.length>1){const e=l[1];let t=s[e];t||(s[e]=t=[]),t.push(r)}}const l=[];for(const e in s)l.push(this.CreateFromMorphTargetSequence(e,s[e],t,r));return l}static parseAnimation(e,t){if(!e)return o.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const addNonemptyTrack=function(e,t,r,s,o){if(0!==r.length){const l=[],c=[];flattenJSON(r,l,c,s),0!==l.length&&o.push(new e(t,l,c))}},r=[],s=e.name||"default",l=e.fps||30,c=e.blendMode;let h=e.length||-1;const d=e.hierarchy||[];for(let e=0;e<d.length;e++){const s=d[e].keys;if(s&&0!==s.length)if(s[0].morphTargets){const e={};let t;for(t=0;t<s.length;t++)if(s[t].morphTargets)for(let r=0;r<s[t].morphTargets.length;r++)e[s[t].morphTargets[r]]=-1;for(const o in e){const e=[],l=[];for(let r=0;r!==s[t].morphTargets.length;++r){const r=s[t];e.push(r.time),l.push(r.morphTarget===o?1:0)}r.push(new NumberKeyframeTrack(".morphTargetInfluence["+o+"]",e,l))}h=e.length*l}else{const o=".bones["+t[e].name+"]";addNonemptyTrack(three_module_VectorKeyframeTrack,o+".position",s,"pos",r),addNonemptyTrack(three_module_QuaternionKeyframeTrack,o+".quaternion",s,"rot",r),addNonemptyTrack(three_module_VectorKeyframeTrack,o+".scale",s,"scl",r)}}if(0===r.length)return null;return new this(s,h,r,c)}resetDuration(){let e=0;for(let t=0,r=this.tracks.length;t!==r;++t){const r=this.tracks[t];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function parseKeyframeTrack(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function getTrackTypeForValueTypeName(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return three_module_VectorKeyframeTrack;case"color":return ColorKeyframeTrack;case"quaternion":return three_module_QuaternionKeyframeTrack;case"bool":case"boolean":return BooleanKeyframeTrack;case"string":return StringKeyframeTrack}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],r=[];flattenJSON(e.keys,t,r,"value"),e.times=t,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const Vr={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class LoadingManager{constructor(e,t,r){const s=this;let o,l=!1,c=0,h=0;const d=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){h++,!1===l&&void 0!==s.onStart&&s.onStart(e,c,h),l=!0},this.itemEnd=function(e){c++,void 0!==s.onProgress&&s.onProgress(e,c,h),c===h&&(l=!1,void 0!==s.onLoad&&s.onLoad())},this.itemError=function(e){void 0!==s.onError&&s.onError(e)},this.resolveURL=function(e){return o?o(e):e},this.setURLModifier=function(e){return o=e,this},this.addHandler=function(e,t){return d.push(e,t),this},this.removeHandler=function(e){const t=d.indexOf(e);return-1!==t&&d.splice(t,2),this},this.getHandler=function(e){for(let t=0,r=d.length;t<r;t+=2){const r=d[t],s=d[t+1];if(r.global&&(r.lastIndex=0),r.test(e))return s}return null}}}const Hr=new LoadingManager;class Loader{constructor(e){this.manager=void 0!==e?e:Hr,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise((function(s,o){r.load(e,s,t,o)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Loader.DEFAULT_MATERIAL_NAME="__DEFAULT";const zr={};class HttpError extends Error{constructor(e,t){super(e),this.response=t}}class three_module_FileLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const l=Vr.get(e);if(void 0!==l)return this.manager.itemStart(e),setTimeout((()=>{t&&t(l),this.manager.itemEnd(e)}),0),l;if(void 0!==zr[e])return void zr[e].push({onLoad:t,onProgress:r,onError:s});zr[e]=[],zr[e].push({onLoad:t,onProgress:r,onError:s});const c=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),h=this.mimeType,d=this.responseType;fetch(c).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&o.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const r=zr[e],s=t.body.getReader(),l=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),c=l?parseInt(l):0,h=0!==c;let d=0;const p=new ReadableStream({start(e){!function readData(){s.read().then((({done:t,value:s})=>{if(t)e.close();else{d+=s.byteLength;const t=new ProgressEvent("progress",{lengthComputable:h,loaded:d,total:c});for(let e=0,s=r.length;e<s;e++){const s=r[e];s.onProgress&&s.onProgress(t)}e.enqueue(s),readData()}}))}()}});return new Response(p)}throw new HttpError(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(d){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,h)));case"json":return e.json();default:if(void 0===h)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(h),r=t&&t[1]?t[1].toLowerCase():void 0,s=new TextDecoder(r);return e.arrayBuffer().then((e=>s.decode(e)))}}})).then((t=>{Vr.add(e,t);const r=zr[e];delete zr[e];for(let e=0,s=r.length;e<s;e++){const s=r[e];s.onLoad&&s.onLoad(t)}})).catch((t=>{const r=zr[e];if(void 0===r)throw this.manager.itemError(e),t;delete zr[e];for(let e=0,s=r.length;e<s;e++){const s=r[e];s.onError&&s.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ImageLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,l=Vr.get(e);if(void 0!==l)return o.manager.itemStart(e),setTimeout((function(){t&&t(l),o.manager.itemEnd(e)}),0),l;const c=createElementNS("img");function onImageLoad(){removeEventListeners(),Vr.add(e,this),t&&t(this),o.manager.itemEnd(e)}function onImageError(t){removeEventListeners(),s&&s(t),o.manager.itemError(e),o.manager.itemEnd(e)}function removeEventListeners(){c.removeEventListener("load",onImageLoad,!1),c.removeEventListener("error",onImageError,!1)}return c.addEventListener("load",onImageLoad,!1),c.addEventListener("error",onImageError,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(c.crossOrigin=this.crossOrigin),o.manager.itemStart(e),c.src=e,c}}class DataTextureLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){const l=this,c=new DataTexture,h=new three_module_FileLoader(this.manager);return h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setPath(this.path),h.setWithCredentials(l.withCredentials),h.load(e,(function(e){let r;try{r=l.parse(e)}catch(e){if(void 0===s)return void o.error(e);s(e)}void 0!==r.image?c.image=r.image:void 0!==r.data&&(c.image.width=r.width,c.image.height=r.height,c.image.data=r.data),c.wrapS=void 0!==r.wrapS?r.wrapS:de,c.wrapT=void 0!==r.wrapT?r.wrapT:de,c.magFilter=void 0!==r.magFilter?r.magFilter:ge,c.minFilter=void 0!==r.minFilter?r.minFilter:ge,c.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,void 0!==r.colorSpace?c.colorSpace=r.colorSpace:void 0!==r.encoding&&(c.encoding=r.encoding),void 0!==r.flipY&&(c.flipY=r.flipY),void 0!==r.format&&(c.format=r.format),void 0!==r.type&&(c.type=r.type),void 0!==r.mipmaps&&(c.mipmaps=r.mipmaps,c.minFilter=ve),1===r.mipmapCount&&(c.minFilter=ge),void 0!==r.generateMipmaps&&(c.generateMipmaps=r.generateMipmaps),c.needsUpdate=!0,t&&t(c,r)}),r,s),c}}class TextureLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){const o=new Texture,l=new ImageLoader(this.manager);return l.setCrossOrigin(this.crossOrigin),l.setPath(this.path),l.load(e,(function(e){o.image=e,o.needsUpdate=!0,void 0!==t&&t(o)}),r,s),o}}class Light extends Object3D{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Color(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}const Wr=new three_module_Matrix4,qr=new three_module_Vector3,jr=new three_module_Vector3;class LightShadow{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vector2(512,512),this.map=null,this.mapPass=null,this.matrix=new three_module_Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;qr.setFromMatrixPosition(e.matrixWorld),t.position.copy(qr),jr.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(jr),t.updateMatrixWorld(),Wr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Wr),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Wr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class SpotLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,r=2*bt*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height,o=e.distance||t.far;r===t.fov&&s===t.aspect&&o===t.far||(t.fov=r,t.aspect=s,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class SpotLight extends Light{constructor(e,t,r=0,s=Math.PI/3,o=0,l=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.distance=r,this.angle=s,this.penumbra=o,this.decay=l,this.map=null,this.shadow=new SpotLightShadow}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Xr=new three_module_Matrix4,Yr=new three_module_Vector3,Kr=new three_module_Vector3;class PointLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Vector2(4,2),this._viewportCount=6,this._viewports=[new Vector4(2,1,1,1),new Vector4(0,1,1,1),new Vector4(3,1,1,1),new Vector4(1,1,1,1),new Vector4(3,0,1,1),new Vector4(1,0,1,1)],this._cubeDirections=[new three_module_Vector3(1,0,0),new three_module_Vector3(-1,0,0),new three_module_Vector3(0,0,1),new three_module_Vector3(0,0,-1),new three_module_Vector3(0,1,0),new three_module_Vector3(0,-1,0)],this._cubeUps=[new three_module_Vector3(0,1,0),new three_module_Vector3(0,1,0),new three_module_Vector3(0,1,0),new three_module_Vector3(0,1,0),new three_module_Vector3(0,0,1),new three_module_Vector3(0,0,-1)]}updateMatrices(e,t=0){const r=this.camera,s=this.matrix,o=e.distance||r.far;o!==r.far&&(r.far=o,r.updateProjectionMatrix()),Yr.setFromMatrixPosition(e.matrixWorld),r.position.copy(Yr),Kr.copy(r.position),Kr.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Kr),r.updateMatrixWorld(),s.makeTranslation(-Yr.x,-Yr.y,-Yr.z),Xr.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Xr)}}class PointLight extends Light{constructor(e,t,r=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=s,this.shadow=new PointLightShadow}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class DirectionalLightShadow extends LightShadow{constructor(){super(new OrthographicCamera(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class DirectionalLight extends Light{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.shadow=new DirectionalLightShadow}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class SphericalHarmonics3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new three_module_Vector3)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const r=e.x,s=e.y,o=e.z,l=this.coefficients;return t.copy(l[0]).multiplyScalar(.282095),t.addScaledVector(l[1],.488603*s),t.addScaledVector(l[2],.488603*o),t.addScaledVector(l[3],.488603*r),t.addScaledVector(l[4],r*s*1.092548),t.addScaledVector(l[5],s*o*1.092548),t.addScaledVector(l[6],.315392*(3*o*o-1)),t.addScaledVector(l[7],r*o*1.092548),t.addScaledVector(l[8],.546274*(r*r-s*s)),t}getIrradianceAt(e,t){const r=e.x,s=e.y,o=e.z,l=this.coefficients;return t.copy(l[0]).multiplyScalar(.886227),t.addScaledVector(l[1],1.023328*s),t.addScaledVector(l[2],1.023328*o),t.addScaledVector(l[3],1.023328*r),t.addScaledVector(l[4],.858086*r*s),t.addScaledVector(l[5],.858086*s*o),t.addScaledVector(l[6],.743125*o*o-.247708),t.addScaledVector(l[7],.858086*r*o),t.addScaledVector(l[8],.429043*(r*r-s*s)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let r=0;r<9;r++)this.coefficients[r].addScaledVector(e.coefficients[r],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let r=0;r<9;r++)this.coefficients[r].lerp(e.coefficients[r],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const r=this.coefficients;for(let s=0;s<9;s++)r[s].fromArray(e,t+3*s);return this}toArray(e=[],t=0){const r=this.coefficients;for(let s=0;s<9;s++)r[s].toArray(e,t+3*s);return e}static getBasisAt(e,t){const r=e.x,s=e.y,o=e.z;t[0]=.282095,t[1]=.488603*s,t[2]=.488603*o,t[3]=.488603*r,t[4]=1.092548*r*s,t[5]=1.092548*s*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*r*o,t[8]=.546274*(r*r-s*s)}}class LightProbe extends Light{constructor(e=new SphericalHarmonics3,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class LoaderUtils{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let r=0,s=e.length;r<s;r++)t+=String.fromCharCode(e[r]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class ImageBitmapLoader extends Loader{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&o.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&o.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,l=Vr.get(e);if(void 0!==l)return o.manager.itemStart(e),l.then?void l.then((r=>{t&&t(r),o.manager.itemEnd(e)})).catch((e=>{s&&s(e)})):(setTimeout((function(){t&&t(l),o.manager.itemEnd(e)}),0),l);const c={};c.credentials="anonymous"===this.crossOrigin?"same-origin":"include",c.headers=this.requestHeader;const h=fetch(e,c).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(o.options,{colorSpaceConversion:"none"}))})).then((function(r){return Vr.add(e,r),t&&t(r),o.manager.itemEnd(e),r})).catch((function(t){s&&s(t),Vr.remove(e),o.manager.itemError(e),o.manager.itemEnd(e)}));Vr.add(e,h),o.manager.itemStart(e)}}class PropertyMixer{constructor(e,t,r){let s,o,l;switch(this.binding=e,this.valueSize=r,t){case"quaternion":s=this._slerp,o=this._slerpAdditive,l=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*r),this._workIndex=5;break;case"string":case"bool":s=this._select,o=this._select,l=this._setAdditiveIdentityOther,this.buffer=new Array(5*r);break;default:s=this._lerp,o=this._lerpAdditive,l=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*r)}this._mixBufferRegion=s,this._mixBufferRegionAdditive=o,this._setIdentity=l,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const r=this.buffer,s=this.valueSize,o=e*s+s;let l=this.cumulativeWeight;if(0===l){for(let e=0;e!==s;++e)r[o+e]=r[e];l=t}else{l+=t;const e=t/l;this._mixBufferRegion(r,o,0,e,s)}this.cumulativeWeight=l}accumulateAdditive(e){const t=this.buffer,r=this.valueSize,s=r*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,s,0,e,r),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,r=this.buffer,s=e*t+t,o=this.cumulativeWeight,l=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const e=t*this._origIndex;this._mixBufferRegion(r,s,e,1-o,t)}l>0&&this._mixBufferRegionAdditive(r,s,this._addIndex*t,1,t);for(let e=t,o=t+t;e!==o;++e)if(r[e]!==r[e+t]){c.setValue(r,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,r=this.valueSize,s=r*this._origIndex;e.getValue(t,s);for(let e=r,o=s;e!==o;++e)t[e]=t[s+e%r];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 r=e;r<t;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[t+r]=this.buffer[e+r]}_select(e,t,r,s,o){if(s>=.5)for(let s=0;s!==o;++s)e[t+s]=e[r+s]}_slerp(e,t,r,s){three_module_Quaternion.slerpFlat(e,t,e,t,e,r,s)}_slerpAdditive(e,t,r,s,o){const l=this._workIndex*o;three_module_Quaternion.multiplyQuaternionsFlat(e,l,e,t,e,r),three_module_Quaternion.slerpFlat(e,t,e,t,e,l,s)}_lerp(e,t,r,s,o){const l=1-s;for(let c=0;c!==o;++c){const o=t+c;e[o]=e[o]*l+e[r+c]*s}}_lerpAdditive(e,t,r,s,o){for(let l=0;l!==o;++l){const o=t+l;e[o]=e[o]+e[r+l]*s}}}const Jr="\\[\\]\\.:\\/",$r=new RegExp("["+Jr+"]","g"),Zr="[^"+Jr+"]",es="[^"+Jr.replace("\\.","")+"]",ts=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Zr)+/(WCOD+)?/.source.replace("WCOD",es)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zr)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zr)+"$"),is=["material","materials","bones","map"];class PropertyBinding{constructor(e,t,r){this.path=t,this.parsedPath=r||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new PropertyBinding.Composite(e,t,r):new PropertyBinding(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace($r,"")}static parseTrackName(e){const t=ts.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==s&&-1!==s){const e=r.nodeName.substring(s+1);-1!==is.indexOf(e)&&(r.nodeName=r.nodeName.substring(0,s),r.objectName=e)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(void 0!==r)return r}if(e.children){const searchNodeSubtree=function(e){for(let r=0;r<e.length;r++){const s=e[r];if(s.name===t||s.uuid===t)return s;const o=searchNodeSubtree(s.children);if(o)return o}return null},r=searchNodeSubtree(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)e[t++]=r[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)r[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)r[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)r[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,r=t.objectName,s=t.propertyName;let l=t.propertyIndex;if(e||(e=PropertyBinding.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void o.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(r){let s=t.objectIndex;switch(r){case"materials":if(!e.material)return void o.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void o.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void o.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===s){s=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void o.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void o.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[r])return void o.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[r]}if(void 0!==s){if(void 0===e[s])return void o.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[s]}}const c=e[s];if(void 0===c){const r=t.nodeName;return void o.error("THREE.PropertyBinding: Trying to update property for track: "+r+"."+s+" but it wasn't found.",e)}let h=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?h=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(h=this.Versioning.MatrixWorldNeedsUpdate);let d=this.BindingType.Direct;if(void 0!==l){if("morphTargetInfluences"===s){if(!e.geometry)return void o.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void o.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[l]&&(l=e.morphTargetDictionary[l])}d=this.BindingType.ArrayElement,this.resolvedProperty=c,this.propertyIndex=l}else void 0!==c.fromArray&&void 0!==c.toArray?(d=this.BindingType.HasFromToArray,this.resolvedProperty=c):Array.isArray(c)?(d=this.BindingType.EntireArray,this.resolvedProperty=c):this.propertyName=s;this.getValue=this.GetterByBindingType[d],this.setValue=this.SetterByBindingTypeAndVersioning[d][h]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}PropertyBinding.Composite=class Composite{constructor(e,t,r){const s=r||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,s=this._bindings[r];void 0!==s&&s.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let s=this._targetGroup.nCachedObjects_,o=r.length;s!==o;++s)r[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}},PropertyBinding.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},PropertyBinding.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},PropertyBinding.prototype.GetterByBindingType=[PropertyBinding.prototype._getValue_direct,PropertyBinding.prototype._getValue_array,PropertyBinding.prototype._getValue_arrayElement,PropertyBinding.prototype._getValue_toArray],PropertyBinding.prototype.SetterByBindingTypeAndVersioning=[[PropertyBinding.prototype._setValue_direct,PropertyBinding.prototype._setValue_direct_setNeedsUpdate,PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_array,PropertyBinding.prototype._setValue_array_setNeedsUpdate,PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_arrayElement,PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate,PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_fromArray,PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate,PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class AnimationAction{constructor(e,t,r=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=r,this.blendMode=s;const o=t.tracks,l=o.length,c=new Array(l),h={endingStart:Ye,endingEnd:Ye};for(let e=0;e!==l;++e){const t=o[e].createInterpolant(null);c[e]=t,t.settings=h}this._interpolantSettings=h,this._interpolants=c,this._propertyBindings=new Array(l),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ze,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,r){if(e.fadeOut(t),this.fadeIn(t),r){const r=this._clip.duration,s=e._clip.duration,o=s/r,l=r/s;e.warp(1,o,t),this.warp(l,1,t)}return this}crossFadeTo(e,t,r){return e.crossFadeFrom(this,t,r)}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,r){const s=this._mixer,o=s.time,l=this.timeScale;let c=this._timeScaleInterpolant;null===c&&(c=s._lendControlInterpolant(),this._timeScaleInterpolant=c);const h=c.parameterPositions,d=c.sampleValues;return h[0]=o,h[1]=o+r,d[0]=e/l,d[1]=t/l,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,r,s){if(!this.enabled)return void this._updateWeight(e);const o=this._startTime;if(null!==o){const s=(e-o)*r;s<0||0===r?t=0:(this._startTime=null,t=r*s)}t*=this._updateTimeScale(e);const l=this._updateTime(t),c=this._updateWeight(e);if(c>0){const e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let r=0,s=e.length;r!==s;++r)e[r].evaluate(l),t[r].accumulateAdditive(c);else for(let r=0,o=e.length;r!==o;++r)e[r].evaluate(l),t[r].accumulate(s,c)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;if(null!==r){const s=r.evaluate(e)[0];t*=s,e>r.parameterPositions[1]&&(this.stopFading(),0===s&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;if(null!==r){t*=r.evaluate(e)[0],e>r.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,r=this.loop;let s=this.time+e,o=this._loopCount;const l=r===We;if(0===e)return-1===o||!l||1&~o?s:t-s;if(2200===r){-1===o&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else{if(!(s<0)){this.time=s;break e}s=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===o&&(e>=0?(o=0,this._setEndings(!0,0===this.repetitions,l)):this._setEndings(0===this.repetitions,!0,l)),s>=t||s<0){const r=Math.floor(s/t);s-=t*r,o+=Math.abs(r);const c=this.repetitions-o;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===c){const t=e<0;this._setEndings(t,!t,l)}else this._setEndings(!1,!1,l);this._loopCount=o,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})}}else this.time=s;if(l&&!(1&~o))return t-s}return s}_setEndings(e,t,r){const s=this._interpolantSettings;r?(s.endingStart=Ke,s.endingEnd=Ke):(s.endingStart=e?this.zeroSlopeAtStart?Ke:Ye:Je,s.endingEnd=t?this.zeroSlopeAtEnd?Ke:Ye:Je)}_scheduleFading(e,t,r){const s=this._mixer,o=s.time;let l=this._weightInterpolant;null===l&&(l=s._lendControlInterpolant(),this._weightInterpolant=l);const c=l.parameterPositions,h=l.sampleValues;return c[0]=o,h[0]=t,c[1]=o+e,h[1]=r,this}}const ns=new Float32Array(1);class three_module_AnimationMixer extends EventDispatcher{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const r=e._localRoot||this._root,s=e._clip.tracks,o=s.length,l=e._propertyBindings,c=e._interpolants,h=r.uuid,d=this._bindingsByRootAndName;let p=d[h];void 0===p&&(p={},d[h]=p);for(let e=0;e!==o;++e){const o=s[e],d=o.name;let A=p[d];if(void 0!==A)++A.referenceCount,l[e]=A;else{if(A=l[e],void 0!==A){null===A._cacheIndex&&(++A.referenceCount,this._addInactiveBinding(A,h,d));continue}const s=t&&t._propertyBindings[e].binding.parsedPath;A=new PropertyMixer(PropertyBinding.create(r,d,s),o.ValueTypeName,o.getValueSize()),++A.referenceCount,this._addInactiveBinding(A,h,d),l[e]=A}c[e].resultBuffer=A.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,t)}const t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){const r=t[e];0==r.useCount++&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){const r=t[e];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}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<this._nActiveActions}_addInactiveAction(e,t,r){const s=this._actions,o=this._actionsByClip;let l=o[t];if(void 0===l)l={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,o[t]=l;else{const t=l.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=s.length,s.push(e),l.actionByRoot[r]=e}_removeInactiveAction(e){const t=this._actions,r=t[t.length-1],s=e._cacheIndex;r._cacheIndex=s,t[s]=r,t.pop(),e._cacheIndex=null;const o=e._clip.uuid,l=this._actionsByClip,c=l[o],h=c.knownActions,d=h[h.length-1],p=e._byClipCacheIndex;d._byClipCacheIndex=p,h[p]=d,h.pop(),e._byClipCacheIndex=null;delete c.actionByRoot[(e._localRoot||this._root).uuid],0===h.length&&delete l[o],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){const r=t[e];0==--r.referenceCount&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,r=e._cacheIndex,s=this._nActiveActions++,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_takeBackAction(e){const t=this._actions,r=e._cacheIndex,s=--this._nActiveActions,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_addInactiveBinding(e,t,r){const s=this._bindingsByRootAndName,o=this._bindings;let l=s[t];void 0===l&&(l={},s[t]=l),l[r]=e,e._cacheIndex=o.length,o.push(e)}_removeInactiveBinding(e){const t=this._bindings,r=e.binding,s=r.rootNode.uuid,o=r.path,l=this._bindingsByRootAndName,c=l[s],h=t[t.length-1],d=e._cacheIndex;h._cacheIndex=d,t[d]=h,t.pop(),delete c[o],0===Object.keys(c).length&&delete l[s]}_lendBinding(e){const t=this._bindings,r=e._cacheIndex,s=this._nActiveBindings++,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_takeBackBinding(e){const t=this._bindings,r=e._cacheIndex,s=--this._nActiveBindings,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let r=e[t];return void 0===r&&(r=new LinearInterpolant(new Float32Array(2),new Float32Array(2),1,ns),r.__cacheIndex=t,e[t]=r),r}_takeBackControlInterpolant(e){const t=this._controlInterpolants,r=e.__cacheIndex,s=--this._nActiveControlInterpolants,o=t[s];e.__cacheIndex=s,t[s]=e,o.__cacheIndex=r,t[r]=o}clipAction(e,t,r){const s=t||this._root,o=s.uuid;let l="string"==typeof e?three_module_AnimationClip.findByName(s,e):e;const c=null!==l?l.uuid:e,h=this._actionsByClip[c];let d=null;if(void 0===r&&(r=null!==l?l.blendMode:$e),void 0!==h){const e=h.actionByRoot[o];if(void 0!==e&&e.blendMode===r)return e;d=h.knownActions[0],null===l&&(l=d._clip)}if(null===l)return null;const p=new AnimationAction(this,l,t,r);return this._bindAction(p,d),this._addInactiveAction(p,c,o),p}existingAction(e,t){const r=t||this._root,s=r.uuid,o="string"==typeof e?three_module_AnimationClip.findByName(r,e):e,l=o?o.uuid:e,c=this._actionsByClip[l];return void 0!==c&&c.actionByRoot[s]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,r=this._nActiveActions,s=this.time+=e,o=Math.sign(e),l=this._accuIndex^=1;for(let c=0;c!==r;++c){t[c]._update(s,e,o,l)}const c=this._bindings,h=this._nActiveBindings;for(let e=0;e!==h;++e)c[e].apply(l);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,r=e.uuid,s=this._actionsByClip,o=s[r];if(void 0!==o){const e=o.knownActions;for(let r=0,s=e.length;r!==s;++r){const s=e[r];this._deactivateAction(s);const o=s._cacheIndex,l=t[t.length-1];s._cacheIndex=null,s._byClipCacheIndex=null,l._cacheIndex=o,t[o]=l,t.pop(),this._removeInactiveBindingsForAction(s)}delete s[r]}}uncacheRoot(e){const t=e.uuid,r=this._actionsByClip;for(const e in r){const s=r[e].actionByRoot[t];void 0!==s&&(this._deactivateAction(s),this._removeInactiveAction(s))}const s=this._bindingsByRootAndName[t];if(void 0!==s)for(const e in s){const t=s[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const r=this.existingAction(e,t);null!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}}class Uniform{constructor(e){this.value=e}clone(){return new Uniform(void 0===this.value.clone?this.value:this.value.clone())}}function ascSort(e,t){return e.distance-t.distance}function intersectObject(e,t,r,s){if(e.layers.test(t.layers)&&e.raycast(t,r),!0===s){const s=e.children;for(let e=0,o=s.length;e<o;e++)intersectObject(s[e],t,r,!0)}}class Spherical{constructor(e=1,t=0,r=0){return this.radius=e,this.phi=t,this.theta=r,this}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(clamp(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:l}})),"undefined"!=typeof window&&(window.__THREE__?o.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=l);const rs=window,ss=rs.ShadowRoot&&(void 0===rs.ShadyCSS||rs.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,as=Symbol(),os=new WeakMap;class css_tag_o{constructor(e,t,r){if(this._$cssResult$=!0,r!==as)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(ss&&void 0===e){const r=void 0!==t&&1===t.length;r&&(e=os.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&os.set(t,e))}return e}toString(){return this.cssText}}const ls=ss?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return(e=>new css_tag_o("string"==typeof e?e:e+"",void 0,as))(t)})(e):e;var cs;const hs=window,us=hs.trustedTypes,ds=us?us.emptyScript:"",ps=hs.reactiveElementPolyfillSupport,As={toAttribute(e,t){switch(t){case Boolean:e=e?ds:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(e){r=null}}return r}},a=(e,t)=>t!==e&&(t==t||e==e),ms={attribute:!0,type:String,converter:As,reflect:!1,hasChanged:a},fs="finalized";class u extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,r)=>{const s=this._$Ep(r,t);void 0!==s&&(this._$Ev.set(s,r),e.push(s))})),e}static createProperty(e,t=ms){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const r="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||ms}static finalize(){if(this.hasOwnProperty(fs))return!1;this[fs]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const r of t)this.createProperty(r,e[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const e of r)t.unshift(ls(e))}else void 0!==e&&t.push(ls(e));return t}static _$Ep(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,r;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(r=e.hostConnected)||void 0===r||r.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{ss?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const r=document.createElement("style"),s=rs.litNonce;void 0!==s&&r.setAttribute("nonce",s),r.textContent=t.cssText,e.appendChild(r)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$EO(e,t,r=ms){var s;const o=this.constructor._$Ep(e,r);if(void 0!==o&&!0===r.reflect){const l=(void 0!==(null===(s=r.converter)||void 0===s?void 0:s.toAttribute)?r.converter:As).toAttribute(t,r.type);this._$El=e,null==l?this.removeAttribute(o):this.setAttribute(o,l),this._$El=null}}_$AK(e,t){var r;const s=this.constructor,o=s._$Ev.get(e);if(void 0!==o&&this._$El!==o){const e=s.getPropertyOptions(o),l="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(r=e.converter)||void 0===r?void 0:r.fromAttribute)?e.converter:As;this._$El=o,this[o]=l.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,r){let s=!0;void 0!==e&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||a)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===r.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(r)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(r)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}var gs;u[fs]=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==ps||ps({ReactiveElement:u}),(null!==(cs=hs.reactiveElementVersions)&&void 0!==cs?cs:hs.reactiveElementVersions=[]).push("1.6.3");const _s=window,vs=_s.trustedTypes,ys=vs?vs.createPolicy("lit-html",{createHTML:e=>e}):void 0,Es="$lit$",xs=`lit$${(Math.random()+"").slice(9)}$`,Ss="?"+xs,Ms=`<${Ss}>`,Cs=document,lit_html_u=()=>Cs.createComment(""),lit_html_d=e=>null===e||"object"!=typeof e&&"function"!=typeof e,bs=Array.isArray,v=e=>bs(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]),ws="[ \t\n\f\r]",Is=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ts=/-->/g,Bs=/>/g,Rs=RegExp(`>|${ws}(?:([^\\s"'>=/]+)(${ws}*=${ws}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Ls=/'/g,Ds=/"/g,Us=/^(?:script|style|textarea|title)$/i,w=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),Ps=w(1),Fs=(w(2),Symbol.for("lit-noChange")),Ns=Symbol.for("lit-nothing"),Os=new WeakMap,Qs=Cs.createTreeWalker(Cs,129,null,!1);function P(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==ys?ys.createHTML(t):t}const V=(e,t)=>{const r=e.length-1,s=[];let o,l=2===t?"<svg>":"",c=Is;for(let t=0;t<r;t++){const r=e[t];let h,d,p=-1,A=0;for(;A<r.length&&(c.lastIndex=A,d=c.exec(r),null!==d);)A=c.lastIndex,c===Is?"!--"===d[1]?c=Ts:void 0!==d[1]?c=Bs:void 0!==d[2]?(Us.test(d[2])&&(o=RegExp("</"+d[2],"g")),c=Rs):void 0!==d[3]&&(c=Rs):c===Rs?">"===d[0]?(c=null!=o?o:Is,p=-1):void 0===d[1]?p=-2:(p=c.lastIndex-d[2].length,h=d[1],c=void 0===d[3]?Rs:'"'===d[3]?Ds:Ls):c===Ds||c===Ls?c=Rs:c===Ts||c===Bs?c=Is:(c=Rs,o=void 0);const m=c===Rs&&e[t+1].startsWith("/>")?" ":"";l+=c===Is?r+Ms:p>=0?(s.push(h),r.slice(0,p)+Es+r.slice(p)+xs+m):r+xs+(-2===p?(s.push(void 0),t):m)}return[P(e,l+(e[r]||"<?>")+(2===t?"</svg>":"")),s]};class N{constructor({strings:e,_$litType$:t},r){let s;this.parts=[];let o=0,l=0;const c=e.length-1,h=this.parts,[d,p]=V(e,t);if(this.el=N.createElement(d,r),Qs.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=Qs.nextNode())&&h.length<c;){if(1===s.nodeType){if(s.hasAttributes()){const e=[];for(const t of s.getAttributeNames())if(t.endsWith(Es)||t.startsWith(xs)){const r=p[l++];if(e.push(t),void 0!==r){const e=s.getAttribute(r.toLowerCase()+Es).split(xs),t=/([.?@])?(.*)/.exec(r);h.push({type:1,index:o,name:t[2],strings:e,ctor:"."===t[1]?H:"?"===t[1]?L:"@"===t[1]?z:k})}else h.push({type:6,index:o})}for(const t of e)s.removeAttribute(t)}if(Us.test(s.tagName)){const e=s.textContent.split(xs),t=e.length-1;if(t>0){s.textContent=vs?vs.emptyScript:"";for(let r=0;r<t;r++)s.append(e[r],lit_html_u()),Qs.nextNode(),h.push({type:2,index:++o});s.append(e[t],lit_html_u())}}}else if(8===s.nodeType)if(s.data===Ss)h.push({type:2,index:o});else{let e=-1;for(;-1!==(e=s.data.indexOf(xs,e+1));)h.push({type:7,index:o}),e+=xs.length-1}o++}}static createElement(e,t){const r=Cs.createElement("template");return r.innerHTML=e,r}}function lit_html_S(e,t,r=e,s){var o,l,c,h;if(t===Fs)return t;let d=void 0!==s?null===(o=r._$Co)||void 0===o?void 0:o[s]:r._$Cl;const p=lit_html_d(t)?void 0:t._$litDirective$;return(null==d?void 0:d.constructor)!==p&&(null===(l=null==d?void 0:d._$AO)||void 0===l||l.call(d,!1),void 0===p?d=void 0:(d=new p(e),d._$AT(e,r,s)),void 0!==s?(null!==(c=(h=r)._$Co)&&void 0!==c?c:h._$Co=[])[s]=d:r._$Cl=d),void 0!==d&&(t=lit_html_S(e,d._$AS(e,t.values),d,s)),t}class M{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:r},parts:s}=this._$AD,o=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:Cs).importNode(r,!0);Qs.currentNode=o;let l=Qs.nextNode(),c=0,h=0,d=s[0];for(;void 0!==d;){if(c===d.index){let t;2===d.type?t=new R(l,l.nextSibling,this,e):1===d.type?t=new d.ctor(l,d.name,d.strings,this,e):6===d.type&&(t=new Z(l,this,e)),this._$AV.push(t),d=s[++h]}c!==(null==d?void 0:d.index)&&(l=Qs.nextNode(),c++)}return Qs.currentNode=Cs,o}v(e){let t=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}class R{constructor(e,t,r,s){var o;this.type=2,this._$AH=Ns,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=s,this._$Cp=null===(o=null==s?void 0:s.isConnected)||void 0===o||o}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===(null==e?void 0:e.nodeType)&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=lit_html_S(this,e,t),lit_html_d(e)?e===Ns||null==e||""===e?(this._$AH!==Ns&&this._$AR(),this._$AH=Ns):e!==this._$AH&&e!==Fs&&this._(e):void 0!==e._$litType$?this.g(e):void 0!==e.nodeType?this.$(e):v(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==Ns&&lit_html_d(this._$AH)?this._$AA.nextSibling.data=e:this.$(Cs.createTextNode(e)),this._$AH=e}g(e){var t;const{values:r,_$litType$:s}=e,o="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===o)this._$AH.v(r);else{const e=new M(o,this),t=e.u(this.options);e.v(r),this.$(t),this._$AH=e}}_$AC(e){let t=Os.get(e.strings);return void 0===t&&Os.set(e.strings,t=new N(e)),t}T(e){bs(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,s=0;for(const o of e)s===t.length?t.push(r=new R(this.k(lit_html_u()),this.k(lit_html_u()),this,this.options)):r=t[s],r._$AI(o),s++;s<t.length&&(this._$AR(r&&r._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var r;for(null===(r=this._$AP)||void 0===r||r.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cp=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class k{constructor(e,t,r,s,o){this.type=1,this._$AH=Ns,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Ns}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,r,s){const o=this.strings;let l=!1;if(void 0===o)e=lit_html_S(this,e,t,0),l=!lit_html_d(e)||e!==this._$AH&&e!==Fs,l&&(this._$AH=e);else{const s=e;let c,h;for(e=o[0],c=0;c<o.length-1;c++)h=lit_html_S(this,s[r+c],t,c),h===Fs&&(h=this._$AH[c]),l||(l=!lit_html_d(h)||h!==this._$AH[c]),h===Ns?e=Ns:e!==Ns&&(e+=(null!=h?h:"")+o[c+1]),this._$AH[c]=h}l&&!s&&this.j(e)}j(e){e===Ns?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class H extends k{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ns?void 0:e}}const ks=vs?vs.emptyScript:"";class L extends k{constructor(){super(...arguments),this.type=4}j(e){e&&e!==Ns?this.element.setAttribute(this.name,ks):this.element.removeAttribute(this.name)}}class z extends k{constructor(e,t,r,s,o){super(e,t,r,s,o),this.type=5}_$AI(e,t=this){var r;if((e=null!==(r=lit_html_S(this,e,t,0))&&void 0!==r?r:Ns)===Fs)return;const s=this._$AH,o=e===Ns&&s!==Ns||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,l=e!==Ns&&(s===Ns||o);o&&this.element.removeEventListener(this.name,this,s),l&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,r;"function"==typeof this._$AH?this._$AH.call(null!==(r=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==r?r:this.element,e):this._$AH.handleEvent(e)}}class Z{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){lit_html_S(this,e)}}const Gs=_s.litHtmlPolyfillSupport;null==Gs||Gs(N,R),(null!==(gs=_s.litHtmlVersions)&&void 0!==gs?gs:_s.litHtmlVersions=[]).push("2.8.0");const D=(e,t,r)=>{var s,o;const l=null!==(s=null==r?void 0:r.renderBefore)&&void 0!==s?s:t;let c=l._$litPart$;if(void 0===c){const e=null!==(o=null==r?void 0:r.renderBefore)&&void 0!==o?o:null;l._$litPart$=c=new R(t.insertBefore(lit_html_u(),e),e,void 0,null!=r?r:{})}return c._$AI(e),c},Vs=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Hs=Symbol(),zs=new Map;class css_tag_s{constructor(e,t){if(this._$cssResult$=!0,t!==Hs)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){let e=zs.get(this.cssText);return Vs&&void 0===e&&(zs.set(this.cssText,e=new CSSStyleSheet),e.replaceSync(this.cssText)),e}toString(){return this.cssText}}const Ws=Vs?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return(e=>new css_tag_s("string"==typeof e?e:e+"",Hs))(t)})(e):e;var qs;const js=window.trustedTypes,Xs=js?js.emptyScript:"",Ys=window.reactiveElementPolyfillSupport,Ks={toAttribute(e,t){switch(t){case Boolean:e=e?Xs:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(e){r=null}}return r}},reactive_element_reactive_element_n=(e,t)=>t!==e&&(t==t||e==e),Js={attribute:!0,type:String,converter:Ks,reflect:!1,hasChanged:reactive_element_reactive_element_n};class reactive_element_a extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(e){var t;null!==(t=this.l)&&void 0!==t||(this.l=[]),this.l.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,r)=>{const s=this._$Eh(r,t);void 0!==s&&(this._$Eu.set(s,r),e.push(s))})),e}static createProperty(e,t=Js){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const r="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Js}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const r of t)this.createProperty(r,e[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const e of r)t.unshift(Ws(e))}else void 0!==e&&t.push(Ws(e));return t}static _$Eh(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}o(){var e;this._$Ep=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(e=this.constructor.l)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,r;(null!==(t=this._$Eg)&&void 0!==t?t:this._$Eg=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(r=e.hostConnected)||void 0===r||r.call(e))}removeController(e){var t;null===(t=this._$Eg)||void 0===t||t.splice(this._$Eg.indexOf(e)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Et.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{Vs?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const r=document.createElement("style"),s=window.litNonce;void 0!==s&&r.setAttribute("nonce",s),r.textContent=t.cssText,e.appendChild(r)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ES(e,t,r=Js){var s,o;const l=this.constructor._$Eh(e,r);if(void 0!==l&&!0===r.reflect){const c=(null!==(o=null===(s=r.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==o?o:Ks.toAttribute)(t,r.type);this._$Ei=e,null==c?this.removeAttribute(l):this.setAttribute(l,c),this._$Ei=null}}_$AK(e,t){var r,s,o;const l=this.constructor,c=l._$Eu.get(e);if(void 0!==c&&this._$Ei!==c){const e=l.getPropertyOptions(c),h=e.converter,d=null!==(o=null!==(s=null===(r=h)||void 0===r?void 0:r.fromAttribute)&&void 0!==s?s:"function"==typeof h?h:null)&&void 0!==o?o:Ks.fromAttribute;this._$Ei=c,this[c]=d(t,e.type),this._$Ei=null}}requestUpdate(e,t,r){let s=!0;void 0!==e&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||reactive_element_reactive_element_n)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===r.reflect&&this._$Ei!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((e,t)=>this[t]=e)),this._$Et=void 0);let t=!1;const r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(r)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(r)}willUpdate(e){}_$AE(e){var t;null===(t=this._$Eg)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$ES(t,this[t],e))),this._$EC=void 0),this._$EU()}updated(e){}firstUpdated(e){}}var $s,Zs;reactive_element_a.finalized=!0,reactive_element_a.elementProperties=new Map,reactive_element_a.elementStyles=[],reactive_element_a.shadowRootOptions={mode:"open"},null==Ys||Ys({ReactiveElement:reactive_element_a}),(null!==(qs=globalThis.reactiveElementVersions)&&void 0!==qs?qs:globalThis.reactiveElementVersions=[]).push("1.3.2");class lit_element_s extends reactive_element_a{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const r=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=r.firstChild),r}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=D(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return Fs}}lit_element_s.finalized=!0,lit_element_s._$litElement$=!0,null===($s=globalThis.litElementHydrateSupport)||void 0===$s||$s.call(globalThis,{LitElement:lit_element_s});const ea=globalThis.litElementPolyfillSupport;null==ea||ea({LitElement:lit_element_s});(null!==(Zs=globalThis.litElementVersions)&&void 0!==Zs?Zs:globalThis.litElementVersions=[]).push("3.3.3");const ta=null!=navigator.xr&&null!=self.XRSession&&null!=navigator.xr.isSessionSupported,ia=ta&&null!=self.XRSession.prototype.requestHitTestSource,na=null!=self.ResizeObserver,ra=null!=self.IntersectionObserver,sa=ia,aa=((()=>{const e=navigator.userAgent||navigator.vendor||self.opera;let t=!1;(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=!0)})(),/\bCrOS\b/.test(navigator.userAgent),/android/i.test(navigator.userAgent)),oa=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,la=(/Safari\//.test(navigator.userAgent),/firefox/i.test(navigator.userAgent)),ca=/OculusBrowser/.test(navigator.userAgent),ha=(oa&&/CriOS\//.test(navigator.userAgent),aa&&!la&&!ca),ua=Boolean(window.webkit&&window.webkit.messageHandlers),da=(()=>{if(oa){if(ua)return Boolean(/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent));{const e=document.createElement("a");return Boolean(e.relList&&e.relList.supports&&e.relList.supports("ar"))}}return!1})();var pa=r(6763);const deserializeUrl=e=>e&&"null"!==e?toFullUrl(e):null,assertIsArCandidate=()=>{if(sa)return;const e=[];throw ta||e.push("WebXR Device API"),ia||e.push("WebXR Hit Test API"),new Error(`The following APIs are required for AR, but are missing in this browser: ${e.join(", ")}`)},toFullUrl=e=>new URL(e,window.location.toString()).toString(),debounce=(e,t)=>{let r=null;return(...s)=>{null!=r&&self.clearTimeout(r),r=self.setTimeout((()=>{r=null,e(...s)}),t)}},utilities_clamp=(e,t,r)=>Math.max(t,Math.min(r,e)),Aa=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||pa.warn('No <meta name="viewport"> detected; <model-viewer> will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})(),ma=(()=>{const e=new RegExp("[?&]model-viewer-debug-mode(&|$)");return()=>self.ModelViewerElement&&self.ModelViewerElement.debugMode||self.location&&self.location.search&&self.location.search.match(e)})();var __decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const fa=Symbol("currentEnvironmentMap"),ga=Symbol("currentBackground"),_a=Symbol("updateEnvironment"),va=Symbol("cancelEnvironmentUpdate"),ya=Ps`
2
+ (self.webpackChunkCrystaldesignProductDetailPage=self.webpackChunkCrystaldesignProductDetailPage||[]).push([[599],{7526:(e,t)=>{"use strict";t.byteLength=function byteLength(e){var t=getLens(e),r=t[0],s=t[1];return 3*(r+s)/4-s},t.toByteArray=function toByteArray(e){var t,r,l=getLens(e),c=l[0],h=l[1],d=new o(function _byteLength(e,t,r){return 3*(t+r)/4-r}(0,c,h)),p=0,A=h>0?c-4:c;for(r=0;r<A;r+=4)t=s[e.charCodeAt(r)]<<18|s[e.charCodeAt(r+1)]<<12|s[e.charCodeAt(r+2)]<<6|s[e.charCodeAt(r+3)],d[p++]=t>>16&255,d[p++]=t>>8&255,d[p++]=255&t;2===h&&(t=s[e.charCodeAt(r)]<<2|s[e.charCodeAt(r+1)]>>4,d[p++]=255&t);1===h&&(t=s[e.charCodeAt(r)]<<10|s[e.charCodeAt(r+1)]<<4|s[e.charCodeAt(r+2)]>>2,d[p++]=t>>8&255,d[p++]=255&t);return d},t.fromByteArray=function fromByteArray(e){for(var t,s=e.length,o=s%3,l=[],c=16383,h=0,d=s-o;h<d;h+=c)l.push(encodeChunk(e,h,h+c>d?d:h+c));1===o?(t=e[s-1],l.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[s-2]<<8)+e[s-1],l.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return l.join("")};for(var r=[],s=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0;c<64;++c)r[c]=l[c],s[l.charCodeAt(c)]=c;function getLens(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function encodeChunk(e,t,s){for(var o,l,c=[],h=t;h<s;h+=3)o=(e[h]<<16&16711680)+(e[h+1]<<8&65280)+(255&e[h+2]),c.push(r[(l=o)>>18&63]+r[l>>12&63]+r[l>>6&63]+r[63&l]);return c.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},8287:(e,t,r)=>{"use strict";var s=r(6763);const o=r(7526),l=r(251),c="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=Buffer,t.IS=50;const h=2147483647;function createBuffer(e){if(e>h)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"==typeof e)return function fromString(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|byteLength(e,t);let s=createBuffer(r);const o=s.write(e,t);o!==r&&(s=s.slice(0,o));return s}(e,t);if(ArrayBuffer.isView(e))return function fromArrayView(e){if(isInstance(e,Uint8Array)){const t=new Uint8Array(e);return fromArrayBuffer(t.buffer,t.byteOffset,t.byteLength)}return fromArrayLike(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const s=e.valueOf&&e.valueOf();if(null!=s&&s!==e)return Buffer.from(s,t,r);const o=function fromObject(e){if(Buffer.isBuffer(e)){const t=0|checked(e.length),r=createBuffer(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||numberIsNaN(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromArrayLike(e){const t=e.length<0?0:0|checked(e.length),r=createBuffer(t);for(let s=0;s<t;s+=1)r[s]=255&e[s];return r}function fromArrayBuffer(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let s;return s=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(s,Buffer.prototype),s}function checked(e){if(e>=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return 0|e}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,s=arguments.length>2&&!0===arguments[2];if(!s&&0===r)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(o)return s?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),o=!0}}function slowToString(e,t,r){let s=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function swap(e,t,r){const s=e[t];e[t]=e[r],e[r]=s}function bidirectionalIndexOf(e,t,r,s,o){if(0===e.length)return-1;if("string"==typeof r?(s=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,s)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,s,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,s,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,s,o){let l,c=1,h=e.length,d=t.length;if(void 0!==s&&("ucs2"===(s=String(s).toLowerCase())||"ucs-2"===s||"utf16le"===s||"utf-16le"===s)){if(e.length<2||t.length<2)return-1;c=2,h/=2,d/=2,r/=2}function read(e,t){return 1===c?e[t]:e.readUInt16BE(t*c)}if(o){let s=-1;for(l=r;l<h;l++)if(read(e,l)===read(t,-1===s?0:l-s)){if(-1===s&&(s=l),l-s+1===d)return s*c}else-1!==s&&(l-=l-s),s=-1}else for(r+d>h&&(r=h-d),l=r;l>=0;l--){let r=!0;for(let s=0;s<d;s++)if(read(e,l+s)!==read(t,s)){r=!1;break}if(r)return l}return-1}function hexWrite(e,t,r,s){r=Number(r)||0;const o=e.length-r;s?(s=Number(s))>o&&(s=o):s=o;const l=t.length;let c;for(s>l/2&&(s=l/2),c=0;c<s;++c){const s=parseInt(t.substr(2*c,2),16);if(numberIsNaN(s))return c;e[r+c]=s}return c}function utf8Write(e,t,r,s){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,s)}function asciiWrite(e,t,r,s){return blitBuffer(function asciiToBytes(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,s)}function base64Write(e,t,r,s){return blitBuffer(base64ToBytes(t),e,r,s)}function ucs2Write(e,t,r,s){return blitBuffer(function utf16leToBytes(e,t){let r,s,o;const l=[];for(let c=0;c<e.length&&!((t-=2)<0);++c)r=e.charCodeAt(c),s=r>>8,o=r%256,l.push(o),l.push(s);return l}(t,e.length-r),e,r,s)}function base64Slice(e,t,r){return 0===t&&r===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(t,r))}function utf8Slice(e,t,r){r=Math.min(e.length,r);const s=[];let o=t;for(;o<r;){const t=e[o];let l=null,c=t>239?4:t>223?3:t>191?2:1;if(o+c<=r){let r,s,h,d;switch(c){case 1:t<128&&(l=t);break;case 2:r=e[o+1],128==(192&r)&&(d=(31&t)<<6|63&r,d>127&&(l=d));break;case 3:r=e[o+1],s=e[o+2],128==(192&r)&&128==(192&s)&&(d=(15&t)<<12|(63&r)<<6|63&s,d>2047&&(d<55296||d>57343)&&(l=d));break;case 4:r=e[o+1],s=e[o+2],h=e[o+3],128==(192&r)&&128==(192&s)&&128==(192&h)&&(d=(15&t)<<18|(63&r)<<12|(63&s)<<6|63&h,d>65535&&d<1114112&&(l=d))}}null===l?(l=65533,c=1):l>65535&&(l-=65536,s.push(l>>>10&1023|55296),l=56320|1023&l),s.push(l),o+=c}return function decodeCodePointsArray(e){const t=e.length;if(t<=d)return String.fromCharCode.apply(String,e);let r="",s=0;for(;s<t;)r+=String.fromCharCode.apply(String,e.slice(s,s+=d));return r}(s)}Buffer.TYPED_ARRAY_SUPPORT=function typedArraySupport(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),Buffer.TYPED_ARRAY_SUPPORT||void 0===s||"function"!=typeof s.error||s.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(e,t,r){return function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function isBuffer(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function compare(e,t){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,s=t.length;for(let o=0,l=Math.min(r,s);o<l;++o)if(e[o]!==t[o]){r=e[o],s=t[o];break}return r<s?-1:s<r?1:0},Buffer.isEncoding=function isEncoding(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function concat(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Buffer.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const s=Buffer.allocUnsafe(t);let o=0;for(r=0;r<e.length;++r){let t=e[r];if(isInstance(t,Uint8Array))o+t.length>s.length?(Buffer.isBuffer(t)||(t=Buffer.from(t)),t.copy(s,o)):Uint8Array.prototype.set.call(s,t,o);else{if(!Buffer.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(s,o)}o+=t.length}return s},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)swap(this,t,t+1);return this},Buffer.prototype.swap32=function swap32(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)swap(this,t,t+3),swap(this,t+1,t+2);return this},Buffer.prototype.swap64=function swap64(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)swap(this,t,t+7),swap(this,t+1,t+6),swap(this,t+2,t+5),swap(this,t+3,t+4);return this},Buffer.prototype.toString=function toString(){const e=this.length;return 0===e?"":0===arguments.length?utf8Slice(this,0,e):slowToString.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function equals(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function inspect(){let e="";const r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},c&&(Buffer.prototype[c]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(e,t,r,s,o){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===s&&(s=0),void 0===o&&(o=this.length),t<0||r>e.length||s<0||o>this.length)throw new RangeError("out of range index");if(s>=o&&t>=r)return 0;if(s>=o)return-1;if(t>=r)return 1;if(this===e)return 0;let l=(o>>>=0)-(s>>>=0),c=(r>>>=0)-(t>>>=0);const h=Math.min(l,c),d=this.slice(s,o),p=e.slice(t,r);for(let e=0;e<h;++e)if(d[e]!==p[e]){l=d[e],c=p[e];break}return l<c?-1:c<l?1:0},Buffer.prototype.includes=function includes(e,t,r){return-1!==this.indexOf(e,t,r)},Buffer.prototype.indexOf=function indexOf(e,t,r){return bidirectionalIndexOf(this,e,t,r,!0)},Buffer.prototype.lastIndexOf=function lastIndexOf(e,t,r){return bidirectionalIndexOf(this,e,t,r,!1)},Buffer.prototype.write=function write(e,t,r,s){if(void 0===t)s="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)s=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===s&&(s="utf8")):(s=r,r=void 0)}const o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let l=!1;for(;;)switch(s){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":case"latin1":case"binary":return asciiWrite(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(l)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),l=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const d=4096;function asciiSlice(e,t,r){let s="";r=Math.min(e.length,r);for(let o=t;o<r;++o)s+=String.fromCharCode(127&e[o]);return s}function latin1Slice(e,t,r){let s="";r=Math.min(e.length,r);for(let o=t;o<r;++o)s+=String.fromCharCode(e[o]);return s}function hexSlice(e,t,r){const s=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>s)&&(r=s);let o="";for(let s=t;s<r;++s)o+=m[e[s]];return o}function utf16leSlice(e,t,r){const s=e.slice(t,r);let o="";for(let e=0;e<s.length-1;e+=2)o+=String.fromCharCode(s[e]+256*s[e+1]);return o}function checkOffset(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,s,o,l){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<l)throw new RangeError('"value" argument is out of bounds');if(r+s>e.length)throw new RangeError("Index out of range")}function wrtBigUInt64LE(e,t,r,s,o){checkIntBI(t,s,o,e,r,7);let l=Number(t&BigInt(4294967295));e[r++]=l,l>>=8,e[r++]=l,l>>=8,e[r++]=l,l>>=8,e[r++]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=c,c>>=8,e[r++]=c,c>>=8,e[r++]=c,c>>=8,e[r++]=c,r}function wrtBigUInt64BE(e,t,r,s,o){checkIntBI(t,s,o,e,r,7);let l=Number(t&BigInt(4294967295));e[r+7]=l,l>>=8,e[r+6]=l,l>>=8,e[r+5]=l,l>>=8,e[r+4]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=c,c>>=8,e[r+2]=c,c>>=8,e[r+1]=c,c>>=8,e[r]=c,r+8}function checkIEEE754(e,t,r,s,o,l){if(r+s>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,s,o){return t=+t,r>>>=0,o||checkIEEE754(e,0,r,4),l.write(e,t,r,s,23,4),r+4}function writeDouble(e,t,r,s,o){return t=+t,r>>>=0,o||checkIEEE754(e,0,r,8),l.write(e,t,r,s,52,8),r+8}Buffer.prototype.slice=function slice(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const s=this.subarray(e,t);return Object.setPrototypeOf(s,Buffer.prototype),s},Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function readUIntLE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=this[e],o=1,l=0;for(;++l<t&&(o*=256);)s+=this[e+l]*o;return s},Buffer.prototype.readUintBE=Buffer.prototype.readUIntBE=function readUIntBE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=this[e+--t],o=1;for(;t>0&&(o*=256);)s+=this[e+--t]*o;return s},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readBigUInt64LE=defineBigIntMethod((function readBigUInt64LE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(s)+(BigInt(o)<<BigInt(32))})),Buffer.prototype.readBigUInt64BE=defineBigIntMethod((function readBigUInt64BE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(s)<<BigInt(32))+BigInt(o)})),Buffer.prototype.readIntLE=function readIntLE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=this[e],o=1,l=0;for(;++l<t&&(o*=256);)s+=this[e+l]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s},Buffer.prototype.readIntBE=function readIntBE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);let s=t,o=1,l=this[e+--s];for(;s>0&&(o*=256);)l+=this[e+--s]*o;return o*=128,l>=o&&(l-=Math.pow(2,8*t)),l},Buffer.prototype.readInt8=function readInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){e>>>=0,t||checkOffset(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function readInt16BE(e,t){e>>>=0,t||checkOffset(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readBigInt64LE=defineBigIntMethod((function readBigInt64LE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(s)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),Buffer.prototype.readBigInt64BE=defineBigIntMethod((function readBigInt64BE(e){validateNumber(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||boundsError(e,this.length-8);const s=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(s)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),Buffer.prototype.readFloatLE=function readFloatLE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),l.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),l.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),l.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),l.read(this,e,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,r,s){if(e=+e,t>>>=0,r>>>=0,!s){checkInt(this,e,t,r,Math.pow(2,8*r)-1,0)}let o=1,l=0;for(this[t]=255&e;++l<r&&(o*=256);)this[t+l]=e/o&255;return t+r},Buffer.prototype.writeUintBE=Buffer.prototype.writeUIntBE=function writeUIntBE(e,t,r,s){if(e=+e,t>>>=0,r>>>=0,!s){checkInt(this,e,t,r,Math.pow(2,8*r)-1,0)}let o=r-1,l=1;for(this[t+o]=255&e;--o>=0&&(l*=256);)this[t+o]=e/l&255;return t+r},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeBigUInt64LE=defineBigIntMethod((function writeBigUInt64LE(e,t=0){return wrtBigUInt64LE(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeBigUInt64BE=defineBigIntMethod((function writeBigUInt64BE(e,t=0){return wrtBigUInt64BE(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeIntLE=function writeIntLE(e,t,r,s){if(e=+e,t>>>=0,!s){const s=Math.pow(2,8*r-1);checkInt(this,e,t,r,s-1,-s)}let o=0,l=1,c=0;for(this[t]=255&e;++o<r&&(l*=256);)e<0&&0===c&&0!==this[t+o-1]&&(c=1),this[t+o]=(e/l|0)-c&255;return t+r},Buffer.prototype.writeIntBE=function writeIntBE(e,t,r,s){if(e=+e,t>>>=0,!s){const s=Math.pow(2,8*r-1);checkInt(this,e,t,r,s-1,-s)}let o=r-1,l=1,c=0;for(this[t+o]=255&e;--o>=0&&(l*=256);)e<0&&0===c&&0!==this[t+o+1]&&(c=1),this[t+o]=(e/l|0)-c&255;return t+r},Buffer.prototype.writeInt8=function writeInt8(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeBigInt64LE=defineBigIntMethod((function writeBigInt64LE(e,t=0){return wrtBigUInt64LE(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeBigInt64BE=defineBigIntMethod((function writeBigInt64BE(e,t=0){return wrtBigUInt64BE(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function copy(e,t,r,s){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),s||0===s||(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<r&&(s=r),s===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-r&&(s=e.length-t+r);const o=s-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,s):Uint8Array.prototype.set.call(e,this.subarray(r,s),t),o},Buffer.prototype.fill=function fill(e,t,r,s){if("string"==typeof e){if("string"==typeof t?(s=t,t=0,r=this.length):"string"==typeof r&&(s=r,r=this.length),void 0!==s&&"string"!=typeof s)throw new TypeError("encoding must be a string");if("string"==typeof s&&!Buffer.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(1===e.length){const t=e.charCodeAt(0);("utf8"===s&&t<128||"latin1"===s)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{const l=Buffer.isBuffer(e)?e:Buffer.from(e,s),c=l.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=l[o%c]}return this};const p={};function E(e,t,r){p[e]=class NodeError extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function addNumericalSeparator(e){let t="",r=e.length;const s="-"===e[0]?1:0;for(;r>=s+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function checkIntBI(e,t,r,s,o,l){if(e>r||e<t){const s="bigint"==typeof t?"n":"";let o;throw o=l>3?0===t||t===BigInt(0)?`>= 0${s} and < 2${s} ** ${8*(l+1)}${s}`:`>= -(2${s} ** ${8*(l+1)-1}${s}) and < 2 ** ${8*(l+1)-1}${s}`:`>= ${t}${s} and <= ${r}${s}`,new p.ERR_OUT_OF_RANGE("value",o,e)}!function checkBounds(e,t,r){validateNumber(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||boundsError(t,e.length-(r+1))}(s,o,l)}function validateNumber(e,t){if("number"!=typeof e)throw new p.ERR_INVALID_ARG_TYPE(t,"number",e)}function boundsError(e,t,r){if(Math.floor(e)!==e)throw validateNumber(e,r),new p.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new p.ERR_BUFFER_OUT_OF_BOUNDS;throw new p.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}E("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),E("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),E("ERR_OUT_OF_RANGE",(function(e,t,r){let s=`The value of "${e}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=addNumericalSeparator(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=addNumericalSeparator(o)),o+="n"),s+=` It must be ${t}. Received ${o}`,s}),RangeError);const A=/[^+/0-9A-Za-z-_]/g;function utf8ToBytes(e,t){let r;t=t||1/0;const s=e.length;let o=null;const l=[];for(let c=0;c<s;++c){if(r=e.charCodeAt(c),r>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&l.push(239,191,189);continue}if(c+1===s){(t-=3)>-1&&l.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&l.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&l.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;l.push(r)}else if(r<2048){if((t-=2)<0)break;l.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;l.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;l.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return l}function base64ToBytes(e){return o.toByteArray(function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(A,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function blitBuffer(e,t,r,s){let o;for(o=0;o<s&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e}const m=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const s=16*r;for(let o=0;o<16;++o)t[s+o]=e[r]+e[o]}return t}();function defineBigIntMethod(e){return"undefined"==typeof BigInt?BufferBigIntNotDefined:e}function BufferBigIntNotDefined(){throw new Error("BigInt not supported")}},251:(e,t)=>{t.read=function(e,t,r,s,o){var l,c,h=8*o-s-1,d=(1<<h)-1,p=d>>1,A=-7,m=r?o-1:0,f=r?-1:1,g=e[t+m];for(m+=f,l=g&(1<<-A)-1,g>>=-A,A+=h;A>0;l=256*l+e[t+m],m+=f,A-=8);for(c=l&(1<<-A)-1,l>>=-A,A+=s;A>0;c=256*c+e[t+m],m+=f,A-=8);if(0===l)l=1-p;else{if(l===d)return c?NaN:1/0*(g?-1:1);c+=Math.pow(2,s),l-=p}return(g?-1:1)*c*Math.pow(2,l-s)},t.write=function(e,t,r,s,o,l){var c,h,d,p=8*l-o-1,A=(1<<p)-1,m=A>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,g=s?0:l-1,_=s?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(h=isNaN(t)?1:0,c=A):(c=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-c))<1&&(c--,d*=2),(t+=c+m>=1?f/d:f*Math.pow(2,1-m))*d>=2&&(c++,d/=2),c+m>=A?(h=0,c=A):c+m>=1?(h=(t*d-1)*Math.pow(2,o),c+=m):(h=t*Math.pow(2,m-1)*Math.pow(2,o),c=0));o>=8;e[r+g]=255&h,g+=_,h/=256,o-=8);for(c=c<<o|h,p+=o;p>0;e[r+g]=255&c,g+=_,c/=256,p-=8);e[r+g-_]|=128*y}},7599:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CanvasTexture:()=>CanvasTexture,FileLoader:()=>three_module_FileLoader,Loader:()=>Loader,ModelViewerElement:()=>RA,NearestFilter:()=>te});const i=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(r){r.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(r){r.createProperty(t.key,e)}};function n(e){return(t,r)=>void 0!==r?((e,t,r)=>{t.constructor.createProperty(r,e)})(e,t,r):i(e,t)}var s;null===(s=window.HTMLSlotElement)||void 0===s||s.prototype.assignedElements;var o=r(6763);const l="160",c=0,h=1,d=2,p=100,A=101,m=102,f=200,g=201,_=202,y=203,x=204,S=205,C=206,b=207,I=208,T=209,B=210,U=211,F=212,O=213,Q=214,G="attached",W=300,q=301,j=302,X=303,Y=304,K=306,J=1e3,$=1001,ee=1002,te=1003,ie=1004,ne=1005,re=1006,se=1007,ae=1008,oe=1009,le=1012,ce=1013,he=1014,ue=1015,de=1016,pe=1020,Ae=1023,me=1026,fe=1027,ge=1028,_e=1030,ve=33776,ye=33777,Ee=33778,xe=33779,Se=35840,Me=35842,Ce=36196,be=37492,we=37496,Ie=37808,Te=37812,Be=36492,Re=2201,Le=2202,De=2300,Ue=2301,Pe=2302,Fe=2400,Ne=2401,Oe=2402,Qe=2500,ke=3001,Ge="",Ve="srgb",He="srgb-linear",ze="display-p3",We="display-p3-linear",qe="linear",je="srgb",Xe="rec709",Ye="p3",Ke=7680,Je=512,$e=513,Ze=514,et=515,tt=516,it=517,nt=518,rt=519,st=35044,at="300 es",ot=1035,lt=2e3,ct=2001;class EventDispatcher{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const r=this._listeners;return void 0!==r[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const r=this._listeners[e];if(void 0!==r){const e=r.indexOf(t);-1!==e&&r.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 r=t.slice(0);for(let t=0,s=r.length;t<s;t++)r[t].call(this,e);e.target=null}}}const ht=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let ut=1234567;const dt=Math.PI/180,pt=180/Math.PI;function generateUUID(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return(ht[255&e]+ht[e>>8&255]+ht[e>>16&255]+ht[e>>24&255]+"-"+ht[255&t]+ht[t>>8&255]+"-"+ht[t>>16&15|64]+ht[t>>24&255]+"-"+ht[63&r|128]+ht[r>>8&255]+"-"+ht[r>>16&255]+ht[r>>24&255]+ht[255&s]+ht[s>>8&255]+ht[s>>16&255]+ht[s>>24&255]).toLowerCase()}function clamp(e,t,r){return Math.max(t,Math.min(r,e))}function euclideanModulo(e,t){return(e%t+t)%t}function lerp(e,t,r){return(1-r)*e+r*t}function isPowerOfTwo(e){return!(e&e-1)&&0!==e}function floorPowerOfTwo(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function denormalize(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 normalize(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 At={DEG2RAD:dt,RAD2DEG:pt,generateUUID,clamp,euclideanModulo,mapLinear:function mapLinear(e,t,r,s,o){return s+(e-t)*(o-s)/(r-t)},inverseLerp:function inverseLerp(e,t,r){return e!==t?(r-e)/(t-e):0},lerp,damp:function damp(e,t,r,s){return lerp(e,t,1-Math.exp(-r*s))},pingpong:function pingpong(e,t=1){return t-Math.abs(euclideanModulo(e,2*t)-t)},smoothstep:function smoothstep(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function smootherstep(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function randInt(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function randFloat(e,t){return e+Math.random()*(t-e)},randFloatSpread:function randFloatSpread(e){return e*(.5-Math.random())},seededRandom:function seededRandom(e){void 0!==e&&(ut=e);let t=ut+=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 degToRad(e){return e*dt},radToDeg:function radToDeg(e){return e*pt},isPowerOfTwo,ceilPowerOfTwo:function ceilPowerOfTwo(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo,setQuaternionFromProperEuler:function setQuaternionFromProperEuler(e,t,r,s,l){const c=Math.cos,h=Math.sin,d=c(r/2),p=h(r/2),A=c((t+s)/2),m=h((t+s)/2),f=c((t-s)/2),g=h((t-s)/2),_=c((s-t)/2),y=h((s-t)/2);switch(l){case"XYX":e.set(d*m,p*f,p*g,d*A);break;case"YZY":e.set(p*g,d*m,p*f,d*A);break;case"ZXZ":e.set(p*f,p*g,d*m,d*A);break;case"XZX":e.set(d*m,p*y,p*_,d*A);break;case"YXY":e.set(p*_,d*m,p*y,d*A);break;case"ZYZ":e.set(p*y,p*_,d*m,d*A);break;default:o.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+l)}},normalize,denormalize};class Vector2{constructor(e=0,t=0){Vector2.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,r=this.y,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6],this.y=s[1]*t+s[4]*r+s[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 r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=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 r=this.dot(e)/t;return Math.acos(clamp(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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 r=Math.cos(t),s=Math.sin(t),o=this.x-e.x,l=this.y-e.y;return this.x=o*r-l*s+e.x,this.y=o*s+l*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Matrix3{constructor(e,t,r,s,o,l,c,h,d){Matrix3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,r,s,o,l,c,h,d)}set(e,t,r,s,o,l,c,h,d){const p=this.elements;return p[0]=e,p[1]=s,p[2]=c,p[3]=t,p[4]=o,p[5]=h,p[6]=r,p[7]=l,p[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.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 r=e.elements,s=t.elements,o=this.elements,l=r[0],c=r[3],h=r[6],d=r[1],p=r[4],A=r[7],m=r[2],f=r[5],g=r[8],_=s[0],y=s[3],x=s[6],S=s[1],C=s[4],b=s[7],I=s[2],T=s[5],B=s[8];return o[0]=l*_+c*S+h*I,o[3]=l*y+c*C+h*T,o[6]=l*x+c*b+h*B,o[1]=d*_+p*S+A*I,o[4]=d*y+p*C+A*T,o[7]=d*x+p*b+A*B,o[2]=m*_+f*S+g*I,o[5]=m*y+f*C+g*T,o[8]=m*x+f*b+g*B,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],r=e[1],s=e[2],o=e[3],l=e[4],c=e[5],h=e[6],d=e[7],p=e[8];return t*l*p-t*c*d-r*o*p+r*c*h+s*o*d-s*l*h}invert(){const e=this.elements,t=e[0],r=e[1],s=e[2],o=e[3],l=e[4],c=e[5],h=e[6],d=e[7],p=e[8],A=p*l-c*d,m=c*h-p*o,f=d*o-l*h,g=t*A+r*m+s*f;if(0===g)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=A*_,e[1]=(s*d-p*r)*_,e[2]=(c*r-s*l)*_,e[3]=m*_,e[4]=(p*t-s*h)*_,e[5]=(s*o-c*t)*_,e[6]=f*_,e[7]=(r*h-d*t)*_,e[8]=(l*t-r*o)*_,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,r,s,o,l,c){const h=Math.cos(o),d=Math.sin(o);return this.set(r*h,r*d,-r*(h*l+d*c)+l+e,-s*d,s*h,-s*(-d*l+h*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(mt.makeScale(e,t)),this}rotate(e){return this.premultiply(mt.makeRotation(-e)),this}translate(e,t){return this.premultiply(mt.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),r=Math.sin(e);return this.set(t,-r,0,r,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,r=e.elements;for(let e=0;e<9;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const mt=new Matrix3;function arrayNeedsUint32(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function createCanvasElement(){const e=createElementNS("canvas");return e.style.display="block",e}const ft={};function warnOnce(e){e in ft||(ft[e]=!0,o.warn(e))}const gt=(new Matrix3).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),_t=(new Matrix3).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),vt={[He]:{transfer:qe,primaries:Xe,toReference:e=>e,fromReference:e=>e},[Ve]:{transfer:je,primaries:Xe,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[We]:{transfer:qe,primaries:Ye,toReference:e=>e.applyMatrix3(_t),fromReference:e=>e.applyMatrix3(gt)},[ze]:{transfer:je,primaries:Ye,toReference:e=>e.convertSRGBToLinear().applyMatrix3(_t),fromReference:e=>e.applyMatrix3(gt).convertLinearToSRGB()}},yt=new Set([He,We]),Et={enabled:!0,_workingColorSpace:He,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!yt.has(e))throw new Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,r){if(!1===this.enabled||t===r||!t||!r)return e;const s=vt[t].toReference;return(0,vt[r].fromReference)(s(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return vt[e].primaries},getTransfer:function(e){return e===Ge?qe:vt[e].transfer}};function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function LinearToSRGB(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let xt;class ImageUtils{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===xt&&(xt=createElementNS("canvas")),xt.width=e.width,xt.height=e.height;const r=xt.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=xt}return t.width>2048||t.height>2048?(o.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=createElementNS("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const s=r.getImageData(0,0,e.width,e.height),o=s.data;for(let e=0;e<o.length;e++)o[e]=255*SRGBToLinear(o[e]/255);return r.putImageData(s,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*SRGBToLinear(t[e]/255)):t[e]=SRGBToLinear(t[e]);return{data:t,width:e.width,height:e.height}}return o.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let St=0;class Source{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:St++}),this.uuid=generateUUID(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const r={uuid:this.uuid,url:""},s=this.data;if(null!==s){let e;if(Array.isArray(s)){e=[];for(let t=0,r=s.length;t<r;t++)s[t].isDataTexture?e.push(serializeImage(s[t].image)):e.push(serializeImage(s[t]))}else e=serializeImage(s);r.url=e}return t||(e.images[this.uuid]=r),r}}function serializeImage(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ImageUtils.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(o.warn("THREE.Texture: Unable to serialize Texture."),{})}let Mt=0;class Texture extends EventDispatcher{constructor(e=Texture.DEFAULT_IMAGE,t=Texture.DEFAULT_MAPPING,r=1001,s=1001,o=1006,l=1008,c=1023,h=1009,d=Texture.DEFAULT_ANISOTROPY,p=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Mt++}),this.uuid=generateUUID(),this.name="",this.source=new Source(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=s,this.magFilter=o,this.minFilter=l,this.anisotropy=d,this.format=c,this.internalFormat=null,this.type=h,this.offset=new Vector2(0,0),this.repeat=new Vector2(1,1),this.center=new Vector2(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Matrix3,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof p?this.colorSpace=p:(warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=p===ke?Ve:Ge),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==W)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case J:e.x=e.x-Math.floor(e.x);break;case $:e.x=e.x<0?0:1;break;case ee: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 J:e.y=e.y-Math.floor(e.y);break;case $:e.y=e.y<0?0:1;break;case ee: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 warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ve?ke:3e3}set encoding(e){warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===ke?Ve:Ge}}Texture.DEFAULT_IMAGE=null,Texture.DEFAULT_MAPPING=W,Texture.DEFAULT_ANISOTROPY=1;class Vector4{constructor(e=0,t=0,r=0,s=1){Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=s}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,r,s){return this.x=e,this.y=t,this.z=r,this.w=s,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,r=this.y,s=this.z,o=this.w,l=e.elements;return this.x=l[0]*t+l[4]*r+l[8]*s+l[12]*o,this.y=l[1]*t+l[5]*r+l[9]*s+l[13]*o,this.z=l[2]*t+l[6]*r+l[10]*s+l[14]*o,this.w=l[3]*t+l[7]*r+l[11]*s+l[15]*o,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,s,o;const l=.01,c=.1,h=e.elements,d=h[0],p=h[4],A=h[8],m=h[1],f=h[5],g=h[9],_=h[2],y=h[6],x=h[10];if(Math.abs(p-m)<l&&Math.abs(A-_)<l&&Math.abs(g-y)<l){if(Math.abs(p+m)<c&&Math.abs(A+_)<c&&Math.abs(g+y)<c&&Math.abs(d+f+x-3)<c)return this.set(1,0,0,0),this;t=Math.PI;const e=(d+1)/2,h=(f+1)/2,S=(x+1)/2,C=(p+m)/4,b=(A+_)/4,I=(g+y)/4;return e>h&&e>S?e<l?(r=0,s=.707106781,o=.707106781):(r=Math.sqrt(e),s=C/r,o=b/r):h>S?h<l?(r=.707106781,s=0,o=.707106781):(s=Math.sqrt(h),r=C/s,o=I/s):S<l?(r=.707106781,s=.707106781,o=0):(o=Math.sqrt(S),r=b/o,s=I/o),this.set(r,s,o,t),this}let S=Math.sqrt((y-g)*(y-g)+(A-_)*(A-_)+(m-p)*(m-p));return Math.abs(S)<.001&&(S=1),this.x=(y-g)/S,this.y=(A-_)/S,this.z=(m-p)/S,this.w=Math.acos((d+f+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class RenderTarget extends EventDispatcher{constructor(e=1,t=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new Vector4(0,0,e,t);const s={width:e,height:t,depth:1};void 0!==r.encoding&&(warnOnce("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===ke?Ve:Ge),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:re,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Texture(s,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps,this.texture.internalFormat=r.internalFormat,this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}setSize(e,t,r=1){this.width===e&&this.height===t&&this.depth===r||(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Source(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class WebGLRenderTarget extends RenderTarget{constructor(e=1,t=1,r={}){super(e,t,r),this.isWebGLRenderTarget=!0}}class DataArrayTexture extends Texture{constructor(e=null,t=1,r=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:s},this.magFilter=te,this.minFilter=te,this.wrapR=$,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Data3DTexture extends Texture{constructor(e=null,t=1,r=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:s},this.magFilter=te,this.minFilter=te,this.wrapR=$,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class three_module_Quaternion{constructor(e=0,t=0,r=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=s}static slerpFlat(e,t,r,s,o,l,c){let h=r[s+0],d=r[s+1],p=r[s+2],A=r[s+3];const m=o[l+0],f=o[l+1],g=o[l+2],_=o[l+3];if(0===c)return e[t+0]=h,e[t+1]=d,e[t+2]=p,void(e[t+3]=A);if(1===c)return e[t+0]=m,e[t+1]=f,e[t+2]=g,void(e[t+3]=_);if(A!==_||h!==m||d!==f||p!==g){let e=1-c;const t=h*m+d*f+p*g+A*_,r=t>=0?1:-1,s=1-t*t;if(s>Number.EPSILON){const o=Math.sqrt(s),l=Math.atan2(o,t*r);e=Math.sin(e*l)/o,c=Math.sin(c*l)/o}const o=c*r;if(h=h*e+m*o,d=d*e+f*o,p=p*e+g*o,A=A*e+_*o,e===1-c){const e=1/Math.sqrt(h*h+d*d+p*p+A*A);h*=e,d*=e,p*=e,A*=e}}e[t]=h,e[t+1]=d,e[t+2]=p,e[t+3]=A}static multiplyQuaternionsFlat(e,t,r,s,o,l){const c=r[s],h=r[s+1],d=r[s+2],p=r[s+3],A=o[l],m=o[l+1],f=o[l+2],g=o[l+3];return e[t]=c*g+p*A+h*f-d*m,e[t+1]=h*g+p*m+d*A-c*f,e[t+2]=d*g+p*f+c*m-h*A,e[t+3]=p*g-c*A-h*m-d*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,r,s){return this._x=e,this._y=t,this._z=r,this._w=s,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=!0){const r=e._x,s=e._y,l=e._z,c=e._order,h=Math.cos,d=Math.sin,p=h(r/2),A=h(s/2),m=h(l/2),f=d(r/2),g=d(s/2),_=d(l/2);switch(c){case"XYZ":this._x=f*A*m+p*g*_,this._y=p*g*m-f*A*_,this._z=p*A*_+f*g*m,this._w=p*A*m-f*g*_;break;case"YXZ":this._x=f*A*m+p*g*_,this._y=p*g*m-f*A*_,this._z=p*A*_-f*g*m,this._w=p*A*m+f*g*_;break;case"ZXY":this._x=f*A*m-p*g*_,this._y=p*g*m+f*A*_,this._z=p*A*_+f*g*m,this._w=p*A*m-f*g*_;break;case"ZYX":this._x=f*A*m-p*g*_,this._y=p*g*m+f*A*_,this._z=p*A*_-f*g*m,this._w=p*A*m+f*g*_;break;case"YZX":this._x=f*A*m+p*g*_,this._y=p*g*m+f*A*_,this._z=p*A*_-f*g*m,this._w=p*A*m-f*g*_;break;case"XZY":this._x=f*A*m-p*g*_,this._y=p*g*m-f*A*_,this._z=p*A*_+f*g*m,this._w=p*A*m+f*g*_;break;default:o.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,s=Math.sin(r);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],s=t[4],o=t[8],l=t[1],c=t[5],h=t[9],d=t[2],p=t[6],A=t[10],m=r+c+A;if(m>0){const e=.5/Math.sqrt(m+1);this._w=.25/e,this._x=(p-h)*e,this._y=(o-d)*e,this._z=(l-s)*e}else if(r>c&&r>A){const e=2*Math.sqrt(1+r-c-A);this._w=(p-h)/e,this._x=.25*e,this._y=(s+l)/e,this._z=(o+d)/e}else if(c>A){const e=2*Math.sqrt(1+c-r-A);this._w=(o-d)/e,this._x=(s+l)/e,this._y=.25*e,this._z=(h+p)/e}else{const e=2*Math.sqrt(1+A-r-c);this._w=(l-s)/e,this._x=(o+d)/e,this._y=(h+p)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(0===r)return this;const s=Math.min(1,t/r);return this.slerp(e,s),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 r=e._x,s=e._y,o=e._z,l=e._w,c=t._x,h=t._y,d=t._z,p=t._w;return this._x=r*p+l*c+s*d-o*h,this._y=s*p+l*h+o*c-r*d,this._z=o*p+l*d+r*h-s*c,this._w=l*p-r*c-s*h-o*d,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const r=this._x,s=this._y,o=this._z,l=this._w;let c=l*e._w+r*e._x+s*e._y+o*e._z;if(c<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,c=-c):this.copy(e),c>=1)return this._w=l,this._x=r,this._y=s,this._z=o,this;const h=1-c*c;if(h<=Number.EPSILON){const e=1-t;return this._w=e*l+t*this._w,this._x=e*r+t*this._x,this._y=e*s+t*this._y,this._z=e*o+t*this._z,this.normalize(),this}const d=Math.sqrt(h),p=Math.atan2(d,c),A=Math.sin((1-t)*p)/d,m=Math.sin(t*p)/d;return this._w=l*A+this._w*m,this._x=r*A+this._x*m,this._y=s*A+this._y*m,this._z=o*A+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=Math.random(),t=Math.sqrt(1-e),r=Math.sqrt(e),s=2*Math.PI*Math.random(),o=2*Math.PI*Math.random();return this.set(t*Math.cos(s),r*Math.sin(o),r*Math.cos(o),t*Math.sin(s))}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._onChangeCallback(),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 three_module_Vector3{constructor(e=0,t=0,r=0){three_module_Vector3.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return void 0===r&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,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(bt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(bt.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[3]*r+o[6]*s,this.y=o[1]*t+o[4]*r+o[7]*s,this.z=o[2]*t+o[5]*r+o[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,s=this.z,o=e.elements,l=1/(o[3]*t+o[7]*r+o[11]*s+o[15]);return this.x=(o[0]*t+o[4]*r+o[8]*s+o[12])*l,this.y=(o[1]*t+o[5]*r+o[9]*s+o[13])*l,this.z=(o[2]*t+o[6]*r+o[10]*s+o[14])*l,this}applyQuaternion(e){const t=this.x,r=this.y,s=this.z,o=e.x,l=e.y,c=e.z,h=e.w,d=2*(l*s-c*r),p=2*(c*t-o*s),A=2*(o*r-l*t);return this.x=t+h*d+l*A-c*p,this.y=r+h*p+c*d-o*A,this.z=s+h*A+o*p-l*d,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,r=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*s,this.y=o[1]*t+o[5]*r+o[9]*s,this.z=o[2]*t+o[6]*r+o[10]*s,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 r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,s=e.y,o=e.z,l=t.x,c=t.y,h=t.z;return this.x=s*h-o*c,this.y=o*l-r*h,this.z=r*c-s*l,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Ct.copy(this).projectOnVector(e),this.sub(Ct)}reflect(e){return this.sub(Ct.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 r=this.dot(e)/t;return Math.acos(clamp(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,s=this.z-e.z;return t*t+r*r+s*s}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,r){const s=Math.sin(t)*e;return this.x=s*Math.sin(r),this.y=Math.cos(t)*e,this.z=s*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=s,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,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ct=new three_module_Vector3,bt=new three_module_Quaternion;class Box3{constructor(e=new three_module_Vector3(1/0,1/0,1/0),t=new three_module_Vector3(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t+=3)this.expandByPoint(It.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(It.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const r=It.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(void 0!==r){const s=r.getAttribute("position");if(!0===t&&void 0!==s&&!0!==e.isInstancedMesh)for(let t=0,r=s.count;t<r;t++)!0===e.isMesh?e.getVertexPosition(t,It):It.fromBufferAttribute(s,t),It.applyMatrix4(e.matrixWorld),this.expandByPoint(It);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),Tt.copy(e.boundingBox)):(null===r.boundingBox&&r.computeBoundingBox(),Tt.copy(r.boundingBox)),Tt.applyMatrix4(e.matrixWorld),this.union(Tt)}const s=e.children;for(let e=0,r=s.length;e<r;e++)this.expandByObject(s[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,It),It.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ft),Nt.subVectors(this.max,Ft),Bt.subVectors(e.a,Ft),Rt.subVectors(e.b,Ft),Lt.subVectors(e.c,Ft),Dt.subVectors(Rt,Bt),Ut.subVectors(Lt,Rt),Pt.subVectors(Bt,Lt);let t=[0,-Dt.z,Dt.y,0,-Ut.z,Ut.y,0,-Pt.z,Pt.y,Dt.z,0,-Dt.x,Ut.z,0,-Ut.x,Pt.z,0,-Pt.x,-Dt.y,Dt.x,0,-Ut.y,Ut.x,0,-Pt.y,Pt.x,0];return!!satForAxes(t,Bt,Rt,Lt,Nt)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,Bt,Rt,Lt,Nt)&&(Ot.crossVectors(Dt,Ut),t=[Ot.x,Ot.y,Ot.z],satForAxes(t,Bt,Rt,Lt,Nt)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,It).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(It).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()||(wt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wt)),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 wt=[new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3,new three_module_Vector3],It=new three_module_Vector3,Tt=new Box3,Bt=new three_module_Vector3,Rt=new three_module_Vector3,Lt=new three_module_Vector3,Dt=new three_module_Vector3,Ut=new three_module_Vector3,Pt=new three_module_Vector3,Ft=new three_module_Vector3,Nt=new three_module_Vector3,Ot=new three_module_Vector3,Qt=new three_module_Vector3;function satForAxes(e,t,r,s,o){for(let l=0,c=e.length-3;l<=c;l+=3){Qt.fromArray(e,l);const c=o.x*Math.abs(Qt.x)+o.y*Math.abs(Qt.y)+o.z*Math.abs(Qt.z),h=t.dot(Qt),d=r.dot(Qt),p=s.dot(Qt);if(Math.max(-Math.max(h,d,p),Math.min(h,d,p))>c)return!1}return!0}const kt=new Box3,Gt=new three_module_Vector3,Vt=new three_module_Vector3;class Sphere{constructor(e=new three_module_Vector3,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const r=this.center;void 0!==t?r.copy(t):kt.setFromPoints(e).getCenter(r);let s=0;for(let t=0,o=e.length;t<o;t++)s=Math.max(s,r.distanceToSquared(e[t]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const r=this.center.distanceToSquared(e);return t.copy(e),r>this.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;Gt.subVectors(e,this.center);const t=Gt.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),r=.5*(e-this.radius);this.center.addScaledVector(Gt,r/e),this.radius+=r}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):(Vt.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gt.copy(e.center).add(Vt)),this.expandByPoint(Gt.copy(e.center).sub(Vt))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Ht=new three_module_Vector3,zt=new three_module_Vector3,Wt=new three_module_Vector3,qt=new three_module_Vector3,jt=new three_module_Vector3,Xt=new three_module_Vector3,Yt=new three_module_Vector3;class Ray{constructor(e=new three_module_Vector3,t=new three_module_Vector3(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.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,Ht)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ht.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ht.copy(this.origin).addScaledVector(this.direction,t),Ht.distanceToSquared(e))}distanceSqToSegment(e,t,r,s){zt.copy(e).add(t).multiplyScalar(.5),Wt.copy(t).sub(e).normalize(),qt.copy(this.origin).sub(zt);const o=.5*e.distanceTo(t),l=-this.direction.dot(Wt),c=qt.dot(this.direction),h=-qt.dot(Wt),d=qt.lengthSq(),p=Math.abs(1-l*l);let A,m,f,g;if(p>0)if(A=l*h-c,m=l*c-h,g=o*p,A>=0)if(m>=-g)if(m<=g){const e=1/p;A*=e,m*=e,f=A*(A+l*m+2*c)+m*(l*A+m+2*h)+d}else m=o,A=Math.max(0,-(l*m+c)),f=-A*A+m*(m+2*h)+d;else m=-o,A=Math.max(0,-(l*m+c)),f=-A*A+m*(m+2*h)+d;else m<=-g?(A=Math.max(0,-(-l*o+c)),m=A>0?-o:Math.min(Math.max(-o,-h),o),f=-A*A+m*(m+2*h)+d):m<=g?(A=0,m=Math.min(Math.max(-o,-h),o),f=m*(m+2*h)+d):(A=Math.max(0,-(l*o+c)),m=A>0?o:Math.min(Math.max(-o,-h),o),f=-A*A+m*(m+2*h)+d);else m=l>0?-o:o,A=Math.max(0,-(l*m+c)),f=-A*A+m*(m+2*h)+d;return r&&r.copy(this.origin).addScaledVector(this.direction,A),s&&s.copy(zt).addScaledVector(Wt,m),f}intersectSphere(e,t){Ht.subVectors(e.center,this.origin);const r=Ht.dot(this.direction),s=Ht.dot(Ht)-r*r,o=e.radius*e.radius;if(s>o)return null;const l=Math.sqrt(o-s),c=r-l,h=r+l;return h<0?null:c<0?this.at(h,t):this.at(c,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 r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return null===r?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,s,o,l,c,h;const d=1/this.direction.x,p=1/this.direction.y,A=1/this.direction.z,m=this.origin;return d>=0?(r=(e.min.x-m.x)*d,s=(e.max.x-m.x)*d):(r=(e.max.x-m.x)*d,s=(e.min.x-m.x)*d),p>=0?(o=(e.min.y-m.y)*p,l=(e.max.y-m.y)*p):(o=(e.max.y-m.y)*p,l=(e.min.y-m.y)*p),r>l||o>s?null:((o>r||isNaN(r))&&(r=o),(l<s||isNaN(s))&&(s=l),A>=0?(c=(e.min.z-m.z)*A,h=(e.max.z-m.z)*A):(c=(e.max.z-m.z)*A,h=(e.min.z-m.z)*A),r>h||c>s?null:((c>r||r!=r)&&(r=c),(h<s||s!=s)&&(s=h),s<0?null:this.at(r>=0?r:s,t)))}intersectsBox(e){return null!==this.intersectBox(e,Ht)}intersectTriangle(e,t,r,s,o){jt.subVectors(t,e),Xt.subVectors(r,e),Yt.crossVectors(jt,Xt);let l,c=this.direction.dot(Yt);if(c>0){if(s)return null;l=1}else{if(!(c<0))return null;l=-1,c=-c}qt.subVectors(this.origin,e);const h=l*this.direction.dot(Xt.crossVectors(qt,Xt));if(h<0)return null;const d=l*this.direction.dot(jt.cross(qt));if(d<0)return null;if(h+d>c)return null;const p=-l*qt.dot(Yt);return p<0?null:this.at(p/c,o)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class three_module_Matrix4{constructor(e,t,r,s,o,l,c,h,d,p,A,m,f,g,_,y){three_module_Matrix4.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,r,s,o,l,c,h,d,p,A,m,f,g,_,y)}set(e,t,r,s,o,l,c,h,d,p,A,m,f,g,_,y){const x=this.elements;return x[0]=e,x[4]=t,x[8]=r,x[12]=s,x[1]=o,x[5]=l,x[9]=c,x[13]=h,x[2]=d,x[6]=p,x[10]=A,x[14]=m,x[3]=f,x[7]=g,x[11]=_,x[15]=y,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 three_module_Matrix4).fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[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,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,s=1/Kt.setFromMatrixColumn(e,0).length(),o=1/Kt.setFromMatrixColumn(e,1).length(),l=1/Kt.setFromMatrixColumn(e,2).length();return t[0]=r[0]*s,t[1]=r[1]*s,t[2]=r[2]*s,t[3]=0,t[4]=r[4]*o,t[5]=r[5]*o,t[6]=r[6]*o,t[7]=0,t[8]=r[8]*l,t[9]=r[9]*l,t[10]=r[10]*l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,s=e.y,o=e.z,l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s),p=Math.cos(o),A=Math.sin(o);if("XYZ"===e.order){const e=l*p,r=l*A,s=c*p,o=c*A;t[0]=h*p,t[4]=-h*A,t[8]=d,t[1]=r+s*d,t[5]=e-o*d,t[9]=-c*h,t[2]=o-e*d,t[6]=s+r*d,t[10]=l*h}else if("YXZ"===e.order){const e=h*p,r=h*A,s=d*p,o=d*A;t[0]=e+o*c,t[4]=s*c-r,t[8]=l*d,t[1]=l*A,t[5]=l*p,t[9]=-c,t[2]=r*c-s,t[6]=o+e*c,t[10]=l*h}else if("ZXY"===e.order){const e=h*p,r=h*A,s=d*p,o=d*A;t[0]=e-o*c,t[4]=-l*A,t[8]=s+r*c,t[1]=r+s*c,t[5]=l*p,t[9]=o-e*c,t[2]=-l*d,t[6]=c,t[10]=l*h}else if("ZYX"===e.order){const e=l*p,r=l*A,s=c*p,o=c*A;t[0]=h*p,t[4]=s*d-r,t[8]=e*d+o,t[1]=h*A,t[5]=o*d+e,t[9]=r*d-s,t[2]=-d,t[6]=c*h,t[10]=l*h}else if("YZX"===e.order){const e=l*h,r=l*d,s=c*h,o=c*d;t[0]=h*p,t[4]=o-e*A,t[8]=s*A+r,t[1]=A,t[5]=l*p,t[9]=-c*p,t[2]=-d*p,t[6]=r*A+s,t[10]=e-o*A}else if("XZY"===e.order){const e=l*h,r=l*d,s=c*h,o=c*d;t[0]=h*p,t[4]=-A,t[8]=d*p,t[1]=e*A+o,t[5]=l*p,t[9]=r*A-s,t[2]=s*A-r,t[6]=c*p,t[10]=o*A+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($t,e,Zt)}lookAt(e,t,r){const s=this.elements;return ii.subVectors(e,t),0===ii.lengthSq()&&(ii.z=1),ii.normalize(),ei.crossVectors(r,ii),0===ei.lengthSq()&&(1===Math.abs(r.z)?ii.x+=1e-4:ii.z+=1e-4,ii.normalize(),ei.crossVectors(r,ii)),ei.normalize(),ti.crossVectors(ii,ei),s[0]=ei.x,s[4]=ti.x,s[8]=ii.x,s[1]=ei.y,s[5]=ti.y,s[9]=ii.y,s[2]=ei.z,s[6]=ti.z,s[10]=ii.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,s=t.elements,o=this.elements,l=r[0],c=r[4],h=r[8],d=r[12],p=r[1],A=r[5],m=r[9],f=r[13],g=r[2],_=r[6],y=r[10],x=r[14],S=r[3],C=r[7],b=r[11],I=r[15],T=s[0],B=s[4],U=s[8],F=s[12],O=s[1],Q=s[5],G=s[9],W=s[13],q=s[2],j=s[6],X=s[10],Y=s[14],K=s[3],J=s[7],$=s[11],ee=s[15];return o[0]=l*T+c*O+h*q+d*K,o[4]=l*B+c*Q+h*j+d*J,o[8]=l*U+c*G+h*X+d*$,o[12]=l*F+c*W+h*Y+d*ee,o[1]=p*T+A*O+m*q+f*K,o[5]=p*B+A*Q+m*j+f*J,o[9]=p*U+A*G+m*X+f*$,o[13]=p*F+A*W+m*Y+f*ee,o[2]=g*T+_*O+y*q+x*K,o[6]=g*B+_*Q+y*j+x*J,o[10]=g*U+_*G+y*X+x*$,o[14]=g*F+_*W+y*Y+x*ee,o[3]=S*T+C*O+b*q+I*K,o[7]=S*B+C*Q+b*j+I*J,o[11]=S*U+C*G+b*X+I*$,o[15]=S*F+C*W+b*Y+I*ee,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],r=e[4],s=e[8],o=e[12],l=e[1],c=e[5],h=e[9],d=e[13],p=e[2],A=e[6],m=e[10],f=e[14];return e[3]*(+o*h*A-s*d*A-o*c*m+r*d*m+s*c*f-r*h*f)+e[7]*(+t*h*f-t*d*m+o*l*m-s*l*f+s*d*p-o*h*p)+e[11]*(+t*d*A-t*c*f-o*l*A+r*l*f+o*c*p-r*d*p)+e[15]*(-s*c*p-t*h*A+t*c*m+s*l*A-r*l*m+r*h*p)}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,r){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],s=e[2],o=e[3],l=e[4],c=e[5],h=e[6],d=e[7],p=e[8],A=e[9],m=e[10],f=e[11],g=e[12],_=e[13],y=e[14],x=e[15],S=A*y*d-_*m*d+_*h*f-c*y*f-A*h*x+c*m*x,C=g*m*d-p*y*d-g*h*f+l*y*f+p*h*x-l*m*x,b=p*_*d-g*A*d+g*c*f-l*_*f-p*c*x+l*A*x,I=g*A*h-p*_*h-g*c*m+l*_*m+p*c*y-l*A*y,T=t*S+r*C+s*b+o*I;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/T;return e[0]=S*B,e[1]=(_*m*o-A*y*o-_*s*f+r*y*f+A*s*x-r*m*x)*B,e[2]=(c*y*o-_*h*o+_*s*d-r*y*d-c*s*x+r*h*x)*B,e[3]=(A*h*o-c*m*o-A*s*d+r*m*d+c*s*f-r*h*f)*B,e[4]=C*B,e[5]=(p*y*o-g*m*o+g*s*f-t*y*f-p*s*x+t*m*x)*B,e[6]=(g*h*o-l*y*o-g*s*d+t*y*d+l*s*x-t*h*x)*B,e[7]=(l*m*o-p*h*o+p*s*d-t*m*d-l*s*f+t*h*f)*B,e[8]=b*B,e[9]=(g*A*o-p*_*o-g*r*f+t*_*f+p*r*x-t*A*x)*B,e[10]=(l*_*o-g*c*o+g*r*d-t*_*d-l*r*x+t*c*x)*B,e[11]=(p*c*o-l*A*o-p*r*d+t*A*d+l*r*f-t*c*f)*B,e[12]=I*B,e[13]=(p*_*s-g*A*s+g*r*m-t*_*m-p*r*y+t*A*y)*B,e[14]=(g*c*s-l*_*s-g*r*h+t*_*h+l*r*y-t*c*y)*B,e[15]=(l*A*s-p*c*s+p*r*h-t*A*h-l*r*m+t*c*m)*B,this}scale(e){const t=this.elements,r=e.x,s=e.y,o=e.z;return t[0]*=r,t[4]*=s,t[8]*=o,t[1]*=r,t[5]*=s,t[9]*=o,t[2]*=r,t[6]*=s,t[10]*=o,t[3]*=r,t[7]*=s,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,s))}makeTranslation(e,t,r){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,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),s=Math.sin(t),o=1-r,l=e.x,c=e.y,h=e.z,d=o*l,p=o*c;return this.set(d*l+r,d*c-s*h,d*h+s*c,0,d*c+s*h,p*c+r,p*h-s*l,0,d*h-s*c,p*h+s*l,o*h*h+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,s,o,l){return this.set(1,r,o,0,e,1,l,0,t,s,1,0,0,0,0,1),this}compose(e,t,r){const s=this.elements,o=t._x,l=t._y,c=t._z,h=t._w,d=o+o,p=l+l,A=c+c,m=o*d,f=o*p,g=o*A,_=l*p,y=l*A,x=c*A,S=h*d,C=h*p,b=h*A,I=r.x,T=r.y,B=r.z;return s[0]=(1-(_+x))*I,s[1]=(f+b)*I,s[2]=(g-C)*I,s[3]=0,s[4]=(f-b)*T,s[5]=(1-(m+x))*T,s[6]=(y+S)*T,s[7]=0,s[8]=(g+C)*B,s[9]=(y-S)*B,s[10]=(1-(m+_))*B,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,r){const s=this.elements;let o=Kt.set(s[0],s[1],s[2]).length();const l=Kt.set(s[4],s[5],s[6]).length(),c=Kt.set(s[8],s[9],s[10]).length();this.determinant()<0&&(o=-o),e.x=s[12],e.y=s[13],e.z=s[14],Jt.copy(this);const h=1/o,d=1/l,p=1/c;return Jt.elements[0]*=h,Jt.elements[1]*=h,Jt.elements[2]*=h,Jt.elements[4]*=d,Jt.elements[5]*=d,Jt.elements[6]*=d,Jt.elements[8]*=p,Jt.elements[9]*=p,Jt.elements[10]*=p,t.setFromRotationMatrix(Jt),r.x=o,r.y=l,r.z=c,this}makePerspective(e,t,r,s,o,l,c=2e3){const h=this.elements,d=2*o/(t-e),p=2*o/(r-s),A=(t+e)/(t-e),m=(r+s)/(r-s);let f,g;if(c===lt)f=-(l+o)/(l-o),g=-2*l*o/(l-o);else{if(c!==ct)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);f=-l/(l-o),g=-l*o/(l-o)}return h[0]=d,h[4]=0,h[8]=A,h[12]=0,h[1]=0,h[5]=p,h[9]=m,h[13]=0,h[2]=0,h[6]=0,h[10]=f,h[14]=g,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,r,s,o,l,c=2e3){const h=this.elements,d=1/(t-e),p=1/(r-s),A=1/(l-o),m=(t+e)*d,f=(r+s)*p;let g,_;if(c===lt)g=(l+o)*A,_=-2*A;else{if(c!==ct)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);g=o*A,_=-1*A}return h[0]=2*d,h[4]=0,h[8]=0,h[12]=-m,h[1]=0,h[5]=2*p,h[9]=0,h[13]=-f,h[2]=0,h[6]=0,h[10]=_,h[14]=-g,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let e=0;e<16;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const Kt=new three_module_Vector3,Jt=new three_module_Matrix4,$t=new three_module_Vector3(0,0,0),Zt=new three_module_Vector3(1,1,1),ei=new three_module_Vector3,ti=new three_module_Vector3,ii=new three_module_Vector3,ni=new three_module_Matrix4,ri=new three_module_Quaternion;class Euler{constructor(e=0,t=0,r=0,s=Euler.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=s}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,r,s=this._order){return this._x=e,this._y=t,this._z=r,this._order=s,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,r=!0){const s=e.elements,l=s[0],c=s[4],h=s[8],d=s[1],p=s[5],A=s[9],m=s[2],f=s[6],g=s[10];switch(t){case"XYZ":this._y=Math.asin(clamp(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-A,g),this._z=Math.atan2(-c,l)):(this._x=Math.atan2(f,p),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(h,g),this._z=Math.atan2(d,p)):(this._y=Math.atan2(-m,l),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-m,g),this._z=Math.atan2(-c,p)):(this._y=0,this._z=Math.atan2(d,l));break;case"ZYX":this._y=Math.asin(-clamp(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(f,g),this._z=Math.atan2(d,l)):(this._x=0,this._z=Math.atan2(-c,p));break;case"YZX":this._z=Math.asin(clamp(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(-A,p),this._y=Math.atan2(-m,l)):(this._x=0,this._y=Math.atan2(h,g));break;case"XZY":this._z=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(f,p),this._y=Math.atan2(h,l)):(this._x=Math.atan2(-A,g),this._y=0);break;default:o.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===r&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return ni.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ni,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ri.setFromEuler(this),this.setFromQuaternion(ri,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}}Euler.DEFAULT_ORDER="XYZ";class Layers{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return!!(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let si=0;const ai=new three_module_Vector3,oi=new three_module_Quaternion,li=new three_module_Matrix4,ci=new three_module_Vector3,hi=new three_module_Vector3,ui=new three_module_Vector3,di=new three_module_Quaternion,pi=new three_module_Vector3(1,0,0),Ai=new three_module_Vector3(0,1,0),mi=new three_module_Vector3(0,0,1),fi={type:"added"},gi={type:"removed"};class Object3D extends EventDispatcher{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:si++}),this.uuid=generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Object3D.DEFAULT_UP.clone();const e=new three_module_Vector3,t=new Euler,r=new three_module_Quaternion,s=new three_module_Vector3(1,1,1);t._onChange((function onRotationChange(){r.setFromEuler(t,!1)})),r._onChange((function onQuaternionChange(){t.setFromQuaternion(r,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new three_module_Matrix4},normalMatrix:{value:new Matrix3}}),this.matrix=new three_module_Matrix4,this.matrixWorld=new three_module_Matrix4,this.matrixAutoUpdate=Object3D.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return oi.setFromAxisAngle(e,t),this.quaternion.multiply(oi),this}rotateOnWorldAxis(e,t){return oi.setFromAxisAngle(e,t),this.quaternion.premultiply(oi),this}rotateX(e){return this.rotateOnAxis(pi,e)}rotateY(e){return this.rotateOnAxis(Ai,e)}rotateZ(e){return this.rotateOnAxis(mi,e)}translateOnAxis(e,t){return ai.copy(e).applyQuaternion(this.quaternion),this.position.add(ai.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(pi,e)}translateY(e){return this.translateOnAxis(Ai,e)}translateZ(e){return this.translateOnAxis(mi,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(li.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?ci.copy(e):ci.set(e,t,r);const s=this.parent;this.updateWorldMatrix(!0,!1),hi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?li.lookAt(hi,ci,this.up):li.lookAt(ci,hi,this.up),this.quaternion.setFromRotationMatrix(li),s&&(li.extractRotation(s.matrixWorld),oi.setFromRotationMatrix(li),this.quaternion.premultiply(oi.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(o.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(fi)):o.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(gi)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),li.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),li.multiply(e.parent.matrixWorld)),e.applyMatrix4(li),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let r=0,s=this.children.length;r<s;r++){const s=this.children[r].getObjectByProperty(e,t);if(void 0!==s)return s}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);const s=this.children;for(let o=0,l=s.length;o<l;o++)s[o].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hi,e,ui),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hi,di,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 r=0,s=t.length;r<s;r++)t[r].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let r=0,s=t.length;r<s;r++)t[r].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let r=0,s=t.length;r<s;r++){const s=t[r];!0!==s.matrixWorldAutoUpdate&&!0!==e||s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const r=this.parent;if(!0===e&&null!==r&&!0===r.matrixWorldAutoUpdate&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,r=e.length;t<r;t++){const r=e[t];!0===r.matrixWorldAutoUpdate&&r.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};function serialize(t,r){return void 0===t[r.uuid]&&(t[r.uuid]=r.toJSON(e)),r.uuid}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),!0===this.castShadow&&(s.castShadow=!0),!0===this.receiveShadow&&(s.receiveShadow=!0),!1===this.visible&&(s.visible=!1),!1===this.frustumCulled&&(s.frustumCulled=!1),0!==this.renderOrder&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),s.maxGeometryCount=this._maxGeometryCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(e),null!==this.boundingSphere&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),null!==this.boundingBox&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=serialize(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const r=t.shapes;if(Array.isArray(r))for(let t=0,s=r.length;t<s;t++){const s=r[t];serialize(e.shapes,s)}else serialize(e.shapes,r)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(serialize(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let r=0,s=this.material.length;r<s;r++)t.push(serialize(e.materials,this.material[r]));s.material=t}else s.material=serialize(e.materials,this.material);if(this.children.length>0){s.children=[];for(let t=0;t<this.children.length;t++)s.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let t=0;t<this.animations.length;t++){const r=this.animations[t];s.animations.push(serialize(e.animations,r))}}if(t){const t=extractFromCache(e.geometries),s=extractFromCache(e.materials),o=extractFromCache(e.textures),l=extractFromCache(e.images),c=extractFromCache(e.shapes),h=extractFromCache(e.skeletons),d=extractFromCache(e.animations),p=extractFromCache(e.nodes);t.length>0&&(r.geometries=t),s.length>0&&(r.materials=s),o.length>0&&(r.textures=o),l.length>0&&(r.images=l),c.length>0&&(r.shapes=c),h.length>0&&(r.skeletons=h),d.length>0&&(r.animations=d),p.length>0&&(r.nodes=p)}return r.object=s,r;function extractFromCache(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,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;t<e.children.length;t++){const r=e.children[t];this.add(r.clone())}return this}}Object3D.DEFAULT_UP=new three_module_Vector3(0,1,0),Object3D.DEFAULT_MATRIX_AUTO_UPDATE=!0,Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const _i=new three_module_Vector3,vi=new three_module_Vector3,yi=new three_module_Vector3,xi=new three_module_Vector3,Mi=new three_module_Vector3,Ci=new three_module_Vector3,bi=new three_module_Vector3,wi=new three_module_Vector3,Ti=new three_module_Vector3,Bi=new three_module_Vector3;let Ri=!1;class Triangle{constructor(e=new three_module_Vector3,t=new three_module_Vector3,r=new three_module_Vector3){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,s){s.subVectors(r,t),_i.subVectors(e,t),s.cross(_i);const o=s.lengthSq();return o>0?s.multiplyScalar(1/Math.sqrt(o)):s.set(0,0,0)}static getBarycoord(e,t,r,s,o){_i.subVectors(s,t),vi.subVectors(r,t),yi.subVectors(e,t);const l=_i.dot(_i),c=_i.dot(vi),h=_i.dot(yi),d=vi.dot(vi),p=vi.dot(yi),A=l*d-c*c;if(0===A)return o.set(0,0,0),null;const m=1/A,f=(d*h-c*p)*m,g=(l*p-c*h)*m;return o.set(1-f-g,g,f)}static containsPoint(e,t,r,s){return null!==this.getBarycoord(e,t,r,s,xi)&&(xi.x>=0&&xi.y>=0&&xi.x+xi.y<=1)}static getUV(e,t,r,s,l,c,h,d){return!1===Ri&&(o.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Ri=!0),this.getInterpolation(e,t,r,s,l,c,h,d)}static getInterpolation(e,t,r,s,o,l,c,h){return null===this.getBarycoord(e,t,r,s,xi)?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(o,xi.x),h.addScaledVector(l,xi.y),h.addScaledVector(c,xi.z),h)}static isFrontFacing(e,t,r,s){return _i.subVectors(r,t),vi.subVectors(e,t),_i.cross(vi).dot(s)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,s){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,r,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,s),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 _i.subVectors(this.c,this.b),vi.subVectors(this.a,this.b),.5*_i.cross(vi).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,s,l){return!1===Ri&&(o.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Ri=!0),Triangle.getInterpolation(e,this.a,this.b,this.c,t,r,s,l)}getInterpolation(e,t,r,s,o){return Triangle.getInterpolation(e,this.a,this.b,this.c,t,r,s,o)}containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,s=this.b,o=this.c;let l,c;Mi.subVectors(s,r),Ci.subVectors(o,r),wi.subVectors(e,r);const h=Mi.dot(wi),d=Ci.dot(wi);if(h<=0&&d<=0)return t.copy(r);Ti.subVectors(e,s);const p=Mi.dot(Ti),A=Ci.dot(Ti);if(p>=0&&A<=p)return t.copy(s);const m=h*A-p*d;if(m<=0&&h>=0&&p<=0)return l=h/(h-p),t.copy(r).addScaledVector(Mi,l);Bi.subVectors(e,o);const f=Mi.dot(Bi),g=Ci.dot(Bi);if(g>=0&&f<=g)return t.copy(o);const _=f*d-h*g;if(_<=0&&d>=0&&g<=0)return c=d/(d-g),t.copy(r).addScaledVector(Ci,c);const y=p*g-f*A;if(y<=0&&A-p>=0&&f-g>=0)return bi.subVectors(o,s),c=(A-p)/(A-p+(f-g)),t.copy(s).addScaledVector(bi,c);const x=1/(y+_+m);return l=_*x,c=m*x,t.copy(r).addScaledVector(Mi,l).addScaledVector(Ci,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Li={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},Di={h:0,s:0,l:0},Ui={h:0,s:0,l:0};function hue2rgb(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}class Color{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(void 0===t&&void 0===r){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,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ve){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Et.toWorkingColorSpace(this,t),this}setRGB(e,t,r,s=Et.workingColorSpace){return this.r=e,this.g=t,this.b=r,Et.toWorkingColorSpace(this,s),this}setHSL(e,t,r,s=Et.workingColorSpace){if(e=euclideanModulo(e,1),t=clamp(t,0,1),r=clamp(r,0,1),0===t)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,o=2*r-s;this.r=hue2rgb(o,s,e+1/3),this.g=hue2rgb(o,s,e),this.b=hue2rgb(o,s,e-1/3)}return Et.toWorkingColorSpace(this,s),this}setStyle(e,t=Ve){function handleAlpha(t){void 0!==t&&parseFloat(t)<1&&o.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const l=r[1],c=r[2];switch(l){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return handleAlpha(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return handleAlpha(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return handleAlpha(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:o.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],l=s.length;if(3===l)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(6===l)return this.setHex(parseInt(s,16),t);o.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ve){const r=Li[e.toLowerCase()];return void 0!==r?this.setHex(r,t):o.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=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ve){return Et.fromWorkingColorSpace(Fi.copy(this),e),65536*Math.round(clamp(255*Fi.r,0,255))+256*Math.round(clamp(255*Fi.g,0,255))+Math.round(clamp(255*Fi.b,0,255))}getHexString(e=Ve){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Et.workingColorSpace){Et.fromWorkingColorSpace(Fi.copy(this),t);const r=Fi.r,s=Fi.g,o=Fi.b,l=Math.max(r,s,o),c=Math.min(r,s,o);let h,d;const p=(c+l)/2;if(c===l)h=0,d=0;else{const e=l-c;switch(d=p<=.5?e/(l+c):e/(2-l-c),l){case r:h=(s-o)/e+(s<o?6:0);break;case s:h=(o-r)/e+2;break;case o:h=(r-s)/e+4}h/=6}return e.h=h,e.s=d,e.l=p,e}getRGB(e,t=Et.workingColorSpace){return Et.fromWorkingColorSpace(Fi.copy(this),t),e.r=Fi.r,e.g=Fi.g,e.b=Fi.b,e}getStyle(e=Ve){Et.fromWorkingColorSpace(Fi.copy(this),e);const t=Fi.r,r=Fi.g,s=Fi.b;return e!==Ve?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*r)},${Math.round(255*s)})`}offsetHSL(e,t,r){return this.getHSL(Di),this.setHSL(Di.h+e,Di.s+t,Di.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(Di),e.getHSL(Ui);const r=lerp(Di.h,Ui.h,t),s=lerp(Di.s,Ui.s,t),o=lerp(Di.l,Ui.l,t);return this.setHSL(r,s,o),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,r=this.g,s=this.b,o=e.elements;return this.r=o[0]*t+o[3]*r+o[6]*s,this.g=o[1]*t+o[4]*r+o[7]*s,this.b=o[2]*t+o[5]*r+o[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Fi=new Color;Color.NAMES=Li;let Ni=0;class Material extends EventDispatcher{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ni++}),this.uuid=generateUUID(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=p,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Color(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ke,this.stencilZFail=Ke,this.stencilZPass=Ke,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 r=e[t];if(void 0===r){o.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];void 0!==s?s&&s.isColor?s.set(r):s&&s.isVector3&&r&&r.isVector3?s.copy(r):this[t]=r:o.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 r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function extractFromCache(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(r.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(r.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(r.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(r.combine=this.combine)),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(r.blending=this.blending),0!==this.side&&(r.side=this.side),!0===this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=!0),204!==this.blendSrc&&(r.blendSrc=this.blendSrc),205!==this.blendDst&&(r.blendDst=this.blendDst),this.blendEquation!==p&&(r.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(r.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(r.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(r.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(r.depthFunc=this.depthFunc),!1===this.depthTest&&(r.depthTest=this.depthTest),!1===this.depthWrite&&(r.depthWrite=this.depthWrite),!1===this.colorWrite&&(r.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(r.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(r.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(r.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ke&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Ke&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Ke&&(r.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(r.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.alphaHash&&(r.alphaHash=!0),!0===this.alphaToCoverage&&(r.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=!0),!0===this.forceSinglePass&&(r.forceSinglePass=!0),!0===this.wireframe&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=!0),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),!1===this.fog&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData),t){const t=extractFromCache(e.textures),s=extractFromCache(e.images);t.length>0&&(r.textures=t),s.length>0&&(r.images=s)}return r}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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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 r=null;if(null!==t){const e=t.length;r=new Array(e);for(let s=0;s!==e;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,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++}}class MeshBasicMaterial extends Material{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Oi=_generateTables();function _generateTables(){const e=new ArrayBuffer(4),t=new Float32Array(e),r=new Uint32Array(e),s=new Uint32Array(512),o=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(s[e]=0,s[256|e]=32768,o[e]=24,o[256|e]=24):t<-14?(s[e]=1024>>-t-14,s[256|e]=1024>>-t-14|32768,o[e]=-t-1,o[256|e]=-t-1):t<=15?(s[e]=t+15<<10,s[256|e]=t+15<<10|32768,o[e]=13,o[256|e]=13):t<128?(s[e]=31744,s[256|e]=64512,o[e]=24,o[256|e]=24):(s[e]=31744,s[256|e]=64512,o[e]=13,o[256|e]=13)}const l=new Uint32Array(2048),c=new Uint32Array(64),h=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,r=0;for(;!(8388608&t);)t<<=1,r-=8388608;t&=-8388609,r+=947912704,l[e]=t|r}for(let e=1024;e<2048;++e)l[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)c[e]=e<<23;c[31]=1199570944,c[32]=2147483648;for(let e=33;e<63;++e)c[e]=2147483648+(e-32<<23);c[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(h[e]=1024);return{floatView:t,uint32View:r,baseTable:s,shiftTable:o,mantissaTable:l,exponentTable:c,offsetTable:h}}function toHalfFloat(e){Math.abs(e)>65504&&o.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=clamp(e,-65504,65504),Oi.floatView[0]=e;const t=Oi.uint32View[0],r=t>>23&511;return Oi.baseTable[r]+((8388607&t)>>Oi.shiftTable[r])}function fromHalfFloat(e){const t=e>>10;return Oi.uint32View[0]=Oi.mantissaTable[Oi.offsetTable[t]+(1023&e)]+Oi.exponentTable[t],Oi.floatView[0]}const Qi={toHalfFloat,fromHalfFloat},ki=new three_module_Vector3,Gi=new Vector2;class three_module_BufferAttribute{constructor(e,t,r=!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=r,this.usage=st,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=ue,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return o.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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,r){e*=this.itemSize,r*=t.itemSize;for(let s=0,o=this.itemSize;s<o;s++)this.array[e+s]=t.array[r+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,r=this.count;t<r;t++)Gi.fromBufferAttribute(this,t),Gi.applyMatrix3(e),this.setXY(t,Gi.x,Gi.y);else if(3===this.itemSize)for(let t=0,r=this.count;t<r;t++)ki.fromBufferAttribute(this,t),ki.applyMatrix3(e),this.setXYZ(t,ki.x,ki.y,ki.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)ki.fromBufferAttribute(this,t),ki.applyMatrix4(e),this.setXYZ(t,ki.x,ki.y,ki.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)ki.fromBufferAttribute(this,t),ki.applyNormalMatrix(e),this.setXYZ(t,ki.x,ki.y,ki.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)ki.fromBufferAttribute(this,t),ki.transformDirection(e),this.setXYZ(t,ki.x,ki.y,ki.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=denormalize(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=normalize(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=denormalize(t,this.array)),t}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=denormalize(t,this.array)),t}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=denormalize(t,this.array)),t}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=denormalize(t,this.array)),t}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,s){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=s,this}setXYZW(e,t,r,s,o){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array),o=normalize(o,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=s,this.array[e+3]=o,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==st&&(e.usage=this.usage),e}}class Uint16BufferAttribute extends three_module_BufferAttribute{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class Uint32BufferAttribute extends three_module_BufferAttribute{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class three_module_Float32BufferAttribute extends three_module_BufferAttribute{constructor(e,t,r){super(new Float32Array(e),t,r)}}let Vi=0;const Hi=new three_module_Matrix4,zi=new Object3D,Wi=new three_module_Vector3,qi=new Box3,ji=new Box3,Xi=new three_module_Vector3;class three_module_BufferGeometry extends EventDispatcher{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Vi++}),this.uuid=generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(arrayNeedsUint32(e)?Uint32BufferAttribute:Uint16BufferAttribute)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(void 0!==r){const t=(new Matrix3).getNormalMatrix(e);r.applyNormalMatrix(t),r.needsUpdate=!0}const s=this.attributes.tangent;return void 0!==s&&(s.transformDirection(e),s.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Hi.makeRotationFromQuaternion(e),this.applyMatrix4(Hi),this}rotateX(e){return Hi.makeRotationX(e),this.applyMatrix4(Hi),this}rotateY(e){return Hi.makeRotationY(e),this.applyMatrix4(Hi),this}rotateZ(e){return Hi.makeRotationZ(e),this.applyMatrix4(Hi),this}translate(e,t,r){return Hi.makeTranslation(e,t,r),this.applyMatrix4(Hi),this}scale(e,t,r){return Hi.makeScale(e,t,r),this.applyMatrix4(Hi),this}lookAt(e){return zi.lookAt(e),zi.updateMatrix(),this.applyMatrix4(zi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Wi).negate(),this.translate(Wi.x,Wi.y,Wi.z),this}setFromPoints(e){const t=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new three_module_Float32BufferAttribute(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Box3);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return o.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new three_module_Vector3(-1/0,-1/0,-1/0),new three_module_Vector3(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){const r=t[e];qi.setFromBufferAttribute(r),this.morphTargetsRelative?(Xi.addVectors(this.boundingBox.min,qi.min),this.boundingBox.expandByPoint(Xi),Xi.addVectors(this.boundingBox.max,qi.max),this.boundingBox.expandByPoint(Xi)):(this.boundingBox.expandByPoint(qi.min),this.boundingBox.expandByPoint(qi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&o.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sphere);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return o.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new three_module_Vector3,1/0);if(e){const r=this.boundingSphere.center;if(qi.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){const r=t[e];ji.setFromBufferAttribute(r),this.morphTargetsRelative?(Xi.addVectors(qi.min,ji.min),qi.expandByPoint(Xi),Xi.addVectors(qi.max,ji.max),qi.expandByPoint(Xi)):(qi.expandByPoint(ji.min),qi.expandByPoint(ji.max))}qi.getCenter(r);let s=0;for(let t=0,o=e.count;t<o;t++)Xi.fromBufferAttribute(e,t),s=Math.max(s,r.distanceToSquared(Xi));if(t)for(let o=0,l=t.length;o<l;o++){const l=t[o],c=this.morphTargetsRelative;for(let t=0,o=l.count;t<o;t++)Xi.fromBufferAttribute(l,t),c&&(Wi.fromBufferAttribute(e,t),Xi.add(Wi)),s=Math.max(s,r.distanceToSquared(Xi))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&o.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void o.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const r=e.array,s=t.position.array,l=t.normal.array,c=t.uv.array,h=s.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new three_module_BufferAttribute(new Float32Array(4*h),4));const d=this.getAttribute("tangent").array,p=[],A=[];for(let e=0;e<h;e++)p[e]=new three_module_Vector3,A[e]=new three_module_Vector3;const m=new three_module_Vector3,f=new three_module_Vector3,g=new three_module_Vector3,_=new Vector2,y=new Vector2,x=new Vector2,S=new three_module_Vector3,C=new three_module_Vector3;function handleTriangle(e,t,r){m.fromArray(s,3*e),f.fromArray(s,3*t),g.fromArray(s,3*r),_.fromArray(c,2*e),y.fromArray(c,2*t),x.fromArray(c,2*r),f.sub(m),g.sub(m),y.sub(_),x.sub(_);const o=1/(y.x*x.y-x.x*y.y);isFinite(o)&&(S.copy(f).multiplyScalar(x.y).addScaledVector(g,-y.y).multiplyScalar(o),C.copy(g).multiplyScalar(y.x).addScaledVector(f,-x.x).multiplyScalar(o),p[e].add(S),p[t].add(S),p[r].add(S),A[e].add(C),A[t].add(C),A[r].add(C))}let b=this.groups;0===b.length&&(b=[{start:0,count:r.length}]);for(let e=0,t=b.length;e<t;++e){const t=b[e],s=t.start;for(let e=s,o=s+t.count;e<o;e+=3)handleTriangle(r[e+0],r[e+1],r[e+2])}const I=new three_module_Vector3,T=new three_module_Vector3,B=new three_module_Vector3,U=new three_module_Vector3;function handleVertex(e){B.fromArray(l,3*e),U.copy(B);const t=p[e];I.copy(t),I.sub(B.multiplyScalar(B.dot(t))).normalize(),T.crossVectors(U,t);const r=T.dot(A[e])<0?-1:1;d[4*e]=I.x,d[4*e+1]=I.y,d[4*e+2]=I.z,d[4*e+3]=r}for(let e=0,t=b.length;e<t;++e){const t=b[e],s=t.start;for(let e=s,o=s+t.count;e<o;e+=3)handleVertex(r[e+0]),handleVertex(r[e+1]),handleVertex(r[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let r=this.getAttribute("normal");if(void 0===r)r=new three_module_BufferAttribute(new Float32Array(3*t.count),3),this.setAttribute("normal",r);else for(let e=0,t=r.count;e<t;e++)r.setXYZ(e,0,0,0);const s=new three_module_Vector3,o=new three_module_Vector3,l=new three_module_Vector3,c=new three_module_Vector3,h=new three_module_Vector3,d=new three_module_Vector3,p=new three_module_Vector3,A=new three_module_Vector3;if(e)for(let m=0,f=e.count;m<f;m+=3){const f=e.getX(m+0),g=e.getX(m+1),_=e.getX(m+2);s.fromBufferAttribute(t,f),o.fromBufferAttribute(t,g),l.fromBufferAttribute(t,_),p.subVectors(l,o),A.subVectors(s,o),p.cross(A),c.fromBufferAttribute(r,f),h.fromBufferAttribute(r,g),d.fromBufferAttribute(r,_),c.add(p),h.add(p),d.add(p),r.setXYZ(f,c.x,c.y,c.z),r.setXYZ(g,h.x,h.y,h.z),r.setXYZ(_,d.x,d.y,d.z)}else for(let e=0,c=t.count;e<c;e+=3)s.fromBufferAttribute(t,e+0),o.fromBufferAttribute(t,e+1),l.fromBufferAttribute(t,e+2),p.subVectors(l,o),A.subVectors(s,o),p.cross(A),r.setXYZ(e+0,p.x,p.y,p.z),r.setXYZ(e+1,p.x,p.y,p.z),r.setXYZ(e+2,p.x,p.y,p.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)Xi.fromBufferAttribute(e,t),Xi.normalize(),e.setXYZ(t,Xi.x,Xi.y,Xi.z)}toNonIndexed(){function convertBufferAttribute(e,t){const r=e.array,s=e.itemSize,o=e.normalized,l=new r.constructor(t.length*s);let c=0,h=0;for(let o=0,d=t.length;o<d;o++){c=e.isInterleavedBufferAttribute?t[o]*e.data.stride+e.offset:t[o]*s;for(let e=0;e<s;e++)l[h++]=r[c++]}return new three_module_BufferAttribute(l,s,o)}if(null===this.index)return o.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new three_module_BufferGeometry,t=this.index.array,r=this.attributes;for(const s in r){const o=convertBufferAttribute(r[s],t);e.setAttribute(s,o)}const s=this.morphAttributes;for(const r in s){const o=[],l=s[r];for(let e=0,r=l.length;e<r;e++){const r=convertBufferAttribute(l[e],t);o.push(r)}e.morphAttributes[r]=o}e.morphTargetsRelative=this.morphTargetsRelative;const l=this.groups;for(let t=0,r=l.length;t<r;t++){const r=l[t];e.addGroup(r.start,r.count,r.materialIndex)}return e}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const r in t)void 0!==t[r]&&(e[r]=t[r]);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 r=this.attributes;for(const t in r){const s=r[t];e.data.attributes[t]=s.toJSON(e.data)}const s={};let o=!1;for(const t in this.morphAttributes){const r=this.morphAttributes[t],l=[];for(let t=0,s=r.length;t<s;t++){const s=r[t];l.push(s.toJSON(e.data))}l.length>0&&(s[t]=l,o=!0)}o&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(e.data.groups=JSON.parse(JSON.stringify(l)));const c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.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 r=e.index;null!==r&&this.setIndex(r.clone(t));const s=e.attributes;for(const e in s){const r=s[e];this.setAttribute(e,r.clone(t))}const o=e.morphAttributes;for(const e in o){const r=[],s=o[e];for(let e=0,o=s.length;e<o;e++)r.push(s[e].clone(t));this.morphAttributes[e]=r}this.morphTargetsRelative=e.morphTargetsRelative;const l=e.groups;for(let e=0,t=l.length;e<t;e++){const t=l[e];this.addGroup(t.start,t.count,t.materialIndex)}const c=e.boundingBox;null!==c&&(this.boundingBox=c.clone());const h=e.boundingSphere;return null!==h&&(this.boundingSphere=h.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Yi=new three_module_Matrix4,Ki=new Ray,Ji=new Sphere,$i=new three_module_Vector3,Zi=new three_module_Vector3,en=new three_module_Vector3,tn=new three_module_Vector3,nn=new three_module_Vector3,rn=new three_module_Vector3,sn=new Vector2,an=new Vector2,on=new Vector2,ln=new three_module_Vector3,cn=new three_module_Vector3,hn=new three_module_Vector3,un=new three_module_Vector3,dn=new three_module_Vector3;class three_module_Mesh extends Object3D{constructor(e=new three_module_BufferGeometry,t=new MeshBasicMaterial){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){const t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const r=this.geometry,s=r.attributes.position,o=r.morphAttributes.position,l=r.morphTargetsRelative;t.fromBufferAttribute(s,e);const c=this.morphTargetInfluences;if(o&&c){rn.set(0,0,0);for(let r=0,s=o.length;r<s;r++){const s=c[r],h=o[r];0!==s&&(nn.fromBufferAttribute(h,e),l?rn.addScaledVector(nn,s):rn.addScaledVector(nn.sub(t),s))}t.add(rn)}return t}raycast(e,t){const r=this.geometry,s=this.material,o=this.matrixWorld;if(void 0!==s){if(null===r.boundingSphere&&r.computeBoundingSphere(),Ji.copy(r.boundingSphere),Ji.applyMatrix4(o),Ki.copy(e.ray).recast(e.near),!1===Ji.containsPoint(Ki.origin)){if(null===Ki.intersectSphere(Ji,$i))return;if(Ki.origin.distanceToSquared($i)>(e.far-e.near)**2)return}Yi.copy(o).invert(),Ki.copy(e.ray).applyMatrix4(Yi),null!==r.boundingBox&&!1===Ki.intersectsBox(r.boundingBox)||this._computeIntersections(e,t,Ki)}}_computeIntersections(e,t,r){let s;const o=this.geometry,l=this.material,c=o.index,h=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,A=o.attributes.normal,m=o.groups,f=o.drawRange;if(null!==c)if(Array.isArray(l))for(let o=0,h=m.length;o<h;o++){const h=m[o],g=l[h.materialIndex];for(let o=Math.max(h.start,f.start),l=Math.min(c.count,Math.min(h.start+h.count,f.start+f.count));o<l;o+=3){s=checkGeometryIntersection(this,g,e,r,d,p,A,c.getX(o),c.getX(o+1),c.getX(o+2)),s&&(s.faceIndex=Math.floor(o/3),s.face.materialIndex=h.materialIndex,t.push(s))}}else{for(let o=Math.max(0,f.start),h=Math.min(c.count,f.start+f.count);o<h;o+=3){s=checkGeometryIntersection(this,l,e,r,d,p,A,c.getX(o),c.getX(o+1),c.getX(o+2)),s&&(s.faceIndex=Math.floor(o/3),t.push(s))}}else if(void 0!==h)if(Array.isArray(l))for(let o=0,c=m.length;o<c;o++){const c=m[o],g=l[c.materialIndex];for(let o=Math.max(c.start,f.start),l=Math.min(h.count,Math.min(c.start+c.count,f.start+f.count));o<l;o+=3){s=checkGeometryIntersection(this,g,e,r,d,p,A,o,o+1,o+2),s&&(s.faceIndex=Math.floor(o/3),s.face.materialIndex=c.materialIndex,t.push(s))}}else{for(let o=Math.max(0,f.start),c=Math.min(h.count,f.start+f.count);o<c;o+=3){s=checkGeometryIntersection(this,l,e,r,d,p,A,o,o+1,o+2),s&&(s.faceIndex=Math.floor(o/3),t.push(s))}}}}function checkGeometryIntersection(e,t,r,s,o,l,c,h,d,p){e.getVertexPosition(h,Zi),e.getVertexPosition(d,en),e.getVertexPosition(p,tn);const A=function checkIntersection(e,t,r,s,o,l,c,h){let d;if(d=1===t.side?s.intersectTriangle(c,l,o,!0,h):s.intersectTriangle(o,l,c,0===t.side,h),null===d)return null;dn.copy(h),dn.applyMatrix4(e.matrixWorld);const p=r.ray.origin.distanceTo(dn);return p<r.near||p>r.far?null:{distance:p,point:dn.clone(),object:e}}(e,t,r,s,Zi,en,tn,un);if(A){o&&(sn.fromBufferAttribute(o,h),an.fromBufferAttribute(o,d),on.fromBufferAttribute(o,p),A.uv=Triangle.getInterpolation(un,Zi,en,tn,sn,an,on,new Vector2)),l&&(sn.fromBufferAttribute(l,h),an.fromBufferAttribute(l,d),on.fromBufferAttribute(l,p),A.uv1=Triangle.getInterpolation(un,Zi,en,tn,sn,an,on,new Vector2),A.uv2=A.uv1),c&&(ln.fromBufferAttribute(c,h),cn.fromBufferAttribute(c,d),hn.fromBufferAttribute(c,p),A.normal=Triangle.getInterpolation(un,Zi,en,tn,ln,cn,hn,new three_module_Vector3),A.normal.dot(s.direction)>0&&A.normal.multiplyScalar(-1));const e={a:h,b:d,c:p,normal:new three_module_Vector3,materialIndex:0};Triangle.getNormal(Zi,en,tn,e.normal),A.face=e}return A}class BoxGeometry extends three_module_BufferGeometry{constructor(e=1,t=1,r=1,s=1,o=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:s,heightSegments:o,depthSegments:l};const c=this;s=Math.floor(s),o=Math.floor(o),l=Math.floor(l);const h=[],d=[],p=[],A=[];let m=0,f=0;function buildPlane(e,t,r,s,o,l,g,_,y,x,S){const C=l/y,b=g/x,I=l/2,T=g/2,B=_/2,U=y+1,F=x+1;let O=0,Q=0;const G=new three_module_Vector3;for(let l=0;l<F;l++){const c=l*b-T;for(let h=0;h<U;h++){const m=h*C-I;G[e]=m*s,G[t]=c*o,G[r]=B,d.push(G.x,G.y,G.z),G[e]=0,G[t]=0,G[r]=_>0?1:-1,p.push(G.x,G.y,G.z),A.push(h/y),A.push(1-l/x),O+=1}}for(let e=0;e<x;e++)for(let t=0;t<y;t++){const r=m+t+U*e,s=m+t+U*(e+1),o=m+(t+1)+U*(e+1),l=m+(t+1)+U*e;h.push(r,s,l),h.push(s,o,l),Q+=6}c.addGroup(f,Q,S),f+=Q,m+=O}buildPlane("z","y","x",-1,-1,r,t,e,l,o,0),buildPlane("z","y","x",1,-1,r,t,-e,l,o,1),buildPlane("x","z","y",1,1,e,r,t,s,l,2),buildPlane("x","z","y",1,-1,e,r,-t,s,l,3),buildPlane("x","y","z",1,-1,e,t,r,s,o,4),buildPlane("x","y","z",-1,-1,e,t,-r,s,o,5),this.setIndex(h),this.setAttribute("position",new three_module_Float32BufferAttribute(d,3)),this.setAttribute("normal",new three_module_Float32BufferAttribute(p,3)),this.setAttribute("uv",new three_module_Float32BufferAttribute(A,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new BoxGeometry(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function cloneUniforms(e){const t={};for(const r in e){t[r]={};for(const s in e[r]){const l=e[r][s];l&&(l.isColor||l.isMatrix3||l.isMatrix4||l.isVector2||l.isVector3||l.isVector4||l.isTexture||l.isQuaternion)?l.isRenderTargetTexture?(o.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[r][s]=null):t[r][s]=l.clone():Array.isArray(l)?t[r][s]=l.slice():t[r][s]=l}}return t}function mergeUniforms(e){const t={};for(let r=0;r<e.length;r++){const s=cloneUniforms(e[r]);for(const e in s)t[e]=s[e]}return t}function getUnlitUniformColorSpace(e){return null===e.getRenderTarget()?e.outputColorSpace:Et.workingColorSpace}const pn={clone:cloneUniforms,merge:mergeUniforms};class ShaderMaterial extends Material{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=cloneUniforms(e.uniforms),this.uniformsGroups=function cloneUniformsGroups(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const r={};for(const e in this.extensions)!0===this.extensions[e]&&(r[e]=!0);return Object.keys(r).length>0&&(t.extensions=r),t}}class Camera extends Object3D{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new three_module_Matrix4,this.projectionMatrix=new three_module_Matrix4,this.projectionMatrixInverse=new three_module_Matrix4,this.coordinateSystem=lt}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){return super.getWorldDirection(e).negate()}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 PerspectiveCamera extends Camera{constructor(e=50,t=1,r=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=s,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*pt*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*dt*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*pt*Math.atan(Math.tan(.5*dt*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,r,s,o,l){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=r,this.view.offsetY=s,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*dt*this.fov)/this.zoom,r=2*t,s=this.aspect*r,o=-.5*s;const l=this.view;if(null!==this.view&&this.view.enabled){const e=l.fullWidth,c=l.fullHeight;o+=l.offsetX*s/e,t-=l.offsetY*r/c,s*=l.width/e,r*=l.height/c}const c=this.filmOffset;0!==c&&(o+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+s,t,t-r,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 An=-90;class CubeCamera extends Object3D{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new PerspectiveCamera(An,1,e,t);s.layers=this.layers,this.add(s);const o=new PerspectiveCamera(An,1,e,t);o.layers=this.layers,this.add(o);const l=new PerspectiveCamera(An,1,e,t);l.layers=this.layers,this.add(l);const c=new PerspectiveCamera(An,1,e,t);c.layers=this.layers,this.add(c);const h=new PerspectiveCamera(An,1,e,t);h.layers=this.layers,this.add(h);const d=new PerspectiveCamera(An,1,e,t);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[r,s,o,l,c,h]=t;for(const e of t)this.remove(e);if(e===lt)r.up.set(0,1,0),r.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),l.up.set(0,0,1),l.lookAt(0,-1,0),c.up.set(0,1,0),c.lookAt(0,0,1),h.up.set(0,1,0),h.lookAt(0,0,-1);else{if(e!==ct)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);r.up.set(0,-1,0),r.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),l.up.set(0,0,-1),l.lookAt(0,-1,0),c.up.set(0,-1,0),c.lookAt(0,0,1),h.up.set(0,-1,0),h.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,l,c,h,d,p]=this.children,A=e.getRenderTarget(),m=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,s),e.render(t,o),e.setRenderTarget(r,1,s),e.render(t,l),e.setRenderTarget(r,2,s),e.render(t,c),e.setRenderTarget(r,3,s),e.render(t,h),e.setRenderTarget(r,4,s),e.render(t,d),r.texture.generateMipmaps=_,e.setRenderTarget(r,5,s),e.render(t,p),e.setRenderTarget(A,m,f),e.xr.enabled=g,r.texture.needsPMREMUpdate=!0}}class CubeTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d,p){super(e=void 0!==e?e:[],t=void 0!==t?t:q,r,s,o,l,c,h,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];void 0!==t.encoding&&(warnOnce("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===ke?Ve:Ge),this.texture=new CubeTexture(s,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:re}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 r={uniforms:{tEquirect:{value:null}},vertexShader:"\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 <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\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 BoxGeometry(5,5,5),o=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:1,blending:0});o.uniforms.tEquirect.value=t;const l=new three_module_Mesh(s,o),c=t.minFilter;t.minFilter===ae&&(t.minFilter=re);return new CubeCamera(1,10,this).update(e,l),t.minFilter=c,l.geometry.dispose(),l.material.dispose(),this}clear(e,t,r,s){const o=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,r,s);e.setRenderTarget(o)}}const mn=new three_module_Vector3,fn=new three_module_Vector3,gn=new Matrix3;class Plane{constructor(e=new three_module_Vector3(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,s){return this.normal.set(e,t,r),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const s=mn.subVectors(r,t).cross(fn.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,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 r=e.delta(mn),s=this.normal.dot(r);if(0===s)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/s;return o<0||o>1?null:t.copy(e.start).addScaledVector(r,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<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 r=t||gn.getNormalMatrix(e),s=this.coplanarPoint(mn).applyMatrix4(e),o=this.normal.applyMatrix3(r).normalize();return this.constant=-s.dot(o),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const _n=new Sphere,vn=new three_module_Vector3;class Frustum{constructor(e=new Plane,t=new Plane,r=new Plane,s=new Plane,o=new Plane,l=new Plane){this.planes=[e,t,r,s,o,l]}set(e,t,r,s,o,l){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(r),c[3].copy(s),c[4].copy(o),c[5].copy(l),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=2e3){const r=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],h=s[3],d=s[4],p=s[5],A=s[6],m=s[7],f=s[8],g=s[9],_=s[10],y=s[11],x=s[12],S=s[13],C=s[14],b=s[15];if(r[0].setComponents(h-o,m-d,y-f,b-x).normalize(),r[1].setComponents(h+o,m+d,y+f,b+x).normalize(),r[2].setComponents(h+l,m+p,y+g,b+S).normalize(),r[3].setComponents(h-l,m-p,y-g,b-S).normalize(),r[4].setComponents(h-c,m-A,y-_,b-C).normalize(),t===lt)r[5].setComponents(h+c,m+A,y+_,b+C).normalize();else{if(t!==ct)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);r[5].setComponents(c,A,_,C).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),_n.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),_n.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_n)}intersectsSprite(e){return _n.center.set(0,0,0),_n.radius=.7071067811865476,_n.applyMatrix4(e.matrixWorld),this.intersectsSphere(_n)}intersectsSphere(e){const t=this.planes,r=e.center,s=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(r)<s)return!1}return!0}intersectsBox(e){const t=this.planes;for(let r=0;r<6;r++){const s=t[r];if(vn.x=s.normal.x>0?e.max.x:e.min.x,vn.y=s.normal.y>0?e.max.y:e.min.y,vn.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(vn)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function WebGLAnimation(){let e=null,t=!1,r=null,s=null;function onAnimationFrame(t,o){r(t,o),s=e.requestAnimationFrame(onAnimationFrame)}return{start:function(){!0!==t&&null!==r&&(s=e.requestAnimationFrame(onAnimationFrame),t=!0)},stop:function(){e.cancelAnimationFrame(s),t=!1},setAnimationLoop:function(e){r=e},setContext:function(t){e=t}}}function WebGLAttributes(e,t){const r=t.isWebGL2,s=new WeakMap;return{get:function get(e){return e.isInterleavedBufferAttribute&&(e=e.data),s.get(e)},remove:function remove(t){t.isInterleavedBufferAttribute&&(t=t.data);const r=s.get(t);r&&(e.deleteBuffer(r.buffer),s.delete(t))},update:function update(t,o){if(t.isGLBufferAttribute){const e=s.get(t);return void((!e||e.version<t.version)&&s.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const l=s.get(t);if(void 0===l)s.set(t,function createBuffer(t,s){const o=t.array,l=t.usage,c=o.byteLength,h=e.createBuffer();let d;if(e.bindBuffer(s,h),e.bufferData(s,o,l),t.onUploadCallback(),o instanceof Float32Array)d=e.FLOAT;else if(o instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!r)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");d=e.HALF_FLOAT}else d=e.UNSIGNED_SHORT;else if(o instanceof Int16Array)d=e.SHORT;else if(o instanceof Uint32Array)d=e.UNSIGNED_INT;else if(o instanceof Int32Array)d=e.INT;else if(o instanceof Int8Array)d=e.BYTE;else if(o instanceof Uint8Array)d=e.UNSIGNED_BYTE;else{if(!(o instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+o);d=e.UNSIGNED_BYTE}return{buffer:h,type:d,bytesPerElement:o.BYTES_PER_ELEMENT,version:t.version,size:c}}(t,o));else if(l.version<t.version){if(l.size!==t.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function updateBuffer(t,s,o){const l=s.array,c=s._updateRange,h=s.updateRanges;if(e.bindBuffer(o,t),-1===c.count&&0===h.length&&e.bufferSubData(o,0,l),0!==h.length){for(let t=0,s=h.length;t<s;t++){const s=h[t];r?e.bufferSubData(o,s.start*l.BYTES_PER_ELEMENT,l,s.start,s.count):e.bufferSubData(o,s.start*l.BYTES_PER_ELEMENT,l.subarray(s.start,s.start+s.count))}s.clearUpdateRanges()}-1!==c.count&&(r?e.bufferSubData(o,c.offset*l.BYTES_PER_ELEMENT,l,c.offset,c.count):e.bufferSubData(o,c.offset*l.BYTES_PER_ELEMENT,l.subarray(c.offset,c.offset+c.count)),c.count=-1),s.onUploadCallback()}(l.buffer,t,o),l.version=t.version}}}}class PlaneGeometry extends three_module_BufferGeometry{constructor(e=1,t=1,r=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:s};const o=e/2,l=t/2,c=Math.floor(r),h=Math.floor(s),d=c+1,p=h+1,A=e/c,m=t/h,f=[],g=[],_=[],y=[];for(let e=0;e<p;e++){const t=e*m-l;for(let r=0;r<d;r++){const s=r*A-o;g.push(s,-t,0),_.push(0,0,1),y.push(r/c),y.push(1-e/h)}}for(let e=0;e<h;e++)for(let t=0;t<c;t++){const r=t+d*e,s=t+d*(e+1),o=t+1+d*(e+1),l=t+1+d*e;f.push(r,s,l),f.push(s,o,l)}this.setIndex(f),this.setAttribute("position",new three_module_Float32BufferAttribute(g,3)),this.setAttribute("normal",new three_module_Float32BufferAttribute(_,3)),this.setAttribute("uv",new three_module_Float32BufferAttribute(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new PlaneGeometry(e.width,e.height,e.widthSegments,e.heightSegments)}}const yn={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 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};\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_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\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_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 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:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( 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}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\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, 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 vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\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 vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\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\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\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 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, 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( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, 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:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\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, geometryPosition, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, geometryPosition, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\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 ], geometryNormal );\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( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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 nonPerturbedNormal = 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 = nonPerturbedNormal;\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_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\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\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\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}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn 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_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <cube_uv_reflection_fragment>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\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 <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\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 <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\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 + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\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 <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},En={common:{diffuse:{value:new Color(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Matrix3}},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 Matrix3}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Matrix3}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Matrix3},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Matrix3},normalScale:{value:new Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Matrix3},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Matrix3}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Matrix3}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Matrix3}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Color(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 Color(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0},uvTransform:{value:new Matrix3}},sprite:{diffuse:{value:new Color(16777215)},opacity:{value:1},center:{value:new Vector2(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}}},xn={basic:{uniforms:mergeUniforms([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.fog]),vertexShader:yn.meshbasic_vert,fragmentShader:yn.meshbasic_frag},lambert:{uniforms:mergeUniforms([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.fog,En.lights,{emissive:{value:new Color(0)}}]),vertexShader:yn.meshlambert_vert,fragmentShader:yn.meshlambert_frag},phong:{uniforms:mergeUniforms([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.fog,En.lights,{emissive:{value:new Color(0)},specular:{value:new Color(1118481)},shininess:{value:30}}]),vertexShader:yn.meshphong_vert,fragmentShader:yn.meshphong_frag},standard:{uniforms:mergeUniforms([En.common,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.roughnessmap,En.metalnessmap,En.fog,En.lights,{emissive:{value:new Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yn.meshphysical_vert,fragmentShader:yn.meshphysical_frag},toon:{uniforms:mergeUniforms([En.common,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.gradientmap,En.fog,En.lights,{emissive:{value:new Color(0)}}]),vertexShader:yn.meshtoon_vert,fragmentShader:yn.meshtoon_frag},matcap:{uniforms:mergeUniforms([En.common,En.bumpmap,En.normalmap,En.displacementmap,En.fog,{matcap:{value:null}}]),vertexShader:yn.meshmatcap_vert,fragmentShader:yn.meshmatcap_frag},points:{uniforms:mergeUniforms([En.points,En.fog]),vertexShader:yn.points_vert,fragmentShader:yn.points_frag},dashed:{uniforms:mergeUniforms([En.common,En.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yn.linedashed_vert,fragmentShader:yn.linedashed_frag},depth:{uniforms:mergeUniforms([En.common,En.displacementmap]),vertexShader:yn.depth_vert,fragmentShader:yn.depth_frag},normal:{uniforms:mergeUniforms([En.common,En.bumpmap,En.normalmap,En.displacementmap,{opacity:{value:1}}]),vertexShader:yn.meshnormal_vert,fragmentShader:yn.meshnormal_frag},sprite:{uniforms:mergeUniforms([En.sprite,En.fog]),vertexShader:yn.sprite_vert,fragmentShader:yn.sprite_frag},background:{uniforms:{uvTransform:{value:new Matrix3},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:yn.background_vert,fragmentShader:yn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:yn.backgroundCube_vert,fragmentShader:yn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yn.cube_vert,fragmentShader:yn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yn.equirect_vert,fragmentShader:yn.equirect_frag},distanceRGBA:{uniforms:mergeUniforms([En.common,En.displacementmap,{referencePosition:{value:new three_module_Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yn.distanceRGBA_vert,fragmentShader:yn.distanceRGBA_frag},shadow:{uniforms:mergeUniforms([En.lights,En.fog,{color:{value:new Color(0)},opacity:{value:1}}]),vertexShader:yn.shadow_vert,fragmentShader:yn.shadow_frag}};xn.physical={uniforms:mergeUniforms([xn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Matrix3},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Matrix3},clearcoatNormalScale:{value:new Vector2(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Matrix3},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Matrix3},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Matrix3},sheen:{value:0},sheenColor:{value:new Color(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Matrix3},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Matrix3},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Matrix3},transmissionSamplerSize:{value:new Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Matrix3},attenuationDistance:{value:0},attenuationColor:{value:new Color(0)},specularColor:{value:new Color(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Matrix3},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Matrix3},anisotropyVector:{value:new Vector2},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Matrix3}}]),vertexShader:yn.meshphysical_vert,fragmentShader:yn.meshphysical_frag};const Sn={r:0,b:0,g:0};function WebGLBackground(e,t,r,s,o,l,c){const h=new Color(0);let d,p,A=!0===l?0:1,m=null,f=0,g=null;function setClear(t,r){t.getRGB(Sn,getUnlitUniformColorSpace(e)),s.buffers.color.setClear(Sn.r,Sn.g,Sn.b,r,c)}return{getClearColor:function(){return h},setClearColor:function(e,t=1){h.set(e),A=t,setClear(h,A)},getClearAlpha:function(){return A},setClearAlpha:function(e){A=e,setClear(h,A)},render:function render(l,_){let y=!1,x=!0===_.isScene?_.background:null;if(x&&x.isTexture){x=(_.backgroundBlurriness>0?r:t).get(x)}null===x?setClear(h,A):x&&x.isColor&&(setClear(x,1),y=!0);const S=e.xr.getEnvironmentBlendMode();"additive"===S?s.buffers.color.setClear(0,0,0,1,c):"alpha-blend"===S&&s.buffers.color.setClear(0,0,0,0,c),(e.autoClear||y)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),x&&(x.isCubeTexture||x.mapping===K)?(void 0===p&&(p=new three_module_Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(xn.backgroundCube.uniforms),vertexShader:xn.backgroundCube.vertexShader,fragmentShader:xn.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),o.update(p)),p.material.uniforms.envMap.value=x,p.material.uniforms.flipEnvMap.value=x.isCubeTexture&&!1===x.isRenderTargetTexture?-1:1,p.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,p.material.toneMapped=Et.getTransfer(x.colorSpace)!==je,m===x&&f===x.version&&g===e.toneMapping||(p.material.needsUpdate=!0,m=x,f=x.version,g=e.toneMapping),p.layers.enableAll(),l.unshift(p,p.geometry,p.material,0,0,null)):x&&x.isTexture&&(void 0===d&&(d=new three_module_Mesh(new PlaneGeometry(2,2),new ShaderMaterial({name:"BackgroundMaterial",uniforms:cloneUniforms(xn.background.uniforms),vertexShader:xn.background.vertexShader,fragmentShader:xn.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),o.update(d)),d.material.uniforms.t2D.value=x,d.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,d.material.toneMapped=Et.getTransfer(x.colorSpace)!==je,!0===x.matrixAutoUpdate&&x.updateMatrix(),d.material.uniforms.uvTransform.value.copy(x.matrix),m===x&&f===x.version&&g===e.toneMapping||(d.material.needsUpdate=!0,m=x,f=x.version,g=e.toneMapping),d.layers.enableAll(),l.unshift(d,d.geometry,d.material,0,0,null))}}}function WebGLBindingStates(e,t,r,s){const o=e.getParameter(e.MAX_VERTEX_ATTRIBS),l=s.isWebGL2?null:t.get("OES_vertex_array_object"),c=s.isWebGL2||null!==l,h={},d=createBindingState(null);let p=d,A=!1;function bindVertexArrayObject(t){return s.isWebGL2?e.bindVertexArray(t):l.bindVertexArrayOES(t)}function deleteVertexArrayObject(t){return s.isWebGL2?e.deleteVertexArray(t):l.deleteVertexArrayOES(t)}function createBindingState(e){const t=[],r=[],s=[];for(let e=0;e<o;e++)t[e]=0,r[e]=0,s[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:s,object:e,attributes:{},index:null}}function initAttributes(){const e=p.newAttributes;for(let t=0,r=e.length;t<r;t++)e[t]=0}function enableAttribute(e){enableAttributeAndDivisor(e,0)}function enableAttributeAndDivisor(r,o){const l=p.newAttributes,c=p.enabledAttributes,h=p.attributeDivisors;if(l[r]=1,0===c[r]&&(e.enableVertexAttribArray(r),c[r]=1),h[r]!==o){(s.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[s.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](r,o),h[r]=o}}function disableUnusedAttributes(){const t=p.newAttributes,r=p.enabledAttributes;for(let s=0,o=r.length;s<o;s++)r[s]!==t[s]&&(e.disableVertexAttribArray(s),r[s]=0)}function vertexAttribPointer(t,r,s,o,l,c,h){!0===h?e.vertexAttribIPointer(t,r,s,l,c):e.vertexAttribPointer(t,r,s,o,l,c)}function reset(){resetDefaultState(),A=!0,p!==d&&(p=d,bindVertexArrayObject(p.object))}function resetDefaultState(){d.geometry=null,d.program=null,d.wireframe=!1}return{setup:function setup(o,d,m,f,g){let _=!1;if(c){const t=function getBindingState(t,r,o){const c=!0===o.wireframe;let d=h[t.id];void 0===d&&(d={},h[t.id]=d);let p=d[r.id];void 0===p&&(p={},d[r.id]=p);let A=p[c];void 0===A&&(A=createBindingState(function createVertexArrayObject(){return s.isWebGL2?e.createVertexArray():l.createVertexArrayOES()}()),p[c]=A);return A}(f,m,d);p!==t&&(p=t,bindVertexArrayObject(p.object)),_=function needsUpdate(e,t,r,s){const o=p.attributes,l=t.attributes;let c=0;const h=r.getAttributes();for(const t in h){if(h[t].location>=0){const r=o[t];let s=l[t];if(void 0===s&&("instanceMatrix"===t&&e.instanceMatrix&&(s=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(s=e.instanceColor)),void 0===r)return!0;if(r.attribute!==s)return!0;if(s&&r.data!==s.data)return!0;c++}}return p.attributesNum!==c||p.index!==s}(o,f,m,g),_&&function saveCache(e,t,r,s){const o={},l=t.attributes;let c=0;const h=r.getAttributes();for(const t in h){if(h[t].location>=0){let r=l[t];void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor));const s={};s.attribute=r,r&&r.data&&(s.data=r.data),o[t]=s,c++}}p.attributes=o,p.attributesNum=c,p.index=s}(o,f,m,g)}else{const e=!0===d.wireframe;p.geometry===f.id&&p.program===m.id&&p.wireframe===e||(p.geometry=f.id,p.program=m.id,p.wireframe=e,_=!0)}null!==g&&r.update(g,e.ELEMENT_ARRAY_BUFFER),(_||A)&&(A=!1,function setupVertexAttributes(o,l,c,h){if(!1===s.isWebGL2&&(o.isInstancedMesh||h.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;initAttributes();const d=h.attributes,p=c.getAttributes(),A=l.defaultAttributeValues;for(const t in p){const l=p[t];if(l.location>=0){let c=d[t];if(void 0===c&&("instanceMatrix"===t&&o.instanceMatrix&&(c=o.instanceMatrix),"instanceColor"===t&&o.instanceColor&&(c=o.instanceColor)),void 0!==c){const t=c.normalized,d=c.itemSize,p=r.get(c);if(void 0===p)continue;const A=p.buffer,m=p.type,f=p.bytesPerElement,g=!0===s.isWebGL2&&(m===e.INT||m===e.UNSIGNED_INT||c.gpuType===ce);if(c.isInterleavedBufferAttribute){const r=c.data,s=r.stride,p=c.offset;if(r.isInstancedInterleavedBuffer){for(let e=0;e<l.locationSize;e++)enableAttributeAndDivisor(l.location+e,r.meshPerAttribute);!0!==o.isInstancedMesh&&void 0===h._maxInstanceCount&&(h._maxInstanceCount=r.meshPerAttribute*r.count)}else for(let e=0;e<l.locationSize;e++)enableAttribute(l.location+e);e.bindBuffer(e.ARRAY_BUFFER,A);for(let e=0;e<l.locationSize;e++)vertexAttribPointer(l.location+e,d/l.locationSize,m,t,s*f,(p+d/l.locationSize*e)*f,g)}else{if(c.isInstancedBufferAttribute){for(let e=0;e<l.locationSize;e++)enableAttributeAndDivisor(l.location+e,c.meshPerAttribute);!0!==o.isInstancedMesh&&void 0===h._maxInstanceCount&&(h._maxInstanceCount=c.meshPerAttribute*c.count)}else for(let e=0;e<l.locationSize;e++)enableAttribute(l.location+e);e.bindBuffer(e.ARRAY_BUFFER,A);for(let e=0;e<l.locationSize;e++)vertexAttribPointer(l.location+e,d/l.locationSize,m,t,d*f,d/l.locationSize*e*f,g)}}else if(void 0!==A){const r=A[t];if(void 0!==r)switch(r.length){case 2:e.vertexAttrib2fv(l.location,r);break;case 3:e.vertexAttrib3fv(l.location,r);break;case 4:e.vertexAttrib4fv(l.location,r);break;default:e.vertexAttrib1fv(l.location,r)}}}}disableUnusedAttributes()}(o,d,m,f),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.get(g).buffer))},reset,resetDefaultState,dispose:function dispose(){reset();for(const e in h){const t=h[e];for(const e in t){const r=t[e];for(const e in r)deleteVertexArrayObject(r[e].object),delete r[e];delete t[e]}delete h[e]}},releaseStatesOfGeometry:function releaseStatesOfGeometry(e){if(void 0===h[e.id])return;const t=h[e.id];for(const e in t){const r=t[e];for(const e in r)deleteVertexArrayObject(r[e].object),delete r[e];delete t[e]}delete h[e.id]},releaseStatesOfProgram:function releaseStatesOfProgram(e){for(const t in h){const r=h[t];if(void 0===r[e.id])continue;const s=r[e.id];for(const e in s)deleteVertexArrayObject(s[e].object),delete s[e];delete r[e.id]}},initAttributes,enableAttribute,disableUnusedAttributes}}function WebGLBufferRenderer(e,t,r,s){const l=s.isWebGL2;let c;this.setMode=function setMode(e){c=e},this.render=function render(t,s){e.drawArrays(c,t,s),r.update(s,c,1)},this.renderInstances=function renderInstances(s,h,d){if(0===d)return;let p,A;if(l)p=e,A="drawArraysInstanced";else if(p=t.get("ANGLE_instanced_arrays"),A="drawArraysInstancedANGLE",null===p)return void o.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");p[A](c,s,h,d),r.update(h,c,d)},this.renderMultiDraw=function renderMultiDraw(e,s,o){if(0===o)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<o;t++)this.render(e[t],s[t]);else{l.multiDrawArraysWEBGL(c,e,0,s,0,o);let t=0;for(let e=0;e<o;e++)t+=s[e];r.update(t,c,1)}}}function WebGLCapabilities(e,t,r){let s;function getMaxPrecision(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&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 l="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let c=void 0!==r.precision?r.precision:"highp";const h=getMaxPrecision(c);h!==c&&(o.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=l||t.has("WEBGL_draw_buffers"),p=!0===r.logarithmicDepthBuffer,A=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),f=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),y=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),x=e.getParameter(e.MAX_VARYING_VECTORS),S=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),C=m>0,b=l||t.has("OES_texture_float");return{isWebGL2:l,drawBuffers:d,getMaxAnisotropy:function getMaxAnisotropy(){if(void 0!==s)return s;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");s=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s},getMaxPrecision,precision:c,logarithmicDepthBuffer:p,maxTextures:A,maxVertexTextures:m,maxTextureSize:f,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:S,vertexTextures:C,floatFragmentTextures:b,floatVertexTextures:C&&b,maxSamples:l?e.getParameter(e.MAX_SAMPLES):0}}function WebGLClipping(e){const t=this;let r=null,s=0,o=!1,l=!1;const c=new Plane,h=new Matrix3,d={value:null,needsUpdate:!1};function projectPlanes(e,r,s,o){const l=null!==e?e.length:0;let p=null;if(0!==l){if(p=d.value,!0!==o||null===p){const t=s+4*l,o=r.matrixWorldInverse;h.getNormalMatrix(o),(null===p||p.length<t)&&(p=new Float32Array(t));for(let t=0,r=s;t!==l;++t,r+=4)c.copy(e[t]).applyMatrix4(o,h),c.normal.toArray(p,r),p[r+3]=c.constant}d.value=p,d.needsUpdate=!0}return t.numPlanes=l,t.numIntersection=0,p}this.uniform=d,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const r=0!==e.length||t||0!==s||o;return o=t,s=e.length,r},this.beginShadows=function(){l=!0,projectPlanes(null)},this.endShadows=function(){l=!1},this.setGlobalState=function(e,t){r=projectPlanes(e,t,0)},this.setState=function(c,h,p){const A=c.clippingPlanes,m=c.clipIntersection,f=c.clipShadows,g=e.get(c);if(!o||null===A||0===A.length||l&&!f)l?projectPlanes(null):function resetGlobalState(){d.value!==r&&(d.value=r,d.needsUpdate=s>0);t.numPlanes=s,t.numIntersection=0}();else{const e=l?0:s,t=4*e;let o=g.clippingState||null;d.value=o,o=projectPlanes(A,h,t,p);for(let e=0;e!==t;++e)o[e]=r[e];g.clippingState=o,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=e}}}function WebGLCubeMaps(e){let t=new WeakMap;function mapTextureMapping(e,t){return t===X?e.mapping=q:t===Y&&(e.mapping=j),e}function onTextureDispose(e){const r=e.target;r.removeEventListener("dispose",onTextureDispose);const s=t.get(r);void 0!==s&&(t.delete(r),s.dispose())}return{get:function get(r){if(r&&r.isTexture){const s=r.mapping;if(s===X||s===Y){if(t.has(r)){return mapTextureMapping(t.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const o=new WebGLCubeRenderTarget(s.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener("dispose",onTextureDispose),mapTextureMapping(o.texture,r.mapping)}return null}}}return r},dispose:function dispose(){t=new WeakMap}}}class OrthographicCamera extends Camera{constructor(e=-1,t=1,r=1,s=-1,o=.1,l=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=s,this.near=o,this.far=l,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,r,s,o,l){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=r,this.view.offsetY=s,this.view.width=o,this.view.height=l,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),r=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let o=r-e,l=r+e,c=s+t,h=s-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=e*this.view.offsetX,l=o+e*this.view.width,c-=t*this.view.offsetY,h=c-t*this.view.height}this.projectionMatrix.makeOrthographic(o,l,c,h,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 Mn=[.125,.215,.35,.446,.526,.582],Cn=20,bn=new OrthographicCamera,wn=new Color;let In=null,Tn=0,Bn=0;const Rn=(1+Math.sqrt(5))/2,Ln=1/Rn,Dn=[new three_module_Vector3(1,1,1),new three_module_Vector3(-1,1,1),new three_module_Vector3(1,1,-1),new three_module_Vector3(-1,1,-1),new three_module_Vector3(0,Rn,Ln),new three_module_Vector3(0,Rn,-Ln),new three_module_Vector3(Ln,0,Rn),new three_module_Vector3(-Ln,0,Rn),new three_module_Vector3(Rn,Ln,0),new three_module_Vector3(-Rn,Ln,0)];class PMREMGenerator{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,r=.1,s=100){In=this._renderer.getRenderTarget(),Tn=this._renderer.getActiveCubeFace(),Bn=this._renderer.getActiveMipmapLevel(),this._setSize(256);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,r,s,o),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial(),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;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(In,Tn,Bn),e.scissorTest=!1,_setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===q||e.mapping===j?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),In=this._renderer.getRenderTarget(),Tn=this._renderer.getActiveCubeFace(),Bn=this._renderer.getActiveMipmapLevel();const r=t||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,r={magFilter:re,minFilter:re,generateMipmaps:!1,type:de,format:Ae,colorSpace:He,depthBuffer:!1},s=_createRenderTarget(e,t,r);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=_createRenderTarget(e,t,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function _createPlanes(e){const t=[],r=[],s=[];let o=e;const l=e-4+1+Mn.length;for(let c=0;c<l;c++){const l=Math.pow(2,o);r.push(l);let h=1/l;c>e-4?h=Mn[c-e+4-1]:0===c&&(h=0),s.push(h);const d=1/(l-2),p=-d,A=1+d,m=[p,p,A,p,A,A,p,p,A,A,p,A],f=6,g=6,_=3,y=2,x=1,S=new Float32Array(_*g*f),C=new Float32Array(y*g*f),b=new Float32Array(x*g*f);for(let e=0;e<f;e++){const t=e%3*2/3-1,r=e>2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0];S.set(s,_*g*e),C.set(m,y*g*e);const o=[e,e,e,e,e,e];b.set(o,x*g*e)}const I=new three_module_BufferGeometry;I.setAttribute("position",new three_module_BufferAttribute(S,_)),I.setAttribute("uv",new three_module_BufferAttribute(C,y)),I.setAttribute("faceIndex",new three_module_BufferAttribute(b,x)),t.push(I),o>4&&o--}return{lodPlanes:t,sizeLods:r,sigmas:s}}(s)),this._blurMaterial=function _getBlurShader(e,t,r){const s=new Float32Array(Cn),o=new three_module_Vector3(0,1,0),l=new ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:Cn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/r,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:s},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:o}},vertexShader:_getCommonVertexShader(),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 <cube_uv_reflection_fragment>\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:0,depthTest:!1,depthWrite:!1});return l}(s,e,t)}return s}_compileMaterial(e){const t=new three_module_Mesh(this._lodPlanes[0],e);this._renderer.compile(t,bn)}_sceneToCubeUV(e,t,r,s){const o=new PerspectiveCamera(90,1,t,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,p=h.toneMapping;h.getClearColor(wn),h.toneMapping=0,h.autoClear=!1;const A=new MeshBasicMaterial({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),m=new three_module_Mesh(new BoxGeometry,A);let f=!1;const g=e.background;g?g.isColor&&(A.color.copy(g),e.background=null,f=!0):(A.color.copy(wn),f=!0);for(let t=0;t<6;t++){const r=t%3;0===r?(o.up.set(0,l[t],0),o.lookAt(c[t],0,0)):1===r?(o.up.set(0,0,l[t]),o.lookAt(0,c[t],0)):(o.up.set(0,l[t],0),o.lookAt(0,0,c[t]));const d=this._cubeSize;_setViewport(s,r*d,t>2?d:0,d,d),h.setRenderTarget(s),f&&h.render(m,o),h.render(e,o)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=p,h.autoClear=d,e.background=g}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===q||e.mapping===j;s?(null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial());const o=s?this._cubemapMaterial:this._equirectMaterial,l=new three_module_Mesh(this._lodPlanes[0],o);o.uniforms.envMap.value=e;const c=this._cubeSize;_setViewport(t,0,0,3*c,2*c),r.setRenderTarget(t),r.render(l,bn)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const r=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),s=Dn[(t-1)%Dn.length];this._blur(e,t-1,t,r,s)}t.autoClear=r}_blur(e,t,r,s,o){const l=this._pingPongRenderTarget;this._halfBlur(e,l,t,r,s,"latitudinal",o),this._halfBlur(l,e,r,r,s,"longitudinal",o)}_halfBlur(e,t,r,s,l,c,h){const d=this._renderer,p=this._blurMaterial;"latitudinal"!==c&&"longitudinal"!==c&&o.error("blur direction must be either latitudinal or longitudinal!");const A=new three_module_Mesh(this._lodPlanes[s],p),m=p.uniforms,f=this._sizeLods[r]-1,g=isFinite(l)?Math.PI/(2*f):2*Math.PI/39,_=l/g,y=isFinite(l)?1+Math.floor(3*_):Cn;y>Cn&&o.warn(`sigmaRadians, ${l}, is too large and will clip, as it requested ${y} samples when the maximum is set to 20`);const x=[];let S=0;for(let e=0;e<Cn;++e){const t=e/_,r=Math.exp(-t*t/2);x.push(r),0===e?S+=r:e<y&&(S+=2*r)}for(let e=0;e<x.length;e++)x[e]=x[e]/S;m.envMap.value=e.texture,m.samples.value=y,m.weights.value=x,m.latitudinal.value="latitudinal"===c,h&&(m.poleAxis.value=h);const{_lodMax:C}=this;m.dTheta.value=g,m.mipInt.value=C-r;const b=this._sizeLods[s];_setViewport(t,3*b*(s>C-4?s-C+4:0),4*(this._cubeSize-b),3*b,2*b),d.setRenderTarget(t),d.render(A,bn)}}function _createRenderTarget(e,t,r){const s=new WebGLRenderTarget(e,t,r);return s.texture.mapping=K,s.texture.name="PMREM.cubeUv",s.scissorTest=!0,s}function _setViewport(e,t,r,s,o){e.viewport.set(t,r,s,o),e.scissor.set(t,r,s,o)}function _getEquirectMaterial(){return new ShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_getCommonVertexShader(),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 <common>\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:0,depthTest:!1,depthWrite:!1})}function _getCubemapMaterial(){return new ShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_getCommonVertexShader(),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:0,depthTest:!1,depthWrite:!1})}function _getCommonVertexShader(){return"\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"}function WebGLCubeUVMaps(e){let t=new WeakMap,r=null;function onTextureDispose(e){const r=e.target;r.removeEventListener("dispose",onTextureDispose);const s=t.get(r);void 0!==s&&(t.delete(r),s.dispose())}return{get:function get(s){if(s&&s.isTexture){const o=s.mapping,l=o===X||o===Y,c=o===q||o===j;if(l||c){if(s.isRenderTargetTexture&&!0===s.needsPMREMUpdate){s.needsPMREMUpdate=!1;let o=t.get(s);return null===r&&(r=new PMREMGenerator(e)),o=l?r.fromEquirectangular(s,o):r.fromCubemap(s,o),t.set(s,o),o.texture}if(t.has(s))return t.get(s).texture;{const o=s.image;if(l&&o&&o.height>0||c&&o&&function isCubeTextureComplete(e){let t=0;const r=6;for(let s=0;s<r;s++)void 0!==e[s]&&t++;return t===r}(o)){null===r&&(r=new PMREMGenerator(e));const o=l?r.fromEquirectangular(s):r.fromCubemap(s);return t.set(s,o),s.addEventListener("dispose",onTextureDispose),o.texture}return null}}}return s},dispose:function dispose(){t=new WeakMap,null!==r&&(r.dispose(),r=null)}}}function WebGLExtensions(e){const t={};function getExtension(r){if(void 0!==t[r])return t[r];let s;switch(r){case"WEBGL_depth_texture":s=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=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":s=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":s=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=e.getExtension(r)}return t[r]=s,s}return{has:function(e){return null!==getExtension(e)},init:function(e){e.isWebGL2?(getExtension("EXT_color_buffer_float"),getExtension("WEBGL_clip_cull_distance")):(getExtension("WEBGL_depth_texture"),getExtension("OES_texture_float"),getExtension("OES_texture_half_float"),getExtension("OES_texture_half_float_linear"),getExtension("OES_standard_derivatives"),getExtension("OES_element_index_uint"),getExtension("OES_vertex_array_object"),getExtension("ANGLE_instanced_arrays")),getExtension("OES_texture_float_linear"),getExtension("EXT_color_buffer_half_float"),getExtension("WEBGL_multisampled_render_to_texture")},get:function(e){const t=getExtension(e);return null===t&&o.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function WebGLGeometries(e,t,r,s){const o={},l=new WeakMap;function onGeometryDispose(e){const c=e.target;null!==c.index&&t.remove(c.index);for(const e in c.attributes)t.remove(c.attributes[e]);for(const e in c.morphAttributes){const r=c.morphAttributes[e];for(let e=0,s=r.length;e<s;e++)t.remove(r[e])}c.removeEventListener("dispose",onGeometryDispose),delete o[c.id];const h=l.get(c);h&&(t.remove(h),l.delete(c)),s.releaseStatesOfGeometry(c),!0===c.isInstancedBufferGeometry&&delete c._maxInstanceCount,r.memory.geometries--}function updateWireframeAttribute(e){const r=[],s=e.index,o=e.attributes.position;let c=0;if(null!==s){const e=s.array;c=s.version;for(let t=0,s=e.length;t<s;t+=3){const s=e[t+0],o=e[t+1],l=e[t+2];r.push(s,o,o,l,l,s)}}else{if(void 0===o)return;{const e=o.array;c=o.version;for(let t=0,s=e.length/3-1;t<s;t+=3){const e=t+0,s=t+1,o=t+2;r.push(e,s,s,o,o,e)}}}const h=new(arrayNeedsUint32(r)?Uint32BufferAttribute:Uint16BufferAttribute)(r,1);h.version=c;const d=l.get(e);d&&t.remove(d),l.set(e,h)}return{get:function get(e,t){return!0===o[t.id]||(t.addEventListener("dispose",onGeometryDispose),o[t.id]=!0,r.memory.geometries++),t},update:function update(r){const s=r.attributes;for(const r in s)t.update(s[r],e.ARRAY_BUFFER);const o=r.morphAttributes;for(const r in o){const s=o[r];for(let r=0,o=s.length;r<o;r++)t.update(s[r],e.ARRAY_BUFFER)}},getWireframeAttribute:function getWireframeAttribute(e){const t=l.get(e);if(t){const r=e.index;null!==r&&t.version<r.version&&updateWireframeAttribute(e)}else updateWireframeAttribute(e);return l.get(e)}}}function WebGLIndexedBufferRenderer(e,t,r,s){const l=s.isWebGL2;let c,h,d;this.setMode=function setMode(e){c=e},this.setIndex=function setIndex(e){h=e.type,d=e.bytesPerElement},this.render=function render(t,s){e.drawElements(c,s,h,t*d),r.update(s,c,1)},this.renderInstances=function renderInstances(s,p,A){if(0===A)return;let m,f;if(l)m=e,f="drawElementsInstanced";else if(m=t.get("ANGLE_instanced_arrays"),f="drawElementsInstancedANGLE",null===m)return void o.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");m[f](c,p,h,s*d,A),r.update(p,c,A)},this.renderMultiDraw=function renderMultiDraw(e,s,o){if(0===o)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<o;t++)this.render(e[t]/d,s[t]);else{l.multiDrawElementsWEBGL(c,s,0,h,e,0,o);let t=0;for(let e=0;e<o;e++)t+=s[e];r.update(t,c,1)}}}function WebGLInfo(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function reset(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function update(r,s,l){switch(t.calls++,s){case e.TRIANGLES:t.triangles+=l*(r/3);break;case e.LINES:t.lines+=l*(r/2);break;case e.LINE_STRIP:t.lines+=l*(r-1);break;case e.LINE_LOOP:t.lines+=l*r;break;case e.POINTS:t.points+=l*r;break;default:o.error("THREE.WebGLInfo: Unknown draw mode:",s)}}}}function numericalSort(e,t){return e[0]-t[0]}function absNumericalSort(e,t){return Math.abs(t[1])-Math.abs(e[1])}function WebGLMorphtargets(e,t,r){const s={},o=new Float32Array(8),l=new WeakMap,c=new Vector4,h=[];for(let e=0;e<8;e++)h[e]=[e,0];return{update:function update(d,p,A){const m=d.morphTargetInfluences;if(!0===t.isWebGL2){const f=p.morphAttributes.position||p.morphAttributes.normal||p.morphAttributes.color,g=void 0!==f?f.length:0;let _=l.get(p);if(void 0===_||_.count!==g){void 0!==_&&_.texture.dispose();const S=void 0!==p.morphAttributes.position,C=void 0!==p.morphAttributes.normal,b=void 0!==p.morphAttributes.color,I=p.morphAttributes.position||[],T=p.morphAttributes.normal||[],B=p.morphAttributes.color||[];let U=0;!0===S&&(U=1),!0===C&&(U=2),!0===b&&(U=3);let F=p.attributes.position.count*U,O=1;F>t.maxTextureSize&&(O=Math.ceil(F/t.maxTextureSize),F=t.maxTextureSize);const Q=new Float32Array(F*O*4*g),G=new DataArrayTexture(Q,F,O,g);G.type=ue,G.needsUpdate=!0;const W=4*U;for(let q=0;q<g;q++){const j=I[q],X=T[q],Y=B[q],K=F*O*4*q;for(let J=0;J<j.count;J++){const $=J*W;!0===S&&(c.fromBufferAttribute(j,J),Q[K+$+0]=c.x,Q[K+$+1]=c.y,Q[K+$+2]=c.z,Q[K+$+3]=0),!0===C&&(c.fromBufferAttribute(X,J),Q[K+$+4]=c.x,Q[K+$+5]=c.y,Q[K+$+6]=c.z,Q[K+$+7]=0),!0===b&&(c.fromBufferAttribute(Y,J),Q[K+$+8]=c.x,Q[K+$+9]=c.y,Q[K+$+10]=c.z,Q[K+$+11]=4===Y.itemSize?c.w:1)}}function disposeTexture(){G.dispose(),l.delete(p),p.removeEventListener("dispose",disposeTexture)}_={count:g,texture:G,size:new Vector2(F,O)},l.set(p,_),p.addEventListener("dispose",disposeTexture)}let y=0;for(let ee=0;ee<m.length;ee++)y+=m[ee];const x=p.morphTargetsRelative?1:1-y;A.getUniforms().setValue(e,"morphTargetBaseInfluence",x),A.getUniforms().setValue(e,"morphTargetInfluences",m),A.getUniforms().setValue(e,"morphTargetsTexture",_.texture,r),A.getUniforms().setValue(e,"morphTargetsTextureSize",_.size)}else{const te=void 0===m?0:m.length;let ie=s[p.id];if(void 0===ie||ie.length!==te){ie=[];for(let oe=0;oe<te;oe++)ie[oe]=[oe,0];s[p.id]=ie}for(let le=0;le<te;le++){const ce=ie[le];ce[0]=le,ce[1]=m[le]}ie.sort(absNumericalSort);for(let he=0;he<8;he++)he<te&&ie[he][1]?(h[he][0]=ie[he][0],h[he][1]=ie[he][1]):(h[he][0]=Number.MAX_SAFE_INTEGER,h[he][1]=0);h.sort(numericalSort);const ne=p.morphAttributes.position,re=p.morphAttributes.normal;let se=0;for(let de=0;de<8;de++){const pe=h[de],Ae=pe[0],me=pe[1];Ae!==Number.MAX_SAFE_INTEGER&&me?(ne&&p.getAttribute("morphTarget"+de)!==ne[Ae]&&p.setAttribute("morphTarget"+de,ne[Ae]),re&&p.getAttribute("morphNormal"+de)!==re[Ae]&&p.setAttribute("morphNormal"+de,re[Ae]),o[de]=me,se+=me):(ne&&!0===p.hasAttribute("morphTarget"+de)&&p.deleteAttribute("morphTarget"+de),re&&!0===p.hasAttribute("morphNormal"+de)&&p.deleteAttribute("morphNormal"+de),o[de]=0)}const ae=p.morphTargetsRelative?1:1-se;A.getUniforms().setValue(e,"morphTargetBaseInfluence",ae),A.getUniforms().setValue(e,"morphTargetInfluences",o)}}}}function WebGLObjects(e,t,r,s){let o=new WeakMap;function onInstancedMeshDispose(e){const t=e.target;t.removeEventListener("dispose",onInstancedMeshDispose),r.remove(t.instanceMatrix),null!==t.instanceColor&&r.remove(t.instanceColor)}return{update:function update(l){const c=s.render.frame,h=l.geometry,d=t.get(l,h);if(o.get(d)!==c&&(t.update(d),o.set(d,c)),l.isInstancedMesh&&(!1===l.hasEventListener("dispose",onInstancedMeshDispose)&&l.addEventListener("dispose",onInstancedMeshDispose),o.get(l)!==c&&(r.update(l.instanceMatrix,e.ARRAY_BUFFER),null!==l.instanceColor&&r.update(l.instanceColor,e.ARRAY_BUFFER),o.set(l,c))),l.isSkinnedMesh){const e=l.skeleton;o.get(e)!==c&&(e.update(),o.set(e,c))}return d},dispose:function dispose(){o=new WeakMap}}}class DepthTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d,p){if((p=void 0!==p?p:me)!==me&&p!==fe)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&p===me&&(r=he),void 0===r&&p===fe&&(r=pe),super(null,s,o,l,c,h,p,r,d),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==c?c:te,this.minFilter=void 0!==h?h:te,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}}const Un=new Texture,Pn=new DepthTexture(1,1);Pn.compareFunction=515;const Fn=new DataArrayTexture,Nn=new Data3DTexture,On=new CubeTexture,Qn=[],kn=[],Gn=new Float32Array(16),Vn=new Float32Array(9),Hn=new Float32Array(4);function flatten(e,t,r){const s=e[0];if(s<=0||s>0)return e;const o=t*r;let l=Qn[o];if(void 0===l&&(l=new Float32Array(o),Qn[o]=l),0!==t){s.toArray(l,0);for(let s=1,o=0;s!==t;++s)o+=r,e[s].toArray(l,o)}return l}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(let r=0,s=e.length;r<s;r++)if(e[r]!==t[r])return!1;return!0}function copyArray(e,t){for(let r=0,s=t.length;r<s;r++)e[r]=t[r]}function allocTexUnits(e,t){let r=kn[t];void 0===r&&(r=new Int32Array(t),kn[t]=r);for(let s=0;s!==t;++s)r[s]=e.allocateTextureUnit();return r}function setValueV1f(e,t){const r=this.cache;r[0]!==t&&(e.uniform1f(this.addr,t),r[0]=t)}function setValueV2f(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y);else{if(arraysEqual(r,t))return;e.uniform2fv(this.addr,t),copyArray(r,t)}}function setValueV3f(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z);else if(void 0!==t.r)r[0]===t.r&&r[1]===t.g&&r[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),r[0]=t.r,r[1]=t.g,r[2]=t.b);else{if(arraysEqual(r,t))return;e.uniform3fv(this.addr,t),copyArray(r,t)}}function setValueV4f(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w);else{if(arraysEqual(r,t))return;e.uniform4fv(this.addr,t),copyArray(r,t)}}function setValueM2(e,t){const r=this.cache,s=t.elements;if(void 0===s){if(arraysEqual(r,t))return;e.uniformMatrix2fv(this.addr,!1,t),copyArray(r,t)}else{if(arraysEqual(r,s))return;Hn.set(s),e.uniformMatrix2fv(this.addr,!1,Hn),copyArray(r,s)}}function setValueM3(e,t){const r=this.cache,s=t.elements;if(void 0===s){if(arraysEqual(r,t))return;e.uniformMatrix3fv(this.addr,!1,t),copyArray(r,t)}else{if(arraysEqual(r,s))return;Vn.set(s),e.uniformMatrix3fv(this.addr,!1,Vn),copyArray(r,s)}}function setValueM4(e,t){const r=this.cache,s=t.elements;if(void 0===s){if(arraysEqual(r,t))return;e.uniformMatrix4fv(this.addr,!1,t),copyArray(r,t)}else{if(arraysEqual(r,s))return;Gn.set(s),e.uniformMatrix4fv(this.addr,!1,Gn),copyArray(r,s)}}function setValueV1i(e,t){const r=this.cache;r[0]!==t&&(e.uniform1i(this.addr,t),r[0]=t)}function setValueV2i(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y);else{if(arraysEqual(r,t))return;e.uniform2iv(this.addr,t),copyArray(r,t)}}function setValueV3i(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z);else{if(arraysEqual(r,t))return;e.uniform3iv(this.addr,t),copyArray(r,t)}}function setValueV4i(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w);else{if(arraysEqual(r,t))return;e.uniform4iv(this.addr,t),copyArray(r,t)}}function setValueV1ui(e,t){const r=this.cache;r[0]!==t&&(e.uniform1ui(this.addr,t),r[0]=t)}function setValueV2ui(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y);else{if(arraysEqual(r,t))return;e.uniform2uiv(this.addr,t),copyArray(r,t)}}function setValueV3ui(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z);else{if(arraysEqual(r,t))return;e.uniform3uiv(this.addr,t),copyArray(r,t)}}function setValueV4ui(e,t){const r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w);else{if(arraysEqual(r,t))return;e.uniform4uiv(this.addr,t),copyArray(r,t)}}function setValueT1(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o);const l=this.type===e.SAMPLER_2D_SHADOW?Pn:Un;r.setTexture2D(t||l,o)}function setValueT3D1(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o),r.setTexture3D(t||Nn,o)}function setValueT6(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o),r.setTextureCube(t||On,o)}function setValueT2DArray1(e,t,r){const s=this.cache,o=r.allocateTextureUnit();s[0]!==o&&(e.uniform1i(this.addr,o),s[0]=o),r.setTexture2DArray(t||Fn,o)}function setValueV1fArray(e,t){e.uniform1fv(this.addr,t)}function setValueV2fArray(e,t){const r=flatten(t,this.size,2);e.uniform2fv(this.addr,r)}function setValueV3fArray(e,t){const r=flatten(t,this.size,3);e.uniform3fv(this.addr,r)}function setValueV4fArray(e,t){const r=flatten(t,this.size,4);e.uniform4fv(this.addr,r)}function setValueM2Array(e,t){const r=flatten(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,r)}function setValueM3Array(e,t){const r=flatten(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,r)}function setValueM4Array(e,t){const r=flatten(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,r)}function setValueV1iArray(e,t){e.uniform1iv(this.addr,t)}function setValueV2iArray(e,t){e.uniform2iv(this.addr,t)}function setValueV3iArray(e,t){e.uniform3iv(this.addr,t)}function setValueV4iArray(e,t){e.uniform4iv(this.addr,t)}function setValueV1uiArray(e,t){e.uniform1uiv(this.addr,t)}function setValueV2uiArray(e,t){e.uniform2uiv(this.addr,t)}function setValueV3uiArray(e,t){e.uniform3uiv(this.addr,t)}function setValueV4uiArray(e,t){e.uniform4uiv(this.addr,t)}function setValueT1Array(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTexture2D(t[e]||Un,l[e])}function setValueT3DArray(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTexture3D(t[e]||Nn,l[e])}function setValueT6Array(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTextureCube(t[e]||On,l[e])}function setValueT2DArrayArray(e,t,r){const s=this.cache,o=t.length,l=allocTexUnits(r,o);arraysEqual(s,l)||(e.uniform1iv(this.addr,l),copyArray(s,l));for(let e=0;e!==o;++e)r.setTexture2DArray(t[e]||Fn,l[e])}class SingleUniform{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.setValue=function getSingularSetter(e){switch(e){case 5126:return setValueV1f;case 35664:return setValueV2f;case 35665:return setValueV3f;case 35666:return setValueV4f;case 35674:return setValueM2;case 35675:return setValueM3;case 35676:return setValueM4;case 5124:case 35670:return setValueV1i;case 35667:case 35671:return setValueV2i;case 35668:case 35672:return setValueV3i;case 35669:case 35673:return setValueV4i;case 5125:return setValueV1ui;case 36294:return setValueV2ui;case 36295:return setValueV3ui;case 36296:return setValueV4ui;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1;case 35679:case 36299:case 36307:return setValueT3D1;case 35680:case 36300:case 36308:case 36293:return setValueT6;case 36289:case 36303:case 36311:case 36292:return setValueT2DArray1}}(t.type)}}class PureArrayUniform{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function getPureArraySetter(e){switch(e){case 5126:return setValueV1fArray;case 35664:return setValueV2fArray;case 35665:return setValueV3fArray;case 35666:return setValueV4fArray;case 35674:return setValueM2Array;case 35675:return setValueM3Array;case 35676:return setValueM4Array;case 5124:case 35670:return setValueV1iArray;case 35667:case 35671:return setValueV2iArray;case 35668:case 35672:return setValueV3iArray;case 35669:case 35673:return setValueV4iArray;case 5125:return setValueV1uiArray;case 36294:return setValueV2uiArray;case 36295:return setValueV3uiArray;case 36296:return setValueV4uiArray;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1Array;case 35679:case 36299:case 36307:return setValueT3DArray;case 35680:case 36300:case 36308:case 36293:return setValueT6Array;case 36289:case 36303:case 36311:case 36292:return setValueT2DArrayArray}}(t.type)}}class StructuredUniform{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,r){const s=this.seq;for(let o=0,l=s.length;o!==l;++o){const l=s[o];l.setValue(e,t[l.id],r)}}}const zn=/(\w+)(\])?(\[|\.)?/g;function addUniform(e,t){e.seq.push(t),e.map[t.id]=t}function parseUniform(e,t,r){const s=e.name,o=s.length;for(zn.lastIndex=0;;){const l=zn.exec(s),c=zn.lastIndex;let h=l[1];const d="]"===l[2],p=l[3];if(d&&(h|=0),void 0===p||"["===p&&c+2===o){addUniform(r,void 0===p?new SingleUniform(h,e,t):new PureArrayUniform(h,e,t));break}{let e=r.map[h];void 0===e&&(e=new StructuredUniform(h),addUniform(r,e)),r=e}}}class WebGLUniforms{constructor(e,t){this.seq=[],this.map={};const r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;++s){const r=e.getActiveUniform(t,s);parseUniform(r,e.getUniformLocation(t,r.name),this)}}setValue(e,t,r,s){const o=this.map[t];void 0!==o&&o.setValue(e,r,s)}setOptional(e,t,r){const s=t[r];void 0!==s&&this.setValue(e,r,s)}static upload(e,t,r,s){for(let o=0,l=t.length;o!==l;++o){const l=t[o],c=r[l.id];!1!==c.needsUpdate&&l.setValue(e,c.value,s)}}static seqWithValue(e,t){const r=[];for(let s=0,o=e.length;s!==o;++s){const o=e[s];o.id in t&&r.push(o)}return r}}function WebGLShader(e,t,r){const s=e.createShader(t);return e.shaderSource(s,r),e.compileShader(s),s}let Wn=0;function getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),o=e.getShaderInfoLog(t).trim();if(s&&""===o)return"";const l=/ERROR: 0:(\d+)/.exec(o);if(l){const s=parseInt(l[1]);return r.toUpperCase()+"\n\n"+o+"\n\n"+function handleSource(e,t){const r=e.split("\n"),s=[],o=Math.max(t-6,0),l=Math.min(t+6,r.length);for(let e=o;e<l;e++){const o=e+1;s.push(`${o===t?">":" "} ${o}: ${r[e]}`)}return s.join("\n")}(e.getShaderSource(t),s)}return o}function getTexelEncodingFunction(e,t){const r=function getEncodingComponents(e){const t=Et.getPrimaries(Et.workingColorSpace),r=Et.getPrimaries(e);let s;switch(t===r?s="":t===Ye&&r===Xe?s="LinearDisplayP3ToLinearSRGB":t===Xe&&r===Ye&&(s="LinearSRGBToLinearDisplayP3"),e){case He:case We:return[s,"LinearTransferOETF"];case Ve:case ze:return[s,"sRGBTransferOETF"];default:return o.warn("THREE.WebGLProgram: Unsupported color space:",e),[s,"LinearTransferOETF"]}}(t);return`vec4 ${e}( vec4 value ) { return ${r[0]}( ${r[1]}( value ) ); }`}function getToneMappingFunction(e,t){let r;switch(t){case 1:r="Linear";break;case 2:r="Reinhard";break;case 3:r="OptimizedCineon";break;case 4:r="ACESFilmic";break;case 6:r="AgX";break;case 5:r="Custom";break;default:o.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),r="Linear"}return"vec3 "+e+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}function filterEmptyLine(e){return""!==e}function replaceLightNums(e,t){const r=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,r).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 replaceClippingPlaneNums(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const qn=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(e){return e.replace(qn,includeReplacer)}const jn=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function includeReplacer(e,t){let r=yn[t];if(void 0===r){const e=jn.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");r=yn[e],o.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return resolveIncludes(r)}const Xn=/#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 unrollLoops(e){return e.replace(Xn,loopReplacer)}function loopReplacer(e,t,r,s){let o="";for(let e=parseInt(t);e<parseInt(r);e++)o+=s.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return o}function generatePrecision(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function WebGLProgram(e,t,r,s){const l=e.getContext(),c=r.defines;let h=r.vertexShader,d=r.fragmentShader;const p=function generateShadowMapTypeDefine(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(r),A=function generateEnvMapTypeDefine(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case q:case j:t="ENVMAP_TYPE_CUBE";break;case K:t="ENVMAP_TYPE_CUBE_UV"}return t}(r),m=function generateEnvMapModeDefine(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===j&&(t="ENVMAP_MODE_REFRACTION");return t}(r),f=function generateEnvMapBlendingDefine(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(r),g=function generateCubeUVSize(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const r=Math.log2(t)-2,s=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,r),112)),texelHeight:s,maxMip:r}}(r),_=r.isWebGL2?"":function generateExtensions(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(filterEmptyLine).join("\n")}(r),y=function generateVertexExtensions(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(filterEmptyLine).join("\n")}(r),x=function generateDefines(e){const t=[];for(const r in e){const s=e[r];!1!==s&&t.push("#define "+r+" "+s)}return t.join("\n")}(c),S=l.createProgram();let C,b,I=r.glslVersion?"#version "+r.glslVersion+"\n":"";r.isRawShaderMaterial?(C=["#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,x].filter(filterEmptyLine).join("\n"),C.length>0&&(C+="\n"),b=[_,"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,x].filter(filterEmptyLine).join("\n"),b.length>0&&(b+="\n")):(C=[generatePrecision(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,x,r.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",r.batching?"#define USE_BATCHING":"",r.instancing?"#define USE_INSTANCING":"",r.instancingColor?"#define USE_INSTANCING_COLOR":"",r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+m:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.displacementMap?"#define USE_DISPLACEMENTMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.mapUv?"#define MAP_UV "+r.mapUv:"",r.alphaMapUv?"#define ALPHAMAP_UV "+r.alphaMapUv:"",r.lightMapUv?"#define LIGHTMAP_UV "+r.lightMapUv:"",r.aoMapUv?"#define AOMAP_UV "+r.aoMapUv:"",r.emissiveMapUv?"#define EMISSIVEMAP_UV "+r.emissiveMapUv:"",r.bumpMapUv?"#define BUMPMAP_UV "+r.bumpMapUv:"",r.normalMapUv?"#define NORMALMAP_UV "+r.normalMapUv:"",r.displacementMapUv?"#define DISPLACEMENTMAP_UV "+r.displacementMapUv:"",r.metalnessMapUv?"#define METALNESSMAP_UV "+r.metalnessMapUv:"",r.roughnessMapUv?"#define ROUGHNESSMAP_UV "+r.roughnessMapUv:"",r.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+r.anisotropyMapUv:"",r.clearcoatMapUv?"#define CLEARCOATMAP_UV "+r.clearcoatMapUv:"",r.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+r.clearcoatNormalMapUv:"",r.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+r.clearcoatRoughnessMapUv:"",r.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+r.iridescenceMapUv:"",r.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+r.iridescenceThicknessMapUv:"",r.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+r.sheenColorMapUv:"",r.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+r.sheenRoughnessMapUv:"",r.specularMapUv?"#define SPECULARMAP_UV "+r.specularMapUv:"",r.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+r.specularColorMapUv:"",r.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+r.specularIntensityMapUv:"",r.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+r.transmissionMapUv:"",r.thicknessMapUv?"#define THICKNESSMAP_UV "+r.thicknessMapUv:"",r.vertexTangents&&!1===r.flatShading?"#define USE_TANGENT":"",r.vertexColors?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&!1===r.flatShading?"#define USE_MORPHNORMALS":"",r.morphColors&&r.isWebGL2?"#define USE_MORPHCOLORS":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+r.morphTextureStride:"",r.morphTargetsCount>0&&r.isWebGL2?"#define MORPHTARGETS_COUNT "+r.morphTargetsCount:"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+p:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.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(filterEmptyLine).join("\n"),b=[_,generatePrecision(r),"#define SHADER_TYPE "+r.shaderType,"#define SHADER_NAME "+r.shaderName,x,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.matcap?"#define USE_MATCAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+A:"",r.envMap?"#define "+m:"",r.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",r.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.anisotropy?"#define USE_ANISOTROPY":"",r.anisotropyMap?"#define USE_ANISOTROPYMAP":"",r.clearcoat?"#define USE_CLEARCOAT":"",r.clearcoatMap?"#define USE_CLEARCOATMAP":"",r.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",r.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",r.iridescence?"#define USE_IRIDESCENCE":"",r.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",r.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",r.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.alphaTest?"#define USE_ALPHATEST":"",r.alphaHash?"#define USE_ALPHAHASH":"",r.sheen?"#define USE_SHEEN":"",r.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",r.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",r.transmission?"#define USE_TRANSMISSION":"",r.transmissionMap?"#define USE_TRANSMISSIONMAP":"",r.thicknessMap?"#define USE_THICKNESSMAP":"",r.vertexTangents&&!1===r.flatShading?"#define USE_TANGENT":"",r.vertexColors||r.instancingColor?"#define USE_COLOR":"",r.vertexAlphas?"#define USE_COLOR_ALPHA":"",r.vertexUv1s?"#define USE_UV1":"",r.vertexUv2s?"#define USE_UV2":"",r.vertexUv3s?"#define USE_UV3":"",r.pointsUvs?"#define USE_POINTS_UV":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"",r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+p:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.numLightProbes>0?"#define USE_LIGHT_PROBES":"",r.useLegacyLights?"#define LEGACY_LIGHTS":"",r.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&r.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==r.toneMapping?"#define TONE_MAPPING":"",0!==r.toneMapping?yn.tonemapping_pars_fragment:"",0!==r.toneMapping?getToneMappingFunction("toneMapping",r.toneMapping):"",r.dithering?"#define DITHERING":"",r.opaque?"#define OPAQUE":"",yn.colorspace_pars_fragment,getTexelEncodingFunction("linearToOutputTexel",r.outputColorSpace),r.useDepthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(filterEmptyLine).join("\n")),h=resolveIncludes(h),h=replaceLightNums(h,r),h=replaceClippingPlaneNums(h,r),d=resolveIncludes(d),d=replaceLightNums(d,r),d=replaceClippingPlaneNums(d,r),h=unrollLoops(h),d=unrollLoops(d),r.isWebGL2&&!0!==r.isRawShaderMaterial&&(I="#version 300 es\n",C=[y,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+C,b=["precision mediump sampler2DArray;","#define varying in",r.glslVersion===at?"":"layout(location = 0) out highp vec4 pc_fragColor;",r.glslVersion===at?"":"#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"+b);const T=I+C+h,B=I+b+d,U=WebGLShader(l,l.VERTEX_SHADER,T),F=WebGLShader(l,l.FRAGMENT_SHADER,B);function onFirstUse(t){if(e.debug.checkShaderErrors){const r=l.getProgramInfoLog(S).trim(),s=l.getShaderInfoLog(U).trim(),c=l.getShaderInfoLog(F).trim();let h=!0,d=!0;if(!1===l.getProgramParameter(S,l.LINK_STATUS))if(h=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(l,S,U,F);else{const e=getShaderErrors(l,U,"vertex"),t=getShaderErrors(l,F,"fragment");o.error("THREE.WebGLProgram: Shader Error "+l.getError()+" - VALIDATE_STATUS "+l.getProgramParameter(S,l.VALIDATE_STATUS)+"\n\nProgram Info Log: "+r+"\n"+e+"\n"+t)}else""!==r?o.warn("THREE.WebGLProgram: Program Info Log:",r):""!==s&&""!==c||(d=!1);d&&(t.diagnostics={runnable:h,programLog:r,vertexShader:{log:s,prefix:C},fragmentShader:{log:c,prefix:b}})}l.deleteShader(U),l.deleteShader(F),O=new WebGLUniforms(l,S),Q=function fetchAttributeLocations(e,t){const r={},s=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){const s=e.getActiveAttrib(t,o),l=s.name;let c=1;s.type===e.FLOAT_MAT2&&(c=2),s.type===e.FLOAT_MAT3&&(c=3),s.type===e.FLOAT_MAT4&&(c=4),r[l]={type:s.type,location:e.getAttribLocation(t,l),locationSize:c}}return r}(l,S)}let O,Q;l.attachShader(S,U),l.attachShader(S,F),void 0!==r.index0AttributeName?l.bindAttribLocation(S,0,r.index0AttributeName):!0===r.morphTargets&&l.bindAttribLocation(S,0,"position"),l.linkProgram(S),this.getUniforms=function(){return void 0===O&&onFirstUse(this),O},this.getAttributes=function(){return void 0===Q&&onFirstUse(this),Q};let G=!1===r.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===G&&(G=l.getProgramParameter(S,37297)),G},this.destroy=function(){s.releaseStatesOfProgram(this),l.deleteProgram(S),this.program=void 0},this.type=r.shaderType,this.name=r.shaderName,this.id=Wn++,this.cacheKey=t,this.usedTimes=1,this.program=S,this.vertexShader=U,this.fragmentShader=F,this}let Yn=0;class WebGLShaderCache{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,s=this._getShaderStage(t),o=this._getShaderStage(r),l=this._getShaderCacheForMaterial(e);return!1===l.has(s)&&(l.add(s),s.usedTimes++),!1===l.has(o)&&(l.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return void 0===r&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return void 0===r&&(r=new WebGLShaderStage(e),t.set(e,r)),r}}class WebGLShaderStage{constructor(e){this.id=Yn++,this.code=e,this.usedTimes=0}}function WebGLPrograms(e,t,r,s,l,c,h){const d=new Layers,p=new WebGLShaderCache,A=[],m=l.isWebGL2,f=l.logarithmicDepthBuffer,g=l.vertexTextures;let _=l.precision;const y={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function getChannel(e){return 0===e?"uv":`uv${e}`}return{getParameters:function getParameters(c,d,A,x,S){const C=x.fog,b=S.geometry,I=c.isMeshStandardMaterial?x.environment:null,T=(c.isMeshStandardMaterial?r:t).get(c.envMap||I),B=T&&T.mapping===K?T.image.height:null,U=y[c.type];null!==c.precision&&(_=l.getMaxPrecision(c.precision),_!==c.precision&&o.warn("THREE.WebGLProgram.getParameters:",c.precision,"not supported, using",_,"instead."));const F=b.morphAttributes.position||b.morphAttributes.normal||b.morphAttributes.color,O=void 0!==F?F.length:0;let Q,G,W,q,j=0;if(void 0!==b.morphAttributes.position&&(j=1),void 0!==b.morphAttributes.normal&&(j=2),void 0!==b.morphAttributes.color&&(j=3),U){const e=xn[U];Q=e.vertexShader,G=e.fragmentShader}else Q=c.vertexShader,G=c.fragmentShader,p.update(c),W=p.getVertexShaderID(c),q=p.getFragmentShaderID(c);const X=e.getRenderTarget(),Y=!0===S.isInstancedMesh,J=!0===S.isBatchedMesh,$=!!c.map,ee=!!c.matcap,te=!!T,ie=!!c.aoMap,ne=!!c.lightMap,re=!!c.bumpMap,se=!!c.normalMap,ae=!!c.displacementMap,oe=!!c.emissiveMap,le=!!c.metalnessMap,ce=!!c.roughnessMap,he=c.anisotropy>0,ue=c.clearcoat>0,de=c.iridescence>0,pe=c.sheen>0,Ae=c.transmission>0,me=he&&!!c.anisotropyMap,fe=ue&&!!c.clearcoatMap,ge=ue&&!!c.clearcoatNormalMap,_e=ue&&!!c.clearcoatRoughnessMap,ve=de&&!!c.iridescenceMap,ye=de&&!!c.iridescenceThicknessMap,Ee=pe&&!!c.sheenColorMap,xe=pe&&!!c.sheenRoughnessMap,Se=!!c.specularMap,Me=!!c.specularColorMap,Ce=!!c.specularIntensityMap,be=Ae&&!!c.transmissionMap,we=Ae&&!!c.thicknessMap,Ie=!!c.gradientMap,Te=!!c.alphaMap,Be=c.alphaTest>0,Re=!!c.alphaHash,Le=!!c.extensions,De=!!b.attributes.uv1,Ue=!!b.attributes.uv2,Pe=!!b.attributes.uv3;let Fe=0;return c.toneMapped&&(null!==X&&!0!==X.isXRRenderTarget||(Fe=e.toneMapping)),{isWebGL2:m,shaderID:U,shaderType:c.type,shaderName:c.name,vertexShader:Q,fragmentShader:G,defines:c.defines,customVertexShaderID:W,customFragmentShaderID:q,isRawShaderMaterial:!0===c.isRawShaderMaterial,glslVersion:c.glslVersion,precision:_,batching:J,instancing:Y,instancingColor:Y&&null!==S.instanceColor,supportsVertexTextures:g,outputColorSpace:null===X?e.outputColorSpace:!0===X.isXRRenderTarget?X.texture.colorSpace:He,map:$,matcap:ee,envMap:te,envMapMode:te&&T.mapping,envMapCubeUVHeight:B,aoMap:ie,lightMap:ne,bumpMap:re,normalMap:se,displacementMap:g&&ae,emissiveMap:oe,normalMapObjectSpace:se&&1===c.normalMapType,normalMapTangentSpace:se&&0===c.normalMapType,metalnessMap:le,roughnessMap:ce,anisotropy:he,anisotropyMap:me,clearcoat:ue,clearcoatMap:fe,clearcoatNormalMap:ge,clearcoatRoughnessMap:_e,iridescence:de,iridescenceMap:ve,iridescenceThicknessMap:ye,sheen:pe,sheenColorMap:Ee,sheenRoughnessMap:xe,specularMap:Se,specularColorMap:Me,specularIntensityMap:Ce,transmission:Ae,transmissionMap:be,thicknessMap:we,gradientMap:Ie,opaque:!1===c.transparent&&1===c.blending,alphaMap:Te,alphaTest:Be,alphaHash:Re,combine:c.combine,mapUv:$&&getChannel(c.map.channel),aoMapUv:ie&&getChannel(c.aoMap.channel),lightMapUv:ne&&getChannel(c.lightMap.channel),bumpMapUv:re&&getChannel(c.bumpMap.channel),normalMapUv:se&&getChannel(c.normalMap.channel),displacementMapUv:ae&&getChannel(c.displacementMap.channel),emissiveMapUv:oe&&getChannel(c.emissiveMap.channel),metalnessMapUv:le&&getChannel(c.metalnessMap.channel),roughnessMapUv:ce&&getChannel(c.roughnessMap.channel),anisotropyMapUv:me&&getChannel(c.anisotropyMap.channel),clearcoatMapUv:fe&&getChannel(c.clearcoatMap.channel),clearcoatNormalMapUv:ge&&getChannel(c.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&getChannel(c.clearcoatRoughnessMap.channel),iridescenceMapUv:ve&&getChannel(c.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&getChannel(c.iridescenceThicknessMap.channel),sheenColorMapUv:Ee&&getChannel(c.sheenColorMap.channel),sheenRoughnessMapUv:xe&&getChannel(c.sheenRoughnessMap.channel),specularMapUv:Se&&getChannel(c.specularMap.channel),specularColorMapUv:Me&&getChannel(c.specularColorMap.channel),specularIntensityMapUv:Ce&&getChannel(c.specularIntensityMap.channel),transmissionMapUv:be&&getChannel(c.transmissionMap.channel),thicknessMapUv:we&&getChannel(c.thicknessMap.channel),alphaMapUv:Te&&getChannel(c.alphaMap.channel),vertexTangents:!!b.attributes.tangent&&(se||he),vertexColors:c.vertexColors,vertexAlphas:!0===c.vertexColors&&!!b.attributes.color&&4===b.attributes.color.itemSize,vertexUv1s:De,vertexUv2s:Ue,vertexUv3s:Pe,pointsUvs:!0===S.isPoints&&!!b.attributes.uv&&($||Te),fog:!!C,useFog:!0===c.fog,fogExp2:C&&C.isFogExp2,flatShading:!0===c.flatShading,sizeAttenuation:!0===c.sizeAttenuation,logarithmicDepthBuffer:f,skinning:!0===S.isSkinnedMesh,morphTargets:void 0!==b.morphAttributes.position,morphNormals:void 0!==b.morphAttributes.normal,morphColors:void 0!==b.morphAttributes.color,morphTargetsCount:O,morphTextureStride:j,numDirLights:d.directional.length,numPointLights:d.point.length,numSpotLights:d.spot.length,numSpotLightMaps:d.spotLightMap.length,numRectAreaLights:d.rectArea.length,numHemiLights:d.hemi.length,numDirLightShadows:d.directionalShadowMap.length,numPointLightShadows:d.pointShadowMap.length,numSpotLightShadows:d.spotShadowMap.length,numSpotLightShadowsWithMaps:d.numSpotLightShadowsWithMaps,numLightProbes:d.numLightProbes,numClippingPlanes:h.numPlanes,numClipIntersection:h.numIntersection,dithering:c.dithering,shadowMapEnabled:e.shadowMap.enabled&&A.length>0,shadowMapType:e.shadowMap.type,toneMapping:Fe,useLegacyLights:e._useLegacyLights,decodeVideoTexture:$&&!0===c.map.isVideoTexture&&Et.getTransfer(c.map.colorSpace)===je,premultipliedAlpha:c.premultipliedAlpha,doubleSided:2===c.side,flipSided:1===c.side,useDepthPacking:c.depthPacking>=0,depthPacking:c.depthPacking||0,index0AttributeName:c.index0AttributeName,extensionDerivatives:Le&&!0===c.extensions.derivatives,extensionFragDepth:Le&&!0===c.extensions.fragDepth,extensionDrawBuffers:Le&&!0===c.extensions.drawBuffers,extensionShaderTextureLOD:Le&&!0===c.extensions.shaderTextureLOD,extensionClipCullDistance:Le&&c.extensions.clipCullDistance&&s.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:m||s.has("EXT_frag_depth"),rendererExtensionDrawBuffers:m||s.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:m||s.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:s.has("KHR_parallel_shader_compile"),customProgramCacheKey:c.customProgramCacheKey()}},getProgramCacheKey:function getProgramCacheKey(t){const r=[];if(t.shaderID?r.push(t.shaderID):(r.push(t.customVertexShaderID),r.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)r.push(e),r.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function getProgramCacheKeyParameters(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.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(r,t),function getProgramCacheKeyBooleans(e,t){d.disableAll(),t.isWebGL2&&d.enable(0);t.supportsVertexTextures&&d.enable(1);t.instancing&&d.enable(2);t.instancingColor&&d.enable(3);t.matcap&&d.enable(4);t.envMap&&d.enable(5);t.normalMapObjectSpace&&d.enable(6);t.normalMapTangentSpace&&d.enable(7);t.clearcoat&&d.enable(8);t.iridescence&&d.enable(9);t.alphaTest&&d.enable(10);t.vertexColors&&d.enable(11);t.vertexAlphas&&d.enable(12);t.vertexUv1s&&d.enable(13);t.vertexUv2s&&d.enable(14);t.vertexUv3s&&d.enable(15);t.vertexTangents&&d.enable(16);t.anisotropy&&d.enable(17);t.alphaHash&&d.enable(18);t.batching&&d.enable(19);e.push(d.mask),d.disableAll(),t.fog&&d.enable(0);t.useFog&&d.enable(1);t.flatShading&&d.enable(2);t.logarithmicDepthBuffer&&d.enable(3);t.skinning&&d.enable(4);t.morphTargets&&d.enable(5);t.morphNormals&&d.enable(6);t.morphColors&&d.enable(7);t.premultipliedAlpha&&d.enable(8);t.shadowMapEnabled&&d.enable(9);t.useLegacyLights&&d.enable(10);t.doubleSided&&d.enable(11);t.flipSided&&d.enable(12);t.useDepthPacking&&d.enable(13);t.dithering&&d.enable(14);t.transmission&&d.enable(15);t.sheen&&d.enable(16);t.opaque&&d.enable(17);t.pointsUvs&&d.enable(18);t.decodeVideoTexture&&d.enable(19);e.push(d.mask)}(r,t),r.push(e.outputColorSpace)),r.push(t.customProgramCacheKey),r.join()},getUniforms:function getUniforms(e){const t=y[e.type];let r;if(t){const e=xn[t];r=pn.clone(e.uniforms)}else r=e.uniforms;return r},acquireProgram:function acquireProgram(t,r){let s;for(let e=0,t=A.length;e<t;e++){const t=A[e];if(t.cacheKey===r){s=t,++s.usedTimes;break}}return void 0===s&&(s=new WebGLProgram(e,r,t,c),A.push(s)),s},releaseProgram:function releaseProgram(e){if(0==--e.usedTimes){const t=A.indexOf(e);A[t]=A[A.length-1],A.pop(),e.destroy()}},releaseShaderCache:function releaseShaderCache(e){p.remove(e)},programs:A,dispose:function dispose(){p.dispose()}}}function WebGLProperties(){let e=new WeakMap;return{get:function get(t){let r=e.get(t);return void 0===r&&(r={},e.set(t,r)),r},remove:function remove(t){e.delete(t)},update:function update(t,r,s){e.get(t)[r]=s},dispose:function dispose(){e=new WeakMap}}}function painterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function reversePainterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function WebGLRenderList(){const e=[];let t=0;const r=[],s=[],o=[];function getNextRenderItem(r,s,o,l,c,h){let d=e[t];return void 0===d?(d={id:r.id,object:r,geometry:s,material:o,groupOrder:l,renderOrder:r.renderOrder,z:c,group:h},e[t]=d):(d.id=r.id,d.object=r,d.geometry=s,d.material=o,d.groupOrder=l,d.renderOrder=r.renderOrder,d.z=c,d.group=h),t++,d}return{opaque:r,transmissive:s,transparent:o,init:function init(){t=0,r.length=0,s.length=0,o.length=0},push:function push(e,t,l,c,h,d){const p=getNextRenderItem(e,t,l,c,h,d);l.transmission>0?s.push(p):!0===l.transparent?o.push(p):r.push(p)},unshift:function unshift(e,t,l,c,h,d){const p=getNextRenderItem(e,t,l,c,h,d);l.transmission>0?s.unshift(p):!0===l.transparent?o.unshift(p):r.unshift(p)},finish:function finish(){for(let r=t,s=e.length;r<s;r++){const t=e[r];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function sort(e,t){r.length>1&&r.sort(e||painterSortStable),s.length>1&&s.sort(t||reversePainterSortStable),o.length>1&&o.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(){let e=new WeakMap;return{get:function get(t,r){const s=e.get(t);let o;return void 0===s?(o=new WebGLRenderList,e.set(t,[o])):r>=s.length?(o=new WebGLRenderList,s.push(o)):o=s[r],o},dispose:function dispose(){e=new WeakMap}}}function UniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let r;switch(t.type){case"DirectionalLight":r={direction:new three_module_Vector3,color:new Color};break;case"SpotLight":r={position:new three_module_Vector3,direction:new three_module_Vector3,color:new Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new three_module_Vector3,color:new Color,distance:0,decay:0};break;case"HemisphereLight":r={direction:new three_module_Vector3,skyColor:new Color,groundColor:new Color};break;case"RectAreaLight":r={color:new Color,position:new three_module_Vector3,halfWidth:new three_module_Vector3,halfHeight:new three_module_Vector3}}return e[t.id]=r,r}}}let Kn=0;function shadowCastingAndTexturingLightsFirst(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function WebGLLights(e,t){const r=new UniformsCache,s=function ShadowUniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let r;switch(t.type){case"DirectionalLight":case"SpotLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2};break;case"PointLight":r={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=r,r}}}(),l={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-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,numLightProbes:0};for(let e=0;e<9;e++)l.probe.push(new three_module_Vector3);const c=new three_module_Vector3,h=new three_module_Matrix4,d=new three_module_Matrix4;return{setup:function setup(c,h){let d=0,p=0,A=0;for(let e=0;e<9;e++)l.probe[e].set(0,0,0);let m=0,f=0,g=0,_=0,y=0,x=0,S=0,C=0,b=0,I=0,T=0;c.sort(shadowCastingAndTexturingLightsFirst);const B=!0===h?Math.PI:1;for(let e=0,t=c.length;e<t;e++){const t=c[e],o=t.color,h=t.intensity,U=t.distance,F=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)d+=o.r*h*B,p+=o.g*h*B,A+=o.b*h*B;else if(t.isLightProbe){for(let e=0;e<9;e++)l.probe[e].addScaledVector(t.sh.coefficients[e],h);T++}else if(t.isDirectionalLight){const e=r.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*B),t.castShadow){const e=t.shadow,r=s.get(t);r.shadowBias=e.bias,r.shadowNormalBias=e.normalBias,r.shadowRadius=e.radius,r.shadowMapSize=e.mapSize,l.directionalShadow[m]=r,l.directionalShadowMap[m]=F,l.directionalShadowMatrix[m]=t.shadow.matrix,x++}l.directional[m]=e,m++}else if(t.isSpotLight){const e=r.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(o).multiplyScalar(h*B),e.distance=U,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,l.spot[g]=e;const c=t.shadow;if(t.map&&(l.spotLightMap[b]=t.map,b++,c.updateMatrices(t),t.castShadow&&I++),l.spotLightMatrix[g]=c.matrix,t.castShadow){const e=s.get(t);e.shadowBias=c.bias,e.shadowNormalBias=c.normalBias,e.shadowRadius=c.radius,e.shadowMapSize=c.mapSize,l.spotShadow[g]=e,l.spotShadowMap[g]=F,C++}g++}else if(t.isRectAreaLight){const e=r.get(t);e.color.copy(o).multiplyScalar(h),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),l.rectArea[_]=e,_++}else if(t.isPointLight){const e=r.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*B),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,r=s.get(t);r.shadowBias=e.bias,r.shadowNormalBias=e.normalBias,r.shadowRadius=e.radius,r.shadowMapSize=e.mapSize,r.shadowCameraNear=e.camera.near,r.shadowCameraFar=e.camera.far,l.pointShadow[f]=r,l.pointShadowMap[f]=F,l.pointShadowMatrix[f]=t.shadow.matrix,S++}l.point[f]=e,f++}else if(t.isHemisphereLight){const e=r.get(t);e.skyColor.copy(t.color).multiplyScalar(h*B),e.groundColor.copy(t.groundColor).multiplyScalar(h*B),l.hemi[y]=e,y++}}_>0&&(t.isWebGL2?!0===e.has("OES_texture_float_linear")?(l.rectAreaLTC1=En.LTC_FLOAT_1,l.rectAreaLTC2=En.LTC_FLOAT_2):(l.rectAreaLTC1=En.LTC_HALF_1,l.rectAreaLTC2=En.LTC_HALF_2):!0===e.has("OES_texture_float_linear")?(l.rectAreaLTC1=En.LTC_FLOAT_1,l.rectAreaLTC2=En.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(l.rectAreaLTC1=En.LTC_HALF_1,l.rectAreaLTC2=En.LTC_HALF_2):o.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),l.ambient[0]=d,l.ambient[1]=p,l.ambient[2]=A;const U=l.hash;U.directionalLength===m&&U.pointLength===f&&U.spotLength===g&&U.rectAreaLength===_&&U.hemiLength===y&&U.numDirectionalShadows===x&&U.numPointShadows===S&&U.numSpotShadows===C&&U.numSpotMaps===b&&U.numLightProbes===T||(l.directional.length=m,l.spot.length=g,l.rectArea.length=_,l.point.length=f,l.hemi.length=y,l.directionalShadow.length=x,l.directionalShadowMap.length=x,l.pointShadow.length=S,l.pointShadowMap.length=S,l.spotShadow.length=C,l.spotShadowMap.length=C,l.directionalShadowMatrix.length=x,l.pointShadowMatrix.length=S,l.spotLightMatrix.length=C+b-I,l.spotLightMap.length=b,l.numSpotLightShadowsWithMaps=I,l.numLightProbes=T,U.directionalLength=m,U.pointLength=f,U.spotLength=g,U.rectAreaLength=_,U.hemiLength=y,U.numDirectionalShadows=x,U.numPointShadows=S,U.numSpotShadows=C,U.numSpotMaps=b,U.numLightProbes=T,l.version=Kn++)},setupView:function setupView(e,t){let r=0,s=0,o=0,p=0,A=0;const m=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){const f=e[t];if(f.isDirectionalLight){const e=l.directional[r];e.direction.setFromMatrixPosition(f.matrixWorld),c.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(c),e.direction.transformDirection(m),r++}else if(f.isSpotLight){const e=l.spot[o];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(m),e.direction.setFromMatrixPosition(f.matrixWorld),c.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(c),e.direction.transformDirection(m),o++}else if(f.isRectAreaLight){const e=l.rectArea[p];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(m),d.identity(),h.copy(f.matrixWorld),h.premultiply(m),d.extractRotation(h),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(d),e.halfHeight.applyMatrix4(d),p++}else if(f.isPointLight){const e=l.point[s];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(m),s++}else if(f.isHemisphereLight){const e=l.hemi[A];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(m),A++}}},state:l}}function WebGLRenderState(e,t){const r=new WebGLLights(e,t),s=[],o=[];return{init:function init(){s.length=0,o.length=0},state:{lightsArray:s,shadowsArray:o,lights:r},setupLights:function setupLights(e){r.setup(s,e)},setupLightsView:function setupLightsView(e){r.setupView(s,e)},pushLight:function pushLight(e){s.push(e)},pushShadow:function pushShadow(e){o.push(e)}}}function WebGLRenderStates(e,t){let r=new WeakMap;return{get:function get(s,o=0){const l=r.get(s);let c;return void 0===l?(c=new WebGLRenderState(e,t),r.set(s,[c])):o>=l.length?(c=new WebGLRenderState(e,t),l.push(c)):c=l[o],c},dispose:function dispose(){r=new WeakMap}}}class MeshDepthMaterial extends Material{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 MeshDistanceMaterial extends Material{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 WebGLShadowMap(e,t,r){let s=new Frustum;const l=new Vector2,p=new Vector2,A=new Vector4,m=new MeshDepthMaterial({depthPacking:3201}),f=new MeshDistanceMaterial,g={},_=r.maxTextureSize,y={[c]:1,[h]:0,[d]:2},x=new ShaderMaterial({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Vector2},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 <packing>\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}"}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const C=new three_module_BufferGeometry;C.setAttribute("position",new three_module_BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new three_module_Mesh(C,x),I=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let T=this.type;function VSMPass(r,s){const o=t.update(b);x.defines.VSM_SAMPLES!==r.blurSamples&&(x.defines.VSM_SAMPLES=r.blurSamples,S.defines.VSM_SAMPLES=r.blurSamples,x.needsUpdate=!0,S.needsUpdate=!0),null===r.mapPass&&(r.mapPass=new WebGLRenderTarget(l.x,l.y)),x.uniforms.shadow_pass.value=r.map.texture,x.uniforms.resolution.value=r.mapSize,x.uniforms.radius.value=r.radius,e.setRenderTarget(r.mapPass),e.clear(),e.renderBufferDirect(s,null,o,x,b,null),S.uniforms.shadow_pass.value=r.mapPass.texture,S.uniforms.resolution.value=r.mapSize,S.uniforms.radius.value=r.radius,e.setRenderTarget(r.map),e.clear(),e.renderBufferDirect(s,null,o,S,b,null)}function getDepthMaterial(t,r,s,o){let l=null;const c=!0===s.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==c)l=c;else if(l=!0===s.isPointLight?f:m,e.localClippingEnabled&&!0===r.clipShadows&&Array.isArray(r.clippingPlanes)&&0!==r.clippingPlanes.length||r.displacementMap&&0!==r.displacementScale||r.alphaMap&&r.alphaTest>0||r.map&&r.alphaTest>0){const e=l.uuid,t=r.uuid;let s=g[e];void 0===s&&(s={},g[e]=s);let o=s[t];void 0===o&&(o=l.clone(),s[t]=o,r.addEventListener("dispose",onMaterialDispose)),l=o}if(l.visible=r.visible,l.wireframe=r.wireframe,l.side=3===o?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:y[r.side],l.alphaMap=r.alphaMap,l.alphaTest=r.alphaTest,l.map=r.map,l.clipShadows=r.clipShadows,l.clippingPlanes=r.clippingPlanes,l.clipIntersection=r.clipIntersection,l.displacementMap=r.displacementMap,l.displacementScale=r.displacementScale,l.displacementBias=r.displacementBias,l.wireframeLinewidth=r.wireframeLinewidth,l.linewidth=r.linewidth,!0===s.isPointLight&&!0===l.isMeshDistanceMaterial){e.properties.get(l).light=s}return l}function renderObject(r,o,l,c,h){if(!1===r.visible)return;if(r.layers.test(o.layers)&&(r.isMesh||r.isLine||r.isPoints)&&(r.castShadow||r.receiveShadow&&3===h)&&(!r.frustumCulled||s.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(l.matrixWorldInverse,r.matrixWorld);const s=t.update(r),d=r.material;if(Array.isArray(d)){const t=s.groups;for(let p=0,A=t.length;p<A;p++){const A=t[p],m=d[A.materialIndex];if(m&&m.visible){const t=getDepthMaterial(r,m,c,h);r.onBeforeShadow(e,r,o,l,s,t,A),e.renderBufferDirect(l,null,s,t,r,A),r.onAfterShadow(e,r,o,l,s,t,A)}}}else if(d.visible){const t=getDepthMaterial(r,d,c,h);r.onBeforeShadow(e,r,o,l,s,t,null),e.renderBufferDirect(l,null,s,t,r,null),r.onAfterShadow(e,r,o,l,s,t,null)}}const d=r.children;for(let e=0,t=d.length;e<t;e++)renderObject(d[e],o,l,c,h)}function onMaterialDispose(e){e.target.removeEventListener("dispose",onMaterialDispose);for(const t in g){const r=g[t],s=e.target.uuid;if(s in r){r[s].dispose(),delete r[s]}}}this.render=function(t,r,c){if(!1===I.enabled)return;if(!1===I.autoUpdate&&!1===I.needsUpdate)return;if(0===t.length)return;const h=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);const g=3!==T&&3===this.type,y=3===T&&3!==this.type;for(let h=0,d=t.length;h<d;h++){const d=t[h],m=d.shadow;if(void 0===m){o.warn("THREE.WebGLShadowMap:",d,"has no shadow.");continue}if(!1===m.autoUpdate&&!1===m.needsUpdate)continue;l.copy(m.mapSize);const x=m.getFrameExtents();if(l.multiply(x),p.copy(m.mapSize),(l.x>_||l.y>_)&&(l.x>_&&(p.x=Math.floor(_/x.x),l.x=p.x*x.x,m.mapSize.x=p.x),l.y>_&&(p.y=Math.floor(_/x.y),l.y=p.y*x.y,m.mapSize.y=p.y)),null===m.map||!0===g||!0===y){const e=3!==this.type?{minFilter:te,magFilter:te}:{};null!==m.map&&m.map.dispose(),m.map=new WebGLRenderTarget(l.x,l.y,e),m.map.texture.name=d.name+".shadowMap",m.camera.updateProjectionMatrix()}e.setRenderTarget(m.map),e.clear();const S=m.getViewportCount();for(let e=0;e<S;e++){const t=m.getViewport(e);A.set(p.x*t.x,p.y*t.y,p.x*t.z,p.y*t.w),f.viewport(A),m.updateMatrices(d,e),s=m.getFrustum(),renderObject(r,c,m.camera,d,this.type)}!0!==m.isPointLightShadow&&3===this.type&&VSMPass(m,c),m.needsUpdate=!1}T=this.type,I.needsUpdate=!1,e.setRenderTarget(h,d,m)}}function WebGLState(e,t,r){const s=r.isWebGL2;const l=new function ColorBuffer(){let t=!1;const r=new Vector4;let s=null;const o=new Vector4(0,0,0,0);return{setMask:function(r){s===r||t||(e.colorMask(r,r,r,r),s=r)},setLocked:function(e){t=e},setClear:function(t,s,l,c,h){!0===h&&(t*=c,s*=c,l*=c),r.set(t,s,l,c),!1===o.equals(r)&&(e.clearColor(t,s,l,c),o.copy(r))},reset:function(){t=!1,s=null,o.set(-1,0,0,0)}}},c=new function DepthBuffer(){let t=!1,r=null,s=null,o=null;return{setTest:function(t){t?enable(e.DEPTH_TEST):disable(e.DEPTH_TEST)},setMask:function(s){r===s||t||(e.depthMask(s),r=s)},setFunc:function(t){if(s!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}s=t}},setLocked:function(e){t=e},setClear:function(t){o!==t&&(e.clearDepth(t),o=t)},reset:function(){t=!1,r=null,s=null,o=null}}},h=new function StencilBuffer(){let t=!1,r=null,s=null,o=null,l=null,c=null,h=null,d=null,p=null;return{setTest:function(r){t||(r?enable(e.STENCIL_TEST):disable(e.STENCIL_TEST))},setMask:function(s){r===s||t||(e.stencilMask(s),r=s)},setFunc:function(t,r,c){s===t&&o===r&&l===c||(e.stencilFunc(t,r,c),s=t,o=r,l=c)},setOp:function(t,r,s){c===t&&h===r&&d===s||(e.stencilOp(t,r,s),c=t,h=r,d=s)},setLocked:function(e){t=e},setClear:function(t){p!==t&&(e.clearStencil(t),p=t)},reset:function(){t=!1,r=null,s=null,o=null,l=null,c=null,h=null,d=null,p=null}}},d=new WeakMap,G=new WeakMap;let W={},q={},j=new WeakMap,X=[],Y=null,K=!1,J=null,$=null,ee=null,te=null,ie=null,ne=null,re=null,se=new Color(0,0,0),ae=0,oe=!1,le=null,ce=null,he=null,ue=null,de=null;const pe=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Ae=!1,me=0;const fe=e.getParameter(e.VERSION);-1!==fe.indexOf("WebGL")?(me=parseFloat(/^WebGL (\d)/.exec(fe)[1]),Ae=me>=1):-1!==fe.indexOf("OpenGL ES")&&(me=parseFloat(/^OpenGL ES (\d)/.exec(fe)[1]),Ae=me>=2);let ge=null,_e={};const ve=e.getParameter(e.SCISSOR_BOX),ye=e.getParameter(e.VIEWPORT),Ee=(new Vector4).fromArray(ve),xe=(new Vector4).fromArray(ye);function createTexture(t,r,o,l){const c=new Uint8Array(4),h=e.createTexture();e.bindTexture(t,h),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let h=0;h<o;h++)!s||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(r+h,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,c):e.texImage3D(r,0,e.RGBA,1,1,l,0,e.RGBA,e.UNSIGNED_BYTE,c);return h}const Se={};function enable(t){!0!==W[t]&&(e.enable(t),W[t]=!0)}function disable(t){!1!==W[t]&&(e.disable(t),W[t]=!1)}Se[e.TEXTURE_2D]=createTexture(e.TEXTURE_2D,e.TEXTURE_2D,1),Se[e.TEXTURE_CUBE_MAP]=createTexture(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),s&&(Se[e.TEXTURE_2D_ARRAY]=createTexture(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),Se[e.TEXTURE_3D]=createTexture(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),h.setClear(0),enable(e.DEPTH_TEST),c.setFunc(3),setFlipSided(!1),setCullFace(1),enable(e.CULL_FACE),setBlending(0);const Me={[p]:e.FUNC_ADD,[A]:e.FUNC_SUBTRACT,[m]:e.FUNC_REVERSE_SUBTRACT};if(s)Me[103]=e.MIN,Me[104]=e.MAX;else{const e=t.get("EXT_blend_minmax");null!==e&&(Me[103]=e.MIN_EXT,Me[104]=e.MAX_EXT)}const Ce={[f]:e.ZERO,[g]:e.ONE,[_]:e.SRC_COLOR,[x]:e.SRC_ALPHA,[B]:e.SRC_ALPHA_SATURATE,[I]:e.DST_COLOR,[C]:e.DST_ALPHA,[y]:e.ONE_MINUS_SRC_COLOR,[S]:e.ONE_MINUS_SRC_ALPHA,[T]:e.ONE_MINUS_DST_COLOR,[b]:e.ONE_MINUS_DST_ALPHA,[U]:e.CONSTANT_COLOR,[F]:e.ONE_MINUS_CONSTANT_COLOR,[O]:e.CONSTANT_ALPHA,[Q]:e.ONE_MINUS_CONSTANT_ALPHA};function setBlending(t,r,s,l,c,h,d,A,m,f){if(0!==t){if(!1===K&&(enable(e.BLEND),K=!0),5===t)c=c||r,h=h||s,d=d||l,r===$&&c===ie||(e.blendEquationSeparate(Me[r],Me[c]),$=r,ie=c),s===ee&&l===te&&h===ne&&d===re||(e.blendFuncSeparate(Ce[s],Ce[l],Ce[h],Ce[d]),ee=s,te=l,ne=h,re=d),!1!==A.equals(se)&&m===ae||(e.blendColor(A.r,A.g,A.b,m),se.copy(A),ae=m),J=t,oe=!1;else if(t!==J||f!==oe){if($===p&&ie===p||(e.blendEquation(e.FUNC_ADD),$=p,ie=p),f)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:o.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:o.error("THREE.WebGLState: Invalid blending: ",t)}ee=null,te=null,ne=null,re=null,se.set(0,0,0),ae=0,J=t,oe=f}}else!0===K&&(disable(e.BLEND),K=!1)}function setFlipSided(t){le!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),le=t)}function setCullFace(t){0!==t?(enable(e.CULL_FACE),t!==ce&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):disable(e.CULL_FACE),ce=t}function setPolygonOffset(t,r,s){t?(enable(e.POLYGON_OFFSET_FILL),ue===r&&de===s||(e.polygonOffset(r,s),ue=r,de=s)):disable(e.POLYGON_OFFSET_FILL)}return{buffers:{color:l,depth:c,stencil:h},enable,disable,bindFramebuffer:function bindFramebuffer(t,r){return q[t]!==r&&(e.bindFramebuffer(t,r),q[t]=r,s&&(t===e.DRAW_FRAMEBUFFER&&(q[e.FRAMEBUFFER]=r),t===e.FRAMEBUFFER&&(q[e.DRAW_FRAMEBUFFER]=r)),!0)},drawBuffers:function drawBuffers(s,o){let l=X,c=!1;if(s)if(l=j.get(o),void 0===l&&(l=[],j.set(o,l)),s.isWebGLMultipleRenderTargets){const t=s.texture;if(l.length!==t.length||l[0]!==e.COLOR_ATTACHMENT0){for(let r=0,s=t.length;r<s;r++)l[r]=e.COLOR_ATTACHMENT0+r;l.length=t.length,c=!0}}else l[0]!==e.COLOR_ATTACHMENT0&&(l[0]=e.COLOR_ATTACHMENT0,c=!0);else l[0]!==e.BACK&&(l[0]=e.BACK,c=!0);c&&(r.isWebGL2?e.drawBuffers(l):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(l))},useProgram:function useProgram(t){return Y!==t&&(e.useProgram(t),Y=t,!0)},setBlending,setMaterial:function setMaterial(t,r){2===t.side?disable(e.CULL_FACE):enable(e.CULL_FACE);let s=1===t.side;r&&(s=!s),setFlipSided(s),1===t.blending&&!1===t.transparent?setBlending(0):setBlending(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),c.setFunc(t.depthFunc),c.setTest(t.depthTest),c.setMask(t.depthWrite),l.setMask(t.colorWrite);const o=t.stencilWrite;h.setTest(o),o&&(h.setMask(t.stencilWriteMask),h.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),h.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),setPolygonOffset(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?enable(e.SAMPLE_ALPHA_TO_COVERAGE):disable(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided,setCullFace,setLineWidth:function setLineWidth(t){t!==he&&(Ae&&e.lineWidth(t),he=t)},setPolygonOffset,setScissorTest:function setScissorTest(t){t?enable(e.SCISSOR_TEST):disable(e.SCISSOR_TEST)},activeTexture:function activeTexture(t){void 0===t&&(t=e.TEXTURE0+pe-1),ge!==t&&(e.activeTexture(t),ge=t)},bindTexture:function bindTexture(t,r,s){void 0===s&&(s=null===ge?e.TEXTURE0+pe-1:ge);let o=_e[s];void 0===o&&(o={type:void 0,texture:void 0},_e[s]=o),o.type===t&&o.texture===r||(ge!==s&&(e.activeTexture(s),ge=s),e.bindTexture(t,r||Se[t]),o.type=t,o.texture=r)},unbindTexture:function unbindTexture(){const t=_e[ge];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function compressedTexImage2D(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},compressedTexImage3D:function compressedTexImage3D(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texImage2D:function texImage2D(){try{e.texImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texImage3D:function texImage3D(){try{e.texImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},updateUBOMapping:function updateUBOMapping(t,r){let s=G.get(r);void 0===s&&(s=new WeakMap,G.set(r,s));let o=s.get(t);void 0===o&&(o=e.getUniformBlockIndex(r,t.name),s.set(t,o))},uniformBlockBinding:function uniformBlockBinding(t,r){const s=G.get(r).get(t);d.get(r)!==s&&(e.uniformBlockBinding(r,s,t.__bindingPointIndex),d.set(r,s))},texStorage2D:function texStorage2D(){try{e.texStorage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texStorage3D:function texStorage3D(){try{e.texStorage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texSubImage2D:function texSubImage2D(){try{e.texSubImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},texSubImage3D:function texSubImage3D(){try{e.texSubImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function compressedTexSubImage2D(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function compressedTexSubImage3D(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){o.error("THREE.WebGLState:",e)}},scissor:function scissor(t){!1===Ee.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),Ee.copy(t))},viewport:function viewport(t){!1===xe.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),xe.copy(t))},reset:function reset(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),!0===s&&(e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),W={},ge=null,_e={},q={},j=new WeakMap,X=[],Y=null,K=!1,J=null,$=null,ee=null,te=null,ie=null,ne=null,re=null,se=new Color(0,0,0),ae=0,oe=!1,le=null,ce=null,he=null,ue=null,de=null,Ee.set(0,0,e.canvas.width,e.canvas.height),xe.set(0,0,e.canvas.width,e.canvas.height),l.reset(),c.reset(),h.reset()}}}function WebGLTextures(e,t,r,s,l,c,h){const d=l.isWebGL2,p=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,A="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap;let f;const g=new WeakMap;let _=!1;try{_="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function createCanvas(e,t){return _?new OffscreenCanvas(e,t):createElementNS("canvas")}function resizeImage(e,t,r,s){let l=1;if((e.width>s||e.height>s)&&(l=s/Math.max(e.width,e.height)),l<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const s=t?floorPowerOfTwo:Math.floor,c=s(l*e.width),h=s(l*e.height);void 0===f&&(f=createCanvas(c,h));const d=r?createCanvas(c,h):f;d.width=c,d.height=h;return d.getContext("2d").drawImage(e,0,0,c,h),o.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+c+"x"+h+")."),d}return"data"in e&&o.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function isPowerOfTwo$1(e){return isPowerOfTwo(e.width)&&isPowerOfTwo(e.height)}function textureNeedsGenerateMipmaps(e,t){return e.generateMipmaps&&t&&e.minFilter!==te&&e.minFilter!==re}function generateMipmap(t){e.generateMipmap(t)}function getInternalFormat(r,s,l,c,h=!1){if(!1===d)return s;if(null!==r){if(void 0!==e[r])return e[r];o.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+r+"'")}let p=s;if(s===e.RED&&(l===e.FLOAT&&(p=e.R32F),l===e.HALF_FLOAT&&(p=e.R16F),l===e.UNSIGNED_BYTE&&(p=e.R8)),s===e.RED_INTEGER&&(l===e.UNSIGNED_BYTE&&(p=e.R8UI),l===e.UNSIGNED_SHORT&&(p=e.R16UI),l===e.UNSIGNED_INT&&(p=e.R32UI),l===e.BYTE&&(p=e.R8I),l===e.SHORT&&(p=e.R16I),l===e.INT&&(p=e.R32I)),s===e.RG&&(l===e.FLOAT&&(p=e.RG32F),l===e.HALF_FLOAT&&(p=e.RG16F),l===e.UNSIGNED_BYTE&&(p=e.RG8)),s===e.RGBA){const t=h?qe:Et.getTransfer(c);l===e.FLOAT&&(p=e.RGBA32F),l===e.HALF_FLOAT&&(p=e.RGBA16F),l===e.UNSIGNED_BYTE&&(p=t===je?e.SRGB8_ALPHA8:e.RGBA8),l===e.UNSIGNED_SHORT_4_4_4_4&&(p=e.RGBA4),l===e.UNSIGNED_SHORT_5_5_5_1&&(p=e.RGB5_A1)}return p!==e.R16F&&p!==e.R32F&&p!==e.RG16F&&p!==e.RG32F&&p!==e.RGBA16F&&p!==e.RGBA32F||t.get("EXT_color_buffer_float"),p}function getMipLevels(e,t,r){return!0===textureNeedsGenerateMipmaps(e,r)||e.isFramebufferTexture&&e.minFilter!==te&&e.minFilter!==re?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 filterFallback(t){return t===te||t===ie||t===ne?e.NEAREST:e.LINEAR}function onTextureDispose(e){const t=e.target;t.removeEventListener("dispose",onTextureDispose),function deallocateTexture(e){const t=s.get(e);if(void 0===t.__webglInit)return;const r=e.source,o=g.get(r);if(o){const s=o[t.__cacheKey];s.usedTimes--,0===s.usedTimes&&deleteTexture(e),0===Object.keys(o).length&&g.delete(r)}s.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function onRenderTargetDispose(t){const r=t.target;r.removeEventListener("dispose",onRenderTargetDispose),function deallocateRenderTarget(t){const r=t.texture,o=s.get(t),l=s.get(r);void 0!==l.__webglTexture&&(e.deleteTexture(l.__webglTexture),h.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(o.__webglFramebuffer[t]))for(let r=0;r<o.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(o.__webglFramebuffer[t][r]);else e.deleteFramebuffer(o.__webglFramebuffer[t]);o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer[t])}else{if(Array.isArray(o.__webglFramebuffer))for(let t=0;t<o.__webglFramebuffer.length;t++)e.deleteFramebuffer(o.__webglFramebuffer[t]);else e.deleteFramebuffer(o.__webglFramebuffer);if(o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer),o.__webglMultisampledFramebuffer&&e.deleteFramebuffer(o.__webglMultisampledFramebuffer),o.__webglColorRenderbuffer)for(let t=0;t<o.__webglColorRenderbuffer.length;t++)o.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(o.__webglColorRenderbuffer[t]);o.__webglDepthRenderbuffer&&e.deleteRenderbuffer(o.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,o=r.length;t<o;t++){const o=s.get(r[t]);o.__webglTexture&&(e.deleteTexture(o.__webglTexture),h.memory.textures--),s.remove(r[t])}s.remove(r),s.remove(t)}(r)}function deleteTexture(t){const r=s.get(t);e.deleteTexture(r.__webglTexture);const o=t.source;delete g.get(o)[r.__cacheKey],h.memory.textures--}let y=0;function setTexture2D(t,l){const c=s.get(t);if(t.isVideoTexture&&function updateVideoTexture(e){const t=h.render.frame;m.get(e)!==t&&(m.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&c.__version!==t.version){const e=t.image;if(null===e)o.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void uploadTexture(c,t,l);o.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}r.bindTexture(e.TEXTURE_2D,c.__webglTexture,e.TEXTURE0+l)}const x={[J]:e.REPEAT,[$]:e.CLAMP_TO_EDGE,[ee]:e.MIRRORED_REPEAT},S={[te]:e.NEAREST,[ie]:e.NEAREST_MIPMAP_NEAREST,[ne]:e.NEAREST_MIPMAP_LINEAR,[re]:e.LINEAR,[se]:e.LINEAR_MIPMAP_NEAREST,[ae]:e.LINEAR_MIPMAP_LINEAR},C={[Je]:e.NEVER,[rt]:e.ALWAYS,[$e]:e.LESS,[et]:e.LEQUAL,[Ze]:e.EQUAL,[nt]:e.GEQUAL,[tt]:e.GREATER,[it]:e.NOTEQUAL};function setTextureParameters(r,c,h){if(h?(e.texParameteri(r,e.TEXTURE_WRAP_S,x[c.wrapS]),e.texParameteri(r,e.TEXTURE_WRAP_T,x[c.wrapT]),r!==e.TEXTURE_3D&&r!==e.TEXTURE_2D_ARRAY||e.texParameteri(r,e.TEXTURE_WRAP_R,x[c.wrapR]),e.texParameteri(r,e.TEXTURE_MAG_FILTER,S[c.magFilter]),e.texParameteri(r,e.TEXTURE_MIN_FILTER,S[c.minFilter])):(e.texParameteri(r,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(r,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),r!==e.TEXTURE_3D&&r!==e.TEXTURE_2D_ARRAY||e.texParameteri(r,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),c.wrapS===$&&c.wrapT===$||o.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(r,e.TEXTURE_MAG_FILTER,filterFallback(c.magFilter)),e.texParameteri(r,e.TEXTURE_MIN_FILTER,filterFallback(c.minFilter)),c.minFilter!==te&&c.minFilter!==re&&o.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),c.compareFunction&&(e.texParameteri(r,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(r,e.TEXTURE_COMPARE_FUNC,C[c.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const o=t.get("EXT_texture_filter_anisotropic");if(c.magFilter===te)return;if(c.minFilter!==ne&&c.minFilter!==ae)return;if(c.type===ue&&!1===t.has("OES_texture_float_linear"))return;if(!1===d&&c.type===de&&!1===t.has("OES_texture_half_float_linear"))return;(c.anisotropy>1||s.get(c).__currentAnisotropy)&&(e.texParameterf(r,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(c.anisotropy,l.getMaxAnisotropy())),s.get(c).__currentAnisotropy=c.anisotropy)}}function initTexture(t,r){let s=!1;void 0===t.__webglInit&&(t.__webglInit=!0,r.addEventListener("dispose",onTextureDispose));const o=r.source;let l=g.get(o);void 0===l&&(l={},g.set(o,l));const c=function getTextureCacheKey(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()}(r);if(c!==t.__cacheKey){void 0===l[c]&&(l[c]={texture:e.createTexture(),usedTimes:0},h.memory.textures++,s=!0),l[c].usedTimes++;const o=l[t.__cacheKey];void 0!==o&&(l[t.__cacheKey].usedTimes--,0===o.usedTimes&&deleteTexture(r)),t.__cacheKey=c,t.__webglTexture=l[c].texture}return s}function uploadTexture(t,h,p){let A=e.TEXTURE_2D;(h.isDataArrayTexture||h.isCompressedArrayTexture)&&(A=e.TEXTURE_2D_ARRAY),h.isData3DTexture&&(A=e.TEXTURE_3D);const m=initTexture(t,h),f=h.source;r.bindTexture(A,t.__webglTexture,e.TEXTURE0+p);const g=s.get(f);if(f.version!==g.__version||!0===m){r.activeTexture(e.TEXTURE0+p);const t=Et.getPrimaries(Et.workingColorSpace),s=h.colorSpace===Ge?null:Et.getPrimaries(h.colorSpace),_=h.colorSpace===Ge||t===s?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,h.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,h.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,_);const y=function textureNeedsPowerOfTwo(e){return!d&&(e.wrapS!==$||e.wrapT!==$||e.minFilter!==te&&e.minFilter!==re)}(h)&&!1===isPowerOfTwo$1(h.image);let x=resizeImage(h.image,y,!1,l.maxTextureSize);x=verifyColorSpace(h,x);const S=isPowerOfTwo$1(x)||d,C=c.convert(h.format,h.colorSpace);let b,I=c.convert(h.type),T=getInternalFormat(h.internalFormat,C,I,h.colorSpace,h.isVideoTexture);setTextureParameters(A,h,S);const B=h.mipmaps,U=d&&!0!==h.isVideoTexture&&T!==Ce,F=void 0===g.__version||!0===m,O=getMipLevels(h,x,S);if(h.isDepthTexture)T=e.DEPTH_COMPONENT,d?T=h.type===ue?e.DEPTH_COMPONENT32F:h.type===he?e.DEPTH_COMPONENT24:h.type===pe?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:h.type===ue&&o.error("WebGLRenderer: Floating point depth texture requires WebGL2."),h.format===me&&T===e.DEPTH_COMPONENT&&h.type!==le&&h.type!==he&&(o.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),h.type=he,I=c.convert(h.type)),h.format===fe&&T===e.DEPTH_COMPONENT&&(T=e.DEPTH_STENCIL,h.type!==pe&&(o.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),h.type=pe,I=c.convert(h.type))),F&&(U?r.texStorage2D(e.TEXTURE_2D,1,T,x.width,x.height):r.texImage2D(e.TEXTURE_2D,0,T,x.width,x.height,0,C,I,null));else if(h.isDataTexture)if(B.length>0&&S){U&&F&&r.texStorage2D(e.TEXTURE_2D,O,T,B[0].width,B[0].height);for(let t=0,s=B.length;t<s;t++)b=B[t],U?r.texSubImage2D(e.TEXTURE_2D,t,0,0,b.width,b.height,C,I,b.data):r.texImage2D(e.TEXTURE_2D,t,T,b.width,b.height,0,C,I,b.data);h.generateMipmaps=!1}else U?(F&&r.texStorage2D(e.TEXTURE_2D,O,T,x.width,x.height),r.texSubImage2D(e.TEXTURE_2D,0,0,0,x.width,x.height,C,I,x.data)):r.texImage2D(e.TEXTURE_2D,0,T,x.width,x.height,0,C,I,x.data);else if(h.isCompressedTexture)if(h.isCompressedArrayTexture){U&&F&&r.texStorage3D(e.TEXTURE_2D_ARRAY,O,T,B[0].width,B[0].height,x.depth);for(let t=0,s=B.length;t<s;t++)b=B[t],h.format!==Ae?null!==C?U?r.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,b.width,b.height,x.depth,C,b.data,0,0):r.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,T,b.width,b.height,x.depth,0,b.data,0,0):o.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):U?r.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,b.width,b.height,x.depth,C,I,b.data):r.texImage3D(e.TEXTURE_2D_ARRAY,t,T,b.width,b.height,x.depth,0,C,I,b.data)}else{U&&F&&r.texStorage2D(e.TEXTURE_2D,O,T,B[0].width,B[0].height);for(let t=0,s=B.length;t<s;t++)b=B[t],h.format!==Ae?null!==C?U?r.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,b.width,b.height,C,b.data):r.compressedTexImage2D(e.TEXTURE_2D,t,T,b.width,b.height,0,b.data):o.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):U?r.texSubImage2D(e.TEXTURE_2D,t,0,0,b.width,b.height,C,I,b.data):r.texImage2D(e.TEXTURE_2D,t,T,b.width,b.height,0,C,I,b.data)}else if(h.isDataArrayTexture)U?(F&&r.texStorage3D(e.TEXTURE_2D_ARRAY,O,T,x.width,x.height,x.depth),r.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,x.width,x.height,x.depth,C,I,x.data)):r.texImage3D(e.TEXTURE_2D_ARRAY,0,T,x.width,x.height,x.depth,0,C,I,x.data);else if(h.isData3DTexture)U?(F&&r.texStorage3D(e.TEXTURE_3D,O,T,x.width,x.height,x.depth),r.texSubImage3D(e.TEXTURE_3D,0,0,0,0,x.width,x.height,x.depth,C,I,x.data)):r.texImage3D(e.TEXTURE_3D,0,T,x.width,x.height,x.depth,0,C,I,x.data);else if(h.isFramebufferTexture){if(F)if(U)r.texStorage2D(e.TEXTURE_2D,O,T,x.width,x.height);else{let t=x.width,s=x.height;for(let o=0;o<O;o++)r.texImage2D(e.TEXTURE_2D,o,T,t,s,0,C,I,null),t>>=1,s>>=1}}else if(B.length>0&&S){U&&F&&r.texStorage2D(e.TEXTURE_2D,O,T,B[0].width,B[0].height);for(let t=0,s=B.length;t<s;t++)b=B[t],U?r.texSubImage2D(e.TEXTURE_2D,t,0,0,C,I,b):r.texImage2D(e.TEXTURE_2D,t,T,C,I,b);h.generateMipmaps=!1}else U?(F&&r.texStorage2D(e.TEXTURE_2D,O,T,x.width,x.height),r.texSubImage2D(e.TEXTURE_2D,0,0,0,C,I,x)):r.texImage2D(e.TEXTURE_2D,0,T,C,I,x);textureNeedsGenerateMipmaps(h,S)&&generateMipmap(A),g.__version=f.version,h.onUpdate&&h.onUpdate(h)}t.__version=h.version}function setupFrameBufferTexture(t,o,l,h,d,A){const m=c.convert(l.format,l.colorSpace),f=c.convert(l.type),g=getInternalFormat(l.internalFormat,m,f,l.colorSpace);if(!s.get(o).__hasExternalTextures){const t=Math.max(1,o.width>>A),s=Math.max(1,o.height>>A);d===e.TEXTURE_3D||d===e.TEXTURE_2D_ARRAY?r.texImage3D(d,A,g,t,s,o.depth,0,m,f,null):r.texImage2D(d,A,g,t,s,0,m,f,null)}r.bindFramebuffer(e.FRAMEBUFFER,t),useMultisampledRTT(o)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,h,d,s.get(l).__webglTexture,0,getRenderTargetSamples(o)):(d===e.TEXTURE_2D||d>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&d<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,h,d,s.get(l).__webglTexture,A),r.bindFramebuffer(e.FRAMEBUFFER,null)}function setupRenderBufferStorage(t,r,s){if(e.bindRenderbuffer(e.RENDERBUFFER,t),r.depthBuffer&&!r.stencilBuffer){let o=!0===d?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(s||useMultisampledRTT(r)){const t=r.depthTexture;t&&t.isDepthTexture&&(t.type===ue?o=e.DEPTH_COMPONENT32F:t.type===he&&(o=e.DEPTH_COMPONENT24));const s=getRenderTargetSamples(r);useMultisampledRTT(r)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,s,o,r.width,r.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,s,o,r.width,r.height)}else e.renderbufferStorage(e.RENDERBUFFER,o,r.width,r.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(r.depthBuffer&&r.stencilBuffer){const o=getRenderTargetSamples(r);s&&!1===useMultisampledRTT(r)?e.renderbufferStorageMultisample(e.RENDERBUFFER,o,e.DEPTH24_STENCIL8,r.width,r.height):useMultisampledRTT(r)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,o,e.DEPTH24_STENCIL8,r.width,r.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,r.width,r.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===r.isWebGLMultipleRenderTargets?r.texture:[r.texture];for(let o=0;o<t.length;o++){const l=t[o],h=c.convert(l.format,l.colorSpace),d=c.convert(l.type),A=getInternalFormat(l.internalFormat,h,d,l.colorSpace),m=getRenderTargetSamples(r);s&&!1===useMultisampledRTT(r)?e.renderbufferStorageMultisample(e.RENDERBUFFER,m,A,r.width,r.height):useMultisampledRTT(r)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,m,A,r.width,r.height):e.renderbufferStorage(e.RENDERBUFFER,A,r.width,r.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function setupDepthRenderbuffer(t){const o=s.get(t),l=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!o.__autoAllocateDepthBuffer){if(l)throw new Error("target.depthTexture not supported in Cube render targets");!function setupDepthTexture(t,o){if(o&&o.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(r.bindFramebuffer(e.FRAMEBUFFER,t),!o.depthTexture||!o.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");s.get(o.depthTexture).__webglTexture&&o.depthTexture.image.width===o.width&&o.depthTexture.image.height===o.height||(o.depthTexture.image.width=o.width,o.depthTexture.image.height=o.height,o.depthTexture.needsUpdate=!0),setTexture2D(o.depthTexture,0);const l=s.get(o.depthTexture).__webglTexture,c=getRenderTargetSamples(o);if(o.depthTexture.format===me)useMultisampledRTT(o)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,l,0,c):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,l,0);else{if(o.depthTexture.format!==fe)throw new Error("Unknown depthTexture format");useMultisampledRTT(o)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,l,0,c):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,l,0)}}(o.__webglFramebuffer,t)}else if(l){o.__webglDepthbuffer=[];for(let s=0;s<6;s++)r.bindFramebuffer(e.FRAMEBUFFER,o.__webglFramebuffer[s]),o.__webglDepthbuffer[s]=e.createRenderbuffer(),setupRenderBufferStorage(o.__webglDepthbuffer[s],t,!1)}else r.bindFramebuffer(e.FRAMEBUFFER,o.__webglFramebuffer),o.__webglDepthbuffer=e.createRenderbuffer(),setupRenderBufferStorage(o.__webglDepthbuffer,t,!1);r.bindFramebuffer(e.FRAMEBUFFER,null)}function getRenderTargetSamples(e){return Math.min(l.maxSamples,e.samples)}function useMultisampledRTT(e){const r=s.get(e);return d&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==r.__useRenderToTexture}function verifyColorSpace(e,r){const s=e.colorSpace,l=e.format,c=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===ot||s!==He&&s!==Ge&&(Et.getTransfer(s)===je?!1===d?!0===t.has("EXT_sRGB")&&l===Ae?(e.format=ot,e.minFilter=re,e.generateMipmaps=!1):r=ImageUtils.sRGBToLinear(r):l===Ae&&c===oe||o.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):o.error("THREE.WebGLTextures: Unsupported texture color space:",s)),r}this.allocateTextureUnit=function allocateTextureUnit(){const e=y;return e>=l.maxTextures&&o.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l.maxTextures),y+=1,e},this.resetTextureUnits=function resetTextureUnits(){y=0},this.setTexture2D=setTexture2D,this.setTexture2DArray=function setTexture2DArray(t,o){const l=s.get(t);t.version>0&&l.__version!==t.version?uploadTexture(l,t,o):r.bindTexture(e.TEXTURE_2D_ARRAY,l.__webglTexture,e.TEXTURE0+o)},this.setTexture3D=function setTexture3D(t,o){const l=s.get(t);t.version>0&&l.__version!==t.version?uploadTexture(l,t,o):r.bindTexture(e.TEXTURE_3D,l.__webglTexture,e.TEXTURE0+o)},this.setTextureCube=function setTextureCube(t,h){const p=s.get(t);t.version>0&&p.__version!==t.version?function uploadCubeTexture(t,h,p){if(6!==h.image.length)return;const A=initTexture(t,h),m=h.source;r.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+p);const f=s.get(m);if(m.version!==f.__version||!0===A){r.activeTexture(e.TEXTURE0+p);const t=Et.getPrimaries(Et.workingColorSpace),s=h.colorSpace===Ge?null:Et.getPrimaries(h.colorSpace),g=h.colorSpace===Ge||t===s?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,h.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,h.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,g);const _=h.isCompressedTexture||h.image[0].isCompressedTexture,y=h.image[0]&&h.image[0].isDataTexture,x=[];for(let e=0;e<6;e++)x[e]=_||y?y?h.image[e].image:h.image[e]:resizeImage(h.image[e],!1,!0,l.maxCubemapSize),x[e]=verifyColorSpace(h,x[e]);const S=x[0],C=isPowerOfTwo$1(S)||d,b=c.convert(h.format,h.colorSpace),I=c.convert(h.type),T=getInternalFormat(h.internalFormat,b,I,h.colorSpace),B=d&&!0!==h.isVideoTexture,U=void 0===f.__version||!0===A;let F,O=getMipLevels(h,S,C);if(setTextureParameters(e.TEXTURE_CUBE_MAP,h,C),_){B&&U&&r.texStorage2D(e.TEXTURE_CUBE_MAP,O,T,S.width,S.height);for(let t=0;t<6;t++){F=x[t].mipmaps;for(let s=0;s<F.length;s++){const l=F[s];h.format!==Ae?null!==b?B?r.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,0,0,l.width,l.height,b,l.data):r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,T,l.width,l.height,0,l.data):o.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,0,0,l.width,l.height,b,I,l.data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s,T,l.width,l.height,0,b,I,l.data)}}}else{F=h.mipmaps,B&&U&&(F.length>0&&O++,r.texStorage2D(e.TEXTURE_CUBE_MAP,O,T,x[0].width,x[0].height));for(let t=0;t<6;t++)if(y){B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,x[t].width,x[t].height,b,I,x[t].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,x[t].width,x[t].height,0,b,I,x[t].data);for(let s=0;s<F.length;s++){const o=F[s].image[t].image;B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,0,0,o.width,o.height,b,I,o.data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,T,o.width,o.height,0,b,I,o.data)}}else{B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,b,I,x[t]):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,b,I,x[t]);for(let s=0;s<F.length;s++){const o=F[s];B?r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,0,0,b,I,o.image[t]):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,s+1,T,b,I,o.image[t])}}}textureNeedsGenerateMipmaps(h,C)&&generateMipmap(e.TEXTURE_CUBE_MAP),f.__version=m.version,h.onUpdate&&h.onUpdate(h)}t.__version=h.version}(p,t,h):r.bindTexture(e.TEXTURE_CUBE_MAP,p.__webglTexture,e.TEXTURE0+h)},this.rebindTextures=function rebindTextures(t,r,o){const l=s.get(t);void 0!==r&&setupFrameBufferTexture(l.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==o&&setupDepthRenderbuffer(t)},this.setupRenderTarget=function setupRenderTarget(t){const p=t.texture,A=s.get(t),m=s.get(p);t.addEventListener("dispose",onRenderTargetDispose),!0!==t.isWebGLMultipleRenderTargets&&(void 0===m.__webglTexture&&(m.__webglTexture=e.createTexture()),m.__version=p.version,h.memory.textures++);const f=!0===t.isWebGLCubeRenderTarget,g=!0===t.isWebGLMultipleRenderTargets,_=isPowerOfTwo$1(t)||d;if(f){A.__webglFramebuffer=[];for(let t=0;t<6;t++)if(d&&p.mipmaps&&p.mipmaps.length>0){A.__webglFramebuffer[t]=[];for(let r=0;r<p.mipmaps.length;r++)A.__webglFramebuffer[t][r]=e.createFramebuffer()}else A.__webglFramebuffer[t]=e.createFramebuffer()}else{if(d&&p.mipmaps&&p.mipmaps.length>0){A.__webglFramebuffer=[];for(let t=0;t<p.mipmaps.length;t++)A.__webglFramebuffer[t]=e.createFramebuffer()}else A.__webglFramebuffer=e.createFramebuffer();if(g)if(l.drawBuffers){const r=t.texture;for(let t=0,o=r.length;t<o;t++){const o=s.get(r[t]);void 0===o.__webglTexture&&(o.__webglTexture=e.createTexture(),h.memory.textures++)}}else o.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(d&&t.samples>0&&!1===useMultisampledRTT(t)){const s=g?p:[p];A.__webglMultisampledFramebuffer=e.createFramebuffer(),A.__webglColorRenderbuffer=[],r.bindFramebuffer(e.FRAMEBUFFER,A.__webglMultisampledFramebuffer);for(let r=0;r<s.length;r++){const o=s[r];A.__webglColorRenderbuffer[r]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,A.__webglColorRenderbuffer[r]);const l=c.convert(o.format,o.colorSpace),h=c.convert(o.type),d=getInternalFormat(o.internalFormat,l,h,o.colorSpace,!0===t.isXRRenderTarget),p=getRenderTargetSamples(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,p,d,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+r,e.RENDERBUFFER,A.__webglColorRenderbuffer[r])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(A.__webglDepthRenderbuffer=e.createRenderbuffer(),setupRenderBufferStorage(A.__webglDepthRenderbuffer,t,!0)),r.bindFramebuffer(e.FRAMEBUFFER,null)}}if(f){r.bindTexture(e.TEXTURE_CUBE_MAP,m.__webglTexture),setTextureParameters(e.TEXTURE_CUBE_MAP,p,_);for(let r=0;r<6;r++)if(d&&p.mipmaps&&p.mipmaps.length>0)for(let s=0;s<p.mipmaps.length;s++)setupFrameBufferTexture(A.__webglFramebuffer[r][s],t,p,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+r,s);else setupFrameBufferTexture(A.__webglFramebuffer[r],t,p,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0);textureNeedsGenerateMipmaps(p,_)&&generateMipmap(e.TEXTURE_CUBE_MAP),r.unbindTexture()}else if(g){const o=t.texture;for(let l=0,c=o.length;l<c;l++){const c=o[l],h=s.get(c);r.bindTexture(e.TEXTURE_2D,h.__webglTexture),setTextureParameters(e.TEXTURE_2D,c,_),setupFrameBufferTexture(A.__webglFramebuffer,t,c,e.COLOR_ATTACHMENT0+l,e.TEXTURE_2D,0),textureNeedsGenerateMipmaps(c,_)&&generateMipmap(e.TEXTURE_2D)}r.unbindTexture()}else{let s=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(d?s=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:o.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),r.bindTexture(s,m.__webglTexture),setTextureParameters(s,p,_),d&&p.mipmaps&&p.mipmaps.length>0)for(let r=0;r<p.mipmaps.length;r++)setupFrameBufferTexture(A.__webglFramebuffer[r],t,p,e.COLOR_ATTACHMENT0,s,r);else setupFrameBufferTexture(A.__webglFramebuffer,t,p,e.COLOR_ATTACHMENT0,s,0);textureNeedsGenerateMipmaps(p,_)&&generateMipmap(s),r.unbindTexture()}t.depthBuffer&&setupDepthRenderbuffer(t)},this.updateRenderTargetMipmap=function updateRenderTargetMipmap(t){const o=isPowerOfTwo$1(t)||d,l=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let c=0,h=l.length;c<h;c++){const h=l[c];if(textureNeedsGenerateMipmaps(h,o)){const o=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,l=s.get(h).__webglTexture;r.bindTexture(o,l),generateMipmap(o),r.unbindTexture()}}},this.updateMultisampleRenderTarget=function updateMultisampleRenderTarget(t){if(d&&t.samples>0&&!1===useMultisampledRTT(t)){const o=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],l=t.width,c=t.height;let h=e.COLOR_BUFFER_BIT;const d=[],p=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,m=s.get(t),f=!0===t.isWebGLMultipleRenderTargets;if(f)for(let t=0;t<o.length;t++)r.bindFramebuffer(e.FRAMEBUFFER,m.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),r.bindFramebuffer(e.FRAMEBUFFER,m.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);r.bindFramebuffer(e.READ_FRAMEBUFFER,m.__webglMultisampledFramebuffer),r.bindFramebuffer(e.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let r=0;r<o.length;r++){d.push(e.COLOR_ATTACHMENT0+r),t.depthBuffer&&d.push(p);const g=void 0!==m.__ignoreDepthValues&&m.__ignoreDepthValues;if(!1===g&&(t.depthBuffer&&(h|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(h|=e.STENCIL_BUFFER_BIT)),f&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,m.__webglColorRenderbuffer[r]),!0===g&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[p]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[p])),f){const t=s.get(o[r]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,l,c,0,0,l,c,h,e.NEAREST),A&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,d)}if(r.bindFramebuffer(e.READ_FRAMEBUFFER,null),r.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),f)for(let t=0;t<o.length;t++){r.bindFramebuffer(e.FRAMEBUFFER,m.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,m.__webglColorRenderbuffer[t]);const l=s.get(o[t]).__webglTexture;r.bindFramebuffer(e.FRAMEBUFFER,m.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,l,0)}r.bindFramebuffer(e.DRAW_FRAMEBUFFER,m.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=setupDepthRenderbuffer,this.setupFrameBufferTexture=setupFrameBufferTexture,this.useMultisampledRTT=useMultisampledRTT}function WebGLUtils(e,t,r){const s=r.isWebGL2;return{convert:function convert(r,o=""){let l;const c=Et.getTransfer(o);if(r===oe)return e.UNSIGNED_BYTE;if(1017===r)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===r)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===r)return e.BYTE;if(1011===r)return e.SHORT;if(r===le)return e.UNSIGNED_SHORT;if(r===ce)return e.INT;if(r===he)return e.UNSIGNED_INT;if(r===ue)return e.FLOAT;if(r===de)return s?e.HALF_FLOAT:(l=t.get("OES_texture_half_float"),null!==l?l.HALF_FLOAT_OES:null);if(1021===r)return e.ALPHA;if(r===Ae)return e.RGBA;if(1024===r)return e.LUMINANCE;if(1025===r)return e.LUMINANCE_ALPHA;if(r===me)return e.DEPTH_COMPONENT;if(r===fe)return e.DEPTH_STENCIL;if(r===ot)return l=t.get("EXT_sRGB"),null!==l?l.SRGB_ALPHA_EXT:null;if(r===ge)return e.RED;if(1029===r)return e.RED_INTEGER;if(r===_e)return e.RG;if(1031===r)return e.RG_INTEGER;if(1033===r)return e.RGBA_INTEGER;if(r===ve||r===ye||r===Ee||r===xe)if(c===je){if(l=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===l)return null;if(r===ve)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===ye)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===Ee)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===xe)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(l=t.get("WEBGL_compressed_texture_s3tc"),null===l)return null;if(r===ve)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===ye)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Ee)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===xe)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(r===Se||35841===r||r===Me||35843===r){if(l=t.get("WEBGL_compressed_texture_pvrtc"),null===l)return null;if(r===Se)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===r)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Me)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===r)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===Ce)return l=t.get("WEBGL_compressed_texture_etc1"),null!==l?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===be||r===we){if(l=t.get("WEBGL_compressed_texture_etc"),null===l)return null;if(r===be)return c===je?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(r===we)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}if(r===Ie||37809===r||37810===r||37811===r||r===Te||37813===r||37814===r||37815===r||37816===r||37817===r||37818===r||37819===r||37820===r||37821===r){if(l=t.get("WEBGL_compressed_texture_astc"),null===l)return null;if(r===Ie)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Te)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===r)return c===je?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}if(r===Be||36494===r||36495===r){if(l=t.get("EXT_texture_compression_bptc"),null===l)return null;if(r===Be)return c===je?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(36494===r)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(36495===r)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(36283===r||36284===r||36285===r||36286===r){if(l=t.get("EXT_texture_compression_rgtc"),null===l)return null;if(r===Be)return l.COMPRESSED_RED_RGTC1_EXT;if(36284===r)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===r)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===r)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return r===pe?s?e.UNSIGNED_INT_24_8:(l=t.get("WEBGL_depth_texture"),null!==l?l.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[r]?e[r]:null}}}class ArrayCamera extends PerspectiveCamera{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class three_module_Group extends Object3D{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Jn={type:"move"};class WebXRController{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new three_module_Group,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new three_module_Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new three_module_Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new three_module_Vector3),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new three_module_Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new three_module_Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new three_module_Vector3),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,r){let s=null,o=null,l=null;const c=this._targetRay,h=this._grip,d=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(d&&e.hand){l=!0;for(const s of e.hand.values()){const e=t.getJointPose(s,r),o=this._getHandJoint(d,s);null!==e&&(o.matrix.fromArray(e.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,o.jointRadius=e.radius),o.visible=null!==e}const s=d.joints["index-finger-tip"],o=d.joints["thumb-tip"],c=s.position.distanceTo(o.position),h=.02,p=.005;d.inputState.pinching&&c>h+p?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!d.inputState.pinching&&c<=h-p&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==h&&e.gripSpace&&(o=t.getPose(e.gripSpace,r),null!==o&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));null!==c&&(s=t.getPose(e.targetRaySpace,r),null===s&&null!==o&&(s=o),null!==s&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(Jn)))}return null!==c&&(c.visible=null!==s),null!==h&&(h.visible=null!==o),null!==d&&(d.visible=null!==l),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const r=new three_module_Group;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class WebXRManager extends EventDispatcher{constructor(e,t){super();const r=this;let s=null,l=1,c=null,h="local-floor",d=1,p=null,A=null,m=null,f=null,g=null,_=null;const y=t.getContextAttributes();let x=null,S=null;const C=[],b=[],I=new Vector2;let T=null;const B=new PerspectiveCamera;B.layers.enable(1),B.viewport=new Vector4;const U=new PerspectiveCamera;U.layers.enable(2),U.viewport=new Vector4;const F=[B,U],O=new ArrayCamera;O.layers.enable(1),O.layers.enable(2);let Q=null,G=null;function onSessionEvent(e){const t=b.indexOf(e.inputSource);if(-1===t)return;const r=C[t];void 0!==r&&(r.update(e.inputSource,e.frame,p||c),r.dispatchEvent({type:e.type,data:e.inputSource}))}function onSessionEnd(){s.removeEventListener("select",onSessionEvent),s.removeEventListener("selectstart",onSessionEvent),s.removeEventListener("selectend",onSessionEvent),s.removeEventListener("squeeze",onSessionEvent),s.removeEventListener("squeezestart",onSessionEvent),s.removeEventListener("squeezeend",onSessionEvent),s.removeEventListener("end",onSessionEnd),s.removeEventListener("inputsourceschange",onInputSourcesChange);for(let e=0;e<C.length;e++){const t=b[e];null!==t&&(b[e]=null,C[e].disconnect(t))}Q=null,G=null,e.setRenderTarget(x),g=null,f=null,m=null,s=null,S=null,X.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(I.width,I.height,!1),r.dispatchEvent({type:"sessionend"})}function onInputSourcesChange(e){for(let t=0;t<e.removed.length;t++){const r=e.removed[t],s=b.indexOf(r);s>=0&&(b[s]=null,C[s].disconnect(r))}for(let t=0;t<e.added.length;t++){const r=e.added[t];let s=b.indexOf(r);if(-1===s){for(let e=0;e<C.length;e++){if(e>=b.length){b.push(r),s=e;break}if(null===b[e]){b[e]=r,s=e;break}}if(-1===s)break}const o=C[s];o&&o.connect(r)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=C[e];return void 0===t&&(t=new WebXRController,C[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=C[e];return void 0===t&&(t=new WebXRController,C[e]=t),t.getGripSpace()},this.getHand=function(e){let t=C[e];return void 0===t&&(t=new WebXRController,C[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){l=e,!0===r.isPresenting&&o.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){h=e,!0===r.isPresenting&&o.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return p||c},this.setReferenceSpace=function(e){p=e},this.getBaseLayer=function(){return null!==f?f:g},this.getBinding=function(){return m},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(o){if(s=o,null!==s){if(x=e.getRenderTarget(),s.addEventListener("select",onSessionEvent),s.addEventListener("selectstart",onSessionEvent),s.addEventListener("selectend",onSessionEvent),s.addEventListener("squeeze",onSessionEvent),s.addEventListener("squeezestart",onSessionEvent),s.addEventListener("squeezeend",onSessionEvent),s.addEventListener("end",onSessionEnd),s.addEventListener("inputsourceschange",onInputSourcesChange),!0!==y.xrCompatible&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(I),void 0===s.renderState.layers||!1===e.capabilities.isWebGL2){const r={antialias:void 0!==s.renderState.layers||y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:l};g=new XRWebGLLayer(s,t,r),s.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),S=new WebGLRenderTarget(g.framebufferWidth,g.framebufferHeight,{format:Ae,type:oe,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let r=null,o=null,c=null;y.depth&&(c=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,r=y.stencil?fe:me,o=y.stencil?pe:he);const h={colorFormat:t.RGBA8,depthFormat:c,scaleFactor:l};m=new XRWebGLBinding(s,t),f=m.createProjectionLayer(h),s.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),S=new WebGLRenderTarget(f.textureWidth,f.textureHeight,{format:Ae,type:oe,depthTexture:new DepthTexture(f.textureWidth,f.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,r),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});e.properties.get(S).__ignoreDepthValues=f.ignoreDepthValues}S.isXRRenderTarget=!0,this.setFoveation(d),p=null,c=await s.requestReferenceSpace(h),X.setContext(s),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==s)return s.environmentBlendMode};const W=new three_module_Vector3,q=new three_module_Vector3;function updateCamera(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===s)return;O.near=U.near=B.near=e.near,O.far=U.far=B.far=e.far,Q===O.near&&G===O.far||(s.updateRenderState({depthNear:O.near,depthFar:O.far}),Q=O.near,G=O.far);const t=e.parent,r=O.cameras;updateCamera(O,t);for(let e=0;e<r.length;e++)updateCamera(r[e],t);2===r.length?function setProjectionFromUnion(e,t,r){W.setFromMatrixPosition(t.matrixWorld),q.setFromMatrixPosition(r.matrixWorld);const s=W.distanceTo(q),o=t.projectionMatrix.elements,l=r.projectionMatrix.elements,c=o[14]/(o[10]-1),h=o[14]/(o[10]+1),d=(o[9]+1)/o[5],p=(o[9]-1)/o[5],A=(o[8]-1)/o[0],m=(l[8]+1)/l[0],f=c*A,g=c*m,_=s/(-A+m),y=_*-A;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(y),e.translateZ(_),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const x=c+_,S=h+_,C=f-y,b=g+(s-y),I=d*h/S*x,T=p*h/S*x;e.projectionMatrix.makePerspective(C,b,I,T,x,S),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(O,B,U):O.projectionMatrix.copy(B.projectionMatrix),function updateUserCamera(e,t,r){null===r?e.matrix.copy(t.matrixWorld):(e.matrix.copy(r.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*pt*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,O,t)},this.getCamera=function(){return O},this.getFoveation=function(){if(null!==f||null!==g)return d},this.setFoveation=function(e){d=e,null!==f&&(f.fixedFoveation=e),null!==g&&void 0!==g.fixedFoveation&&(g.fixedFoveation=e)};let j=null;const X=new WebGLAnimation;X.setAnimationLoop((function onAnimationFrame(t,s){if(A=s.getViewerPose(p||c),_=s,null!==A){const t=A.views;null!==g&&(e.setRenderTargetFramebuffer(S,g.framebuffer),e.setRenderTarget(S));let r=!1;t.length!==O.cameras.length&&(O.cameras.length=0,r=!0);for(let s=0;s<t.length;s++){const o=t[s];let l=null;if(null!==g)l=g.getViewport(o);else{const t=m.getViewSubImage(f,o);l=t.viewport,0===s&&(e.setRenderTargetTextures(S,t.colorTexture,f.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(S))}let c=F[s];void 0===c&&(c=new PerspectiveCamera,c.layers.enable(s),c.viewport=new Vector4,F[s]=c),c.matrix.fromArray(o.transform.matrix),c.matrix.decompose(c.position,c.quaternion,c.scale),c.projectionMatrix.fromArray(o.projectionMatrix),c.projectionMatrixInverse.copy(c.projectionMatrix).invert(),c.viewport.set(l.x,l.y,l.width,l.height),0===s&&(O.matrix.copy(c.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),!0===r&&O.cameras.push(c)}}for(let e=0;e<C.length;e++){const t=b[e],r=C[e];null!==t&&void 0!==r&&r.update(t,s,p||c)}j&&j(t,s),s.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:s}),_=null})),this.setAnimationLoop=function(e){j=e},this.dispose=function(){}}}function WebGLMaterials(e,t){function refreshTransformUniform(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function refreshUniformsCommon(r,s){r.opacity.value=s.opacity,s.color&&r.diffuse.value.copy(s.color),s.emissive&&r.emissive.value.copy(s.emissive).multiplyScalar(s.emissiveIntensity),s.map&&(r.map.value=s.map,refreshTransformUniform(s.map,r.mapTransform)),s.alphaMap&&(r.alphaMap.value=s.alphaMap,refreshTransformUniform(s.alphaMap,r.alphaMapTransform)),s.bumpMap&&(r.bumpMap.value=s.bumpMap,refreshTransformUniform(s.bumpMap,r.bumpMapTransform),r.bumpScale.value=s.bumpScale,1===s.side&&(r.bumpScale.value*=-1)),s.normalMap&&(r.normalMap.value=s.normalMap,refreshTransformUniform(s.normalMap,r.normalMapTransform),r.normalScale.value.copy(s.normalScale),1===s.side&&r.normalScale.value.negate()),s.displacementMap&&(r.displacementMap.value=s.displacementMap,refreshTransformUniform(s.displacementMap,r.displacementMapTransform),r.displacementScale.value=s.displacementScale,r.displacementBias.value=s.displacementBias),s.emissiveMap&&(r.emissiveMap.value=s.emissiveMap,refreshTransformUniform(s.emissiveMap,r.emissiveMapTransform)),s.specularMap&&(r.specularMap.value=s.specularMap,refreshTransformUniform(s.specularMap,r.specularMapTransform)),s.alphaTest>0&&(r.alphaTest.value=s.alphaTest);const o=t.get(s).envMap;if(o&&(r.envMap.value=o,r.flipEnvMap.value=o.isCubeTexture&&!1===o.isRenderTargetTexture?-1:1,r.reflectivity.value=s.reflectivity,r.ior.value=s.ior,r.refractionRatio.value=s.refractionRatio),s.lightMap){r.lightMap.value=s.lightMap;const t=!0===e._useLegacyLights?Math.PI:1;r.lightMapIntensity.value=s.lightMapIntensity*t,refreshTransformUniform(s.lightMap,r.lightMapTransform)}s.aoMap&&(r.aoMap.value=s.aoMap,r.aoMapIntensity.value=s.aoMapIntensity,refreshTransformUniform(s.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function refreshFogUniforms(t,r){r.color.getRGB(t.fogColor.value,getUnlitUniformColorSpace(e)),r.isFog?(t.fogNear.value=r.near,t.fogFar.value=r.far):r.isFogExp2&&(t.fogDensity.value=r.density)},refreshMaterialUniforms:function refreshMaterialUniforms(e,r,s,o,l){r.isMeshBasicMaterial||r.isMeshLambertMaterial?refreshUniformsCommon(e,r):r.isMeshToonMaterial?(refreshUniformsCommon(e,r),function refreshUniformsToon(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(refreshUniformsCommon(e,r),function refreshUniformsPhong(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(refreshUniformsCommon(e,r),function refreshUniformsStandard(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,refreshTransformUniform(r.metalnessMap,e.metalnessMapTransform));e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,refreshTransformUniform(r.roughnessMap,e.roughnessMapTransform));const s=t.get(r).envMap;s&&(e.envMapIntensity.value=r.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function refreshUniformsPhysical(e,t,r){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,refreshTransformUniform(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,refreshTransformUniform(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,refreshTransformUniform(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,refreshTransformUniform(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,refreshTransformUniform(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&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,refreshTransformUniform(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,refreshTransformUniform(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,refreshTransformUniform(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,refreshTransformUniform(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,refreshTransformUniform(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,refreshTransformUniform(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,refreshTransformUniform(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,l)):r.isMeshMatcapMaterial?(refreshUniformsCommon(e,r),function refreshUniformsMatcap(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?refreshUniformsCommon(e,r):r.isMeshDistanceMaterial?(refreshUniformsCommon(e,r),function refreshUniformsDistance(e,r){const s=t.get(r).light;e.referencePosition.value.setFromMatrixPosition(s.matrixWorld),e.nearDistance.value=s.shadow.camera.near,e.farDistance.value=s.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?refreshUniformsCommon(e,r):r.isLineBasicMaterial?(!function refreshUniformsLine(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,refreshTransformUniform(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function refreshUniformsDash(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function refreshUniformsPoints(e,t,r,s){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*s,t.map&&(e.map.value=t.map,refreshTransformUniform(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,refreshTransformUniform(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,o):r.isSpriteMaterial?function refreshUniformsSprites(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,refreshTransformUniform(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,refreshTransformUniform(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 WebGLUniformsGroups(e,t,r,s){let l={},c={},h=[];const d=r.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function hasUniformChanged(e,t,r,s){const o=e.value,l=t+"_"+r;if(void 0===s[l])return s[l]="number"==typeof o||"boolean"==typeof o?o:o.clone(),!0;{const e=s[l];if("number"==typeof o||"boolean"==typeof o){if(e!==o)return s[l]=o,!0}else if(!1===e.equals(o))return e.copy(o),!0}return!1}function getUniformSize(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?o.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):o.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function onUniformsGroupsDispose(t){const r=t.target;r.removeEventListener("dispose",onUniformsGroupsDispose);const s=h.indexOf(r.__bindingPointIndex);h.splice(s,1),e.deleteBuffer(l[r.id]),delete l[r.id],delete c[r.id]}return{bind:function bind(e,t){const r=t.program;s.uniformBlockBinding(e,r)},update:function update(r,p){let A=l[r.id];void 0===A&&(!function prepareUniformsGroup(e){const t=e.uniforms;let r=0;const s=16;for(let e=0,o=t.length;e<o;e++){const o=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=o.length;e<t;e++){const t=o[e],l=Array.isArray(t.value)?t.value:[t.value];for(let e=0,o=l.length;e<o;e++){const o=getUniformSize(l[e]),c=r%s;0!==c&&s-c<o.boundary&&(r+=s-c),t.__data=new Float32Array(o.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=r,r+=o.storage}}}const o=r%s;o>0&&(r+=s-o);return e.__size=r,e.__cache={},this}(r),A=function createBuffer(t){const r=function allocateBindingPointIndex(){for(let e=0;e<d;e++)if(-1===h.indexOf(e))return h.push(e),e;return o.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=r;const s=e.createBuffer(),l=t.__size,c=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,s),e.bufferData(e.UNIFORM_BUFFER,l,c),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,r,s),s}(r),l[r.id]=A,r.addEventListener("dispose",onUniformsGroupsDispose));const m=p.program;s.updateUBOMapping(r,m);const f=t.render.frame;c[r.id]!==f&&(!function updateBufferData(t){const r=l[t.id],s=t.uniforms,o=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,r);for(let t=0,r=s.length;t<r;t++){const r=Array.isArray(s[t])?s[t]:[s[t]];for(let s=0,l=r.length;s<l;s++){const l=r[s];if(!0===hasUniformChanged(l,t,s,o)){const t=l.__offset,r=Array.isArray(l.value)?l.value:[l.value];let s=0;for(let o=0;o<r.length;o++){const c=r[o],h=getUniformSize(c);"number"==typeof c||"boolean"==typeof c?(l.__data[0]=c,e.bufferSubData(e.UNIFORM_BUFFER,t+s,l.__data)):c.isMatrix3?(l.__data[0]=c.elements[0],l.__data[1]=c.elements[1],l.__data[2]=c.elements[2],l.__data[3]=0,l.__data[4]=c.elements[3],l.__data[5]=c.elements[4],l.__data[6]=c.elements[5],l.__data[7]=0,l.__data[8]=c.elements[6],l.__data[9]=c.elements[7],l.__data[10]=c.elements[8],l.__data[11]=0):(c.toArray(l.__data,s),s+=h.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,l.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(r),c[r.id]=f)},dispose:function dispose(){for(const t in l)e.deleteBuffer(l[t]);h=[],l={},c={}}}}class WebGLRenderer{constructor(e={}){const{canvas:t=createCanvasElement(),context:r=null,depth:s=!0,stencil:c=!0,alpha:h=!1,antialias:d=!1,premultipliedAlpha:p=!0,preserveDrawingBuffer:A=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:f=!1}=e;let g;this.isWebGLRenderer=!0,g=null!==r?r.getContextAttributes().alpha:h;const _=new Uint32Array(4),y=new Int32Array(4);let x=null,S=null;const C=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ve,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const I=this;let T=!1,B=0,U=0,F=null,O=-1,Q=null;const G=new Vector4,W=new Vector4;let q=null;const j=new Color(0);let X=0,Y=t.width,K=t.height,J=1,$=null,ee=null;const te=new Vector4(0,0,Y,K),ie=new Vector4(0,0,Y,K);let ne=!1;const re=new Frustum;let se=!1,ce=!1,me=null;const fe=new three_module_Matrix4,ge=new Vector2,_e=new three_module_Vector3,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function getTargetPixelRatio(){return null===F?J:1}let ye,Ee,xe,Se,Me,Ce,be,we,Ie,Te,Be,Re,Le,De,Ue,Pe,Fe,Ne,Oe,Qe,ke,Ge,ze,We,qe=r;function getContext(e,r){for(let s=0;s<e.length;s++){const o=e[s],l=t.getContext(o,r);if(null!==l)return l}return null}try{const e={alpha:!0,depth:s,stencil:c,antialias:d,premultipliedAlpha:p,preserveDrawingBuffer:A,powerPreference:m,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${l}`),t.addEventListener("webglcontextlost",onContextLost,!1),t.addEventListener("webglcontextrestored",onContextRestore,!1),t.addEventListener("webglcontextcreationerror",onContextCreationError,!1),null===qe){const t=["webgl2","webgl","experimental-webgl"];if(!0===I.isWebGL1Renderer&&t.shift(),qe=getContext(t,e),null===qe)throw getContext(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!=typeof WebGLRenderingContext&&qe instanceof WebGLRenderingContext&&o.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===qe.getShaderPrecisionFormat&&(qe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw o.error("THREE.WebGLRenderer: "+e.message),e}function initGLContext(){ye=new WebGLExtensions(qe),Ee=new WebGLCapabilities(qe,ye,e),ye.init(Ee),Ge=new WebGLUtils(qe,ye,Ee),xe=new WebGLState(qe,ye,Ee),Se=new WebGLInfo(qe),Me=new WebGLProperties,Ce=new WebGLTextures(qe,ye,xe,Me,Ee,Ge,Se),be=new WebGLCubeMaps(I),we=new WebGLCubeUVMaps(I),Ie=new WebGLAttributes(qe,Ee),ze=new WebGLBindingStates(qe,ye,Ie,Ee),Te=new WebGLGeometries(qe,Ie,Se,ze),Be=new WebGLObjects(qe,Te,Ie,Se),Oe=new WebGLMorphtargets(qe,Ee,Ce),Pe=new WebGLClipping(Me),Re=new WebGLPrograms(I,be,we,ye,Ee,ze,Pe),Le=new WebGLMaterials(I,Me),De=new WebGLRenderLists,Ue=new WebGLRenderStates(ye,Ee),Ne=new WebGLBackground(I,be,we,xe,Be,g,p),Fe=new WebGLShadowMap(I,Be,Ee),We=new WebGLUniformsGroups(qe,Se,Ee,xe),Qe=new WebGLBufferRenderer(qe,ye,Se,Ee),ke=new WebGLIndexedBufferRenderer(qe,ye,Se,Ee),Se.programs=Re.programs,I.capabilities=Ee,I.extensions=ye,I.properties=Me,I.renderLists=De,I.shadowMap=Fe,I.state=xe,I.info=Se}initGLContext();const je=new WebXRManager(I,qe);function onContextLost(e){e.preventDefault(),o.log("THREE.WebGLRenderer: Context Lost."),T=!0}function onContextRestore(){o.log("THREE.WebGLRenderer: Context Restored."),T=!1;const e=Se.autoReset,t=Fe.enabled,r=Fe.autoUpdate,s=Fe.needsUpdate,l=Fe.type;initGLContext(),Se.autoReset=e,Fe.enabled=t,Fe.autoUpdate=r,Fe.needsUpdate=s,Fe.type=l}function onContextCreationError(e){o.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function onMaterialDispose(e){const t=e.target;t.removeEventListener("dispose",onMaterialDispose),function deallocateMaterial(e){(function releaseMaterialProgramReferences(e){const t=Me.get(e).programs;void 0!==t&&(t.forEach((function(e){Re.releaseProgram(e)})),e.isShaderMaterial&&Re.releaseShaderCache(e))})(e),Me.remove(e)}(t)}function prepareMaterial(e,t,r){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,getProgram(e,t,r),e.side=0,e.needsUpdate=!0,getProgram(e,t,r),e.side=2):getProgram(e,t,r)}this.xr=je,this.getContext=function(){return qe},this.getContextAttributes=function(){return qe.getContextAttributes()},this.forceContextLoss=function(){const e=ye.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=ye.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(e){void 0!==e&&(J=e,this.setSize(Y,K,!1))},this.getSize=function(e){return e.set(Y,K)},this.setSize=function(e,r,s=!0){je.isPresenting?o.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(Y=e,K=r,t.width=Math.floor(e*J),t.height=Math.floor(r*J),!0===s&&(t.style.width=e+"px",t.style.height=r+"px"),this.setViewport(0,0,e,r))},this.getDrawingBufferSize=function(e){return e.set(Y*J,K*J).floor()},this.setDrawingBufferSize=function(e,r,s){Y=e,K=r,J=s,t.width=Math.floor(e*s),t.height=Math.floor(r*s),this.setViewport(0,0,e,r)},this.getCurrentViewport=function(e){return e.copy(G)},this.getViewport=function(e){return e.copy(te)},this.setViewport=function(e,t,r,s){e.isVector4?te.set(e.x,e.y,e.z,e.w):te.set(e,t,r,s),xe.viewport(G.copy(te).multiplyScalar(J).floor())},this.getScissor=function(e){return e.copy(ie)},this.setScissor=function(e,t,r,s){e.isVector4?ie.set(e.x,e.y,e.z,e.w):ie.set(e,t,r,s),xe.scissor(W.copy(ie).multiplyScalar(J).floor())},this.getScissorTest=function(){return ne},this.setScissorTest=function(e){xe.setScissorTest(ne=e)},this.setOpaqueSort=function(e){$=e},this.setTransparentSort=function(e){ee=e},this.getClearColor=function(e){return e.copy(Ne.getClearColor())},this.setClearColor=function(){Ne.setClearColor.apply(Ne,arguments)},this.getClearAlpha=function(){return Ne.getClearAlpha()},this.setClearAlpha=function(){Ne.setClearAlpha.apply(Ne,arguments)},this.clear=function(e=!0,t=!0,r=!0){let s=0;if(e){let e=!1;if(null!==F){const t=F.texture.format;e=1033===t||1031===t||1029===t}if(e){const e=F.texture.type,t=e===oe||e===he||e===le||e===pe||1017===e||1018===e,r=Ne.getClearColor(),s=Ne.getClearAlpha(),o=r.r,l=r.g,c=r.b;t?(_[0]=o,_[1]=l,_[2]=c,_[3]=s,qe.clearBufferuiv(qe.COLOR,0,_)):(y[0]=o,y[1]=l,y[2]=c,y[3]=s,qe.clearBufferiv(qe.COLOR,0,y))}else s|=qe.COLOR_BUFFER_BIT}t&&(s|=qe.DEPTH_BUFFER_BIT),r&&(s|=qe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),qe.clear(s)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",onContextLost,!1),t.removeEventListener("webglcontextrestored",onContextRestore,!1),t.removeEventListener("webglcontextcreationerror",onContextCreationError,!1),De.dispose(),Ue.dispose(),Me.dispose(),be.dispose(),we.dispose(),Be.dispose(),ze.dispose(),We.dispose(),Re.dispose(),je.dispose(),je.removeEventListener("sessionstart",onXRSessionStart),je.removeEventListener("sessionend",onXRSessionEnd),me&&(me.dispose(),me=null),Ye.stop()},this.renderBufferDirect=function(e,t,r,s,l,c){null===t&&(t=ve);const h=l.isMesh&&l.matrixWorld.determinant()<0,d=function setProgram(e,t,r,s,l){!0!==t.isScene&&(t=ve);Ce.resetTextureUnits();const c=t.fog,h=s.isMeshStandardMaterial?t.environment:null,d=null===F?I.outputColorSpace:!0===F.isXRRenderTarget?F.texture.colorSpace:He,p=(s.isMeshStandardMaterial?we:be).get(s.envMap||h),A=!0===s.vertexColors&&!!r.attributes.color&&4===r.attributes.color.itemSize,m=!!r.attributes.tangent&&(!!s.normalMap||s.anisotropy>0),f=!!r.morphAttributes.position,g=!!r.morphAttributes.normal,_=!!r.morphAttributes.color;let y=0;s.toneMapped&&(null!==F&&!0!==F.isXRRenderTarget||(y=I.toneMapping));const x=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,C=void 0!==x?x.length:0,b=Me.get(s),T=S.state.lights;if(!0===se&&(!0===ce||e!==Q)){const t=e===Q&&s.id===O;Pe.setState(s,e,t)}let B=!1;s.version===b.__version?b.needsLights&&b.lightsStateVersion!==T.state.version||b.outputColorSpace!==d||l.isBatchedMesh&&!1===b.batching?B=!0:l.isBatchedMesh||!0!==b.batching?l.isInstancedMesh&&!1===b.instancing?B=!0:l.isInstancedMesh||!0!==b.instancing?l.isSkinnedMesh&&!1===b.skinning?B=!0:l.isSkinnedMesh||!0!==b.skinning?l.isInstancedMesh&&!0===b.instancingColor&&null===l.instanceColor||l.isInstancedMesh&&!1===b.instancingColor&&null!==l.instanceColor||b.envMap!==p||!0===s.fog&&b.fog!==c?B=!0:void 0===b.numClippingPlanes||b.numClippingPlanes===Pe.numPlanes&&b.numIntersection===Pe.numIntersection?(b.vertexAlphas!==A||b.vertexTangents!==m||b.morphTargets!==f||b.morphNormals!==g||b.morphColors!==_||b.toneMapping!==y||!0===Ee.isWebGL2&&b.morphTargetsCount!==C)&&(B=!0):B=!0:B=!0:B=!0:B=!0:(B=!0,b.__version=s.version);let U=b.currentProgram;!0===B&&(U=getProgram(s,t,l));let G=!1,W=!1,q=!1;const j=U.getUniforms(),X=b.uniforms;xe.useProgram(U.program)&&(G=!0,W=!0,q=!0);s.id!==O&&(O=s.id,W=!0);if(G||Q!==e){j.setValue(qe,"projectionMatrix",e.projectionMatrix),j.setValue(qe,"viewMatrix",e.matrixWorldInverse);const t=j.map.cameraPosition;void 0!==t&&t.setValue(qe,_e.setFromMatrixPosition(e.matrixWorld)),Ee.logarithmicDepthBuffer&&j.setValue(qe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(s.isMeshPhongMaterial||s.isMeshToonMaterial||s.isMeshLambertMaterial||s.isMeshBasicMaterial||s.isMeshStandardMaterial||s.isShaderMaterial)&&j.setValue(qe,"isOrthographic",!0===e.isOrthographicCamera),Q!==e&&(Q=e,W=!0,q=!0)}if(l.isSkinnedMesh){j.setOptional(qe,l,"bindMatrix"),j.setOptional(qe,l,"bindMatrixInverse");const e=l.skeleton;e&&(Ee.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),j.setValue(qe,"boneTexture",e.boneTexture,Ce)):o.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}l.isBatchedMesh&&(j.setOptional(qe,l,"batchingTexture"),j.setValue(qe,"batchingTexture",l._matricesTexture,Ce));const Y=r.morphAttributes;(void 0!==Y.position||void 0!==Y.normal||void 0!==Y.color&&!0===Ee.isWebGL2)&&Oe.update(l,r,U);(W||b.receiveShadow!==l.receiveShadow)&&(b.receiveShadow=l.receiveShadow,j.setValue(qe,"receiveShadow",l.receiveShadow));s.isMeshGouraudMaterial&&null!==s.envMap&&(X.envMap.value=p,X.flipEnvMap.value=p.isCubeTexture&&!1===p.isRenderTargetTexture?-1:1);W&&(j.setValue(qe,"toneMappingExposure",I.toneMappingExposure),b.needsLights&&function markUniformsLightsNeedsUpdate(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(X,q),c&&!0===s.fog&&Le.refreshFogUniforms(X,c),Le.refreshMaterialUniforms(X,s,J,K,me),WebGLUniforms.upload(qe,getUniformList(b),X,Ce));s.isShaderMaterial&&!0===s.uniformsNeedUpdate&&(WebGLUniforms.upload(qe,getUniformList(b),X,Ce),s.uniformsNeedUpdate=!1);s.isSpriteMaterial&&j.setValue(qe,"center",l.center);if(j.setValue(qe,"modelViewMatrix",l.modelViewMatrix),j.setValue(qe,"normalMatrix",l.normalMatrix),j.setValue(qe,"modelMatrix",l.matrixWorld),s.isShaderMaterial||s.isRawShaderMaterial){const e=s.uniformsGroups;for(let t=0,r=e.length;t<r;t++)if(Ee.isWebGL2){const r=e[t];We.update(r,U),We.bind(r,U)}else o.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return U}(e,t,r,s,l);xe.setMaterial(s,h);let p=r.index,A=1;if(!0===s.wireframe){if(p=Te.getWireframeAttribute(r),void 0===p)return;A=2}const m=r.drawRange,f=r.attributes.position;let g=m.start*A,_=(m.start+m.count)*A;null!==c&&(g=Math.max(g,c.start*A),_=Math.min(_,(c.start+c.count)*A)),null!==p?(g=Math.max(g,0),_=Math.min(_,p.count)):null!=f&&(g=Math.max(g,0),_=Math.min(_,f.count));const y=_-g;if(y<0||y===1/0)return;let x;ze.setup(l,s,d,r,p);let C=Qe;if(null!==p&&(x=Ie.get(p),C=ke,C.setIndex(x)),l.isMesh)!0===s.wireframe?(xe.setLineWidth(s.wireframeLinewidth*getTargetPixelRatio()),C.setMode(qe.LINES)):C.setMode(qe.TRIANGLES);else if(l.isLine){let e=s.linewidth;void 0===e&&(e=1),xe.setLineWidth(e*getTargetPixelRatio()),l.isLineSegments?C.setMode(qe.LINES):l.isLineLoop?C.setMode(qe.LINE_LOOP):C.setMode(qe.LINE_STRIP)}else l.isPoints?C.setMode(qe.POINTS):l.isSprite&&C.setMode(qe.TRIANGLES);if(l.isBatchedMesh)C.renderMultiDraw(l._multiDrawStarts,l._multiDrawCounts,l._multiDrawCount);else if(l.isInstancedMesh)C.renderInstances(g,y,l.count);else if(r.isInstancedBufferGeometry){const e=void 0!==r._maxInstanceCount?r._maxInstanceCount:1/0,t=Math.min(r.instanceCount,e);C.renderInstances(g,y,t)}else C.render(g,y)},this.compile=function(e,t,r=null){null===r&&(r=e),S=Ue.get(r),S.init(),b.push(S),r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(S.pushLight(e),e.castShadow&&S.pushShadow(e))})),e!==r&&e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(S.pushLight(e),e.castShadow&&S.pushShadow(e))})),S.setupLights(I._useLegacyLights);const s=new Set;return e.traverse((function(e){const t=e.material;if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++){const l=t[o];prepareMaterial(l,r,e),s.add(l)}else prepareMaterial(t,r,e),s.add(t)})),b.pop(),S=null,s},this.compileAsync=function(e,t,r=null){const s=this.compile(e,t,r);return new Promise((t=>{function checkMaterialsReady(){s.forEach((function(e){Me.get(e).currentProgram.isReady()&&s.delete(e)})),0!==s.size?setTimeout(checkMaterialsReady,10):t(e)}null!==ye.get("KHR_parallel_shader_compile")?checkMaterialsReady():setTimeout(checkMaterialsReady,10)}))};let Xe=null;function onXRSessionStart(){Ye.stop()}function onXRSessionEnd(){Ye.start()}const Ye=new WebGLAnimation;function projectObject(e,t,r,s){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)S.pushLight(e),e.castShadow&&S.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||re.intersectsSprite(e)){s&&_e.setFromMatrixPosition(e.matrixWorld).applyMatrix4(fe);const t=Be.update(e),o=e.material;o.visible&&x.push(e,t,o,r,_e.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||re.intersectsObject(e))){const t=Be.update(e),o=e.material;if(s&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),_e.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),_e.copy(t.boundingSphere.center)),_e.applyMatrix4(e.matrixWorld).applyMatrix4(fe)),Array.isArray(o)){const s=t.groups;for(let l=0,c=s.length;l<c;l++){const c=s[l],h=o[c.materialIndex];h&&h.visible&&x.push(e,t,h,r,_e.z,c)}}else o.visible&&x.push(e,t,o,r,_e.z,null)}const o=e.children;for(let e=0,l=o.length;e<l;e++)projectObject(o[e],t,r,s)}function renderScene(e,t,r,s){const o=e.opaque,l=e.transmissive,c=e.transparent;S.setupLightsView(r),!0===se&&Pe.setGlobalState(I.clippingPlanes,r),l.length>0&&function renderTransmissionPass(e,t,r,s){const o=!0===r.isScene?r.overrideMaterial:null;if(null!==o)return;const l=Ee.isWebGL2;null===me&&(me=new WebGLRenderTarget(1,1,{generateMipmaps:!0,type:ye.has("EXT_color_buffer_half_float")?de:oe,minFilter:ae,samples:l?4:0}));I.getDrawingBufferSize(ge),l?me.setSize(ge.x,ge.y):me.setSize(floorPowerOfTwo(ge.x),floorPowerOfTwo(ge.y));const c=I.getRenderTarget();I.setRenderTarget(me),I.getClearColor(j),X=I.getClearAlpha(),X<1&&I.setClearColor(16777215,.5);I.clear();const h=I.toneMapping;I.toneMapping=0,renderObjects(e,r,s),Ce.updateMultisampleRenderTarget(me),Ce.updateRenderTargetMipmap(me);let d=!1;for(let e=0,o=t.length;e<o;e++){const o=t[e],l=o.object,c=o.geometry,h=o.material,p=o.group;if(2===h.side&&l.layers.test(s.layers)){const e=h.side;h.side=1,h.needsUpdate=!0,renderObject(l,r,s,c,h,p),h.side=e,h.needsUpdate=!0,d=!0}}!0===d&&(Ce.updateMultisampleRenderTarget(me),Ce.updateRenderTargetMipmap(me));I.setRenderTarget(c),I.setClearColor(j,X),I.toneMapping=h}(o,l,t,r),s&&xe.viewport(G.copy(s)),o.length>0&&renderObjects(o,t,r),l.length>0&&renderObjects(l,t,r),c.length>0&&renderObjects(c,t,r),xe.buffers.depth.setTest(!0),xe.buffers.depth.setMask(!0),xe.buffers.color.setMask(!0),xe.setPolygonOffset(!1)}function renderObjects(e,t,r){const s=!0===t.isScene?t.overrideMaterial:null;for(let o=0,l=e.length;o<l;o++){const l=e[o],c=l.object,h=l.geometry,d=null===s?l.material:s,p=l.group;c.layers.test(r.layers)&&renderObject(c,t,r,h,d,p)}}function renderObject(e,t,r,s,o,l){e.onBeforeRender(I,t,r,s,o,l),e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),o.onBeforeRender(I,t,r,s,e,l),!0===o.transparent&&2===o.side&&!1===o.forceSinglePass?(o.side=1,o.needsUpdate=!0,I.renderBufferDirect(r,t,s,o,e,l),o.side=0,o.needsUpdate=!0,I.renderBufferDirect(r,t,s,o,e,l),o.side=2):I.renderBufferDirect(r,t,s,o,e,l),e.onAfterRender(I,t,r,s,o,l)}function getProgram(e,t,r){!0!==t.isScene&&(t=ve);const s=Me.get(e),o=S.state.lights,l=S.state.shadowsArray,c=o.state.version,h=Re.getParameters(e,o.state,l,t,r),d=Re.getProgramCacheKey(h);let p=s.programs;s.environment=e.isMeshStandardMaterial?t.environment:null,s.fog=t.fog,s.envMap=(e.isMeshStandardMaterial?we:be).get(e.envMap||s.environment),void 0===p&&(e.addEventListener("dispose",onMaterialDispose),p=new Map,s.programs=p);let A=p.get(d);if(void 0!==A){if(s.currentProgram===A&&s.lightsStateVersion===c)return updateCommonMaterialProperties(e,h),A}else h.uniforms=Re.getUniforms(e),e.onBuild(r,h,I),e.onBeforeCompile(h,I),A=Re.acquireProgram(h,d),p.set(d,A),s.uniforms=h.uniforms;const m=s.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(m.clippingPlanes=Pe.uniform),updateCommonMaterialProperties(e,h),s.needsLights=function materialNeedsLights(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),s.lightsStateVersion=c,s.needsLights&&(m.ambientLightColor.value=o.state.ambient,m.lightProbe.value=o.state.probe,m.directionalLights.value=o.state.directional,m.directionalLightShadows.value=o.state.directionalShadow,m.spotLights.value=o.state.spot,m.spotLightShadows.value=o.state.spotShadow,m.rectAreaLights.value=o.state.rectArea,m.ltc_1.value=o.state.rectAreaLTC1,m.ltc_2.value=o.state.rectAreaLTC2,m.pointLights.value=o.state.point,m.pointLightShadows.value=o.state.pointShadow,m.hemisphereLights.value=o.state.hemi,m.directionalShadowMap.value=o.state.directionalShadowMap,m.directionalShadowMatrix.value=o.state.directionalShadowMatrix,m.spotShadowMap.value=o.state.spotShadowMap,m.spotLightMatrix.value=o.state.spotLightMatrix,m.spotLightMap.value=o.state.spotLightMap,m.pointShadowMap.value=o.state.pointShadowMap,m.pointShadowMatrix.value=o.state.pointShadowMatrix),s.currentProgram=A,s.uniformsList=null,A}function getUniformList(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=WebGLUniforms.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function updateCommonMaterialProperties(e,t){const r=Me.get(e);r.outputColorSpace=t.outputColorSpace,r.batching=t.batching,r.instancing=t.instancing,r.instancingColor=t.instancingColor,r.skinning=t.skinning,r.morphTargets=t.morphTargets,r.morphNormals=t.morphNormals,r.morphColors=t.morphColors,r.morphTargetsCount=t.morphTargetsCount,r.numClippingPlanes=t.numClippingPlanes,r.numIntersection=t.numClipIntersection,r.vertexAlphas=t.vertexAlphas,r.vertexTangents=t.vertexTangents,r.toneMapping=t.toneMapping}Ye.setAnimationLoop((function onAnimationFrame(e){Xe&&Xe(e)})),"undefined"!=typeof self&&Ye.setContext(self),this.setAnimationLoop=function(e){Xe=e,je.setAnimationLoop(e),null===e?Ye.stop():Ye.start()},je.addEventListener("sessionstart",onXRSessionStart),je.addEventListener("sessionend",onXRSessionEnd),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void o.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===T)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===je.enabled&&!0===je.isPresenting&&(!0===je.cameraAutoUpdate&&je.updateCamera(t),t=je.getCamera()),!0===e.isScene&&e.onBeforeRender(I,e,t,F),S=Ue.get(e,b.length),S.init(),b.push(S),fe.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),re.setFromProjectionMatrix(fe),ce=this.localClippingEnabled,se=Pe.init(this.clippingPlanes,ce),x=De.get(e,C.length),x.init(),C.push(x),projectObject(e,t,0,I.sortObjects),x.finish(),!0===I.sortObjects&&x.sort($,ee),this.info.render.frame++,!0===se&&Pe.beginShadows();const r=S.state.shadowsArray;if(Fe.render(r,e,t),!0===se&&Pe.endShadows(),!0===this.info.autoReset&&this.info.reset(),Ne.render(x,e),S.setupLights(I._useLegacyLights),t.isArrayCamera){const r=t.cameras;for(let t=0,s=r.length;t<s;t++){const s=r[t];renderScene(x,e,s,s.viewport)}}else renderScene(x,e,t);null!==F&&(Ce.updateMultisampleRenderTarget(F),Ce.updateRenderTargetMipmap(F)),!0===e.isScene&&e.onAfterRender(I,e,t),ze.resetDefaultState(),O=-1,Q=null,b.pop(),S=b.length>0?b[b.length-1]:null,C.pop(),x=C.length>0?C[C.length-1]:null},this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return U},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(e,t,r){Me.get(e.texture).__webglTexture=t,Me.get(e.depthTexture).__webglTexture=r;const s=Me.get(e);s.__hasExternalTextures=!0,s.__hasExternalTextures&&(s.__autoAllocateDepthBuffer=void 0===r,s.__autoAllocateDepthBuffer||!0===ye.has("WEBGL_multisampled_render_to_texture")&&(o.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),s.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const r=Me.get(e);r.__webglFramebuffer=t,r.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,r=0){F=e,B=t,U=r;let s=!0,o=null,l=!1,c=!1;if(e){const h=Me.get(e);void 0!==h.__useDefaultFramebuffer?(xe.bindFramebuffer(qe.FRAMEBUFFER,null),s=!1):void 0===h.__webglFramebuffer?Ce.setupRenderTarget(e):h.__hasExternalTextures&&Ce.rebindTextures(e,Me.get(e.texture).__webglTexture,Me.get(e.depthTexture).__webglTexture);const d=e.texture;(d.isData3DTexture||d.isDataArrayTexture||d.isCompressedArrayTexture)&&(c=!0);const p=Me.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(o=Array.isArray(p[t])?p[t][r]:p[t],l=!0):o=Ee.isWebGL2&&e.samples>0&&!1===Ce.useMultisampledRTT(e)?Me.get(e).__webglMultisampledFramebuffer:Array.isArray(p)?p[r]:p,G.copy(e.viewport),W.copy(e.scissor),q=e.scissorTest}else G.copy(te).multiplyScalar(J).floor(),W.copy(ie).multiplyScalar(J).floor(),q=ne;if(xe.bindFramebuffer(qe.FRAMEBUFFER,o)&&Ee.drawBuffers&&s&&xe.drawBuffers(e,o),xe.viewport(G),xe.scissor(W),xe.setScissorTest(q),l){const s=Me.get(e.texture);qe.framebufferTexture2D(qe.FRAMEBUFFER,qe.COLOR_ATTACHMENT0,qe.TEXTURE_CUBE_MAP_POSITIVE_X+t,s.__webglTexture,r)}else if(c){const s=Me.get(e.texture),o=t||0;qe.framebufferTextureLayer(qe.FRAMEBUFFER,qe.COLOR_ATTACHMENT0,s.__webglTexture,r||0,o)}O=-1},this.readRenderTargetPixels=function(e,t,r,s,l,c,h){if(!e||!e.isWebGLRenderTarget)return void o.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let d=Me.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==h&&(d=d[h]),d){xe.bindFramebuffer(qe.FRAMEBUFFER,d);try{const h=e.texture,d=h.format,p=h.type;if(d!==Ae&&Ge.convert(d)!==qe.getParameter(qe.IMPLEMENTATION_COLOR_READ_FORMAT))return void o.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const A=p===de&&(ye.has("EXT_color_buffer_half_float")||Ee.isWebGL2&&ye.has("EXT_color_buffer_float"));if(!(p===oe||Ge.convert(p)===qe.getParameter(qe.IMPLEMENTATION_COLOR_READ_TYPE)||p===ue&&(Ee.isWebGL2||ye.has("OES_texture_float")||ye.has("WEBGL_color_buffer_float"))||A))return void o.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-s&&r>=0&&r<=e.height-l&&qe.readPixels(t,r,s,l,Ge.convert(d),Ge.convert(p),c)}finally{const e=null!==F?Me.get(F).__webglFramebuffer:null;xe.bindFramebuffer(qe.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,r=0){const s=Math.pow(2,-r),o=Math.floor(t.image.width*s),l=Math.floor(t.image.height*s);Ce.setTexture2D(t,0),qe.copyTexSubImage2D(qe.TEXTURE_2D,r,0,0,e.x,e.y,o,l),xe.unbindTexture()},this.copyTextureToTexture=function(e,t,r,s=0){const o=t.image.width,l=t.image.height,c=Ge.convert(r.format),h=Ge.convert(r.type);Ce.setTexture2D(r,0),qe.pixelStorei(qe.UNPACK_FLIP_Y_WEBGL,r.flipY),qe.pixelStorei(qe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),qe.pixelStorei(qe.UNPACK_ALIGNMENT,r.unpackAlignment),t.isDataTexture?qe.texSubImage2D(qe.TEXTURE_2D,s,e.x,e.y,o,l,c,h,t.image.data):t.isCompressedTexture?qe.compressedTexSubImage2D(qe.TEXTURE_2D,s,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,c,t.mipmaps[0].data):qe.texSubImage2D(qe.TEXTURE_2D,s,e.x,e.y,c,h,t.image),0===s&&r.generateMipmaps&&qe.generateMipmap(qe.TEXTURE_2D),xe.unbindTexture()},this.copyTextureToTexture3D=function(e,t,r,s,l=0){if(I.isWebGL1Renderer)return void o.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const c=e.max.x-e.min.x+1,h=e.max.y-e.min.y+1,d=e.max.z-e.min.z+1,p=Ge.convert(s.format),A=Ge.convert(s.type);let m;if(s.isData3DTexture)Ce.setTexture3D(s,0),m=qe.TEXTURE_3D;else{if(!s.isDataArrayTexture&&!s.isCompressedArrayTexture)return void o.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Ce.setTexture2DArray(s,0),m=qe.TEXTURE_2D_ARRAY}qe.pixelStorei(qe.UNPACK_FLIP_Y_WEBGL,s.flipY),qe.pixelStorei(qe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),qe.pixelStorei(qe.UNPACK_ALIGNMENT,s.unpackAlignment);const f=qe.getParameter(qe.UNPACK_ROW_LENGTH),g=qe.getParameter(qe.UNPACK_IMAGE_HEIGHT),_=qe.getParameter(qe.UNPACK_SKIP_PIXELS),y=qe.getParameter(qe.UNPACK_SKIP_ROWS),x=qe.getParameter(qe.UNPACK_SKIP_IMAGES),S=r.isCompressedTexture?r.mipmaps[l]:r.image;qe.pixelStorei(qe.UNPACK_ROW_LENGTH,S.width),qe.pixelStorei(qe.UNPACK_IMAGE_HEIGHT,S.height),qe.pixelStorei(qe.UNPACK_SKIP_PIXELS,e.min.x),qe.pixelStorei(qe.UNPACK_SKIP_ROWS,e.min.y),qe.pixelStorei(qe.UNPACK_SKIP_IMAGES,e.min.z),r.isDataTexture||r.isData3DTexture?qe.texSubImage3D(m,l,t.x,t.y,t.z,c,h,d,p,A,S.data):r.isCompressedArrayTexture?(o.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),qe.compressedTexSubImage3D(m,l,t.x,t.y,t.z,c,h,d,p,S.data)):qe.texSubImage3D(m,l,t.x,t.y,t.z,c,h,d,p,A,S),qe.pixelStorei(qe.UNPACK_ROW_LENGTH,f),qe.pixelStorei(qe.UNPACK_IMAGE_HEIGHT,g),qe.pixelStorei(qe.UNPACK_SKIP_PIXELS,_),qe.pixelStorei(qe.UNPACK_SKIP_ROWS,y),qe.pixelStorei(qe.UNPACK_SKIP_IMAGES,x),0===l&&s.generateMipmaps&&qe.generateMipmap(m),xe.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Ce.setTextureCube(e,0):e.isData3DTexture?Ce.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Ce.setTexture2DArray(e,0):Ce.setTexture2D(e,0),xe.unbindTexture()},this.resetState=function(){B=0,U=0,F=null,xe.reset(),ze.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return lt}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ze?"display-p3":"srgb",t.unpackColorSpace=Et.workingColorSpace===We?"display-p3":"srgb"}get outputEncoding(){return o.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ve?ke:3e3}set outputEncoding(e){o.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===ke?Ve:He}get useLegacyLights(){return o.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){o.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 WebGL1Renderer extends WebGLRenderer{}).prototype.isWebGL1Renderer=!0;class Scene extends Object3D{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"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 three_module_InterleavedBuffer{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=st,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=generateUUID()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return o.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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,r){e*=this.stride,r*=t.stride;for(let s=0,o=this.stride;s<o;s++)this.array[e+s]=t.array[r+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const $n=new three_module_Vector3;class three_module_InterleavedBufferAttribute{constructor(e,t,r,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,r=this.data.count;t<r;t++)$n.fromBufferAttribute(this,t),$n.applyMatrix4(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)$n.fromBufferAttribute(this,t),$n.applyNormalMatrix(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)$n.fromBufferAttribute(this,t),$n.transformDirection(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=denormalize(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=denormalize(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=denormalize(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=denormalize(t,this.array)),t}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=s,this}setXYZW(e,t,r,s,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),r=normalize(r,this.array),s=normalize(s,this.array),o=normalize(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=s,this.data.array[e+3]=o,this}clone(e){if(void 0===e){o.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return new three_module_BufferAttribute(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new three_module_InterleavedBufferAttribute(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){o.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const Zn=new three_module_Vector3,er=new Vector4,tr=new Vector4,ir=new three_module_Vector3,nr=new three_module_Matrix4,rr=new three_module_Vector3,sr=new Sphere,ar=new three_module_Matrix4,or=new Ray;class SkinnedMesh extends three_module_Mesh{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=G,this.bindMatrix=new three_module_Matrix4,this.bindMatrixInverse=new three_module_Matrix4,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new Box3),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,rr),this.boundingBox.expandByPoint(rr)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Sphere),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)this.getVertexPosition(e,rr),this.boundingSphere.expandByPoint(rr)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const r=this.material,s=this.matrixWorld;void 0!==r&&(null===this.boundingSphere&&this.computeBoundingSphere(),sr.copy(this.boundingSphere),sr.applyMatrix4(s),!1!==e.ray.intersectsSphere(sr)&&(ar.copy(s).invert(),or.copy(e.ray).applyMatrix4(ar),null!==this.boundingBox&&!1===or.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,or)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Vector4,t=this.geometry.attributes.skinWeight;for(let r=0,s=t.count;r<s;r++){e.fromBufferAttribute(t,r);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(r,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===G?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():o.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const r=this.skeleton,s=this.geometry;er.fromBufferAttribute(s.attributes.skinIndex,e),tr.fromBufferAttribute(s.attributes.skinWeight,e),Zn.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const s=tr.getComponent(e);if(0!==s){const o=er.getComponent(e);nr.multiplyMatrices(r.bones[o].matrixWorld,r.boneInverses[o]),t.addScaledVector(ir.copy(Zn).applyMatrix4(nr),s)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return o.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class Bone extends Object3D{constructor(){super(),this.isBone=!0,this.type="Bone"}}class DataTexture extends Texture{constructor(e=null,t=1,r=1,s,o,l,c,h,d=te,p=te,A,m){super(null,l,c,h,d,p,s,o,A,m),this.isDataTexture=!0,this.image={data:e,width:t,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const lr=new three_module_Matrix4,cr=new three_module_Matrix4;class Skeleton{constructor(e=[],t=[]){this.uuid=generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){o.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new three_module_Matrix4)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new three_module_Matrix4;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,r=this.boneMatrices,s=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const o=e[s]?e[s].matrixWorld:cr;lr.multiplyMatrices(o,t[s]),lr.toArray(r,16*s)}null!==s&&(s.needsUpdate=!0)}clone(){return new Skeleton(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=4*Math.ceil(e/4),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const r=new DataTexture(t,e,e,Ae,ue);return r.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=r,this}getBoneByName(e){for(let t=0,r=this.bones.length;t<r;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let r=0,s=e.bones.length;r<s;r++){const s=e.bones[r];let l=t[s];void 0===l&&(o.warn("THREE.Skeleton: No bone found with UUID:",s),l=new Bone),this.bones.push(l),this.boneInverses.push((new three_module_Matrix4).fromArray(e.boneInverses[r]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,r=this.boneInverses;for(let s=0,o=t.length;s<o;s++){const o=t[s];e.bones.push(o.uuid);const l=r[s];e.boneInverses.push(l.toArray())}return e}}class three_module_InstancedBufferAttribute extends three_module_BufferAttribute{constructor(e,t,r,s=1){super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const hr=new three_module_Matrix4,ur=new three_module_Matrix4,dr=[],pr=new Box3,Ar=new three_module_Matrix4,mr=new three_module_Mesh,fr=new Sphere;class InstancedMesh extends three_module_Mesh{constructor(e,t,r){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new three_module_InstancedBufferAttribute(new Float32Array(16*r),16),this.instanceColor=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<r;e++)this.setMatrixAt(e,Ar)}computeBoundingBox(){const e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Box3),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,hr),pr.copy(e.boundingBox).applyMatrix4(hr),this.boundingBox.union(pr)}computeBoundingSphere(){const e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new Sphere),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,hr),fr.copy(e.boundingSphere).applyMatrix4(hr),this.boundingSphere.union(fr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const r=this.matrixWorld,s=this.count;if(mr.geometry=this.geometry,mr.material=this.material,void 0!==mr.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),fr.copy(this.boundingSphere),fr.applyMatrix4(r),!1!==e.ray.intersectsSphere(fr)))for(let o=0;o<s;o++){this.getMatrixAt(o,hr),ur.multiplyMatrices(r,hr),mr.matrixWorld=ur,mr.raycast(e,dr);for(let e=0,r=dr.length;e<r;e++){const r=dr[e];r.instanceId=o,r.object=this,t.push(r)}dr.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new three_module_InstancedBufferAttribute(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class LineBasicMaterial extends Material{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Color(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const gr=new three_module_Vector3,_r=new three_module_Vector3,vr=new three_module_Matrix4,yr=new Ray,Er=new Sphere;class Line extends Object3D{constructor(e=new three_module_BufferGeometry,t=new LineBasicMaterial){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,r=[0];for(let e=1,s=t.count;e<s;e++)gr.fromBufferAttribute(t,e-1),_r.fromBufferAttribute(t,e),r[e]=r[e-1],r[e]+=gr.distanceTo(_r);e.setAttribute("lineDistance",new three_module_Float32BufferAttribute(r,1))}else o.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const r=this.geometry,s=this.matrixWorld,o=e.params.Line.threshold,l=r.drawRange;if(null===r.boundingSphere&&r.computeBoundingSphere(),Er.copy(r.boundingSphere),Er.applyMatrix4(s),Er.radius+=o,!1===e.ray.intersectsSphere(Er))return;vr.copy(s).invert(),yr.copy(e.ray).applyMatrix4(vr);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,d=new three_module_Vector3,p=new three_module_Vector3,A=new three_module_Vector3,m=new three_module_Vector3,f=this.isLineSegments?2:1,g=r.index,_=r.attributes.position;if(null!==g){for(let r=Math.max(0,l.start),s=Math.min(g.count,l.start+l.count)-1;r<s;r+=f){const s=g.getX(r),o=g.getX(r+1);d.fromBufferAttribute(_,s),p.fromBufferAttribute(_,o);if(yr.distanceSqToSegment(d,p,m,A)>h)continue;m.applyMatrix4(this.matrixWorld);const l=e.ray.origin.distanceTo(m);l<e.near||l>e.far||t.push({distance:l,point:A.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}else{for(let r=Math.max(0,l.start),s=Math.min(_.count,l.start+l.count)-1;r<s;r+=f){d.fromBufferAttribute(_,r),p.fromBufferAttribute(_,r+1);if(yr.distanceSqToSegment(d,p,m,A)>h)continue;m.applyMatrix4(this.matrixWorld);const s=e.ray.origin.distanceTo(m);s<e.near||s>e.far||t.push({distance:s,point:A.clone().applyMatrix4(this.matrixWorld),index:r,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){const t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const xr=new three_module_Vector3,Sr=new three_module_Vector3;class LineSegments extends Line{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,r=[];for(let e=0,s=t.count;e<s;e+=2)xr.fromBufferAttribute(t,e),Sr.fromBufferAttribute(t,e+1),r[e]=0===e?0:r[e-1],r[e+1]=r[e]+xr.distanceTo(Sr);e.setAttribute("lineDistance",new three_module_Float32BufferAttribute(r,1))}else o.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class LineLoop extends Line{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class PointsMaterial extends Material{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Mr=new three_module_Matrix4,Cr=new Ray,br=new Sphere,wr=new three_module_Vector3;class Points extends Object3D{constructor(e=new three_module_BufferGeometry,t=new PointsMaterial){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const r=this.geometry,s=this.matrixWorld,o=e.params.Points.threshold,l=r.drawRange;if(null===r.boundingSphere&&r.computeBoundingSphere(),br.copy(r.boundingSphere),br.applyMatrix4(s),br.radius+=o,!1===e.ray.intersectsSphere(br))return;Mr.copy(s).invert(),Cr.copy(e.ray).applyMatrix4(Mr);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,d=r.index,p=r.attributes.position;if(null!==d){for(let r=Math.max(0,l.start),o=Math.min(d.count,l.start+l.count);r<o;r++){const o=d.getX(r);wr.fromBufferAttribute(p,o),testPoint(wr,o,h,s,e,t,this)}}else{for(let r=Math.max(0,l.start),o=Math.min(p.count,l.start+l.count);r<o;r++)wr.fromBufferAttribute(p,r),testPoint(wr,r,h,s,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){const t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function testPoint(e,t,r,s,o,l,c){const h=Cr.distanceSqToPoint(e);if(h<r){const r=new three_module_Vector3;Cr.closestPointToPoint(e,r),r.applyMatrix4(s);const d=o.ray.origin.distanceTo(r);if(d<o.near||d>o.far)return;l.push({distance:d,distanceToRay:Math.sqrt(h),point:r,index:t,face:null,object:c})}}class VideoTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d){super(e,t,r,s,o,l,c,h,d),this.isVideoTexture=!0,this.minFilter=void 0!==l?l:re,this.magFilter=void 0!==o?o:re,this.generateMipmaps=!1;const p=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function updateVideo(){p.needsUpdate=!0,e.requestVideoFrameCallback(updateVideo)}))}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 CompressedTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d,p,A,m){super(null,l,c,h,d,p,s,o,A,m),this.isCompressedTexture=!0,this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class CompressedArrayTexture extends CompressedTexture{constructor(e,t,r,s,o,l){super(e,t,r,o,l),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=$}}class CompressedCubeTexture extends CompressedTexture{constructor(e,t,r){super(void 0,e[0].width,e[0].height,t,r,q),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class CanvasTexture extends Texture{constructor(e,t,r,s,o,l,c,h,d){super(e,t,r,s,o,l,c,h,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class SphereGeometry extends three_module_BufferGeometry{constructor(e=1,t=32,r=16,s=0,o=2*Math.PI,l=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:s,phiLength:o,thetaStart:l,thetaLength:c},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));const h=Math.min(l+c,Math.PI);let d=0;const p=[],A=new three_module_Vector3,m=new three_module_Vector3,f=[],g=[],_=[],y=[];for(let f=0;f<=r;f++){const x=[],S=f/r;let C=0;0===f&&0===l?C=.5/t:f===r&&h===Math.PI&&(C=-.5/t);for(let r=0;r<=t;r++){const h=r/t;A.x=-e*Math.cos(s+h*o)*Math.sin(l+S*c),A.y=e*Math.cos(l+S*c),A.z=e*Math.sin(s+h*o)*Math.sin(l+S*c),g.push(A.x,A.y,A.z),m.copy(A).normalize(),_.push(m.x,m.y,m.z),y.push(h+C,1-S),x.push(d++)}p.push(x)}for(let e=0;e<r;e++)for(let s=0;s<t;s++){const t=p[e][s+1],o=p[e][s],c=p[e+1][s],d=p[e+1][s+1];(0!==e||l>0)&&f.push(t,o,d),(e!==r-1||h<Math.PI)&&f.push(o,c,d)}this.setIndex(f),this.setAttribute("position",new three_module_Float32BufferAttribute(g,3)),this.setAttribute("normal",new three_module_Float32BufferAttribute(_,3)),this.setAttribute("uv",new three_module_Float32BufferAttribute(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new SphereGeometry(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class MeshStandardMaterial extends Material{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Color(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.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.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,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 MeshPhysicalMaterial extends MeshStandardMaterial{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Vector2(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return clamp(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Color(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Color(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Color(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=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}}function convertArray(e,t,r){return!e||!r&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function getKeyframeOrder(e){const t=e.length,r=new Array(t);for(let e=0;e!==t;++e)r[e]=e;return r.sort((function compareTime(t,r){return e[t]-e[r]})),r}function sortedArray(e,t,r){const s=e.length,o=new e.constructor(s);for(let l=0,c=0;c!==s;++l){const s=r[l]*t;for(let r=0;r!==t;++r)o[c++]=e[s+r]}return o}function flattenJSON(e,t,r,s){let o=1,l=e[0];for(;void 0!==l&&void 0===l[s];)l=e[o++];if(void 0===l)return;let c=l[s];if(void 0!==c)if(Array.isArray(c))do{c=l[s],void 0!==c&&(t.push(l.time),r.push.apply(r,c)),l=e[o++]}while(void 0!==l);else if(void 0!==c.toArray)do{c=l[s],void 0!==c&&(t.push(l.time),c.toArray(r,r.length)),l=e[o++]}while(void 0!==l);else do{c=l[s],void 0!==c&&(t.push(l.time),r.push(c)),l=e[o++]}while(void 0!==l)}class Interpolant{constructor(e,t,r,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==s?s:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let r=this._cachedIndex,s=t[r],o=t[r-1];e:{t:{let l;i:{n:if(!(e<s)){for(let l=r+2;;){if(void 0===s){if(e<o)break n;return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===l)break;if(o=s,s=t[++r],e<s)break t}l=t.length;break i}if(e>=o)break e;{const c=t[1];e<c&&(r=2,o=c);for(let l=r-2;;){if(void 0===o)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(s=o,o=t[--r-1],e>=o)break t}l=r,r=0}}for(;r<l;){const s=r+l>>>1;e<t[s]?l=s:r=s+1}if(s=t[r],o=t[r-1],void 0===o)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===s)return r=t.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,o,s)}return this.interpolate_(r,o,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,o=e*s;for(let e=0;e!==s;++e)t[e]=r[o+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class CubicInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Fe,endingEnd:Fe}}intervalChanged_(e,t,r){const s=this.parameterPositions;let o=e-2,l=e+1,c=s[o],h=s[l];if(void 0===c)switch(this.getSettings_().endingStart){case Ne:o=e,c=2*t-r;break;case Oe:o=s.length-2,c=t+s[o]-s[o+1];break;default:o=e,c=r}if(void 0===h)switch(this.getSettings_().endingEnd){case Ne:l=e,h=2*r-t;break;case Oe:l=1,h=r+s[1]-s[0];break;default:l=e-1,h=t}const d=.5*(r-t),p=this.valueSize;this._weightPrev=d/(t-c),this._weightNext=d/(h-r),this._offsetPrev=o*p,this._offsetNext=l*p}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=e*c,d=h-c,p=this._offsetPrev,A=this._offsetNext,m=this._weightPrev,f=this._weightNext,g=(r-t)/(s-t),_=g*g,y=_*g,x=-m*y+2*m*_-m*g,S=(1+m)*y+(-1.5-2*m)*_+(-.5+m)*g+1,C=(-1-f)*y+(1.5+f)*_+.5*g,b=f*y-f*_;for(let e=0;e!==c;++e)o[e]=x*l[p+e]+S*l[d+e]+C*l[h+e]+b*l[A+e];return o}}class LinearInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=e*c,d=h-c,p=(r-t)/(s-t),A=1-p;for(let e=0;e!==c;++e)o[e]=l[d+e]*A+l[h+e]*p;return o}}class DiscreteInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class KeyframeTrack{constructor(e,t,r,s){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=convertArray(t,this.TimeBufferType),this.values=convertArray(r,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:convertArray(e.times,Array),values:convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(r.interpolation=t)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new LinearInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new CubicInterpolant(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case De:t=this.InterpolantFactoryMethodDiscrete;break;case Ue:t=this.InterpolantFactoryMethodLinear;break;case Pe:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return o.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return De;case this.InterpolantFactoryMethodLinear:return Ue;case this.InterpolantFactoryMethodSmooth:return Pe}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let r=0,s=t.length;r!==s;++r)t[r]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let r=0,s=t.length;r!==s;++r)t[r]*=e}return this}trim(e,t){const r=this.times,s=r.length;let o=0,l=s-1;for(;o!==s&&r[o]<e;)++o;for(;-1!==l&&r[l]>t;)--l;if(++l,0!==o||l!==s){o>=l&&(l=Math.max(l,1),o=l-1);const e=this.getValueSize();this.times=r.slice(o,l),this.values=this.values.slice(o*e,l*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(o.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,s=this.values,l=r.length;0===l&&(o.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let c=null;for(let t=0;t!==l;t++){const s=r[t];if("number"==typeof s&&isNaN(s)){o.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,s),e=!1;break}if(null!==c&&c>s){o.error("THREE.KeyframeTrack: Out of order keys.",this,t,s,c),e=!1;break}c=s}if(void 0!==s&&isTypedArray(s))for(let t=0,r=s.length;t!==r;++t){const r=s[t];if(isNaN(r)){o.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,r),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),r=this.getValueSize(),s=this.getInterpolation()===Pe,o=e.length-1;let l=1;for(let c=1;c<o;++c){let o=!1;const h=e[c];if(h!==e[c+1]&&(1!==c||h!==e[0]))if(s)o=!0;else{const e=c*r,s=e-r,l=e+r;for(let c=0;c!==r;++c){const r=t[e+c];if(r!==t[s+c]||r!==t[l+c]){o=!0;break}}}if(o){if(c!==l){e[l]=e[c];const s=c*r,o=l*r;for(let e=0;e!==r;++e)t[o+e]=t[s+e]}++l}}if(o>0){e[l]=e[o];for(let e=o*r,s=l*r,c=0;c!==r;++c)t[s+c]=t[e+c];++l}return l!==e.length?(this.times=e.slice(0,l),this.values=t.slice(0,l*r)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),r=new(0,this.constructor)(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}KeyframeTrack.prototype.TimeBufferType=Float32Array,KeyframeTrack.prototype.ValueBufferType=Float32Array,KeyframeTrack.prototype.DefaultInterpolation=Ue;class BooleanKeyframeTrack extends KeyframeTrack{}BooleanKeyframeTrack.prototype.ValueTypeName="bool",BooleanKeyframeTrack.prototype.ValueBufferType=Array,BooleanKeyframeTrack.prototype.DefaultInterpolation=De,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class ColorKeyframeTrack extends KeyframeTrack{}ColorKeyframeTrack.prototype.ValueTypeName="color";class NumberKeyframeTrack extends KeyframeTrack{}NumberKeyframeTrack.prototype.ValueTypeName="number";class QuaternionLinearInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=(r-t)/(s-t);let d=e*c;for(let e=d+c;d!==e;d+=4)three_module_Quaternion.slerpFlat(o,0,l,d-c,l,d,h);return o}}class three_module_QuaternionKeyframeTrack extends KeyframeTrack{InterpolantFactoryMethodLinear(e){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)}}three_module_QuaternionKeyframeTrack.prototype.ValueTypeName="quaternion",three_module_QuaternionKeyframeTrack.prototype.DefaultInterpolation=Ue,three_module_QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class StringKeyframeTrack extends KeyframeTrack{}StringKeyframeTrack.prototype.ValueTypeName="string",StringKeyframeTrack.prototype.ValueBufferType=Array,StringKeyframeTrack.prototype.DefaultInterpolation=De,StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class three_module_VectorKeyframeTrack extends KeyframeTrack{}three_module_VectorKeyframeTrack.prototype.ValueTypeName="vector";class three_module_AnimationClip{constructor(e,t=-1,r,s=2500){this.name=e,this.tracks=r,this.duration=t,this.blendMode=s,this.uuid=generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,s=1/(e.fps||1);for(let e=0,o=r.length;e!==o;++e)t.push(parseKeyframeTrack(r[e]).scale(s));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){const t=[],r=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,s=r.length;e!==s;++e)t.push(KeyframeTrack.toJSON(r[e]));return s}static CreateFromMorphTargetSequence(e,t,r,s){const o=t.length,l=[];for(let e=0;e<o;e++){let c=[],h=[];c.push((e+o-1)%o,e,(e+1)%o),h.push(0,1,0);const d=getKeyframeOrder(c);c=sortedArray(c,1,d),h=sortedArray(h,1,d),s||0!==c[0]||(c.push(o),h.push(h[0])),l.push(new NumberKeyframeTrack(".morphTargetInfluences["+t[e].name+"]",c,h).scale(1/r))}return new this(e,-1,l)}static findByName(e,t){let r=e;if(!Array.isArray(e)){const t=e;r=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<r.length;e++)if(r[e].name===t)return r[e];return null}static CreateClipsFromMorphTargetSequences(e,t,r){const s={},o=/^([\w-]*?)([\d]+)$/;for(let t=0,r=e.length;t<r;t++){const r=e[t],l=r.name.match(o);if(l&&l.length>1){const e=l[1];let t=s[e];t||(s[e]=t=[]),t.push(r)}}const l=[];for(const e in s)l.push(this.CreateFromMorphTargetSequence(e,s[e],t,r));return l}static parseAnimation(e,t){if(!e)return o.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const addNonemptyTrack=function(e,t,r,s,o){if(0!==r.length){const l=[],c=[];flattenJSON(r,l,c,s),0!==l.length&&o.push(new e(t,l,c))}},r=[],s=e.name||"default",l=e.fps||30,c=e.blendMode;let h=e.length||-1;const d=e.hierarchy||[];for(let e=0;e<d.length;e++){const s=d[e].keys;if(s&&0!==s.length)if(s[0].morphTargets){const e={};let t;for(t=0;t<s.length;t++)if(s[t].morphTargets)for(let r=0;r<s[t].morphTargets.length;r++)e[s[t].morphTargets[r]]=-1;for(const o in e){const e=[],l=[];for(let r=0;r!==s[t].morphTargets.length;++r){const r=s[t];e.push(r.time),l.push(r.morphTarget===o?1:0)}r.push(new NumberKeyframeTrack(".morphTargetInfluence["+o+"]",e,l))}h=e.length*l}else{const o=".bones["+t[e].name+"]";addNonemptyTrack(three_module_VectorKeyframeTrack,o+".position",s,"pos",r),addNonemptyTrack(three_module_QuaternionKeyframeTrack,o+".quaternion",s,"rot",r),addNonemptyTrack(three_module_VectorKeyframeTrack,o+".scale",s,"scl",r)}}if(0===r.length)return null;return new this(s,h,r,c)}resetDuration(){let e=0;for(let t=0,r=this.tracks.length;t!==r;++t){const r=this.tracks[t];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function parseKeyframeTrack(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function getTrackTypeForValueTypeName(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return three_module_VectorKeyframeTrack;case"color":return ColorKeyframeTrack;case"quaternion":return three_module_QuaternionKeyframeTrack;case"bool":case"boolean":return BooleanKeyframeTrack;case"string":return StringKeyframeTrack}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],r=[];flattenJSON(e.keys,t,r,"value"),e.times=t,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const Ir={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class LoadingManager{constructor(e,t,r){const s=this;let o,l=!1,c=0,h=0;const d=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){h++,!1===l&&void 0!==s.onStart&&s.onStart(e,c,h),l=!0},this.itemEnd=function(e){c++,void 0!==s.onProgress&&s.onProgress(e,c,h),c===h&&(l=!1,void 0!==s.onLoad&&s.onLoad())},this.itemError=function(e){void 0!==s.onError&&s.onError(e)},this.resolveURL=function(e){return o?o(e):e},this.setURLModifier=function(e){return o=e,this},this.addHandler=function(e,t){return d.push(e,t),this},this.removeHandler=function(e){const t=d.indexOf(e);return-1!==t&&d.splice(t,2),this},this.getHandler=function(e){for(let t=0,r=d.length;t<r;t+=2){const r=d[t],s=d[t+1];if(r.global&&(r.lastIndex=0),r.test(e))return s}return null}}}const Tr=new LoadingManager;class Loader{constructor(e){this.manager=void 0!==e?e:Tr,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise((function(s,o){r.load(e,s,t,o)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Loader.DEFAULT_MATERIAL_NAME="__DEFAULT";const Br={};class HttpError extends Error{constructor(e,t){super(e),this.response=t}}class three_module_FileLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const l=Ir.get(e);if(void 0!==l)return this.manager.itemStart(e),setTimeout((()=>{t&&t(l),this.manager.itemEnd(e)}),0),l;if(void 0!==Br[e])return void Br[e].push({onLoad:t,onProgress:r,onError:s});Br[e]=[],Br[e].push({onLoad:t,onProgress:r,onError:s});const c=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),h=this.mimeType,d=this.responseType;fetch(c).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&o.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const r=Br[e],s=t.body.getReader(),l=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),c=l?parseInt(l):0,h=0!==c;let d=0;const p=new ReadableStream({start(e){!function readData(){s.read().then((({done:t,value:s})=>{if(t)e.close();else{d+=s.byteLength;const t=new ProgressEvent("progress",{lengthComputable:h,loaded:d,total:c});for(let e=0,s=r.length;e<s;e++){const s=r[e];s.onProgress&&s.onProgress(t)}e.enqueue(s),readData()}}))}()}});return new Response(p)}throw new HttpError(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(d){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,h)));case"json":return e.json();default:if(void 0===h)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(h),r=t&&t[1]?t[1].toLowerCase():void 0,s=new TextDecoder(r);return e.arrayBuffer().then((e=>s.decode(e)))}}})).then((t=>{Ir.add(e,t);const r=Br[e];delete Br[e];for(let e=0,s=r.length;e<s;e++){const s=r[e];s.onLoad&&s.onLoad(t)}})).catch((t=>{const r=Br[e];if(void 0===r)throw this.manager.itemError(e),t;delete Br[e];for(let e=0,s=r.length;e<s;e++){const s=r[e];s.onError&&s.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ImageLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,l=Ir.get(e);if(void 0!==l)return o.manager.itemStart(e),setTimeout((function(){t&&t(l),o.manager.itemEnd(e)}),0),l;const c=createElementNS("img");function onImageLoad(){removeEventListeners(),Ir.add(e,this),t&&t(this),o.manager.itemEnd(e)}function onImageError(t){removeEventListeners(),s&&s(t),o.manager.itemError(e),o.manager.itemEnd(e)}function removeEventListeners(){c.removeEventListener("load",onImageLoad,!1),c.removeEventListener("error",onImageError,!1)}return c.addEventListener("load",onImageLoad,!1),c.addEventListener("error",onImageError,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(c.crossOrigin=this.crossOrigin),o.manager.itemStart(e),c.src=e,c}}class DataTextureLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){const l=this,c=new DataTexture,h=new three_module_FileLoader(this.manager);return h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setPath(this.path),h.setWithCredentials(l.withCredentials),h.load(e,(function(e){let r;try{r=l.parse(e)}catch(e){if(void 0===s)return void o.error(e);s(e)}void 0!==r.image?c.image=r.image:void 0!==r.data&&(c.image.width=r.width,c.image.height=r.height,c.image.data=r.data),c.wrapS=void 0!==r.wrapS?r.wrapS:$,c.wrapT=void 0!==r.wrapT?r.wrapT:$,c.magFilter=void 0!==r.magFilter?r.magFilter:re,c.minFilter=void 0!==r.minFilter?r.minFilter:re,c.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,void 0!==r.colorSpace?c.colorSpace=r.colorSpace:void 0!==r.encoding&&(c.encoding=r.encoding),void 0!==r.flipY&&(c.flipY=r.flipY),void 0!==r.format&&(c.format=r.format),void 0!==r.type&&(c.type=r.type),void 0!==r.mipmaps&&(c.mipmaps=r.mipmaps,c.minFilter=ae),1===r.mipmapCount&&(c.minFilter=re),void 0!==r.generateMipmaps&&(c.generateMipmaps=r.generateMipmaps),c.needsUpdate=!0,t&&t(c,r)}),r,s),c}}class TextureLoader extends Loader{constructor(e){super(e)}load(e,t,r,s){const o=new Texture,l=new ImageLoader(this.manager);return l.setCrossOrigin(this.crossOrigin),l.setPath(this.path),l.load(e,(function(e){o.image=e,o.needsUpdate=!0,void 0!==t&&t(o)}),r,s),o}}class Light extends Object3D{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Color(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}const Rr=new three_module_Matrix4,Lr=new three_module_Vector3,Dr=new three_module_Vector3;class LightShadow{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vector2(512,512),this.map=null,this.mapPass=null,this.matrix=new three_module_Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;Lr.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lr),Dr.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Dr),t.updateMatrixWorld(),Rr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Rr),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Rr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class SpotLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,r=2*pt*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height,o=e.distance||t.far;r===t.fov&&s===t.aspect&&o===t.far||(t.fov=r,t.aspect=s,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class SpotLight extends Light{constructor(e,t,r=0,s=Math.PI/3,o=0,l=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.distance=r,this.angle=s,this.penumbra=o,this.decay=l,this.map=null,this.shadow=new SpotLightShadow}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Ur=new three_module_Matrix4,Pr=new three_module_Vector3,Fr=new three_module_Vector3;class PointLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Vector2(4,2),this._viewportCount=6,this._viewports=[new Vector4(2,1,1,1),new Vector4(0,1,1,1),new Vector4(3,1,1,1),new Vector4(1,1,1,1),new Vector4(3,0,1,1),new Vector4(1,0,1,1)],this._cubeDirections=[new three_module_Vector3(1,0,0),new three_module_Vector3(-1,0,0),new three_module_Vector3(0,0,1),new three_module_Vector3(0,0,-1),new three_module_Vector3(0,1,0),new three_module_Vector3(0,-1,0)],this._cubeUps=[new three_module_Vector3(0,1,0),new three_module_Vector3(0,1,0),new three_module_Vector3(0,1,0),new three_module_Vector3(0,1,0),new three_module_Vector3(0,0,1),new three_module_Vector3(0,0,-1)]}updateMatrices(e,t=0){const r=this.camera,s=this.matrix,o=e.distance||r.far;o!==r.far&&(r.far=o,r.updateProjectionMatrix()),Pr.setFromMatrixPosition(e.matrixWorld),r.position.copy(Pr),Fr.copy(r.position),Fr.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Fr),r.updateMatrixWorld(),s.makeTranslation(-Pr.x,-Pr.y,-Pr.z),Ur.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ur)}}class PointLight extends Light{constructor(e,t,r=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=s,this.shadow=new PointLightShadow}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class DirectionalLightShadow extends LightShadow{constructor(){super(new OrthographicCamera(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class DirectionalLight extends Light{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.shadow=new DirectionalLightShadow}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class SphericalHarmonics3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new three_module_Vector3)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const r=e.x,s=e.y,o=e.z,l=this.coefficients;return t.copy(l[0]).multiplyScalar(.282095),t.addScaledVector(l[1],.488603*s),t.addScaledVector(l[2],.488603*o),t.addScaledVector(l[3],.488603*r),t.addScaledVector(l[4],r*s*1.092548),t.addScaledVector(l[5],s*o*1.092548),t.addScaledVector(l[6],.315392*(3*o*o-1)),t.addScaledVector(l[7],r*o*1.092548),t.addScaledVector(l[8],.546274*(r*r-s*s)),t}getIrradianceAt(e,t){const r=e.x,s=e.y,o=e.z,l=this.coefficients;return t.copy(l[0]).multiplyScalar(.886227),t.addScaledVector(l[1],1.023328*s),t.addScaledVector(l[2],1.023328*o),t.addScaledVector(l[3],1.023328*r),t.addScaledVector(l[4],.858086*r*s),t.addScaledVector(l[5],.858086*s*o),t.addScaledVector(l[6],.743125*o*o-.247708),t.addScaledVector(l[7],.858086*r*o),t.addScaledVector(l[8],.429043*(r*r-s*s)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let r=0;r<9;r++)this.coefficients[r].addScaledVector(e.coefficients[r],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let r=0;r<9;r++)this.coefficients[r].lerp(e.coefficients[r],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const r=this.coefficients;for(let s=0;s<9;s++)r[s].fromArray(e,t+3*s);return this}toArray(e=[],t=0){const r=this.coefficients;for(let s=0;s<9;s++)r[s].toArray(e,t+3*s);return e}static getBasisAt(e,t){const r=e.x,s=e.y,o=e.z;t[0]=.282095,t[1]=.488603*s,t[2]=.488603*o,t[3]=.488603*r,t[4]=1.092548*r*s,t[5]=1.092548*s*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*r*o,t[8]=.546274*(r*r-s*s)}}class LightProbe extends Light{constructor(e=new SphericalHarmonics3,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class LoaderUtils{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let r=0,s=e.length;r<s;r++)t+=String.fromCharCode(e[r]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class ImageBitmapLoader extends Loader{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&o.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&o.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,l=Ir.get(e);if(void 0!==l)return o.manager.itemStart(e),l.then?void l.then((r=>{t&&t(r),o.manager.itemEnd(e)})).catch((e=>{s&&s(e)})):(setTimeout((function(){t&&t(l),o.manager.itemEnd(e)}),0),l);const c={};c.credentials="anonymous"===this.crossOrigin?"same-origin":"include",c.headers=this.requestHeader;const h=fetch(e,c).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(o.options,{colorSpaceConversion:"none"}))})).then((function(r){return Ir.add(e,r),t&&t(r),o.manager.itemEnd(e),r})).catch((function(t){s&&s(t),Ir.remove(e),o.manager.itemError(e),o.manager.itemEnd(e)}));Ir.add(e,h),o.manager.itemStart(e)}}class PropertyMixer{constructor(e,t,r){let s,o,l;switch(this.binding=e,this.valueSize=r,t){case"quaternion":s=this._slerp,o=this._slerpAdditive,l=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*r),this._workIndex=5;break;case"string":case"bool":s=this._select,o=this._select,l=this._setAdditiveIdentityOther,this.buffer=new Array(5*r);break;default:s=this._lerp,o=this._lerpAdditive,l=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*r)}this._mixBufferRegion=s,this._mixBufferRegionAdditive=o,this._setIdentity=l,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const r=this.buffer,s=this.valueSize,o=e*s+s;let l=this.cumulativeWeight;if(0===l){for(let e=0;e!==s;++e)r[o+e]=r[e];l=t}else{l+=t;const e=t/l;this._mixBufferRegion(r,o,0,e,s)}this.cumulativeWeight=l}accumulateAdditive(e){const t=this.buffer,r=this.valueSize,s=r*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,s,0,e,r),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,r=this.buffer,s=e*t+t,o=this.cumulativeWeight,l=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const e=t*this._origIndex;this._mixBufferRegion(r,s,e,1-o,t)}l>0&&this._mixBufferRegionAdditive(r,s,this._addIndex*t,1,t);for(let e=t,o=t+t;e!==o;++e)if(r[e]!==r[e+t]){c.setValue(r,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,r=this.valueSize,s=r*this._origIndex;e.getValue(t,s);for(let e=r,o=s;e!==o;++e)t[e]=t[s+e%r];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 r=e;r<t;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[t+r]=this.buffer[e+r]}_select(e,t,r,s,o){if(s>=.5)for(let s=0;s!==o;++s)e[t+s]=e[r+s]}_slerp(e,t,r,s){three_module_Quaternion.slerpFlat(e,t,e,t,e,r,s)}_slerpAdditive(e,t,r,s,o){const l=this._workIndex*o;three_module_Quaternion.multiplyQuaternionsFlat(e,l,e,t,e,r),three_module_Quaternion.slerpFlat(e,t,e,t,e,l,s)}_lerp(e,t,r,s,o){const l=1-s;for(let c=0;c!==o;++c){const o=t+c;e[o]=e[o]*l+e[r+c]*s}}_lerpAdditive(e,t,r,s,o){for(let l=0;l!==o;++l){const o=t+l;e[o]=e[o]+e[r+l]*s}}}const Nr="\\[\\]\\.:\\/",Or=new RegExp("["+Nr+"]","g"),Qr="[^"+Nr+"]",kr="[^"+Nr.replace("\\.","")+"]",Gr=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Qr)+/(WCOD+)?/.source.replace("WCOD",kr)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qr)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qr)+"$"),Vr=["material","materials","bones","map"];class PropertyBinding{constructor(e,t,r){this.path=t,this.parsedPath=r||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new PropertyBinding.Composite(e,t,r):new PropertyBinding(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Or,"")}static parseTrackName(e){const t=Gr.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==s&&-1!==s){const e=r.nodeName.substring(s+1);-1!==Vr.indexOf(e)&&(r.nodeName=r.nodeName.substring(0,s),r.objectName=e)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(void 0!==r)return r}if(e.children){const searchNodeSubtree=function(e){for(let r=0;r<e.length;r++){const s=e[r];if(s.name===t||s.uuid===t)return s;const o=searchNodeSubtree(s.children);if(o)return o}return null},r=searchNodeSubtree(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)e[t++]=r[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)r[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)r[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const r=this.resolvedProperty;for(let s=0,o=r.length;s!==o;++s)r[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,r=t.objectName,s=t.propertyName;let l=t.propertyIndex;if(e||(e=PropertyBinding.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void o.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(r){let s=t.objectIndex;switch(r){case"materials":if(!e.material)return void o.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void o.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void o.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===s){s=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void o.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void o.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[r])return void o.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[r]}if(void 0!==s){if(void 0===e[s])return void o.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[s]}}const c=e[s];if(void 0===c){const r=t.nodeName;return void o.error("THREE.PropertyBinding: Trying to update property for track: "+r+"."+s+" but it wasn't found.",e)}let h=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?h=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(h=this.Versioning.MatrixWorldNeedsUpdate);let d=this.BindingType.Direct;if(void 0!==l){if("morphTargetInfluences"===s){if(!e.geometry)return void o.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void o.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[l]&&(l=e.morphTargetDictionary[l])}d=this.BindingType.ArrayElement,this.resolvedProperty=c,this.propertyIndex=l}else void 0!==c.fromArray&&void 0!==c.toArray?(d=this.BindingType.HasFromToArray,this.resolvedProperty=c):Array.isArray(c)?(d=this.BindingType.EntireArray,this.resolvedProperty=c):this.propertyName=s;this.getValue=this.GetterByBindingType[d],this.setValue=this.SetterByBindingTypeAndVersioning[d][h]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}PropertyBinding.Composite=class Composite{constructor(e,t,r){const s=r||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,s=this._bindings[r];void 0!==s&&s.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let s=this._targetGroup.nCachedObjects_,o=r.length;s!==o;++s)r[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}},PropertyBinding.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},PropertyBinding.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},PropertyBinding.prototype.GetterByBindingType=[PropertyBinding.prototype._getValue_direct,PropertyBinding.prototype._getValue_array,PropertyBinding.prototype._getValue_arrayElement,PropertyBinding.prototype._getValue_toArray],PropertyBinding.prototype.SetterByBindingTypeAndVersioning=[[PropertyBinding.prototype._setValue_direct,PropertyBinding.prototype._setValue_direct_setNeedsUpdate,PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_array,PropertyBinding.prototype._setValue_array_setNeedsUpdate,PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_arrayElement,PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate,PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_fromArray,PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate,PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class AnimationAction{constructor(e,t,r=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=r,this.blendMode=s;const o=t.tracks,l=o.length,c=new Array(l),h={endingStart:Fe,endingEnd:Fe};for(let e=0;e!==l;++e){const t=o[e].createInterpolant(null);c[e]=t,t.settings=h}this._interpolantSettings=h,this._interpolants=c,this._propertyBindings=new Array(l),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Re,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,r){if(e.fadeOut(t),this.fadeIn(t),r){const r=this._clip.duration,s=e._clip.duration,o=s/r,l=r/s;e.warp(1,o,t),this.warp(l,1,t)}return this}crossFadeTo(e,t,r){return e.crossFadeFrom(this,t,r)}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,r){const s=this._mixer,o=s.time,l=this.timeScale;let c=this._timeScaleInterpolant;null===c&&(c=s._lendControlInterpolant(),this._timeScaleInterpolant=c);const h=c.parameterPositions,d=c.sampleValues;return h[0]=o,h[1]=o+r,d[0]=e/l,d[1]=t/l,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,r,s){if(!this.enabled)return void this._updateWeight(e);const o=this._startTime;if(null!==o){const s=(e-o)*r;s<0||0===r?t=0:(this._startTime=null,t=r*s)}t*=this._updateTimeScale(e);const l=this._updateTime(t),c=this._updateWeight(e);if(c>0){const e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let r=0,s=e.length;r!==s;++r)e[r].evaluate(l),t[r].accumulateAdditive(c);else for(let r=0,o=e.length;r!==o;++r)e[r].evaluate(l),t[r].accumulate(s,c)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;if(null!==r){const s=r.evaluate(e)[0];t*=s,e>r.parameterPositions[1]&&(this.stopFading(),0===s&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;if(null!==r){t*=r.evaluate(e)[0],e>r.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,r=this.loop;let s=this.time+e,o=this._loopCount;const l=r===Le;if(0===e)return-1===o||!l||1&~o?s:t-s;if(2200===r){-1===o&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else{if(!(s<0)){this.time=s;break e}s=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===o&&(e>=0?(o=0,this._setEndings(!0,0===this.repetitions,l)):this._setEndings(0===this.repetitions,!0,l)),s>=t||s<0){const r=Math.floor(s/t);s-=t*r,o+=Math.abs(r);const c=this.repetitions-o;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===c){const t=e<0;this._setEndings(t,!t,l)}else this._setEndings(!1,!1,l);this._loopCount=o,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})}}else this.time=s;if(l&&!(1&~o))return t-s}return s}_setEndings(e,t,r){const s=this._interpolantSettings;r?(s.endingStart=Ne,s.endingEnd=Ne):(s.endingStart=e?this.zeroSlopeAtStart?Ne:Fe:Oe,s.endingEnd=t?this.zeroSlopeAtEnd?Ne:Fe:Oe)}_scheduleFading(e,t,r){const s=this._mixer,o=s.time;let l=this._weightInterpolant;null===l&&(l=s._lendControlInterpolant(),this._weightInterpolant=l);const c=l.parameterPositions,h=l.sampleValues;return c[0]=o,h[0]=t,c[1]=o+e,h[1]=r,this}}const Hr=new Float32Array(1);class three_module_AnimationMixer extends EventDispatcher{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const r=e._localRoot||this._root,s=e._clip.tracks,o=s.length,l=e._propertyBindings,c=e._interpolants,h=r.uuid,d=this._bindingsByRootAndName;let p=d[h];void 0===p&&(p={},d[h]=p);for(let e=0;e!==o;++e){const o=s[e],d=o.name;let A=p[d];if(void 0!==A)++A.referenceCount,l[e]=A;else{if(A=l[e],void 0!==A){null===A._cacheIndex&&(++A.referenceCount,this._addInactiveBinding(A,h,d));continue}const s=t&&t._propertyBindings[e].binding.parsedPath;A=new PropertyMixer(PropertyBinding.create(r,d,s),o.ValueTypeName,o.getValueSize()),++A.referenceCount,this._addInactiveBinding(A,h,d),l[e]=A}c[e].resultBuffer=A.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,t)}const t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){const r=t[e];0==r.useCount++&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){const r=t[e];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}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<this._nActiveActions}_addInactiveAction(e,t,r){const s=this._actions,o=this._actionsByClip;let l=o[t];if(void 0===l)l={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,o[t]=l;else{const t=l.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=s.length,s.push(e),l.actionByRoot[r]=e}_removeInactiveAction(e){const t=this._actions,r=t[t.length-1],s=e._cacheIndex;r._cacheIndex=s,t[s]=r,t.pop(),e._cacheIndex=null;const o=e._clip.uuid,l=this._actionsByClip,c=l[o],h=c.knownActions,d=h[h.length-1],p=e._byClipCacheIndex;d._byClipCacheIndex=p,h[p]=d,h.pop(),e._byClipCacheIndex=null;delete c.actionByRoot[(e._localRoot||this._root).uuid],0===h.length&&delete l[o],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){const r=t[e];0==--r.referenceCount&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,r=e._cacheIndex,s=this._nActiveActions++,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_takeBackAction(e){const t=this._actions,r=e._cacheIndex,s=--this._nActiveActions,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_addInactiveBinding(e,t,r){const s=this._bindingsByRootAndName,o=this._bindings;let l=s[t];void 0===l&&(l={},s[t]=l),l[r]=e,e._cacheIndex=o.length,o.push(e)}_removeInactiveBinding(e){const t=this._bindings,r=e.binding,s=r.rootNode.uuid,o=r.path,l=this._bindingsByRootAndName,c=l[s],h=t[t.length-1],d=e._cacheIndex;h._cacheIndex=d,t[d]=h,t.pop(),delete c[o],0===Object.keys(c).length&&delete l[s]}_lendBinding(e){const t=this._bindings,r=e._cacheIndex,s=this._nActiveBindings++,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_takeBackBinding(e){const t=this._bindings,r=e._cacheIndex,s=--this._nActiveBindings,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=r,t[r]=o}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let r=e[t];return void 0===r&&(r=new LinearInterpolant(new Float32Array(2),new Float32Array(2),1,Hr),r.__cacheIndex=t,e[t]=r),r}_takeBackControlInterpolant(e){const t=this._controlInterpolants,r=e.__cacheIndex,s=--this._nActiveControlInterpolants,o=t[s];e.__cacheIndex=s,t[s]=e,o.__cacheIndex=r,t[r]=o}clipAction(e,t,r){const s=t||this._root,o=s.uuid;let l="string"==typeof e?three_module_AnimationClip.findByName(s,e):e;const c=null!==l?l.uuid:e,h=this._actionsByClip[c];let d=null;if(void 0===r&&(r=null!==l?l.blendMode:Qe),void 0!==h){const e=h.actionByRoot[o];if(void 0!==e&&e.blendMode===r)return e;d=h.knownActions[0],null===l&&(l=d._clip)}if(null===l)return null;const p=new AnimationAction(this,l,t,r);return this._bindAction(p,d),this._addInactiveAction(p,c,o),p}existingAction(e,t){const r=t||this._root,s=r.uuid,o="string"==typeof e?three_module_AnimationClip.findByName(r,e):e,l=o?o.uuid:e,c=this._actionsByClip[l];return void 0!==c&&c.actionByRoot[s]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,r=this._nActiveActions,s=this.time+=e,o=Math.sign(e),l=this._accuIndex^=1;for(let c=0;c!==r;++c){t[c]._update(s,e,o,l)}const c=this._bindings,h=this._nActiveBindings;for(let e=0;e!==h;++e)c[e].apply(l);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,r=e.uuid,s=this._actionsByClip,o=s[r];if(void 0!==o){const e=o.knownActions;for(let r=0,s=e.length;r!==s;++r){const s=e[r];this._deactivateAction(s);const o=s._cacheIndex,l=t[t.length-1];s._cacheIndex=null,s._byClipCacheIndex=null,l._cacheIndex=o,t[o]=l,t.pop(),this._removeInactiveBindingsForAction(s)}delete s[r]}}uncacheRoot(e){const t=e.uuid,r=this._actionsByClip;for(const e in r){const s=r[e].actionByRoot[t];void 0!==s&&(this._deactivateAction(s),this._removeInactiveAction(s))}const s=this._bindingsByRootAndName[t];if(void 0!==s)for(const e in s){const t=s[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const r=this.existingAction(e,t);null!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}}class Uniform{constructor(e){this.value=e}clone(){return new Uniform(void 0===this.value.clone?this.value:this.value.clone())}}function ascSort(e,t){return e.distance-t.distance}function intersectObject(e,t,r,s){if(e.layers.test(t.layers)&&e.raycast(t,r),!0===s){const s=e.children;for(let e=0,o=s.length;e<o;e++)intersectObject(s[e],t,r,!0)}}class Spherical{constructor(e=1,t=0,r=0){return this.radius=e,this.phi=t,this.theta=r,this}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(clamp(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:l}})),"undefined"!=typeof window&&(window.__THREE__?o.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=l);const zr=window,Wr=zr.ShadowRoot&&(void 0===zr.ShadyCSS||zr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qr=Symbol(),jr=new WeakMap;class css_tag_o{constructor(e,t,r){if(this._$cssResult$=!0,r!==qr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Wr&&void 0===e){const r=void 0!==t&&1===t.length;r&&(e=jr.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&jr.set(t,e))}return e}toString(){return this.cssText}}const Xr=Wr?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return(e=>new css_tag_o("string"==typeof e?e:e+"",void 0,qr))(t)})(e):e;var Yr;const Kr=window,Jr=Kr.trustedTypes,$r=Jr?Jr.emptyScript:"",Zr=Kr.reactiveElementPolyfillSupport,es={toAttribute(e,t){switch(t){case Boolean:e=e?$r:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(e){r=null}}return r}},a=(e,t)=>t!==e&&(t==t||e==e),ts={attribute:!0,type:String,converter:es,reflect:!1,hasChanged:a},is="finalized";class u extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,r)=>{const s=this._$Ep(r,t);void 0!==s&&(this._$Ev.set(s,r),e.push(s))})),e}static createProperty(e,t=ts){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const r="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||ts}static finalize(){if(this.hasOwnProperty(is))return!1;this[is]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const r of t)this.createProperty(r,e[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const e of r)t.unshift(Xr(e))}else void 0!==e&&t.push(Xr(e));return t}static _$Ep(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,r;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(r=e.hostConnected)||void 0===r||r.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{Wr?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const r=document.createElement("style"),s=zr.litNonce;void 0!==s&&r.setAttribute("nonce",s),r.textContent=t.cssText,e.appendChild(r)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$EO(e,t,r=ts){var s;const o=this.constructor._$Ep(e,r);if(void 0!==o&&!0===r.reflect){const l=(void 0!==(null===(s=r.converter)||void 0===s?void 0:s.toAttribute)?r.converter:es).toAttribute(t,r.type);this._$El=e,null==l?this.removeAttribute(o):this.setAttribute(o,l),this._$El=null}}_$AK(e,t){var r;const s=this.constructor,o=s._$Ev.get(e);if(void 0!==o&&this._$El!==o){const e=s.getPropertyOptions(o),l="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(r=e.converter)||void 0===r?void 0:r.fromAttribute)?e.converter:es;this._$El=o,this[o]=l.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,r){let s=!0;void 0!==e&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||a)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===r.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(r)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(r)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}var ns;u[is]=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==Zr||Zr({ReactiveElement:u}),(null!==(Yr=Kr.reactiveElementVersions)&&void 0!==Yr?Yr:Kr.reactiveElementVersions=[]).push("1.6.3");const rs=window,ss=rs.trustedTypes,as=ss?ss.createPolicy("lit-html",{createHTML:e=>e}):void 0,os="$lit$",ls=`lit$${(Math.random()+"").slice(9)}$`,cs="?"+ls,hs=`<${cs}>`,us=document,lit_html_u=()=>us.createComment(""),lit_html_d=e=>null===e||"object"!=typeof e&&"function"!=typeof e,ds=Array.isArray,v=e=>ds(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]),ps="[ \t\n\f\r]",As=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ms=/-->/g,fs=/>/g,gs=RegExp(`>|${ps}(?:([^\\s"'>=/]+)(${ps}*=${ps}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),_s=/'/g,vs=/"/g,ys=/^(?:script|style|textarea|title)$/i,w=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),Es=w(1),xs=(w(2),Symbol.for("lit-noChange")),Ss=Symbol.for("lit-nothing"),Ms=new WeakMap,Cs=us.createTreeWalker(us,129,null,!1);function P(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==as?as.createHTML(t):t}const V=(e,t)=>{const r=e.length-1,s=[];let o,l=2===t?"<svg>":"",c=As;for(let t=0;t<r;t++){const r=e[t];let h,d,p=-1,A=0;for(;A<r.length&&(c.lastIndex=A,d=c.exec(r),null!==d);)A=c.lastIndex,c===As?"!--"===d[1]?c=ms:void 0!==d[1]?c=fs:void 0!==d[2]?(ys.test(d[2])&&(o=RegExp("</"+d[2],"g")),c=gs):void 0!==d[3]&&(c=gs):c===gs?">"===d[0]?(c=null!=o?o:As,p=-1):void 0===d[1]?p=-2:(p=c.lastIndex-d[2].length,h=d[1],c=void 0===d[3]?gs:'"'===d[3]?vs:_s):c===vs||c===_s?c=gs:c===ms||c===fs?c=As:(c=gs,o=void 0);const m=c===gs&&e[t+1].startsWith("/>")?" ":"";l+=c===As?r+hs:p>=0?(s.push(h),r.slice(0,p)+os+r.slice(p)+ls+m):r+ls+(-2===p?(s.push(void 0),t):m)}return[P(e,l+(e[r]||"<?>")+(2===t?"</svg>":"")),s]};class N{constructor({strings:e,_$litType$:t},r){let s;this.parts=[];let o=0,l=0;const c=e.length-1,h=this.parts,[d,p]=V(e,t);if(this.el=N.createElement(d,r),Cs.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=Cs.nextNode())&&h.length<c;){if(1===s.nodeType){if(s.hasAttributes()){const e=[];for(const t of s.getAttributeNames())if(t.endsWith(os)||t.startsWith(ls)){const r=p[l++];if(e.push(t),void 0!==r){const e=s.getAttribute(r.toLowerCase()+os).split(ls),t=/([.?@])?(.*)/.exec(r);h.push({type:1,index:o,name:t[2],strings:e,ctor:"."===t[1]?H:"?"===t[1]?L:"@"===t[1]?z:k})}else h.push({type:6,index:o})}for(const t of e)s.removeAttribute(t)}if(ys.test(s.tagName)){const e=s.textContent.split(ls),t=e.length-1;if(t>0){s.textContent=ss?ss.emptyScript:"";for(let r=0;r<t;r++)s.append(e[r],lit_html_u()),Cs.nextNode(),h.push({type:2,index:++o});s.append(e[t],lit_html_u())}}}else if(8===s.nodeType)if(s.data===cs)h.push({type:2,index:o});else{let e=-1;for(;-1!==(e=s.data.indexOf(ls,e+1));)h.push({type:7,index:o}),e+=ls.length-1}o++}}static createElement(e,t){const r=us.createElement("template");return r.innerHTML=e,r}}function lit_html_S(e,t,r=e,s){var o,l,c,h;if(t===xs)return t;let d=void 0!==s?null===(o=r._$Co)||void 0===o?void 0:o[s]:r._$Cl;const p=lit_html_d(t)?void 0:t._$litDirective$;return(null==d?void 0:d.constructor)!==p&&(null===(l=null==d?void 0:d._$AO)||void 0===l||l.call(d,!1),void 0===p?d=void 0:(d=new p(e),d._$AT(e,r,s)),void 0!==s?(null!==(c=(h=r)._$Co)&&void 0!==c?c:h._$Co=[])[s]=d:r._$Cl=d),void 0!==d&&(t=lit_html_S(e,d._$AS(e,t.values),d,s)),t}class M{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:r},parts:s}=this._$AD,o=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:us).importNode(r,!0);Cs.currentNode=o;let l=Cs.nextNode(),c=0,h=0,d=s[0];for(;void 0!==d;){if(c===d.index){let t;2===d.type?t=new R(l,l.nextSibling,this,e):1===d.type?t=new d.ctor(l,d.name,d.strings,this,e):6===d.type&&(t=new Z(l,this,e)),this._$AV.push(t),d=s[++h]}c!==(null==d?void 0:d.index)&&(l=Cs.nextNode(),c++)}return Cs.currentNode=us,o}v(e){let t=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}class R{constructor(e,t,r,s){var o;this.type=2,this._$AH=Ss,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=s,this._$Cp=null===(o=null==s?void 0:s.isConnected)||void 0===o||o}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===(null==e?void 0:e.nodeType)&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=lit_html_S(this,e,t),lit_html_d(e)?e===Ss||null==e||""===e?(this._$AH!==Ss&&this._$AR(),this._$AH=Ss):e!==this._$AH&&e!==xs&&this._(e):void 0!==e._$litType$?this.g(e):void 0!==e.nodeType?this.$(e):v(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==Ss&&lit_html_d(this._$AH)?this._$AA.nextSibling.data=e:this.$(us.createTextNode(e)),this._$AH=e}g(e){var t;const{values:r,_$litType$:s}=e,o="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===o)this._$AH.v(r);else{const e=new M(o,this),t=e.u(this.options);e.v(r),this.$(t),this._$AH=e}}_$AC(e){let t=Ms.get(e.strings);return void 0===t&&Ms.set(e.strings,t=new N(e)),t}T(e){ds(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,s=0;for(const o of e)s===t.length?t.push(r=new R(this.k(lit_html_u()),this.k(lit_html_u()),this,this.options)):r=t[s],r._$AI(o),s++;s<t.length&&(this._$AR(r&&r._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var r;for(null===(r=this._$AP)||void 0===r||r.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cp=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class k{constructor(e,t,r,s,o){this.type=1,this._$AH=Ss,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Ss}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,r,s){const o=this.strings;let l=!1;if(void 0===o)e=lit_html_S(this,e,t,0),l=!lit_html_d(e)||e!==this._$AH&&e!==xs,l&&(this._$AH=e);else{const s=e;let c,h;for(e=o[0],c=0;c<o.length-1;c++)h=lit_html_S(this,s[r+c],t,c),h===xs&&(h=this._$AH[c]),l||(l=!lit_html_d(h)||h!==this._$AH[c]),h===Ss?e=Ss:e!==Ss&&(e+=(null!=h?h:"")+o[c+1]),this._$AH[c]=h}l&&!s&&this.j(e)}j(e){e===Ss?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class H extends k{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ss?void 0:e}}const bs=ss?ss.emptyScript:"";class L extends k{constructor(){super(...arguments),this.type=4}j(e){e&&e!==Ss?this.element.setAttribute(this.name,bs):this.element.removeAttribute(this.name)}}class z extends k{constructor(e,t,r,s,o){super(e,t,r,s,o),this.type=5}_$AI(e,t=this){var r;if((e=null!==(r=lit_html_S(this,e,t,0))&&void 0!==r?r:Ss)===xs)return;const s=this._$AH,o=e===Ss&&s!==Ss||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,l=e!==Ss&&(s===Ss||o);o&&this.element.removeEventListener(this.name,this,s),l&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,r;"function"==typeof this._$AH?this._$AH.call(null!==(r=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==r?r:this.element,e):this._$AH.handleEvent(e)}}class Z{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){lit_html_S(this,e)}}const ws=rs.litHtmlPolyfillSupport;null==ws||ws(N,R),(null!==(ns=rs.litHtmlVersions)&&void 0!==ns?ns:rs.litHtmlVersions=[]).push("2.8.0");const D=(e,t,r)=>{var s,o;const l=null!==(s=null==r?void 0:r.renderBefore)&&void 0!==s?s:t;let c=l._$litPart$;if(void 0===c){const e=null!==(o=null==r?void 0:r.renderBefore)&&void 0!==o?o:null;l._$litPart$=c=new R(t.insertBefore(lit_html_u(),e),e,void 0,null!=r?r:{})}return c._$AI(e),c},Is=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ts=Symbol(),Bs=new Map;class css_tag_s{constructor(e,t){if(this._$cssResult$=!0,t!==Ts)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){let e=Bs.get(this.cssText);return Is&&void 0===e&&(Bs.set(this.cssText,e=new CSSStyleSheet),e.replaceSync(this.cssText)),e}toString(){return this.cssText}}const Rs=Is?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return(e=>new css_tag_s("string"==typeof e?e:e+"",Ts))(t)})(e):e;var Ls;const Ds=window.trustedTypes,Us=Ds?Ds.emptyScript:"",Ps=window.reactiveElementPolyfillSupport,Fs={toAttribute(e,t){switch(t){case Boolean:e=e?Us:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(e){r=null}}return r}},reactive_element_reactive_element_n=(e,t)=>t!==e&&(t==t||e==e),Ns={attribute:!0,type:String,converter:Fs,reflect:!1,hasChanged:reactive_element_reactive_element_n};class reactive_element_a extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(e){var t;null!==(t=this.l)&&void 0!==t||(this.l=[]),this.l.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,r)=>{const s=this._$Eh(r,t);void 0!==s&&(this._$Eu.set(s,r),e.push(s))})),e}static createProperty(e,t=Ns){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const r="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Ns}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const r of t)this.createProperty(r,e[r])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const e of r)t.unshift(Rs(e))}else void 0!==e&&t.push(Rs(e));return t}static _$Eh(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}o(){var e;this._$Ep=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(e=this.constructor.l)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,r;(null!==(t=this._$Eg)&&void 0!==t?t:this._$Eg=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(r=e.hostConnected)||void 0===r||r.call(e))}removeController(e){var t;null===(t=this._$Eg)||void 0===t||t.splice(this._$Eg.indexOf(e)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Et.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{Is?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const r=document.createElement("style"),s=window.litNonce;void 0!==s&&r.setAttribute("nonce",s),r.textContent=t.cssText,e.appendChild(r)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ES(e,t,r=Ns){var s,o;const l=this.constructor._$Eh(e,r);if(void 0!==l&&!0===r.reflect){const c=(null!==(o=null===(s=r.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==o?o:Fs.toAttribute)(t,r.type);this._$Ei=e,null==c?this.removeAttribute(l):this.setAttribute(l,c),this._$Ei=null}}_$AK(e,t){var r,s,o;const l=this.constructor,c=l._$Eu.get(e);if(void 0!==c&&this._$Ei!==c){const e=l.getPropertyOptions(c),h=e.converter,d=null!==(o=null!==(s=null===(r=h)||void 0===r?void 0:r.fromAttribute)&&void 0!==s?s:"function"==typeof h?h:null)&&void 0!==o?o:Fs.fromAttribute;this._$Ei=c,this[c]=d(t,e.type),this._$Ei=null}}requestUpdate(e,t,r){let s=!0;void 0!==e&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||reactive_element_reactive_element_n)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===r.reflect&&this._$Ei!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((e,t)=>this[t]=e)),this._$Et=void 0);let t=!1;const r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(r)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(r)}willUpdate(e){}_$AE(e){var t;null===(t=this._$Eg)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$ES(t,this[t],e))),this._$EC=void 0),this._$EU()}updated(e){}firstUpdated(e){}}var Os,Qs;reactive_element_a.finalized=!0,reactive_element_a.elementProperties=new Map,reactive_element_a.elementStyles=[],reactive_element_a.shadowRootOptions={mode:"open"},null==Ps||Ps({ReactiveElement:reactive_element_a}),(null!==(Ls=globalThis.reactiveElementVersions)&&void 0!==Ls?Ls:globalThis.reactiveElementVersions=[]).push("1.3.2");class lit_element_s extends reactive_element_a{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const r=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=r.firstChild),r}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=D(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return xs}}lit_element_s.finalized=!0,lit_element_s._$litElement$=!0,null===(Os=globalThis.litElementHydrateSupport)||void 0===Os||Os.call(globalThis,{LitElement:lit_element_s});const ks=globalThis.litElementPolyfillSupport;null==ks||ks({LitElement:lit_element_s});(null!==(Qs=globalThis.litElementVersions)&&void 0!==Qs?Qs:globalThis.litElementVersions=[]).push("3.3.3");const Gs=null!=navigator.xr&&null!=self.XRSession&&null!=navigator.xr.isSessionSupported,Vs=Gs&&null!=self.XRSession.prototype.requestHitTestSource,Hs=null!=self.ResizeObserver,zs=null!=self.IntersectionObserver,Ws=Vs,qs=((()=>{const e=navigator.userAgent||navigator.vendor||self.opera;let t=!1;(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=!0)})(),/\bCrOS\b/.test(navigator.userAgent),/android/i.test(navigator.userAgent)),js=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,Xs=(/Safari\//.test(navigator.userAgent),/firefox/i.test(navigator.userAgent)),Ys=/OculusBrowser/.test(navigator.userAgent),Ks=(js&&/CriOS\//.test(navigator.userAgent),qs&&!Xs&&!Ys),Js=Boolean(window.webkit&&window.webkit.messageHandlers),$s=(()=>{if(js){if(Js)return Boolean(/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent));{const e=document.createElement("a");return Boolean(e.relList&&e.relList.supports&&e.relList.supports("ar"))}}return!1})();var Zs=r(6763);const deserializeUrl=e=>e&&"null"!==e?toFullUrl(e):null,assertIsArCandidate=()=>{if(Ws)return;const e=[];throw Gs||e.push("WebXR Device API"),Vs||e.push("WebXR Hit Test API"),new Error(`The following APIs are required for AR, but are missing in this browser: ${e.join(", ")}`)},toFullUrl=e=>new URL(e,window.location.toString()).toString(),debounce=(e,t)=>{let r=null;return(...s)=>{null!=r&&self.clearTimeout(r),r=self.setTimeout((()=>{r=null,e(...s)}),t)}},utilities_clamp=(e,t,r)=>Math.max(t,Math.min(r,e)),ea=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||Zs.warn('No <meta name="viewport"> detected; <model-viewer> will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})(),ta=(()=>{const e=new RegExp("[?&]model-viewer-debug-mode(&|$)");return()=>self.ModelViewerElement&&self.ModelViewerElement.debugMode||self.location&&self.location.search&&self.location.search.match(e)})();var __decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const ia=Symbol("currentEnvironmentMap"),na=Symbol("currentBackground"),ra=Symbol("updateEnvironment"),sa=Symbol("cancelEnvironmentUpdate"),aa=Es`
3
3
  <style>
4
4
  :host {
5
5
  display: block;
@@ -298,7 +298,7 @@ canvas {
298
298
  role="button"
299
299
  href="javascript:void(0);"
300
300
  aria-label="View in your space">
301
- ${Ps`
301
+ ${Es`
302
302
  <svg version="1.1" id="view_x5F_in_x5F_AR_x5F_icon"
303
303
  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px"
304
304
  viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
@@ -329,7 +329,7 @@ canvas {
329
329
  <div class="slot interaction-prompt cover centered">
330
330
  <div id="prompt" class="animated-container">
331
331
  <slot name="interaction-prompt" aria-hidden="true">
332
- ${Ps`
332
+ ${Es`
333
333
  <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="36">
334
334
  <defs>
335
335
  <path id="A" d="M.001.232h24.997V36H.001z" />
@@ -379,7 +379,7 @@ canvas {
379
379
  tabindex="3"
380
380
  aria-label="Exit AR"
381
381
  aria-hidden="true">
382
- ${Ps`
382
+ ${Es`
383
383
  <svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000">
384
384
  <!-- NOTE(cdata): This SVG filter is a stop-gap until we can implement
385
385
  support for dynamic re-coloring of UI components -->
@@ -405,4 +405,4 @@ canvas {
405
405
  </div>
406
406
  <div class="screen-reader-only" role="region" aria-label="Live announcements">
407
407
  <span id="status" role="status"></span>
408
- </div>`;var Ea=r(6763);const xa=new WeakMap;function DRACOWorker(){let e,t;function decodeAttribute(e,t,r,s,o,l){const c=l.num_components(),h=r.num_points()*c,d=h*o.BYTES_PER_ELEMENT,p=function getDracoDataType(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,o),A=e._malloc(d);t.GetAttributeDataArrayForAllPoints(r,l,p,d,A);const m=new o(e.HEAPF32.buffer,A,h).slice();return e._free(A),{name:s,array:m,itemSize:c}}onmessage=function(r){const s=r.data;switch(s.type){case"init":e=s.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=s.buffer,o=s.taskConfig;t.then((e=>{const t=e.draco,l=new t.Decoder;try{const e=function decodeGeometry(e,t,r,s){const o=s.attributeIDs,l=s.attributeTypes;let c,h;const d=t.GetEncodedGeometryType(r);if(d===e.TRIANGULAR_MESH)c=new e.Mesh,h=t.DecodeArrayToMesh(r,r.byteLength,c);else{if(d!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");c=new e.PointCloud,h=t.DecodeArrayToPointCloud(r,r.byteLength,c)}if(!h.ok()||0===c.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+h.error_msg());const p={index:null,attributes:[]};for(const r in o){const h=self[l[r]];let d,A;if(s.useUniqueIDs)A=o[r],d=t.GetAttributeByUniqueId(c,A);else{if(A=t.GetAttributeId(c,e[o[r]]),-1===A)continue;d=t.GetAttribute(c,A)}const m=decodeAttribute(e,t,c,r,h,d);"color"===r&&(m.vertexColorSpace=s.vertexColorSpace),p.attributes.push(m)}d===e.TRIANGULAR_MESH&&(p.index=function decodeIndex(e,t,r){const s=r.num_faces(),o=3*s,l=4*o,c=e._malloc(l);t.GetTrianglesUInt32Array(r,l,c);const h=new Uint32Array(e.HEAPF32.buffer,c,o).slice();return e._free(c),{array:h,itemSize:1}}(e,t,c));return e.destroy(c),p}(t,l,new Int8Array(r),o),c=e.attributes.map((e=>e.array.buffer));e.index&&c.push(e.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:e},c)}catch(e){Ea.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(l)}}))}}}var Sa=r(6763);function toTrianglesDrawMode(e,t){if(0===t)return Sa.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let r=e.getIndex();if(null===r){const t=[],s=e.getAttribute("position");if(void 0===s)return Sa.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<s.count;e++)t.push(e);e.setIndex(t),r=e.getIndex()}const s=r.count-2,o=[];if(2===t)for(let e=1;e<=s;e++)o.push(r.getX(0)),o.push(r.getX(e)),o.push(r.getX(e+1));else for(let e=0;e<s;e++)e%2==0?(o.push(r.getX(e)),o.push(r.getX(e+1)),o.push(r.getX(e+2))):(o.push(r.getX(e+2)),o.push(r.getX(e+1)),o.push(r.getX(e)));o.length/3!==s&&Sa.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const l=e.clone();return l.setIndex(o),l.clearGroups(),l}return Sa.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}var Ma=r(6763);class GLTFLoader extends Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFTextureAVIFExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)}))}load(e,t,r,s){const o=this;let l;if(""!==this.resourcePath)l=this.resourcePath;else if(""!==this.path){const t=LoaderUtils.extractUrlBase(e);l=LoaderUtils.resolveURL(t,this.path)}else l=LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const _onError=function(t){s?s(t):Ma.error(t),o.manager.itemError(e),o.manager.itemEnd(e)},c=new three_module_FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,(function(r){try{o.parse(r,l,(function(r){t(r),o.manager.itemEnd(e)}),_onError)}catch(e){_onError(e)}}),r,_onError)}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,r,s){let o;const l={},c={},h=new TextDecoder;if("string"==typeof e)o=JSON.parse(e);else if(e instanceof ArrayBuffer){if(h.decode(new Uint8Array(e,0,4))===ba){try{l[Ca.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(s&&s(e))}o=JSON.parse(l[Ca.KHR_BINARY_GLTF].content)}else o=JSON.parse(h.decode(e))}else o=e;if(void 0===o.asset||o.asset.version[0]<2)return void(s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const d=new GLTFParser(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](d);t.name||Ma.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[t.name]=t,l[t.name]=!0}if(o.extensionsUsed)for(let e=0;e<o.extensionsUsed.length;++e){const t=o.extensionsUsed[e],r=o.extensionsRequired||[];switch(t){case Ca.KHR_MATERIALS_UNLIT:l[t]=new GLTFMaterialsUnlitExtension;break;case Ca.KHR_DRACO_MESH_COMPRESSION:l[t]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case Ca.KHR_TEXTURE_TRANSFORM:l[t]=new GLTFTextureTransformExtension;break;case Ca.KHR_MESH_QUANTIZATION:l[t]=new GLTFMeshQuantizationExtension;break;default:r.indexOf(t)>=0&&void 0===c[t]&&Ma.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}d.setExtensions(l),d.setPlugins(c),d.parse(r,s)}parseAsync(e,t){const r=this;return new Promise((function(s,o){r.parse(e,t,s,o)}))}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Ca={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_MATERIALS_BUMP:"EXT_materials_bump",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 GLTFLightsExtension{constructor(e){this.parser=e,this.name=Ca.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,s=t.length;r<s;r++){const s=t[r];s.extensions&&s.extensions[this.name]&&void 0!==s.extensions[this.name].light&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let s=t.cache.get(r);if(s)return s;const o=t.json,l=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let c;const h=new Color(16777215);void 0!==l.color&&h.setRGB(l.color[0],l.color[1],l.color[2],it);const d=void 0!==l.range?l.range:0;switch(l.type){case"directional":c=new DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new PointLight(h),c.distance=d;break;case"spot":c=new SpotLight(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=void 0!==l.spot.innerConeAngle?l.spot.innerConeAngle:0,l.spot.outerConeAngle=void 0!==l.spot.outerConeAngle?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),c.decay=2,assignExtrasToUserData(c,l),void 0!==l.intensity&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(c),t.cache.add(r,s),s}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,s=r.json.nodes[e],o=(s.extensions&&s.extensions[this.name]||{}).light;return void 0===o?null:this._loadLight(o).then((function(e){return r._getNodeRef(t.cache,o,e)}))}}class GLTFMaterialsUnlitExtension{constructor(){this.name=Ca.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(e,t,r){const s=[];e.color=new Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const t=o.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],it),e.opacity=t[3]}void 0!==o.baseColorTexture&&s.push(r.assignTexture(e,"map",o.baseColorTexture,tt))}return Promise.all(s)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name].emissiveStrength;return void 0!==s&&(t.emissiveIntensity=s),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];if(void 0!==l.clearcoatFactor&&(t.clearcoat=l.clearcoatFactor),void 0!==l.clearcoatTexture&&o.push(r.assignTexture(t,"clearcoatMap",l.clearcoatTexture)),void 0!==l.clearcoatRoughnessFactor&&(t.clearcoatRoughness=l.clearcoatRoughnessFactor),void 0!==l.clearcoatRoughnessTexture&&o.push(r.assignTexture(t,"clearcoatRoughnessMap",l.clearcoatRoughnessTexture)),void 0!==l.clearcoatNormalTexture&&(o.push(r.assignTexture(t,"clearcoatNormalMap",l.clearcoatNormalTexture)),void 0!==l.clearcoatNormalTexture.scale)){const e=l.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Vector2(e,e)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return void 0!==l.iridescenceFactor&&(t.iridescence=l.iridescenceFactor),void 0!==l.iridescenceTexture&&o.push(r.assignTexture(t,"iridescenceMap",l.iridescenceTexture)),void 0!==l.iridescenceIor&&(t.iridescenceIOR=l.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==l.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=l.iridescenceThicknessMinimum),void 0!==l.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=l.iridescenceThicknessMaximum),void 0!==l.iridescenceThicknessTexture&&o.push(r.assignTexture(t,"iridescenceThicknessMap",l.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const l=s.extensions[this.name];if(void 0!==l.sheenColorFactor){const e=l.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],it)}return void 0!==l.sheenRoughnessFactor&&(t.sheenRoughness=l.sheenRoughnessFactor),void 0!==l.sheenColorTexture&&o.push(r.assignTexture(t,"sheenColorMap",l.sheenColorTexture,tt)),void 0!==l.sheenRoughnessTexture&&o.push(r.assignTexture(t,"sheenRoughnessMap",l.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return void 0!==l.transmissionFactor&&(t.transmission=l.transmissionFactor),void 0!==l.transmissionTexture&&o.push(r.assignTexture(t,"transmissionMap",l.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];t.thickness=void 0!==l.thicknessFactor?l.thicknessFactor:0,void 0!==l.thicknessTexture&&o.push(r.assignTexture(t,"thicknessMap",l.thicknessTexture)),t.attenuationDistance=l.attenuationDistance||1/0;const c=l.attenuationColor||[1,1,1];return t.attenuationColor=(new Color).setRGB(c[0],c[1],c[2],it),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name];return t.ior=void 0!==s.ior?s.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];t.specularIntensity=void 0!==l.specularFactor?l.specularFactor:1,void 0!==l.specularTexture&&o.push(r.assignTexture(t,"specularIntensityMap",l.specularTexture));const c=l.specularColorFactor||[1,1,1];return t.specularColor=(new Color).setRGB(c[0],c[1],c[2],it),void 0!==l.specularColorTexture&&o.push(r.assignTexture(t,"specularColorMap",l.specularColorTexture,tt)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=Ca.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return t.bumpScale=void 0!==l.bumpFactor?l.bumpFactor:1,void 0!==l.bumpTexture&&o.push(r.assignTexture(t,"bumpMap",l.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=Ca.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return void 0!==l.anisotropyStrength&&(t.anisotropy=l.anisotropyStrength),void 0!==l.anisotropyRotation&&(t.anisotropyRotation=l.anisotropyRotation),void 0!==l.anisotropyTexture&&o.push(r.assignTexture(t,"anisotropyMap",l.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=Ca.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,s=r.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.extensions[this.name],l=t.options.ktx2Loader;if(!l){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,l)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=Ca.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,s=r.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const l=o.extensions[t],c=s.images[l.source];let h=r.textureLoader;if(c.uri){const e=r.options.manager.getHandler(c.uri);null!==e&&(h=e)}return this.detectSupport().then((function(o){if(o)return r.loadTextureImage(e,l.source,h);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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 GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=Ca.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,s=r.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const l=o.extensions[t],c=s.images[l.source];let h=r.textureLoader;if(c.uri){const e=r.options.manager.getHandler(c.uri);null!==e&&(h=e)}return this.detectSupport().then((function(o){if(o)return r.loadTextureImage(e,l.source,h);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.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 GLTFMeshoptCompression{constructor(e){this.name=Ca.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const e=r.extensions[this.name],s=this.parser.getDependency("buffer",e.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then((function(t){const r=e.byteOffset||0,s=e.byteLength||0,l=e.count,c=e.byteStride,h=new Uint8Array(t,r,s);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(l,c,h,e.mode,e.filter).then((function(e){return e.buffer})):o.ready.then((function(){const t=new ArrayBuffer(l*c);return o.decodeGltfBuffer(new Uint8Array(t),l,c,h,e.mode,e.filter),t}))}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=Ca.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;const s=t.meshes[r.mesh];for(const e of s.primitives)if(e.mode!==Ba.TRIANGLES&&e.mode!==Ba.TRIANGLE_STRIP&&e.mode!==Ba.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=r.extensions[this.name].attributes,l=[],c={};for(const e in o)l.push(this.parser.getDependency("accessor",o[e]).then((t=>(c[e]=t,c[e]))));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then((e=>{const t=e.pop(),r=t.isGroup?t.children:[t],s=e[0].count,o=[];for(const e of r){const t=new three_module_Matrix4,r=new three_module_Vector3,l=new three_module_Quaternion,h=new three_module_Vector3(1,1,1),d=new InstancedMesh(e.geometry,e.material,s);for(let e=0;e<s;e++)c.TRANSLATION&&r.fromBufferAttribute(c.TRANSLATION,e),c.ROTATION&&l.fromBufferAttribute(c.ROTATION,e),c.SCALE&&h.fromBufferAttribute(c.SCALE,e),d.setMatrixAt(e,t.compose(r,l,h));for(const t in c)if("_COLOR_0"===t){const e=c[t];d.instanceColor=new three_module_InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,c[t]);Object3D.prototype.copy.call(d,e),this.parser.assignFinalMaterial(d),o.push(d)}return t.isGroup?(t.clear(),t.add(...o),t):o[0]})))}}const ba="glTF",wa=1313821514,Ia=5130562;class GLTFBinaryExtension{constructor(e){this.name=Ca.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ba)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,o=new DataView(e,12);let l=0;for(;l<s;){const t=o.getUint32(l,!0);l+=4;const s=o.getUint32(l,!0);if(l+=4,s===wa){const s=new Uint8Array(e,12+l,t);this.content=r.decode(s)}else if(s===Ia){const r=12+l;this.body=e.slice(r,r+t)}l+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ca.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,s=this.dracoLoader,o=e.extensions[this.name].bufferView,l=e.extensions[this.name].attributes,c={},h={},d={};for(const e in l){const t=Pa[e]||e.toLowerCase();c[t]=l[e]}for(const t in e.attributes){const s=Pa[t]||t.toLowerCase();if(void 0!==l[t]){const o=r.accessors[e.attributes[t]],l=Ra[o.componentType];d[s]=l.name,h[s]=!0===o.normalized}}return t.getDependency("bufferView",o).then((function(e){return new Promise((function(t,r){s.decodeDracoFile(e,(function(e){for(const t in e.attributes){const r=e.attributes[t],s=h[t];void 0!==s&&(r.normalized=s)}t(e)}),c,d,it,r)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=Ca.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class GLTFMeshQuantizationExtension{constructor(){this.name=Ca.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let e=0;e!==s;e++)t[e]=r[o+e];return t}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=2*c,d=3*c,p=s-t,A=(r-t)/p,m=A*A,f=m*A,g=e*d,_=g-d,y=-2*f+3*m,x=f-m,S=1-y,C=x-m+A;for(let e=0;e!==c;e++){const t=l[_+e+c],r=l[_+e+h]*p,s=l[g+e+c],d=l[g+e]*p;o[e]=S*t+C*r+y*s+x*d}return o}}const Ta=new three_module_Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,r,s){const o=super.interpolate_(e,t,r,s);return Ta.fromArray(o).normalize().toArray(o),o}}const Ba={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ra={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},La={9728:Ae,9729:ge,9984:me,9985:_e,9986:fe,9987:ve},Da={33071:de,33648:pe,10497:ue},Ua={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Pa={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Fa={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Na={CUBICSPLINE:void 0,LINEAR:je,STEP:qe},Oa="OPAQUE",Qa="MASK",ka="BLEND";function createDefaultMaterial(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:p})),e.DefaultMaterial}function addUnknownExtensionsToUserData(e,t,r){for(const s in r.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=r.extensions[s])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):Ma.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function updateMorphTargets(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,s=t.weights.length;r<s;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){const r=t.extras.targetNames;if(e.morphTargetInfluences.length===r.length){e.morphTargetDictionary={};for(let t=0,s=r.length;t<s;t++)e.morphTargetDictionary[r[t]]=t}else Ma.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const r=e.extensions&&e.extensions[Ca.KHR_DRACO_MESH_COMPRESSION];if(t=r?"draco:"+r.bufferView+":"+r.indices+":"+createAttributesKey(r.attributes):e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,s=e.targets.length;r<s;r++)t+=":"+createAttributesKey(e.targets[r]);return t}function createAttributesKey(e){let t="";const r=Object.keys(e).sort();for(let s=0,o=r.length;s<o;s++)t+=r[s]+":"+e[r[s]]+";";return t}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Ga=new three_module_Matrix4;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,s=!1,o=-1;"undefined"!=typeof navigator&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||r||s&&o<98?this.textureLoader=new TextureLoader(this.options.manager):this.textureLoader=new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three_module_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 r=this,s=this.json,o=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([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])})).then((function(t){const l={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:r,userData:{}};return addUnknownExtensionsToUserData(o,l,s),assignExtrasToUserData(l,s),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(l)}))).then((function(){e(l)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){const s=t[r].joints;for(let t=0,r=s.length;t<r;t++)e[s[t]].isBone=!0}for(let t=0,s=e.length;t<s;t++){const s=e[t];void 0!==s.mesh&&(this._addNodeRef(this.meshCache,s.mesh),void 0!==s.skin&&(r[s.mesh].isSkinnedMesh=!0)),void 0!==s.camera&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const s=r.clone(),updateMappings=(e,t)=>{const r=this.associations.get(e);null!=r&&this.associations.set(t,r);for(const[r,s]of e.children.entries())updateMappings(s,t.children[r])};return updateMappings(r,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const s=e(t[r]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let s=0;s<t.length;s++){const o=e(t[s]);o&&r.push(o)}return r}getDependency(e,t){const r=e+":"+t;let s=this.cache.get(r);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":s=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne((function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)})),!s)throw new Error("Unknown type: "+e)}this.cache.add(r,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return r.getDependency(e,s)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Ca.KHR_BINARY_GLTF].body);const s=this.options;return new Promise((function(e,o){r.load(LoaderUtils.resolveURL(t.uri,s.path),e,void 0,(function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const r=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+r)}))}loadAccessor(e){const t=this,r=this.json,s=this.json.accessors[e];if(void 0===s.bufferView&&void 0===s.sparse){const e=Ua[s.type],t=Ra[s.componentType],r=!0===s.normalized,o=new t(s.count*e);return Promise.resolve(new three_module_BufferAttribute(o,e,r))}const o=[];return void 0!==s.bufferView?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),void 0!==s.sparse&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then((function(e){const o=e[0],l=Ua[s.type],c=Ra[s.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,p=s.byteOffset||0,A=void 0!==s.bufferView?r.bufferViews[s.bufferView].byteStride:void 0,m=!0===s.normalized;let f,g;if(A&&A!==d){const e=Math.floor(p/A),r="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+e+":"+s.count;let d=t.cache.get(r);d||(f=new c(o,e*A,s.count*A/h),d=new three_module_InterleavedBuffer(f,A/h),t.cache.add(r,d)),g=new three_module_InterleavedBufferAttribute(d,l,p%A/h,m)}else f=null===o?new c(s.count*l):new c(o,p,s.count*l),g=new three_module_BufferAttribute(f,l,m);if(void 0!==s.sparse){const t=Ua.SCALAR,r=Ra[s.sparse.indices.componentType],h=s.sparse.indices.byteOffset||0,d=s.sparse.values.byteOffset||0,p=new r(e[1],h,s.sparse.count*t),A=new c(e[2],d,s.sparse.count*l);null!==o&&(g=new three_module_BufferAttribute(g.array.slice(),g.itemSize,g.normalized));for(let e=0,t=p.length;e<t;e++){const t=p[e];if(g.setX(t,A[e*l]),l>=2&&g.setY(t,A[e*l+1]),l>=3&&g.setZ(t,A[e*l+2]),l>=4&&g.setW(t,A[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g}))}loadTexture(e){const t=this.json,r=this.options,s=t.textures[e].source,o=t.images[s];let l=this.textureLoader;if(o.uri){const e=r.manager.getHandler(o.uri);null!==e&&(l=e)}return this.loadTextureImage(e,s,l)}loadTextureImage(e,t,r){const s=this,o=this.json,l=o.textures[e],c=o.images[t],h=(c.uri||c.bufferView)+":"+l.sampler;if(this.textureCache[h])return this.textureCache[h];const d=this.loadImageSource(t,r).then((function(t){t.flipY=!1,t.name=l.name||c.name||"",""===t.name&&"string"==typeof c.uri&&!1===c.uri.startsWith("data:image/")&&(t.name=c.uri);const r=(o.samplers||{})[l.sampler]||{};return t.magFilter=La[r.magFilter]||ge,t.minFilter=La[r.minFilter]||ve,t.wrapS=Da[r.wrapS]||ue,t.wrapT=Da[r.wrapT]||ue,s.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[h]=d,d}loadImageSource(e,t){const r=this,s=this.json,o=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=s.images[e],c=self.URL||self.webkitURL;let h=l.uri||"",d=!1;if(void 0!==l.bufferView)h=r.getDependency("bufferView",l.bufferView).then((function(e){d=!0;const t=new Blob([e],{type:l.mimeType});return h=c.createObjectURL(t),h}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(h).then((function(e){return new Promise((function(r,s){let l=r;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,r(t)}),t.load(LoaderUtils.resolveURL(e,o.path),l,void 0,s)}))})).then((function(e){return!0===d&&c.revokeObjectURL(h),e.userData.mimeType=l.mimeType||function getImageURIMimeType(e){return e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"}(l.uri),e})).catch((function(e){throw Ma.error("THREE.GLTFLoader: Couldn't load texture",h),e}));return this.sourceCache[e]=p,p}assignTexture(e,t,r,s){const o=this;return this.getDependency("texture",r.index).then((function(l){if(!l)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((l=l.clone()).channel=r.texCoord),o.extensions[Ca.KHR_TEXTURE_TRANSFORM]){const e=void 0!==r.extensions?r.extensions[Ca.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=o.associations.get(l);l=o.extensions[Ca.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),o.associations.set(l,t)}}return void 0!==s&&(l.colorSpace=s),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const s=void 0===t.attributes.tangent,o=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){const e="LineBasicMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(s||o||l){let e="ClonedMaterial:"+r.uuid+":";s&&(e+="derivative-tangents:"),o&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),o&&(t.vertexColors=!0),l&&(t.flatShading=!0),s&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,s=this.extensions,o=r.materials[e];let l;const c={},h=[];if((o.extensions||{})[Ca.KHR_MATERIALS_UNLIT]){const e=s[Ca.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),h.push(e.extendParams(c,o,t))}else{const r=o.pbrMetallicRoughness||{};if(c.color=new Color(1,1,1),c.opacity=1,Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;c.color.setRGB(e[0],e[1],e[2],it),c.opacity=e[3]}void 0!==r.baseColorTexture&&h.push(t.assignTexture(c,"map",r.baseColorTexture,tt)),c.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,c.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(h.push(t.assignTexture(c,"metalnessMap",r.metallicRoughnessTexture)),h.push(t.assignTexture(c,"roughnessMap",r.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),h.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,c)}))))}!0===o.doubleSided&&(c.side=m);const d=o.alphaMode||Oa;if(d===ka?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,d===Qa&&(c.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&l!==MeshBasicMaterial&&(h.push(t.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;c.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&l!==MeshBasicMaterial&&(h.push(t.assignTexture(c,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(c.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&l!==MeshBasicMaterial){const e=o.emissiveFactor;c.emissive=(new Color).setRGB(e[0],e[1],e[2],it)}return void 0!==o.emissiveTexture&&l!==MeshBasicMaterial&&h.push(t.assignTexture(c,"emissiveMap",o.emissiveTexture,tt)),Promise.all(h).then((function(){const r=new l(c);return o.name&&(r.name=o.name),assignExtrasToUserData(r,o),t.associations.set(r,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(s,r,o),r}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,s=this.primitiveCache;function createDracoPrimitive(e){return r[Ca.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return addPrimitiveAttributes(r,e,t)}))}const o=[];for(let r=0,l=e.length;r<l;r++){const l=e[r],c=createPrimitiveKey(l),h=s[c];if(h)o.push(h.promise);else{let e;e=l.extensions&&l.extensions[Ca.KHR_DRACO_MESH_COMPRESSION]?createDracoPrimitive(l):addPrimitiveAttributes(new three_module_BufferGeometry,l,t),s[c]={primitive:l,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const t=this,r=this.json,s=this.extensions,o=r.meshes[e],l=o.primitives,c=[];for(let e=0,t=l.length;e<t;e++){const t=void 0===l[e].material?createDefaultMaterial(this.cache):this.getDependency("material",l[e].material);c.push(t)}return c.push(t.loadGeometries(l)),Promise.all(c).then((function(r){const c=r.slice(0,r.length-1),h=r[r.length-1],d=[];for(let r=0,p=h.length;r<p;r++){const p=h[r],A=l[r];let m;const f=c[r];if(A.mode===Ba.TRIANGLES||A.mode===Ba.TRIANGLE_STRIP||A.mode===Ba.TRIANGLE_FAN||void 0===A.mode)m=!0===o.isSkinnedMesh?new SkinnedMesh(p,f):new three_module_Mesh(p,f),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),A.mode===Ba.TRIANGLE_STRIP?m.geometry=toTrianglesDrawMode(m.geometry,1):A.mode===Ba.TRIANGLE_FAN&&(m.geometry=toTrianglesDrawMode(m.geometry,2));else if(A.mode===Ba.LINES)m=new LineSegments(p,f);else if(A.mode===Ba.LINE_STRIP)m=new Line(p,f);else if(A.mode===Ba.LINE_LOOP)m=new LineLoop(p,f);else{if(A.mode!==Ba.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);m=new Points(p,f)}Object.keys(m.geometry.morphAttributes).length>0&&updateMorphTargets(m,o),m.name=t.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(m,o),A.extensions&&addUnknownExtensionsToUserData(s,m,A),t.assignFinalMaterial(m),d.push(m)}for(let r=0,s=d.length;r<s;r++)t.associations.set(d[r],{meshes:e,primitives:r});if(1===d.length)return o.extensions&&addUnknownExtensionsToUserData(s,d[0],o),d[0];const p=new three_module_Group;o.extensions&&addUnknownExtensionsToUserData(s,p,o),t.associations.set(p,{meshes:e});for(let e=0,t=d.length;e<t;e++)p.add(d[e]);return p}))}loadCamera(e){let t;const r=this.json.cameras[e],s=r[r.type];if(s)return"perspective"===r.type?t=new PerspectiveCamera(wt.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===r.type&&(t=new OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),assignExtrasToUserData(t,r),Promise.resolve(t);Ma.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],r=[];for(let e=0,s=t.joints.length;e<s;e++)r.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then((function(e){const r=e.pop(),s=e,o=[],l=[];for(let e=0,c=s.length;e<c;e++){const c=s[e];if(c){o.push(c);const t=new three_module_Matrix4;null!==r&&t.fromArray(r.array,16*e),l.push(t)}else Ma.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Skeleton(o,l)}))}loadAnimation(e){const t=this.json,r=this,s=t.animations[e],o=s.name?s.name:"animation_"+e,l=[],c=[],h=[],d=[],p=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],r=s.samplers[t.sampler],o=t.target,A=o.node,m=void 0!==s.parameters?s.parameters[r.input]:r.input,f=void 0!==s.parameters?s.parameters[r.output]:r.output;void 0!==o.node&&(l.push(this.getDependency("node",A)),c.push(this.getDependency("accessor",m)),h.push(this.getDependency("accessor",f)),d.push(r),p.push(o))}return Promise.all([Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d),Promise.all(p)]).then((function(e){const t=e[0],s=e[1],l=e[2],c=e[3],h=e[4],d=[];for(let e=0,o=t.length;e<o;e++){const o=t[e],p=s[e],A=l[e],m=c[e],f=h[e];if(void 0===o)continue;o.updateMatrix&&o.updateMatrix();const g=r._createAnimationTracks(o,p,A,m,f);if(g)for(let e=0;e<g.length;e++)d.push(g[e])}return new three_module_AnimationClip(o,void 0,d)}))}createNodeMesh(e){const t=this.json,r=this,s=t.nodes[e];return void 0===s.mesh?null:r.getDependency("mesh",s.mesh).then((function(e){const t=r._getNodeRef(r.meshCache,s.mesh,e);return void 0!==s.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,r=s.weights.length;t<r;t++)e.morphTargetInfluences[t]=s.weights[t]})),t}))}loadNode(e){const t=this,r=this.json.nodes[e],s=t._loadNodeShallow(e),o=[],l=r.children||[];for(let e=0,r=l.length;e<r;e++)o.push(t.getDependency("node",l[e]));const c=void 0===r.skin?Promise.resolve(null):t.getDependency("skin",r.skin);return Promise.all([s,Promise.all(o),c]).then((function(e){const t=e[0],r=e[1],s=e[2];null!==s&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(s,Ga)}));for(let e=0,s=r.length;e<s;e++)t.add(r[e]);return t}))}_loadNodeShallow(e){const t=this.json,r=this.extensions,s=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const o=t.nodes[e],l=o.name?s.createUniqueName(o.name):"",c=[],h=s._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return h&&c.push(h),void 0!==o.camera&&c.push(s.getDependency("camera",o.camera).then((function(e){return s._getNodeRef(s.cameraCache,o.camera,e)}))),s._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){c.push(e)})),this.nodeCache[e]=Promise.all(c).then((function(t){let c;if(c=!0===o.isBone?new Bone:t.length>1?new three_module_Group:1===t.length?t[0]:new Object3D,c!==t[0])for(let e=0,r=t.length;e<r;e++)c.add(t[e]);if(o.name&&(c.userData.name=o.name,c.name=l),assignExtrasToUserData(c,o),o.extensions&&addUnknownExtensionsToUserData(r,c,o),void 0!==o.matrix){const e=new three_module_Matrix4;e.fromArray(o.matrix),c.applyMatrix4(e)}else void 0!==o.translation&&c.position.fromArray(o.translation),void 0!==o.rotation&&c.quaternion.fromArray(o.rotation),void 0!==o.scale&&c.scale.fromArray(o.scale);return s.associations.has(c)||s.associations.set(c,{}),s.associations.get(c).nodes=e,c})),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],s=this,o=new three_module_Group;r.name&&(o.name=s.createUniqueName(r.name)),assignExtrasToUserData(o,r),r.extensions&&addUnknownExtensionsToUserData(t,o,r);const l=r.nodes||[],c=[];for(let e=0,t=l.length;e<t;e++)c.push(s.getDependency("node",l[e]));return Promise.all(c).then((function(e){for(let t=0,r=e.length;t<r;t++)o.add(e[t]);return s.associations=(e=>{const t=new Map;for(const[e,r]of s.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,r);return e.traverse((e=>{const r=s.associations.get(e);null!=r&&t.set(e,r)})),t})(o),o}))}_createAnimationTracks(e,t,r,s,o){const l=[],c=e.name?e.name:e.uuid,h=[];let d;switch(Fa[o.path]===Fa.weights?e.traverse((function(e){e.morphTargetInfluences&&h.push(e.name?e.name:e.uuid)})):h.push(c),Fa[o.path]){case Fa.weights:d=NumberKeyframeTrack;break;case Fa.rotation:d=three_module_QuaternionKeyframeTrack;break;case Fa.position:case Fa.scale:d=three_module_VectorKeyframeTrack;break;default:if(1===r.itemSize)d=NumberKeyframeTrack;else d=three_module_VectorKeyframeTrack}const p=void 0!==s.interpolation?Na[s.interpolation]:je,A=this._getArrayFromAccessor(r);for(let e=0,r=h.length;e<r;e++){const r=new d(h[e]+"."+Fa[o.path],t.array,A,p);"CUBICSPLINE"===s.interpolation&&this._createCubicSplineTrackInterpolant(r),l.push(r)}return l}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=getNormalizedComponentScale(t.constructor),r=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)r[s]=t[s]*e;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function InterpolantFactoryMethodGLTFCubicSpline(e){return new(this instanceof three_module_QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function addPrimitiveAttributes(e,t,r){const s=t.attributes,o=[];function assignAttributeAccessor(t,s){return r.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}for(const t in s){const r=Pa[t]||t.toLowerCase();r in e.attributes||o.push(assignAttributeAccessor(s[t],r))}if(void 0!==t.indices&&!e.index){const s=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));o.push(s)}return Ut.workingColorSpace!==it&&"COLOR_0"in s&&Ma.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ut.workingColorSpace}" not supported.`),assignExtrasToUserData(e,t),function computeBounds(e,t,r){const s=t.attributes,o=new Box3;if(void 0===s.POSITION)return;{const e=r.json.accessors[s.POSITION],t=e.min,l=e.max;if(void 0===t||void 0===l)return void Ma.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new three_module_Vector3(t[0],t[1],t[2]),new three_module_Vector3(l[0],l[1],l[2])),e.normalized){const t=getNormalizedComponentScale(Ra[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const l=t.targets;if(void 0!==l){const e=new three_module_Vector3,t=new three_module_Vector3;for(let s=0,o=l.length;s<o;s++){const o=l[s];if(void 0!==o.POSITION){const s=r.json.accessors[o.POSITION],l=s.min,c=s.max;if(void 0!==l&&void 0!==c){if(t.setX(Math.max(Math.abs(l[0]),Math.abs(c[0]))),t.setY(Math.max(Math.abs(l[1]),Math.abs(c[1]))),t.setZ(Math.max(Math.abs(l[2]),Math.abs(c[2]))),s.normalized){const e=getNormalizedComponentScale(Ra[s.componentType]);t.multiplyScalar(e)}e.max(t)}else Ma.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const c=new Sphere;o.getCenter(c.center),c.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=c}(e,t,r),Promise.all(o).then((function(){return void 0!==t.targets?function addMorphTargets(e,t,r){let s=!1,o=!1,l=!1;for(let e=0,r=t.length;e<r;e++){const r=t[e];if(void 0!==r.POSITION&&(s=!0),void 0!==r.NORMAL&&(o=!0),void 0!==r.COLOR_0&&(l=!0),s&&o&&l)break}if(!s&&!o&&!l)return Promise.resolve(e);const c=[],h=[],d=[];for(let p=0,A=t.length;p<A;p++){const A=t[p];if(s){const t=void 0!==A.POSITION?r.getDependency("accessor",A.POSITION):e.attributes.position;c.push(t)}if(o){const t=void 0!==A.NORMAL?r.getDependency("accessor",A.NORMAL):e.attributes.normal;h.push(t)}if(l){const t=void 0!==A.COLOR_0?r.getDependency("accessor",A.COLOR_0):e.attributes.color;d.push(t)}}return Promise.all([Promise.all(c),Promise.all(h),Promise.all(d)]).then((function(t){const r=t[0],c=t[1],h=t[2];return s&&(e.morphAttributes.position=r),o&&(e.morphAttributes.normal=c),l&&(e.morphAttributes.color=h),e.morphTargetsRelative=!0,e}))}(e,t.targets,r):e}))}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const r=this.workersResolve[e];if(r&&r(t),this.queue.length){const{resolve:t,msg:r,transfer:s}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(r,s)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((r=>{const s=this._getIdleWorker();-1!==s?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=r,this.workers[s].postMessage(e,t)):this.queue.push({resolve:r,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}var Va=r(8287).hp;const Ha=2,za=0,Wa=1,qa=10,ja=9,Xa=15,Ya=16,Ka=22,Ja=37,$a=43,Za=76,eo=83,to=97,io=100,no=103,ro=109,so=165,ao=166;class Si{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Ii{constructor(e,t,r,s){this._dataView=new DataView(e.buffer,e.byteOffset+t,r),this._littleEndian=s,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const r=this._offset;let s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,s)}}new Uint8Array([0]);const oo=[171,75,84,88,32,50,48,187,13,10,26,10];function Ei(e){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):Va.from(e).toString("utf8")}var lo=r(8287).hp;let co,ho,uo;const po={env:{emscripten_notify_memory_growth:function(e){uo=new Uint8Array(ho.exports.memory.buffer)}}};class zstddec_module_Q{init(){return co||(co="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+Ao).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,po))).then(this._init):WebAssembly.instantiate(lo.from(Ao,"base64"),po).then(this._init),co)}_init(e){ho=e.instance,po.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!ho)throw new Error("ZSTDDecoder: Await .init() before decoding.");const r=e.byteLength,s=ho.exports.malloc(r);uo.set(e,s),t=t||Number(ho.exports.ZSTD_findDecompressedSize(s,r));const o=ho.exports.malloc(t),l=ho.exports.ZSTD_decompress(o,t,s,r),c=uo.slice(o,o+l);return ho.exports.free(s),ho.exports.free(o),c}}const Ao="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ";var mo=r(6763);const fo=new WeakMap;let go,_o=0;class KTX2Loader extends Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&mo.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return!0===e.isWebGPURenderer?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new three_module_FileLoader(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),r=new three_module_FileLoader(this.manager);r.setPath(this.transcoderPath),r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials);const s=r.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then((([e,t])=>{const r=KTX2Loader.BasisWorker.toString(),s=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([s])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),_o>0&&mo.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),_o++}return this.transcoderPending}load(e,t,r,s){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const o=new three_module_FileLoader(this.manager);o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials),o.load(e,(e=>{if(fo.has(e)){return fo.get(e).promise.then(t).catch(s)}this._createTexture(e).then((e=>t?t(e):null)).catch(s)}),r,s)}_createTextureFrom(e,t){const{faces:r,width:s,height:o,format:l,type:c,error:h,dfdFlags:d}=e;if("error"===c)return Promise.reject(h);let p;if(6===t.faceCount)p=new CompressedCubeTexture(r,l,ye);else{const e=r[0].mipmaps;p=t.layerCount>1?new CompressedArrayTexture(e,s,o,t.layerCount,l,ye):new CompressedTexture(e,s,o,l,ye)}return p.minFilter=1===r[0].mipmaps.length?ge:ve,p.magFilter=ge,p.generateMipmaps=!1,p.needsUpdate=!0,p.colorSpace=parseColorSpace(t),p.premultiplyAlpha=!!(1&d),p}async _createTexture(e,t={}){const r=function Pi(e){const t=new Uint8Array(e.buffer,e.byteOffset,oo.length);if(t[0]!==oo[0]||t[1]!==oo[1]||t[2]!==oo[2]||t[3]!==oo[3]||t[4]!==oo[4]||t[5]!==oo[5]||t[6]!==oo[6]||t[7]!==oo[7]||t[8]!==oo[8]||t[9]!==oo[9]||t[10]!==oo[10]||t[11]!==oo[11])throw new Error("Missing KTX 2.0 identifier.");const r=new Si,s=17*Uint32Array.BYTES_PER_ELEMENT,o=new Ii(e,oo.length,s,!0);r.vkFormat=o._nextUint32(),r.typeSize=o._nextUint32(),r.pixelWidth=o._nextUint32(),r.pixelHeight=o._nextUint32(),r.pixelDepth=o._nextUint32(),r.layerCount=o._nextUint32(),r.faceCount=o._nextUint32();const l=o._nextUint32();r.supercompressionScheme=o._nextUint32();const c=o._nextUint32(),h=o._nextUint32(),d=o._nextUint32(),p=o._nextUint32(),A=o._nextUint64(),m=o._nextUint64(),f=new Ii(e,oo.length+s,3*l*8,!0);for(let t=0;t<l;t++)r.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});const g=new Ii(e,c,h,!0),_={vendorId:g._skip(4)._nextUint16(),descriptorType:g._nextUint16(),versionNumber:g._nextUint16(),descriptorBlockSize:g._nextUint16(),colorModel:g._nextUint8(),colorPrimaries:g._nextUint8(),transferFunction:g._nextUint8(),flags:g._nextUint8(),texelBlockDimension:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],bytesPlane:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],samples:[]},y=(_.descriptorBlockSize/4-6)/4;for(let e=0;e<y;e++){const t={bitOffset:g._nextUint16(),bitLength:g._nextUint8(),channelType:g._nextUint8(),samplePosition:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&t.channelType?(t.sampleLower=g._nextInt32(),t.sampleUpper=g._nextInt32()):(t.sampleLower=g._nextUint32(),t.sampleUpper=g._nextUint32()),_.samples[e]=t}r.dataFormatDescriptor.length=0,r.dataFormatDescriptor.push(_);const x=new Ii(e,d,p,!0);for(;x._offset<p;){const e=x._nextUint32(),t=x._scan(e),s=Ei(t),o=x._scan(e-t.byteLength);r.keyValue[s]=s.match(/^ktx/i)?Ei(o):o,x._offset%4&&x._skip(4-x._offset%4)}if(m<=0)return r;const S=new Ii(e,A,m,!0),C=S._nextUint16(),b=S._nextUint16(),I=S._nextUint32(),T=S._nextUint32(),B=S._nextUint32(),U=S._nextUint32(),F=[];for(let e=0;e<l;e++)F.push({imageFlags:S._nextUint32(),rgbSliceByteOffset:S._nextUint32(),rgbSliceByteLength:S._nextUint32(),alphaSliceByteOffset:S._nextUint32(),alphaSliceByteLength:S._nextUint32()});const O=A+S._offset,Q=O+I,G=Q+T,W=G+B,q=new Uint8Array(e.buffer,e.byteOffset+O,I),j=new Uint8Array(e.buffer,e.byteOffset+Q,T),X=new Uint8Array(e.buffer,e.byteOffset+G,B),Y=new Uint8Array(e.buffer,e.byteOffset+W,U);return r.globalData={endpointCount:C,selectorCount:b,imageDescs:F,endpointsData:q,selectorsData:j,tablesData:X,extendedData:Y},r}(new Uint8Array(e));if(0!==r.vkFormat)return async function createRawTexture(e){const{vkFormat:t}=e;if(void 0===yo[t])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let r;2===e.supercompressionScheme&&(go||(go=new Promise((async e=>{const t=new zstddec_module_Q;await t.init(),e(t)}))),r=await go);const s=[];for(let o=0;o<e.levels.length;o++){const l=Math.max(1,e.pixelWidth>>o),c=Math.max(1,e.pixelHeight>>o),h=e.pixelDepth?Math.max(1,e.pixelDepth>>o):0,d=e.levels[o];let p,A;if(0===e.supercompressionScheme)p=d.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");p=r.decode(d.levelData,d.uncompressedByteLength)}A=Eo[t]===Me?new Float32Array(p.buffer,p.byteOffset,p.byteLength/Float32Array.BYTES_PER_ELEMENT):Eo[t]===Ce?new Uint16Array(p.buffer,p.byteOffset,p.byteLength/Uint16Array.BYTES_PER_ELEMENT):p,s.push({data:A,width:l,height:c,depth:h})}let o;if(vo.has(yo[t]))o=0===e.pixelDepth?new DataTexture(s[0].data,e.pixelWidth,e.pixelHeight):new Data3DTexture(s[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth);else{if(e.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");o=new CompressedTexture(s,e.pixelWidth,e.pixelHeight)}return o.mipmaps=s,o.type=Eo[t],o.format=yo[t],o.colorSpace=parseColorSpace(e),o.needsUpdate=!0,Promise.resolve(o)}(r);const s=t,o=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:s},[e]))).then((e=>this._createTextureFrom(e.data,r)));return fo.set(e,{promise:o}),o}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),_o--,this}}KTX2Loader.BasisFormat={ETC1S:0,UASTC_4x4:1},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},KTX2Loader.EngineFormat={RGBAFormat:we,RGBA_ASTC_4x4_Format:Ge,RGBA_BPTC_Format:He,RGBA_ETC2_EAC_Format:ke,RGBA_PVRTC_4BPPV1_Format:Ne,RGBA_S3TC_DXT5_Format:Pe,RGB_ETC1_Format:Oe,RGB_ETC2_Format:Qe,RGB_PVRTC_4BPPV1_Format:Fe,RGB_S3TC_DXT1_Format:Le},KTX2Loader.BasisWorker=function(){let e,t,r;const s=_EngineFormat,o=_TranscoderFormat,l=_BasisFormat;self.addEventListener("message",(function(c){const p=c.data;switch(p.type){case"init":e=p.config,function init(e){t=new Promise((t=>{r={wasmBinary:e,onRuntimeInitialized:t},BASIS(r)})).then((()=>{r.initializeBasis(),void 0===r.KTX2File&&mo.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}))}(p.transcoderBinary);break;case"transcode":t.then((()=>{try{const{faces:t,buffers:c,width:A,height:m,hasAlpha:f,format:g,dfdFlags:_}=function transcode(t){const c=new r.KTX2File(new Uint8Array(t));function cleanup(){c.close(),c.delete()}if(!c.isValid())throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const p=c.isUASTC()?l.UASTC_4x4:l.ETC1S,A=c.getWidth(),m=c.getHeight(),f=c.getLayers()||1,g=c.getLevels(),_=c.getFaces(),y=c.getHasAlpha(),x=c.getDFDFlags(),{transcoderFormat:S,engineFormat:C}=function getTranscoderFormat(t,r,c,p){let A,m;const f=t===l.ETC1S?h:d;for(let s=0;s<f.length;s++){const o=f[s];if(e[o.if]&&(o.basisFormat.includes(t)&&!(p&&o.transcoderFormat.length<2)&&(!o.needsPowerOfTwo||isPowerOfTwo(r)&&isPowerOfTwo(c))))return A=o.transcoderFormat[p?1:0],m=o.engineFormat[p?1:0],{transcoderFormat:A,engineFormat:m}}return mo.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),A=o.RGBA32,m=s.RGBAFormat,{transcoderFormat:A,engineFormat:m}}(p,A,m,y);if(!A||!m||!g)throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!c.startTranscoding())throw cleanup(),new Error("THREE.KTX2Loader: .startTranscoding failed");const b=[],I=[];for(let e=0;e<_;e++){const t=[];for(let r=0;r<g;r++){const s=[];let o,l;for(let t=0;t<f;t++){const h=c.getImageLevelInfo(r,t,e);0!==e||0!==r||0!==t||h.origWidth%4==0&&h.origHeight%4==0||mo.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),g>1?(o=h.origWidth,l=h.origHeight):(o=h.width,l=h.height);const d=new Uint8Array(c.getImageTranscodedSizeInBytes(r,t,0,S));if(!c.transcodeImage(d,r,t,e,S,0,-1,-1))throw cleanup(),new Error("THREE.KTX2Loader: .transcodeImage failed.");s.push(d)}const h=concat(s);t.push({data:h,width:o,height:l}),I.push(h.buffer)}b.push({mipmaps:t,width:A,height:m,format:C})}return cleanup(),{faces:b,buffers:I,width:A,height:m,hasAlpha:y,format:C,dfdFlags:x}}(p.buffer);self.postMessage({type:"transcode",id:p.id,faces:t,width:A,height:m,hasAlpha:f,format:g,dfdFlags:_},c)}catch(e){mo.error(e),self.postMessage({type:"error",id:p.id,error:e.message})}}))}}));const c=[{if:"astcSupported",basisFormat:[l.UASTC_4x4],transcoderFormat:[o.ASTC_4x4,o.ASTC_4x4],engineFormat:[s.RGBA_ASTC_4x4_Format,s.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.BC7_M5,o.BC7_M5],engineFormat:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.BC1,o.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.ETC1,o.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.ETC1],engineFormat:[s.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.PVRTC1_4_RGB,o.PVRTC1_4_RGBA],engineFormat:[s.RGB_PVRTC_4BPPV1_Format,s.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],h=c.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),d=c.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function isPowerOfTwo(e){return e<=2||!(e&e-1)&&0!==e}function concat(e){if(1===e.length)return e[0];let t=0;for(let r=0;r<e.length;r++){t+=e[r].byteLength}const r=new Uint8Array(t);let s=0;for(let t=0;t<e.length;t++){const o=e[t];r.set(o,s),s+=o.byteLength}return r}};const vo=new Set([we,Re,Be]),yo={[ro]:we,[to]:we,[Ja]:we,[$a]:we,[no]:Re,[eo]:Re,[Ya]:Re,[Ka]:Re,[io]:Be,[Za]:Be,[Xa]:Be,[ja]:Be,[ao]:Ve,[so]:Ve},Eo={[ro]:Me,[to]:Ce,[Ja]:ye,[$a]:ye,[no]:Me,[eo]:Ce,[Ya]:ye,[Ka]:ye,[io]:Me,[Za]:Ce,[Xa]:ye,[ja]:ye,[ao]:ye,[so]:ye};function parseColorSpace(e){const t=e.dataFormatDescriptor[0];return t.colorPrimaries===Wa?t.transferFunction===Ha?tt:it:t.colorPrimaries===qa?t.transferFunction===Ha?nt:rt:(t.colorPrimaries===za||mo.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),et)}var xo,So;const Mo=Symbol("retainerCount"),Co=Symbol("recentlyUsed"),bo=Symbol("evict"),wo=Symbol("evictionThreshold"),Io=Symbol("cache");class CacheEvictionPolicy{constructor(e,t=5){this[xo]=new Map,this[So]=[],this[Io]=e,this[wo]=t}set evictionThreshold(e){this[wo]=e,this[bo]()}get evictionThreshold(){return this[wo]}get cache(){return this[Io]}retainerCount(e){return this[Mo].get(e)||0}reset(){this[Mo].clear(),this[Co]=[]}retain(e){this[Mo].has(e)||this[Mo].set(e,0),this[Mo].set(e,this[Mo].get(e)+1);const t=this[Co].indexOf(e);-1!==t&&this[Co].splice(t,1),this[Co].unshift(e),this[bo]()}release(e){this[Mo].has(e)&&this[Mo].set(e,Math.max(this[Mo].get(e)-1,0)),this[bo]()}[(xo=Mo,So=Co,bo)](){if(!(this[Co].length<this[wo]))for(let e=this[Co].length-1;e>=this[wo];--e){const t=this[Co][e];0===this[Mo].get(t)&&(this[Io].delete(t),this[Co].splice(e,1))}}}const mappingsArrayToTable=e=>{const t=new Map;for(const r of e.mappings)for(const e of r.variants)t.set(e,{material:null,gltfMaterialIndex:r.material});return t};class GLTFMaterialsVariantsExtension{constructor(e){this.parser=e,this.name="KHR_materials_variants"}afterRoot(e){const t=this.parser,r=t.json;if(void 0===r.extensions||void 0===r.extensions[this.name])return null;const s=(e=>{const t=[],r=new Set;for(const s of e){let e=s,o=0;for(;r.has(e);)e=s+"."+ ++o;r.add(e),t.push(e)}return t})((r.extensions[this.name].variants||[]).map((e=>e.name)));for(const s of e.scenes)s.traverse((e=>{const s=e;if(!s.material)return;const o=t.associations.get(s);if(null==o||null==o.meshes||null==o.primitives)return;const l=r.meshes[o.meshes].primitives[o.primitives].extensions;l&&l[this.name]&&(s.userData.variantMaterials=mappingsArrayToTable(l[this.name]))}));return e.userData.variants=s,Promise.resolve()}}var To,Bo,Ro=r(6763);Texture.DEFAULT_ANISOTROPY=4;const Lo=new Map,Do=new Map;let Uo;const Po=new class DRACOLoader extends Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,s){const o=new three_module_FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(e=>{this.parse(e,t,s)}),r,s)}parse(e,t,r=()=>{}){this.decodeDracoFile(e,t,null,null,tt).catch(r)}decodeDracoFile(e,t,r,s,o=it,l=()=>{}){const c={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:o};return this.decodeGeometry(e,c).then(t).catch(l)}decodeGeometry(e,t){const r=JSON.stringify(t);if(xa.has(e)){const t=xa.get(e);if(t.key===r)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const o=this.workerNextTaskID++,l=e.byteLength,c=this._getWorker(o,l).then((r=>(s=r,new Promise(((r,l)=>{s._callbacks[o]={resolve:r,reject:l},s.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return c.catch((()=>!0)).then((()=>{s&&o&&this._releaseTask(s,o)})),xa.set(e,{key:r,promise:c}),c}_createGeometry(e){const t=new three_module_BufferGeometry;e.index&&t.setIndex(new three_module_BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r],o=s.name,l=s.array,c=s.itemSize,h=new three_module_BufferAttribute(l,c);"color"===o&&(this._assignVertexColorSpace(h,s.vertexColorSpace),h.normalized=l instanceof Float32Array==!1),t.setAttribute(o,h)}return t}_assignVertexColorSpace(e,t){if(t!==tt)return;const r=new Color;for(let t=0,s=e.count;t<s;t++)r.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,r.r,r.g,r.b)}_loadLibrary(e,t){const r=new three_module_FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise(((t,s)=>{r.load(e,t,void 0,s)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const s=DRACOWorker.toString(),o=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([o]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const r=t.data;switch(r.type){case"decode":e._callbacks[r.id].resolve(r);break;case"error":e._callbacks[r.id].reject(r);break;default:Ea.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){Ea.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}};let Fo;const No=new KTX2Loader;let Oo,Qo;const ko=Symbol("loader"),Go=Symbol("evictionPolicy"),Vo=Symbol("GLTFInstance");class CachingGLTFLoader extends EventDispatcher{constructor(e){super(),this[Bo]=(new GLTFLoader).register((e=>new GLTFMaterialsVariantsExtension(e))),this[Vo]=e,this[ko].setDRACOLoader(Po),this[ko].setKTX2Loader(No)}static setDRACODecoderLocation(e){Uo=e,Po.setDecoderPath(e)}static getDRACODecoderLocation(){return Uo}static setKTX2TranscoderLocation(e){Fo=e,No.setTranscoderPath(e)}static getKTX2TranscoderLocation(){return Fo}static setMeshoptDecoderLocation(e){var t;Oo!==e&&(Oo=e,Qo=(t=e,new Promise(((e,r)=>{const s=document.createElement("script");document.body.appendChild(s),s.onload=e,s.onerror=r,s.async=!0,s.src=t}))).then((()=>MeshoptDecoder.ready)).then((()=>MeshoptDecoder)))}static getMeshoptDecoderLocation(){return Oo}static initializeKTX2Loader(e){No.detectSupport(e)}static get cache(){return Lo}static clearCache(){Lo.forEach(((e,t)=>{this.delete(t)})),this[Go].reset()}static has(e){return Lo.has(e)}static async delete(e){if(!this.has(e))return;const t=Lo.get(e);Do.delete(e),Lo.delete(e);(await t).dispose()}static hasFinishedLoading(e){return!!Do.get(e)}get[(To=Go,Bo=ko,Go)](){return this.constructor[Go]}async preload(e,t,r=()=>{}){if(this[ko].setWithCredentials(CachingGLTFLoader.withCredentials),this.dispatchEvent({type:"preload",element:t,src:e}),!Lo.has(e)){null!=Qo&&this[ko].setMeshoptDecoder(await Qo);const t=((e,t,r=()=>{})=>{const onProgress=e=>{const t=e.loaded/e.total;r(Math.max(0,Math.min(1,isFinite(t)?t:1)))};return new Promise(((r,s)=>{t.load(e,r,onProgress,s)}))})(e,this[ko],(e=>{r(.8*e)})),s=this[Vo],o=t.then((e=>s.prepare(e))).then((e=>(r(.9),new s(e)))).catch((e=>(Ro.error(e),new s)));Lo.set(e,o)}await Lo.get(e),Do.set(e,!0),r&&r(1)}async load(e,t,r=()=>{}){await this.preload(e,t,r);const s=await Lo.get(e),o=await s.clone();return this[Go].retain(e),o.dispose=()=>{this[Go].release(e)},o}}CachingGLTFLoader[To]=new CacheEvictionPolicy(CachingGLTFLoader);class CSS2DObject extends Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new Vector2(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const Ho=new three_module_Vector3,zo=new three_module_Matrix4,Wo=new three_module_Matrix4,qo=new three_module_Vector3,jo=new three_module_Vector3;class CSS2DRenderer{constructor(e={}){const t=this;let r,s,o,l;const c={objects:new WeakMap},h=void 0!==e.element?e.element:document.createElement("div");function renderObject(e,r,s){if(e.isCSS2DObject){Ho.setFromMatrixPosition(e.matrixWorld),Ho.applyMatrix4(Wo);const d=!0===e.visible&&Ho.z>=-1&&Ho.z<=1&&!0===e.layers.test(s.layers);if(e.element.style.display=!0===d?"":"none",!0===d){e.onBeforeRender(t,r,s);const c=e.element;c.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(Ho.x*o+o)+"px,"+(-Ho.y*l+l)+"px)",c.parentNode!==h&&h.appendChild(c),e.onAfterRender(t,r,s)}const p={distanceToCameraSquared:getDistanceToSquared(s,e)};c.objects.set(e,p)}for(let t=0,o=e.children.length;t<o;t++)renderObject(e.children[t],r,s)}function getDistanceToSquared(e,t){return qo.setFromMatrixPosition(e.matrixWorld),jo.setFromMatrixPosition(t.matrixWorld),qo.distanceToSquared(jo)}h.style.overflow="hidden",this.domElement=h,this.getSize=function(){return{width:r,height:s}},this.render=function(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),zo.copy(t.matrixWorldInverse),Wo.multiplyMatrices(t.projectionMatrix,zo),renderObject(e,e,t),function zOrder(e){const t=function filterAndFlatten(e){const t=[];return e.traverse((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){if(e.renderOrder!==t.renderOrder)return t.renderOrder-e.renderOrder;return c.objects.get(e).distanceToCameraSquared-c.objects.get(t).distanceToCameraSquared})),r=t.length;for(let e=0,s=t.length;e<s;e++)t[e].element.style.zIndex=r-e}(e)},this.setSize=function(e,t){r=e,s=t,o=r/2,l=s/2,h.style.width=e+"px",h.style.height=t+"px"}}}r(6763);function reduceVertices(e,t,r){let s=r;const o=new three_module_Vector3;return e.updateWorldMatrix(!0,!0),e.traverseVisible((e=>{const{geometry:r}=e;if(void 0!==r){const{position:l}=r.attributes;if(void 0!==l)for(let r=0,c=l.count;r<c;r++)e.isMesh?e.getVertexPosition(r,o):o.fromBufferAttribute(l,r),e.isSkinnedMesh||o.applyMatrix4(e.matrixWorld),s=t(s,o)}})),s}let Xo,Yo,Ko,Jo;function decompress(e,t=1/0,r=null){Yo||(Yo=new PlaneGeometry(2,2,1,1)),Ko||(Ko=new ShaderMaterial({uniforms:{blitTexture:new Uniform(e)},vertexShader:"\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main(){\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = vec4(position.xy * 1.0,0.,.999999);\n\t\t\t}",fragmentShader:"\n\t\t\tuniform sampler2D blitTexture; \n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main(){ \n\t\t\t\tgl_FragColor = vec4(vUv.xy, 0, 1);\n\t\t\t\t\n\t\t\t\t#ifdef IS_SRGB\n\t\t\t\tgl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n\t\t\t\t#else\n\t\t\t\tgl_FragColor = texture2D( blitTexture, vUv);\n\t\t\t\t#endif\n\t\t\t}"})),Ko.uniforms.blitTexture.value=e,Ko.defines.IS_SRGB=e.colorSpace==tt,Ko.needsUpdate=!0,Jo||(Jo=new three_module_Mesh(Yo,Ko),Jo.frustrumCulled=!1);const s=new PerspectiveCamera,o=new Scene;o.add(Jo),null===r&&(r=Xo=new WebGLRenderer({antialias:!1}));const l=Math.min(e.image.width,t),c=Math.min(e.image.height,t);r.setSize(l,c),r.clear(),r.render(o,s);const h=document.createElement("canvas"),d=h.getContext("2d");h.width=l,h.height=c,d.drawImage(r.domElement,0,0,l,c);const p=new CanvasTexture(h);return p.minFilter=e.minFilter,p.magFilter=e.magFilter,p.wrapS=e.wrapS,p.wrapT=e.wrapT,p.name=e.name,Xo&&(Xo.forceContextLoss(),Xo.dispose(),Xo=null),p}var $o=r(6763);const Zo={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class GLTFExporter{constructor(){this.pluginCallbacks=[],this.register((function(e){return new GLTFLightExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsUnlitExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMeshGpuInstancing(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,s){const o=new GLTFWriter,l=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)l.push(this.pluginCallbacks[e](o));o.setPlugins(l),o.write(e,t,s).catch(r)}parseAsync(e,t){const r=this;return new Promise((function(s,o){r.parse(e,s,o,t)}))}}const el=0,tl=1,il=2,nl=3,rl=4,sl=5120,al=5121,ol=5122,ll=5123,cl=5124,hl=5125,ul=5126,dl=34962,pl=34963,Al=9728,ml=9729,fl=9984,gl=9985,_l=9986,vl=9987,yl=33071,El=33648,xl=10497,Sl="KHR_mesh_quantization",Ml={};Ml[Ae]=Al,Ml[1004]=fl,Ml[1005]=_l,Ml[1006]=ml,Ml[1007]=gl,Ml[1008]=vl,Ml[1001]=yl,Ml[1e3]=xl,Ml[1002]=El;const Cl={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},bl=new Color;function equalArray(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function getPaddedBufferSize(e){return 4*Math.ceil(e/4)}function getPaddedArrayBuffer(e,t=0){const r=getPaddedBufferSize(e.byteLength);if(r!==e.byteLength){const s=new Uint8Array(r);if(s.set(new Uint8Array(e)),0!==t)for(let o=e.byteLength;o<r;o++)s[o]=t;return s.buffer}return e}function getCanvas(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function getToBlobPromise(e,t){if(void 0!==e.toBlob)return new Promise((r=>e.toBlob(r,t)));let r;return"image/jpeg"===t?r=.92:"image/webp"===t&&(r=.8),e.convertToBlob({type:t,quality:r})}class GLTFWriter{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,r={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const s=this,o=s.buffers,l=s.json;r=s.options;const c=s.extensionsUsed,h=s.extensionsRequired,d=new Blob(o,{type:"application/octet-stream"}),p=Object.keys(c),A=Object.keys(h);if(p.length>0&&(l.extensionsUsed=p),A.length>0&&(l.extensionsRequired=A),l.buffers&&l.buffers.length>0&&(l.buffers[0].byteLength=d.size),!0===r.binary){const e=new FileReader;e.readAsArrayBuffer(d),e.onloadend=function(){const r=getPaddedArrayBuffer(e.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);const o=getPaddedArrayBuffer(function stringToArrayBuffer(e){return(new TextEncoder).encode(e).buffer}(JSON.stringify(l)),32),c=new DataView(new ArrayBuffer(8));c.setUint32(0,o.byteLength,!0),c.setUint32(4,1313821514,!0);const h=new ArrayBuffer(12),d=new DataView(h);d.setUint32(0,1179937895,!0),d.setUint32(4,2,!0);const p=12+c.byteLength+o.byteLength+s.byteLength+r.byteLength;d.setUint32(8,p,!0);const A=new Blob([h,c,o,s,r],{type:"application/octet-stream"}),m=new FileReader;m.readAsArrayBuffer(A),m.onloadend=function(){t(m.result)}}}else if(l.buffers&&l.buffers.length>0){const e=new FileReader;e.readAsDataURL(d),e.onloadend=function(){const r=e.result;l.buffers[0].uri=r,t(l)}}else t(l)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const r=this.options,s=this.extensionsUsed;try{const o=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&o.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in o.gltfExtensions)t.extensions[e]=o.gltfExtensions[e],s[e]=!0;delete o.gltfExtensions}Object.keys(o).length>0&&(t.extras=o)}catch(t){$o.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new three_module_Vector3;for(let r=0,s=e.count;r<s;r++)if(Math.abs(t.fromBufferAttribute(e,r).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),s=new three_module_Vector3;for(let e=0,t=r.count;e<t;e++)s.fromBufferAttribute(r,e),0===s.x&&0===s.y&&0===s.z?s.setX(1):s.normalize(),r.setXYZ(e,s.x,s.y,s.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1;const s={};0===t.offset.x&&0===t.offset.y||(s.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(s.rotation=t.rotation,r=!0),1===t.repeat.x&&1===t.repeat.y||(s.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function getEncodingConversion(e){return e.colorSpace===tt?function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function LinearToLinear(e){return e}}$o.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof CompressedTexture&&(e=decompress(e)),t instanceof CompressedTexture&&(t=decompress(t));const r=e?e.image:null,s=t?t.image:null,o=Math.max(r?r.width:0,s?s.width:0),l=Math.max(r?r.height:0,s?s.height:0),c=getCanvas();c.width=o,c.height=l;const h=c.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,o,l);const d=h.getImageData(0,0,o,l);if(r){h.drawImage(r,0,0,o,l);const t=getEncodingConversion(e),s=h.getImageData(0,0,o,l).data;for(let e=2;e<s.length;e+=4)d.data[e]=256*t(s[e]/256)}if(s){h.drawImage(s,0,0,o,l);const e=getEncodingConversion(t),r=h.getImageData(0,0,o,l).data;for(let t=1;t<r.length;t+=4)d.data[t]=256*e(r[t]/256)}h.putImageData(d,0,0);const p=(e||t).clone();return p.source=new Source(c),p.colorSpace=et,p.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&$o.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),p}processBuffer(e){const t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,s,o){const l=this.json;let c;switch(l.bufferViews||(l.bufferViews=[]),t){case sl:case al:c=1;break;case ol:case ll:c=2;break;default:c=4}const h=getPaddedBufferSize(s*e.itemSize*c),d=new DataView(new ArrayBuffer(h));let p=0;for(let o=r;o<r+s;o++)for(let r=0;r<e.itemSize;r++){let s;e.itemSize>4?s=e.array[o*e.itemSize+r]:(0===r?s=e.getX(o):1===r?s=e.getY(o):2===r?s=e.getZ(o):3===r&&(s=e.getW(o)),!0===e.normalized&&(s=wt.normalize(s,e.array))),t===ul?d.setFloat32(p,s,!0):t===cl?d.setInt32(p,s,!0):t===hl?d.setUint32(p,s,!0):t===ol?d.setInt16(p,s,!0):t===ll?d.setUint16(p,s,!0):t===sl?d.setInt8(p,s):t===al&&d.setUint8(p,s),p+=c}const A={buffer:this.processBuffer(d.buffer),byteOffset:this.byteOffset,byteLength:h};void 0!==o&&(A.target=o),o===dl&&(A.byteStride=e.itemSize*c),this.byteOffset+=h,l.bufferViews.push(A);return{id:l.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise((function(s){const o=new FileReader;o.readAsArrayBuffer(e),o.onloadend=function(){const e=getPaddedArrayBuffer(o.result),l={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,s(r.bufferViews.push(l)-1)}}))}processAccessor(e,t,r,s){const o=this.json;let l;if(e.array.constructor===Float32Array)l=ul;else if(e.array.constructor===Int32Array)l=cl;else if(e.array.constructor===Uint32Array)l=hl;else if(e.array.constructor===Int16Array)l=ol;else if(e.array.constructor===Uint16Array)l=ll;else if(e.array.constructor===Int8Array)l=sl;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);l=al}if(void 0===r&&(r=0),void 0!==s&&s!==1/0||(s=e.count),0===s)return null;const c=function getMinMax(e,t,r){const s={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let o=t;o<t+r;o++)for(let t=0;t<e.itemSize;t++){let r;e.itemSize>4?r=e.array[o*e.itemSize+t]:(0===t?r=e.getX(o):1===t?r=e.getY(o):2===t?r=e.getZ(o):3===t&&(r=e.getW(o)),!0===e.normalized&&(r=wt.normalize(r,e.array))),s.min[t]=Math.min(s.min[t],r),s.max[t]=Math.max(s.max[t],r)}return s}(e,r,s);let h;void 0!==t&&(h=e===t.index?pl:dl);const d=this.processBufferView(e,l,r,s,h),p={bufferView:d.id,byteOffset:d.byteOffset,componentType:l,count:s,max:c.max,min:c.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(p.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(p)-1}processImage(e,t,r,s="image/png"){if(null!==e){const o=this,l=o.cache,c=o.json,h=o.options,d=o.pending;l.images.has(e)||l.images.set(e,{});const p=l.images.get(e),A=s+":flipY/"+r.toString();if(void 0!==p[A])return p[A];c.images||(c.images=[]);const m={mimeType:s},f=getCanvas();f.width=Math.min(e.width,h.maxTextureSize),f.height=Math.min(e.height,h.maxTextureSize);const g=f.getContext("2d");if(!0===r&&(g.translate(0,f.height),g.scale(1,-1)),void 0!==e.data){t!==we&&$o.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>h.maxTextureSize||e.height>h.maxTextureSize)&&$o.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const r=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<r.length;t+=4)r[t+0]=e.data[t+0],r[t+1]=e.data[t+1],r[t+2]=e.data[t+2],r[t+3]=e.data[t+3];g.putImageData(new ImageData(r,e.width,e.height),0,0)}else g.drawImage(e,0,0,f.width,f.height);!0===h.binary?d.push(getToBlobPromise(f,s).then((e=>o.processBufferViewImage(e))).then((e=>{m.bufferView=e}))):void 0!==f.toDataURL?m.uri=f.toDataURL(s):d.push(getToBlobPromise(f,s).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{m.uri=e})));const _=c.images.push(m)-1;return p[A]=_,_}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const r={magFilter:Ml[e.magFilter],minFilter:Ml[e.minFilter],wrapS:Ml[e.wrapS],wrapT:Ml[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){const t=this.options,r=this.cache,s=this.json;if(r.textures.has(e))return r.textures.get(e);s.textures||(s.textures=[]),e instanceof CompressedTexture&&(e=decompress(e,t.maxTextureSize));let o=e.userData.mimeType;"image/webp"===o&&(o="image/png");const l={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,o)};e.name&&(l.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,l)}));const c=s.textures.push(l)-1;return r.textures.set(e,c),c}processMaterial(e){const t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return $o.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);const s={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&$o.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const o=e.color.toArray().concat([e.opacity]);if(equalArray(o,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),r={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(r,t),s.pbrMetallicRoughness.metallicRoughnessTexture=r}if(e.map){const t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),s.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),s.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),s.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),s.occlusionTexture=t}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===m&&(s.doubleSided=!0),""!==e.name&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,s)}));const l=r.materials.push(s)-1;return t.materials.set(e,l),l}processMesh(e){const t=this.cache,r=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,r=e.material.length;t<r;t++)s.push(e.material[t].uuid);else s.push(e.material.uuid);const o=s.join(":");if(t.meshes.has(o))return t.meshes.get(o);const l=e.geometry;let c;c=e.isLineSegments?tl:e.isLineLoop?il:e.isLine?nl:e.isPoints?el:e.material.wireframe?tl:rl;const h={},d={},p=[],A=[],m={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=l.getAttribute("normal");void 0===f||this.isNormalizedNormalAttribute(f)||($o.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),l.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let g=null;for(let e in l.attributes){if("morph"===e.slice(0,5))continue;const r=l.attributes[e];e=m[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(r))){d[e]=t.attributes.get(this.getUID(r));continue}g=null;const s=r.array;"JOINTS_0"!==e||s instanceof Uint16Array||s instanceof Uint8Array||($o.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),g=new three_module_BufferAttribute(new Uint16Array(s),r.itemSize,r.normalized));const o=this.processAccessor(g||r,l);null!==o&&(e.startsWith("_")||this.detectMeshQuantization(e,r),d[e]=o,t.attributes.set(this.getUID(r),o))}if(void 0!==f&&l.setAttribute("normal",f),0===Object.keys(d).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const r=[],s=[],o={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)o[e.morphTargetDictionary[t]]=t;for(let c=0;c<e.morphTargetInfluences.length;++c){const h={};let d=!1;for(const e in l.morphAttributes){if("position"!==e&&"normal"!==e){d||($o.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),d=!0);continue}const r=l.morphAttributes[e][c],s=e.toUpperCase(),o=l.attributes[e];if(t.attributes.has(this.getUID(r,!0))){h[s]=t.attributes.get(this.getUID(r,!0));continue}const p=r.clone();if(!l.morphTargetsRelative)for(let e=0,t=r.count;e<t;e++)for(let t=0;t<r.itemSize;t++)0===t&&p.setX(e,r.getX(e)-o.getX(e)),1===t&&p.setY(e,r.getY(e)-o.getY(e)),2===t&&p.setZ(e,r.getZ(e)-o.getZ(e)),3===t&&p.setW(e,r.getW(e)-o.getW(e));h[s]=this.processAccessor(p,l),t.attributes.set(this.getUID(o,!0),h[s])}A.push(h),r.push(e.morphTargetInfluences[c]),void 0!==e.morphTargetDictionary&&s.push(o[c])}h.weights=r,s.length>0&&(h.extras={},h.extras.targetNames=s)}const _=Array.isArray(e.material);if(_&&0===l.groups.length)return null;let y=!1;if(_&&null===l.index){const e=[];for(let t=0,r=l.attributes.position.count;t<r;t++)e[t]=t;l.setIndex(e),y=!0}const x=_?e.material:[e.material],S=_?l.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=S.length;e<r;e++){const r={mode:c,attributes:d};if(this.serializeUserData(l,r),A.length>0&&(r.targets=A),null!==l.index){let s=this.getUID(l.index);void 0===S[e].start&&void 0===S[e].count||(s+=":"+S[e].start+":"+S[e].count),t.attributes.has(s)?r.indices=t.attributes.get(s):(r.indices=this.processAccessor(l.index,l,S[e].start,S[e].count),t.attributes.set(s,r.indices)),null===r.indices&&delete r.indices}const s=this.processMaterial(x[S[e].materialIndex]);null!==s&&(r.material=s),p.push(r)}!0===y&&l.setIndex(null),h.primitives=p,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,h)}));const C=r.meshes.push(h)-1;return t.meshes.set(o,C),C}detectMeshQuantization(e,t){if(this.extensionsUsed[Sl])return;let r;switch(t.array.constructor){case Int8Array:r="byte";break;case Uint8Array:r="unsigned byte";break;case Int16Array:r="short";break;case Uint16Array:r="unsigned short";break;default:return}t.normalized&&(r+=" normalized");const s=e.split("_",1)[0];Zo[s]&&Zo[s].includes(r)&&(this.extensionsUsed[Sl]=!0,this.extensionsRequired[Sl]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const r=e.isOrthographicCamera,s={type:r?"orthographic":"perspective"};return r?s.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:wt.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){const r=this.json,s=this.nodeMap;r.animations||(r.animations=[]);const o=(e=GLTFExporter.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,l=[],c=[];for(let e=0;e<o.length;++e){const r=o[e],h=PropertyBinding.parseTrackName(r.name);let d=PropertyBinding.findNode(t,h.nodeName);const p=Cl[h.propertyName];if("bones"===h.objectName&&(d=!0===d.isSkinnedMesh?d.skeleton.getBoneByName(h.objectIndex):void 0),!d||!p)return $o.warn('THREE.GLTFExporter: Could not export animation track "%s".',r.name),null;const A=1;let m,f=r.values.length/r.times.length;p===Cl.morphTargetInfluences&&(f/=d.morphTargetInfluences.length),!0===r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(m="CUBICSPLINE",f/=3):m=r.getInterpolation()===qe?"STEP":"LINEAR",c.push({input:this.processAccessor(new three_module_BufferAttribute(r.times,A)),output:this.processAccessor(new three_module_BufferAttribute(r.values,f)),interpolation:m}),l.push({sampler:c.length-1,target:{node:s.get(d),path:p}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:c,channels:l}),r.animations.length-1}processSkin(e){const t=this.json,r=this.nodeMap,s=t.nodes[r.get(e)],o=e.skeleton;if(void 0===o)return null;const l=e.skeleton.bones[0];if(void 0===l)return null;const c=[],h=new Float32Array(16*o.bones.length),d=new three_module_Matrix4;for(let t=0;t<o.bones.length;++t)c.push(r.get(o.bones[t])),d.copy(o.boneInverses[t]),d.multiply(e.bindMatrix).toArray(h,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new three_module_BufferAttribute(h,16)),joints:c,skeleton:r.get(l)});return s.skin=t.skins.length-1}processNode(e){const t=this.json,r=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);const o={};if(r.trs){const t=e.quaternion.toArray(),r=e.position.toArray(),s=e.scale.toArray();equalArray(t,[0,0,0,1])||(o.rotation=t),equalArray(r,[0,0,0])||(o.translation=r),equalArray(s,[1,1,1])||(o.scale=s)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===function isIdentityMatrix(e){return equalArray(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}(e.matrix)&&(o.matrix=e.matrix.elements);if(""!==e.name&&(o.name=String(e.name)),this.serializeUserData(e,o),e.isMesh||e.isLine||e.isPoints){const t=this.processMesh(e);null!==t&&(o.mesh=t)}else e.isCamera&&(o.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let s=0,o=e.children.length;s<o;s++){const o=e.children[s];if(o.visible||!1===r.onlyVisible){const e=this.processNode(o);null!==e&&t.push(e)}}t.length>0&&(o.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,o)}));const l=t.nodes.push(o)-1;return s.set(e,l),l}processScene(e){const t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={};""!==e.name&&(s.name=e.name),t.scenes.push(s);const o=[];for(let t=0,s=e.children.length;t<s;t++){const s=e.children[t];if(s.visible||!1===r.onlyVisible){const e=this.processNode(s);null!==e&&o.push(e)}}o.length>0&&(s.nodes=o),this.serializeUserData(e,s)}processObjects(e){const t=new Scene;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const r=[];for(let t=0;t<e.length;t++)e[t]instanceof Scene?this.processScene(e[t]):r.push(e[t]);r.length>0&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class GLTFLightExtension{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void $o.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const r=this.writer,s=r.json,o=r.extensionsUsed,l={};e.name&&(l.name=e.name),l.color=e.color.toArray(),l.intensity=e.intensity,e.isDirectionalLight?l.type="directional":e.isPointLight?(l.type="point",e.distance>0&&(l.range=e.distance)):e.isSpotLight&&(l.type="spot",e.distance>0&&(l.range=e.distance),l.spot={},l.spot.innerConeAngle=(1-e.penumbra)*e.angle,l.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&$o.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||$o.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),o[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},o[this.name]=!0);const c=s.extensions[this.name].lights;c.push(l),t.extensions=t.extensions||{},t.extensions[this.name]={light:c.length-1}}}class GLTFExporter_GLTFMaterialsUnlitExtension{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class GLTFExporter_GLTFMaterialsClearcoatExtension{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:r.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};r.applyTextureTransform(t,e.clearcoatMap),o.clearcoatTexture=t}if(o.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:r.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};r.applyTextureTransform(t,e.clearcoatRoughnessMap),o.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:r.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};r.applyTextureTransform(t,e.clearcoatNormalMap),o.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsIridescenceExtension{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:r.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};r.applyTextureTransform(t,e.iridescenceMap),o.iridescenceTexture=t}if(o.iridescenceIor=e.iridescenceIOR,o.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],o.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:r.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};r.applyTextureTransform(t,e.iridescenceThicknessMap),o.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsTransmissionExtension{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.transmissionFactor=e.transmission,e.transmissionMap){const t={index:r.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};r.applyTextureTransform(t,e.transmissionMap),o.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsVolumeExtension{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.thicknessFactor=e.thickness,e.thicknessMap){const t={index:r.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};r.applyTextureTransform(t,e.thicknessMap),o.thicknessTexture=t}o.attenuationDistance=e.attenuationDistance,o.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsIorExtension{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const r=this.writer.extensionsUsed,s={};s.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}}class GLTFExporter_GLTFMaterialsSpecularExtension{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(bl)&&!e.specularIntensityMap&&!e.specularColorMap)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.specularIntensityMap){const t={index:r.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};r.applyTextureTransform(t,e.specularIntensityMap),o.specularTexture=t}if(e.specularColorMap){const t={index:r.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};r.applyTextureTransform(t,e.specularColorMap),o.specularColorTexture=t}o.specularFactor=e.specularIntensity,o.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsSheenExtension{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.sheenRoughnessMap){const t={index:r.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};r.applyTextureTransform(t,e.sheenRoughnessMap),o.sheenRoughnessTexture=t}if(e.sheenColorMap){const t={index:r.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};r.applyTextureTransform(t,e.sheenColorMap),o.sheenColorTexture=t}o.sheenRoughnessFactor=e.sheenRoughness,o.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsAnisotropyExtension{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.anisotropyMap){const t={index:r.processTexture(e.anisotropyMap)};r.applyTextureTransform(t,e.anisotropyMap),o.anisotropyTexture=t}o.anisotropyStrength=e.anisotropy,o.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;const r=this.writer.extensionsUsed,s={};s.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}}class GLTFExporter_GLTFMaterialsBumpExtension{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.bumpMap){const t={index:r.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};r.applyTextureTransform(t,e.bumpMap),o.bumpTexture=t}o.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMeshGpuInstancing{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const r=this.writer,s=e,o=new Float32Array(3*s.count),l=new Float32Array(4*s.count),c=new Float32Array(3*s.count),h=new three_module_Matrix4,d=new three_module_Vector3,p=new three_module_Quaternion,A=new three_module_Vector3;for(let e=0;e<s.count;e++)s.getMatrixAt(e,h),h.decompose(d,p,A),d.toArray(o,3*e),p.toArray(l,4*e),A.toArray(c,3*e);const m={TRANSLATION:r.processAccessor(new three_module_BufferAttribute(o,3)),ROTATION:r.processAccessor(new three_module_BufferAttribute(l,4)),SCALE:r.processAccessor(new three_module_BufferAttribute(c,3))};s.instanceColor&&(m._COLOR_0=r.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:m},r.extensionsUsed[this.name]=!0,r.extensionsRequired[this.name]=!0}}GLTFExporter.Utils={insertKeyframe:function(e,t){const r=.001,s=e.getValueSize(),o=new e.TimeBufferType(e.times.length+1),l=new e.ValueBufferType(e.values.length+s),c=e.createInterpolant(new e.ValueBufferType(s));let h;if(0===e.times.length){o[0]=t;for(let e=0;e<s;e++)l[e]=0;h=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<r)return 0;o[0]=t,o.set(e.times,1),l.set(c.evaluate(t),0),l.set(e.values,s),h=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<r)return e.times.length-1;o[o.length-1]=t,o.set(e.times,0),l.set(e.values,0),l.set(c.evaluate(t),e.values.length),h=o.length-1}else for(let d=0;d<e.times.length;d++){if(Math.abs(e.times[d]-t)<r)return d;if(e.times[d]<t&&e.times[d+1]>t){o.set(e.times.slice(0,d+1),0),o[d+1]=t,o.set(e.times.slice(d+1),d+2),l.set(e.values.slice(0,(d+1)*s),0),l.set(c.evaluate(t),(d+1)*s),l.set(e.values.slice((d+1)*s),(d+2)*s),h=d+1;break}}return e.times=o,e.values=l,h},mergeMorphTargetTracks:function(e,t){const r=[],s={},o=e.tracks;for(let e=0;e<o.length;++e){let l=o[e];const c=PropertyBinding.parseTrackName(l.name),h=PropertyBinding.findNode(t,c.nodeName);if("morphTargetInfluences"!==c.propertyName||void 0===c.propertyIndex){r.push(l);continue}if(l.createInterpolant!==l.InterpolantFactoryMethodDiscrete&&l.createInterpolant!==l.InterpolantFactoryMethodLinear){if(l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");$o.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),l=l.clone(),l.setInterpolation(je)}const d=h.morphTargetInfluences.length,p=h.morphTargetDictionary[c.propertyIndex];if(void 0===p)throw new Error("THREE.GLTFExporter: Morph target name not found: "+c.propertyIndex);let A;if(void 0===s[h.uuid]){A=l.clone();const e=new A.ValueBufferType(d*A.times.length);for(let t=0;t<A.times.length;t++)e[t*d+p]=A.values[t];A.name=(c.nodeName||"")+".morphTargetInfluences",A.values=e,s[h.uuid]=A,r.push(A);continue}const m=l.createInterpolant(new l.ValueBufferType(1));A=s[h.uuid];for(let e=0;e<A.times.length;e++)A.values[e*d+p]=m.evaluate(A.times[e]);for(let e=0;e<l.times.length;e++){const t=this.insertKeyframe(A,l.times[e]);A.values[t*d+p]=l.values[e]}}return e.tracks=r,e}};const compatibleObject=e=>void 0!==e.material&&e.userData&&e.userData.variantMaterials&&!!Array.from(e.userData.variantMaterials.values()).filter((e=>compatibleMaterial(e.material))),compatibleMaterial=e=>e&&e.isMaterial&&!Array.isArray(e);class GLTFExporterMaterialsVariantsExtension{constructor(e){this.writer=e,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(e){const t=new Set;for(const r of e)r.traverse((e=>{if(!compatibleObject(e))return;const r=e.userData.variantMaterials,s=e.userData.variantData;for(const[e,o]of s){const s=r.get(o.index);s&&compatibleMaterial(s.material)&&t.add(e)}}));t.forEach((e=>this.variantNames.push(e)))}writeMesh(e,t){if(!compatibleObject(e))return;const r=e.userData,s=r.variantMaterials,o=r.variantData,l=new Map,c=new Map,h=Array.from(o.values()).sort(((e,t)=>e.index-t.index));for(const[e,t]of h.entries())c.set(t.index,e);for(const e of o.values()){const t=s.get(e.index);if(!t||!compatibleMaterial(t.material))continue;const r=this.writer.processMaterial(t.material);l.has(r)||l.set(r,{material:r,variants:[]}),l.get(r).variants.push(c.get(e.index))}const d=Array.from(l.values()).map((e=>e.variants.sort(((e,t)=>e-t))&&e)).sort(((e,t)=>e.material-t.material));if(0===d.length)return;const p=compatibleMaterial(r.originalMaterial)?this.writer.processMaterial(r.originalMaterial):-1;for(const e of t.primitives)p>=0&&(e.material=p),e.extensions=e.extensions||{},e.extensions[this.name]={mappings:d}}afterParse(){if(0===this.variantNames.length)return;const e=this.writer.json;e.extensions=e.extensions||{};const t=this.variantNames.map((e=>({name:e})));e.extensions[this.name]={variants:t},this.writer.extensionsUsed[this.name]=!0}}class SessionLightProbe{constructor(e,t,r,s,o){this.xrLight=e,this.renderer=t,this.lightProbe=r,this.xrWebGLBinding=null,this.estimationStartCallback=o,this.frameCallback=this.onXRFrame.bind(this);const l=t.xr.getSession();if(s&&"XRWebGLBinding"in window){const r=new WebGLCubeRenderTarget(16);e.environment=r.texture;const s=t.getContext();switch(l.preferredReflectionFormat){case"srgba8":s.getExtension("EXT_sRGB");break;case"rgba16f":s.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(l,s),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}l.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const r=t.getLightEstimate(this.lightProbe);if(r){this.xrLight.lightProbe.sh.fromArray(r.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const e=Math.max(1,Math.max(r.primaryLightIntensity.x,Math.max(r.primaryLightIntensity.y,r.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(r.primaryLightIntensity.x/e,r.primaryLightIntensity.y/e,r.primaryLightIntensity.z/e),this.xrLight.directionalLight.intensity=e,this.xrLight.directionalLight.position.copy(r.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class XREstimatedLight extends three_module_Group{constructor(e,t=!0){super(),this.lightProbe=new LightProbe,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new DirectionalLight,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let r=null,s=!1;e.xr.addEventListener("sessionstart",(()=>{const o=e.xr.getSession();"requestLightProbe"in o&&o.requestLightProbe({reflectionFormat:o.preferredReflectionFormat}).then((o=>{r=new SessionLightProbe(this,e,o,t,(()=>{s=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),e.xr.addEventListener("sessionend",(()=>{r&&(r.dispose(),r=null),s&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{r&&(r.dispose(),r=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}class Damper{constructor(e=50){this.velocity=0,this.naturalFrequency=0,this.setDecayTime(e)}setDecayTime(e){this.naturalFrequency=1/Math.max(.001,e)}update(e,t,r,s){const o=2e-4*this.naturalFrequency;if(null==e||0===s)return t;if(e===t&&0===this.velocity)return t;if(r<0)return e;const l=e-t,c=this.velocity+this.naturalFrequency*l,h=l+r*c,d=Math.exp(-this.naturalFrequency*r),p=(c-this.naturalFrequency*h)*d,A=-this.naturalFrequency*(p+c*d);return Math.abs(p)<o*Math.abs(s)&&A*l>=0?(this.velocity=0,t):(this.velocity=p,t+h*d)}}const wl=.2,Il=Math.PI/24,Tl=new Vector2,addCorner=(e,t,r)=>{let s=t>0?r>0?0:-Math.PI/2:r>0?Math.PI/2:Math.PI;for(let o=0;o<=12;++o)e.push(t+.17*Math.cos(s),r+.17*Math.sin(s),0,t+wl*Math.cos(s),r+wl*Math.sin(s),0),s+=Il};class PlacementBox extends three_module_Mesh{constructor(e,t){const r=new three_module_BufferGeometry,s=[],o=[],{size:l,boundingBox:c}=e,h=l.x/2,d=("back"===t?l.y:l.z)/2;addCorner(o,h,d),addCorner(o,-h,d),addCorner(o,-h,-d),addCorner(o,h,-d);const p=o.length/3;for(let e=0;e<p-2;e+=2)s.push(e,e+1,e+3,e,e+3,e+2);const A=p-2;s.push(A,A+1,1,A,1,0),r.setAttribute("position",new three_module_Float32BufferAttribute(o,3)),r.setIndex(s),super(r),this.side=t;const f=this.material;switch(f.side=m,f.transparent=!0,f.opacity=0,this.goalOpacity=0,this.opacityDamper=new Damper,this.hitPlane=new three_module_Mesh(new PlaneGeometry(2*(h+wl),2*(d+wl))),this.hitPlane.visible=!1,this.hitPlane.material.side=m,this.add(this.hitPlane),c.getCenter(this.position),t){case"bottom":this.rotateX(-Math.PI/2),this.shadowHeight=c.min.y,this.position.y=this.shadowHeight;break;case"back":this.shadowHeight=c.min.z,this.position.z=this.shadowHeight}e.target.add(this),this.offsetHeight=0}getHit(e,t,r){Tl.set(t,-r),this.hitPlane.visible=!0;const s=e.positionAndNormalFromPoint(Tl,this.hitPlane);return this.hitPlane.visible=!1,null==s?null:s.position}getExpandedHit(e,t,r){this.hitPlane.scale.set(1e3,1e3,1e3),this.hitPlane.updateMatrixWorld();const s=this.getHit(e,t,r);return this.hitPlane.scale.set(1,1,1),s}set offsetHeight(e){e-=.001,"back"===this.side?this.position.z=this.shadowHeight+e:this.position.y=this.shadowHeight+e}get offsetHeight(){return"back"===this.side?this.position.z-this.shadowHeight:this.position.y-this.shadowHeight}set show(e){this.goalOpacity=e?.75:0}updateOpacity(e){const t=this.material;t.opacity=this.opacityDamper.update(t.opacity,this.goalOpacity,e,1),this.visible=t.opacity>0}dispose(){var e;const{geometry:t,material:r}=this.hitPlane;t.dispose(),r.dispose(),this.geometry.dispose(),this.material.dispose(),null===(e=this.parent)||void 0===e||e.remove(this)}}const numberNode=(e,t)=>({type:"number",number:e,unit:t}),Bl=(()=>{const e={};return t=>{const r=t;if(r in e)return e[r];const s=[];let o=0;for(;t;){if(++o>1e3){t="";break}const e=Rl(t),r=e.nodes[0];if(null==r||0===r.terms.length)break;s.push(r),t=e.remainingInput}return e[r]=s}})(),Rl=(()=>{const e=/^(\-\-|[a-z\u0240-\uffff])/i,t=/^([\*\+\/]|[\-]\s)/i,r=/^[\),]/;return s=>{const o=[];for(;s.length&&(s=s.trim(),!r.test(s));)if("("===s[0]){const{nodes:e,remainingInput:t}=parseFunctionArguments(s);s=t,o.push({type:"function",name:{type:"ident",value:"calc"},arguments:e})}else if(e.test(s)){const e=Ll(s),t=e.nodes[0];if("("===(s=e.remainingInput)[0]){const{nodes:e,remainingInput:r}=parseFunctionArguments(s);o.push({type:"function",name:t,arguments:e}),s=r}else o.push(t)}else if(t.test(s))o.push({type:"operator",value:s[0]}),s=s.slice(1);else{const{nodes:e,remainingInput:t}="#"===s[0]?Ul(s):Dl(s);if(0===e.length)break;o.push(e[0]),s=t}return{nodes:[{type:"expression",terms:o}],remainingInput:s}}})(),Ll=(()=>{const e=/[^a-z0-9_\-\u0240-\uffff]/i;return t=>{const r=t.match(e);return{nodes:[{type:"ident",value:null==r?t:t.substr(0,r.index)}],remainingInput:null==r?"":t.substr(r.index)}}})(),Dl=(()=>{const e=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,t=/^[a-z%]+/i,r=/^(m|mm|cm|rad|deg|[%])$/;return s=>{const o=s.match(e),l=null==o?"0":o[0],c=(s=null==l?s:s.slice(l.length)).match(t);let h=null!=c&&""!==c[0]?c[0]:null;const d=null==c?s:s.slice(h.length);return null==h||r.test(h)||(h=null),{nodes:[{type:"number",number:parseFloat(l)||0,unit:h}],remainingInput:d}}})(),Ul=(()=>{const e=/^[a-f0-9]*/i;return t=>{const r=(t=t.slice(1).trim()).match(e);return{nodes:null==r?[]:[{type:"hex",value:r[0]}],remainingInput:null==r?t:t.slice(r[0].length)}}})(),parseFunctionArguments=e=>{const t=[];for(e=e.slice(1).trim();e.length;){const r=Rl(e);if(t.push(r.nodes[0]),","===(e=r.remainingInput.trim())[0])e=e.slice(1).trim();else if(")"===e[0]){e=e.slice(1);break}}return{nodes:t,remainingInput:e}},Pl=Symbol("visitedTypes");class ASTWalker{constructor(e){this[Pl]=e}walk(e,t){const r=e.slice();for(;r.length;){const e=r.shift();switch(this[Pl].indexOf(e.type)>-1&&t(e),e.type){case"expression":r.unshift(...e.terms);break;case"function":r.unshift(e.name,...e.arguments)}}}}const Fl=Object.freeze({type:"number",number:0,unit:null}),degreesToRadians=(e,t=0)=>{let{number:r,unit:s}=e;if(isFinite(r)){if("rad"===e.unit||null==e.unit)return e}else r=t,s="rad";return{type:"number",number:("deg"===s&&null!=r?r:0)*Math.PI/180,unit:"rad"}},lengthToBaseMeters=(e,t=0)=>{let r,{number:s,unit:o}=e;if(isFinite(s)){if("m"===e.unit)return e}else s=t,o="m";switch(o){default:r=1;break;case"cm":r=.01;break;case"mm":r=.001}return{type:"number",number:r*s,unit:"m"}},Nl=(()=>{const identity=e=>e,e={rad:identity,deg:degreesToRadians,m:identity,mm:lengthToBaseMeters,cm:lengthToBaseMeters};return(t,r=Fl)=>{isFinite(t.number)||(t.number=r.number,t.unit=r.unit);const{unit:s}=t;if(null==s)return t;const o=e[s];return null==o?r:o(t)}})();var Ol,Ql,kl;const Gl=Symbol("evaluate"),Vl=Symbol("lastValue");class Evaluator{constructor(){this[Ol]=null}static evaluatableFor(e,t=Fl){if(e instanceof Evaluator)return e;if("number"===e.type)return"%"===e.unit?new PercentageEvaluator(e,t):e;switch(e.name.value){case"calc":return new CalcEvaluator(e,t);case"env":return new EnvEvaluator(e)}return Fl}static evaluate(e){return e instanceof Evaluator?e.evaluate():e}static isConstant(e){return!(e instanceof Evaluator)||e.isConstant}static applyIntrinsics(e,t){const{basis:r,keywords:s}=t,{auto:o}=s;return r.map(((t,r)=>{const l=null==o[r]?t:o[r];let c=e[r]?e[r]:l;if("ident"===c.type){const e=c.value;e in s&&(c=s[e][r])}return null!=c&&"ident"!==c.type||(c=l),"%"===c.unit?numberNode(c.number/100*t.number,t.unit):(c=Nl(c,t),c.unit!==t.unit?t:c)}))}get isConstant(){return!1}evaluate(){return this.isConstant&&null!=this[Vl]||(this[Vl]=this[Gl]()),this[Vl]}}Ol=Vl;const Hl=Symbol("percentage"),zl=Symbol("basis");class PercentageEvaluator extends Evaluator{constructor(e,t){super(),this[Hl]=e,this[zl]=t}get isConstant(){return!0}[Gl](){return numberNode(this[Hl].number/100*this[zl].number,this[zl].unit)}}const Wl=Symbol("identNode");class EnvEvaluator extends Evaluator{constructor(e){super(),this[Ql]=null;const t=e.arguments.length?e.arguments[0].terms[0]:null;null!=t&&"ident"===t.type&&(this[Wl]=t)}get isConstant(){return!1}[(Ql=Wl,Gl)](){if(null!=this[Wl]&&"window-scroll-y"===this[Wl].value){return{type:"number",number:window.pageYOffset/(Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)-window.innerHeight)||0,unit:null}}return Fl}}const ql=/[\*\/]/,jl=Symbol("evaluator");class CalcEvaluator extends Evaluator{constructor(e,t=Fl){if(super(),this[kl]=null,1!==e.arguments.length)return;const r=e.arguments[0].terms.slice(),s=[];for(;r.length;){const e=r.shift();if(s.length>0){const r=s[s.length-1];if("operator"===r.type&&ql.test(r.value)){const r=s.pop(),o=s.pop();if(null==o)return;s.push(new OperatorEvaluator(r,Evaluator.evaluatableFor(o,t),Evaluator.evaluatableFor(e,t)));continue}}s.push("operator"===e.type?e:Evaluator.evaluatableFor(e,t))}for(;s.length>2;){const[e,r,o]=s.splice(0,3);if("operator"!==r.type)return;s.unshift(new OperatorEvaluator(r,Evaluator.evaluatableFor(e,t),Evaluator.evaluatableFor(o,t)))}1===s.length&&(this[jl]=s[0])}get isConstant(){return null==this[jl]||Evaluator.isConstant(this[jl])}[(kl=jl,Gl)](){return null!=this[jl]?Evaluator.evaluate(this[jl]):Fl}}const Xl=Symbol("operator"),Yl=Symbol("left"),Kl=Symbol("right");class OperatorEvaluator extends Evaluator{constructor(e,t,r){super(),this[Xl]=e,this[Yl]=t,this[Kl]=r}get isConstant(){return Evaluator.isConstant(this[Yl])&&Evaluator.isConstant(this[Kl])}[Gl](){const e=Nl(Evaluator.evaluate(this[Yl])),t=Nl(Evaluator.evaluate(this[Kl])),{number:r,unit:s}=e,{number:o,unit:l}=t;if(null!=l&&null!=s&&l!=s)return Fl;const c=s||l;let h;switch(this[Xl].value){case"+":h=r+o;break;case"-":h=r-o;break;case"/":h=r/o;break;case"*":h=r*o;break;default:return Fl}return{type:"number",number:h,unit:c}}}const Jl=Symbol("evaluatables"),$l=Symbol("intrinsics");class StyleEvaluator extends Evaluator{constructor(e,t){super(),this[$l]=t;const r=e[0],s=null!=r?r.terms:[];this[Jl]=t.basis.map(((e,t)=>{const r=s[t];return null==r?{type:"ident",value:"auto"}:"ident"===r.type?r:Evaluator.evaluatableFor(r,e)}))}get isConstant(){for(const e of this[Jl])if(!Evaluator.isConstant(e))return!1;return!0}[Gl](){const e=this[Jl].map((e=>Evaluator.evaluate(e)));return Evaluator.applyIntrinsics(e,this[$l]).map((e=>e.number))}}var Zl,ec,tc,ic;const nc=Symbol("instances"),rc=Symbol("activateListener"),sc=Symbol("deactivateListener"),ac=Symbol("notifyInstances"),oc=Symbol("notify"),cc=Symbol("callback");class ScrollObserver{constructor(e){this[cc]=e}static[ac](){for(const e of ScrollObserver[nc])e[oc]()}static[(Zl=nc,rc)](){window.addEventListener("scroll",this[ac],{passive:!0})}static[sc](){window.removeEventListener("scroll",this[ac])}observe(){0===ScrollObserver[nc].size&&ScrollObserver[rc](),ScrollObserver[nc].add(this)}disconnect(){ScrollObserver[nc].delete(this),0===ScrollObserver[nc].size&&ScrollObserver[sc]()}[oc](){this[cc]()}}ScrollObserver[Zl]=new Set;const hc=Symbol("computeStyleCallback"),uc=Symbol("astWalker"),dc=Symbol("dependencies"),pc=Symbol("onScroll");class StyleEffector{constructor(e){this[ec]={},this[tc]=new ASTWalker(["function"]),this[ic]=()=>{this[hc]({relatedState:"window-scroll"})},this[hc]=e}observeEffectsFor(e){const t={},r=this[dc];this[uc].walk(e,(e=>{const{name:s}=e,o=e.arguments[0].terms[0];if("env"===s.value&&null!=o&&"ident"===o.type&&"window-scroll-y"===o.value)if(null==t["window-scroll"]){const e="window-scroll"in r?r["window-scroll"]:new ScrollObserver(this[pc]);e.observe(),delete r["window-scroll"],t["window-scroll"]=e}}));for(const e in r){r[e].disconnect()}this[dc]=t}dispose(){for(const e in this[dc]){this[dc][e].disconnect()}}}ec=dc,tc=uc,ic=pc;const style=e=>{const t=e.observeEffects||!1,r=e.intrinsics instanceof Function?e.intrinsics:()=>e.intrinsics;return(s,o)=>{const l=s.updated,c=s.connectedCallback,h=s.disconnectedCallback,d=Symbol(`${o}StyleEffector`),p=Symbol(`${o}StyleEvaluator`),A=Symbol(`${o}UpdateEvaluator`),m=Symbol(`${o}EvaluateAndSync`);Object.defineProperties(s,{[d]:{value:null,writable:!0},[p]:{value:null,writable:!0},[A]:{value:function(){const e=Bl(this[o]);this[p]=new StyleEvaluator(e,r(this)),null==this[d]&&t&&(this[d]=new StyleEffector((()=>this[m]()))),null!=this[d]&&this[d].observeEffectsFor(e)}},[m]:{value:function(){if(null==this[p])return;const t=this[p].evaluate();this[e.updateHandler](t)}},updated:{value:function(e){e.has(o)&&(this[A](),this[m]()),l.call(this,e)}},connectedCallback:{value:function(){c.call(this),this.requestUpdate(o,this[o])}},disconnectedCallback:{value:function(){h.call(this),null!=this[d]&&(this[d].dispose(),this[d]=null)}}})}},easeInOutQuad=e=>e<.5?2*e*e:(4-2*e)*e-1,interpolate=(e,t,r=easeInOutQuad)=>s=>e+(t-e)*r(s),timeline=e=>{const t=[],r=[];let s=e.initialValue;for(let o=0;o<e.keyframes.length;++o){const l=e.keyframes[o],{value:c,frames:h}=l,d=l.ease||easeInOutQuad,p=interpolate(s,c,d);t.push(p),r.push(h),s=c}return((e,t)=>{const r=t.map((s=0,e=>s+=e));var s;return t=>{t=utilities_clamp(t,0,1),t*=r[r.length-1];const s=r.findIndex((e=>e>=t)),o=s<1?0:r[s-1],l=r[s];return e[s]((t-o)/(l-o))}})(t,r)};var Ac=r(6763),controls_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const mc=timeline({initialValue:0,keyframes:[{frames:5,value:-1},{frames:1,value:-1},{frames:8,value:1},{frames:1,value:1},{frames:5,value:0},{frames:18,value:0}]}),fc=timeline({initialValue:0,keyframes:[{frames:1,value:1},{frames:5,value:1},{frames:1,value:0},{frames:6,value:0}]}),gc="0deg 75deg 105%",_c=["front","right","back","left"],vc=["upper-","","lower-"],yc="auto",Ec="basic",xc="wiggle",Sc="none",fieldOfViewIntrinsics=()=>({basis:[degreesToRadians(numberNode(30,"deg"))],keywords:{auto:[null]}}),minFieldOfViewIntrinsics=()=>({basis:[degreesToRadians(numberNode(12,"deg"))],keywords:{auto:[null]}}),Mc=(()=>{const e=Bl(gc)[0].terms,t=Nl(e[0]),r=Nl(e[1]);return e=>{const s=e[fp].idealCameraDistance();return{basis:[t,r,numberNode(s,"m")],keywords:{auto:[null,null,numberNode(105,"%")]}}}})(),minCameraOrbitIntrinsics=e=>{const t=2.2*e[fp].boundingSphere.radius;return{basis:[numberNode(-1/0,"rad"),numberNode(Math.PI/8,"rad"),numberNode(t,"m")],keywords:{auto:[null,null,null]}}},maxCameraOrbitIntrinsics=e=>{const t=Mc(e),r=new StyleEvaluator([],t).evaluate()[2];return{basis:[numberNode(1/0,"rad"),numberNode(Math.PI-Math.PI/8,"rad"),numberNode(r,"m")],keywords:{auto:[null,null,null]}}},cameraTargetIntrinsics=e=>{const t=e[fp].boundingBox.getCenter(new three_module_Vector3);return{basis:[numberNode(t.x,"m"),numberNode(t.y,"m"),numberNode(t.z,"m")],keywords:{auto:[null,null,null]}}},Cc=Math.PI/2,bc=Math.PI/3,wc=Cc/2,Ic=2*Math.PI,Tc=Symbol("controls"),Bc=Symbol("panElement"),Rc=Symbol("promptElement"),Lc=Symbol("promptAnimatedContainer"),Dc=Symbol("fingerAnimatedContainers"),Uc=Symbol("deferInteractionPrompt"),Pc=Symbol("updateAria"),Fc=Symbol("updateCameraForRadius"),Nc=Symbol("cancelPrompts"),Oc=Symbol("onChange"),Qc=Symbol("onPointerChange"),kc=Symbol("waitingToPromptUser"),Gc=Symbol("userHasInteracted"),Vc=Symbol("promptElementVisibleTime"),Hc=Symbol("lastPromptOffset"),zc=Symbol("cancellationSource"),Wc=Symbol("lastSpherical"),qc=Symbol("jumpCamera"),jc=Symbol("initialized"),Xc=Symbol("maintainThetaPhi"),Yc=Symbol("syncCameraOrbit"),Kc=Symbol("syncFieldOfView"),Jc=Symbol("syncCameraTarget"),$c=Symbol("syncMinCameraOrbit"),Zc=Symbol("syncMaxCameraOrbit"),eh=Symbol("syncMinFieldOfView"),th=Symbol("syncMaxFieldOfView"),ih=new Vector2,nh=new three_module_Vector3,rh=Object.freeze({minimumRadius:0,maximumRadius:1/0,minimumPolarAngle:Math.PI/8,maximumPolarAngle:Math.PI-Math.PI/8,minimumAzimuthalAngle:-1/0,maximumAzimuthalAngle:1/0,minimumFieldOfView:10,maximumFieldOfView:45,touchAction:"none"}),sh=Math.PI/8,ah=.04,oh={USER_INTERACTION:"user-interaction",NONE:"none",AUTOMATIC:"automatic"};class SmoothControls extends EventDispatcher{constructor(e,t,r){super(),this.camera=e,this.element=t,this.scene=r,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.inputSensitivity=1,this.changeSource=oh.NONE,this._interactionEnabled=!1,this._disableZoom=!1,this.isUserPointing=!1,this.enablePan=!0,this.enableTap=!0,this.panProjection=new Matrix3,this.panPerPixel=0,this.spherical=new Spherical,this.goalSpherical=new Spherical,this.thetaDamper=new Damper,this.phiDamper=new Damper,this.radiusDamper=new Damper,this.logFov=Math.log(rh.maximumFieldOfView),this.goalLogFov=this.logFov,this.fovDamper=new Damper,this.touchMode=null,this.pointers=[],this.startTime=0,this.startPointerPosition={clientX:0,clientY:0},this.lastSeparation=0,this.touchDecided=!1,this.onContext=e=>{if(this.enablePan)e.preventDefault();else for(const e of this.pointers)this.onPointerUp(new PointerEvent("pointercancel",Object.assign(Object.assign({},this.startPointerPosition),{pointerId:e.id})))},this.touchModeZoom=(e,t)=>{if(!this._disableZoom){const e=this.twoTouchDistance(this.pointers[0],this.pointers[1]),t=ah*this.zoomSensitivity*(this.lastSeparation-e)*50/this.scene.height;this.lastSeparation=e,this.userAdjustOrbit(0,0,t)}this.panPerPixel>0&&this.movePan(e,t)},this.disableScroll=e=>{e.preventDefault()},this.touchModeRotate=(e,t)=>{const{touchAction:r}=this._options;if(!this.touchDecided&&"none"!==r){this.touchDecided=!0;const s=Math.abs(e),o=Math.abs(t);if(this.changeSource===oh.USER_INTERACTION&&("pan-y"===r&&o>s||"pan-x"===r&&s>o))return void(this.touchMode=null);this.element.addEventListener("touchmove",this.disableScroll,{passive:!1})}this.handleSinglePointerMove(e,t)},this.onPointerDown=e=>{if(this.pointers.length>2)return;const{element:t}=this;0===this.pointers.length&&(t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.touchMode=null,this.touchDecided=!1,this.startPointerPosition.clientX=e.clientX,this.startPointerPosition.clientY=e.clientY,this.startTime=performance.now());try{t.setPointerCapture(e.pointerId)}catch(e){}this.pointers.push({clientX:e.clientX,clientY:e.clientY,id:e.pointerId}),this.isUserPointing=!1,"touch"===e.pointerType?(this.changeSource=e.altKey?oh.AUTOMATIC:oh.USER_INTERACTION,this.onTouchChange(e)):(this.changeSource=oh.USER_INTERACTION,this.onMouseDown(e)),this.changeSource===oh.USER_INTERACTION&&this.dispatchEvent({type:"user-interaction"})},this.onPointerMove=e=>{const t=this.pointers.find((t=>t.id===e.pointerId));if(null==t)return;if("mouse"===e.pointerType&&0===e.buttons)return void this.onPointerUp(e);const r=this.pointers.length,s=(e.clientX-t.clientX)/r,o=(e.clientY-t.clientY)/r;0===s&&0===o||(t.clientX=e.clientX,t.clientY=e.clientY,"touch"===e.pointerType?(this.changeSource=e.altKey?oh.AUTOMATIC:oh.USER_INTERACTION,null!==this.touchMode&&this.touchMode(s,o)):(this.changeSource=oh.USER_INTERACTION,this.panPerPixel>0?this.movePan(s,o):this.handleSinglePointerMove(s,o)))},this.onPointerUp=e=>{const{element:t}=this,r=this.pointers.findIndex((t=>t.id===e.pointerId));-1!==r&&this.pointers.splice(r,1),this.panPerPixel>0&&!e.altKey&&this.resetRadius(),0===this.pointers.length?(t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),t.removeEventListener("touchmove",this.disableScroll),this.enablePan&&this.enableTap&&this.recenter(e)):null!==this.touchMode&&this.onTouchChange(e),this.scene.element[Bc].style.opacity=0,t.style.cursor="grab",this.panPerPixel=0,this.isUserPointing&&this.dispatchEvent({type:"pointer-change-end"})},this.onWheel=e=>{this.changeSource=oh.USER_INTERACTION;const t=e.deltaY*(1==e.deltaMode?18:1)*ah*this.zoomSensitivity/30;this.userAdjustOrbit(0,0,t),e.preventDefault(),this.dispatchEvent({type:"user-interaction"})},this.onKeyDown=e=>{const{changeSource:t}=this;this.changeSource=oh.USER_INTERACTION;(e.shiftKey&&this.enablePan?this.panKeyCodeHandler(e):this.orbitZoomKeyCodeHandler(e))?(e.preventDefault(),this.dispatchEvent({type:"user-interaction"})):this.changeSource=t},this._options=Object.assign({},rh),this.setOrbit(0,Math.PI/2,1),this.setFieldOfView(100),this.jumpToGoal()}get interactionEnabled(){return this._interactionEnabled}enableInteraction(){if(!1===this._interactionEnabled){const{element:e}=this;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointercancel",this.onPointerUp),this._disableZoom||e.addEventListener("wheel",this.onWheel),e.addEventListener("keydown",this.onKeyDown),e.addEventListener("touchmove",(()=>{}),{passive:!1}),e.addEventListener("contextmenu",this.onContext),this.element.style.cursor="grab",this._interactionEnabled=!0,this.updateTouchActionStyle()}}disableInteraction(){if(!0===this._interactionEnabled){const{element:e}=this;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),e.removeEventListener("pointercancel",this.onPointerUp),e.removeEventListener("wheel",this.onWheel),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("contextmenu",this.onContext),e.style.cursor="",this.touchMode=null,this._interactionEnabled=!1,this.updateTouchActionStyle()}}get options(){return this._options}set disableZoom(e){this._disableZoom!=e&&(this._disableZoom=e,!0===e?this.element.removeEventListener("wheel",this.onWheel):this.element.addEventListener("wheel",this.onWheel),this.updateTouchActionStyle())}getCameraSpherical(e=new Spherical){return e.copy(this.spherical)}getFieldOfView(){return this.camera.fov}applyOptions(e){Object.assign(this._options,e),this.setOrbit(),this.setFieldOfView(Math.exp(this.goalLogFov))}updateNearFar(e,t){this.camera.far=0===t?2:t,this.camera.near=Math.max(e,this.camera.far/1e3),this.camera.updateProjectionMatrix()}updateAspect(e){this.camera.aspect=e,this.camera.updateProjectionMatrix()}setOrbit(e=this.goalSpherical.theta,t=this.goalSpherical.phi,r=this.goalSpherical.radius){const{minimumAzimuthalAngle:s,maximumAzimuthalAngle:o,minimumPolarAngle:l,maximumPolarAngle:c,minimumRadius:h,maximumRadius:d}=this._options,{theta:p,phi:A,radius:m}=this.goalSpherical,f=utilities_clamp(e,s,o);isFinite(s)||isFinite(o)||(this.spherical.theta=this.wrapAngle(this.spherical.theta-f)+f);const g=utilities_clamp(t,l,c),_=utilities_clamp(r,h,d);return(f!==p||g!==A||_!==m)&&(!!(isFinite(f)&&isFinite(g)&&isFinite(_))&&(this.goalSpherical.theta=f,this.goalSpherical.phi=g,this.goalSpherical.radius=_,this.goalSpherical.makeSafe(),!0))}setRadius(e){this.goalSpherical.radius=e,this.setOrbit()}setFieldOfView(e){const{minimumFieldOfView:t,maximumFieldOfView:r}=this._options;e=utilities_clamp(e,t,r),this.goalLogFov=Math.log(e)}setDamperDecayTime(e){this.thetaDamper.setDecayTime(e),this.phiDamper.setDecayTime(e),this.radiusDamper.setDecayTime(e),this.fovDamper.setDecayTime(e)}adjustOrbit(e,t,r){const{theta:s,phi:o,radius:l}=this.goalSpherical,{minimumRadius:c,maximumRadius:h,minimumFieldOfView:d,maximumFieldOfView:p}=this._options,A=this.spherical.theta-s,m=Math.PI-.001,f=s-utilities_clamp(e,-m-A,m-A),g=o-t,_=0===r?0:((r>0?h:c)-l)/(Math.log(r>0?p:d)-this.goalLogFov),y=l+r*(isFinite(_)?_:2*(h-c));if(this.setOrbit(f,g,y),0!==r){const e=this.goalLogFov+r;this.setFieldOfView(Math.exp(e))}}jumpToGoal(){this.update(0,1e4)}update(e,t){if(this.isStationary())return!1;const{maximumPolarAngle:r,maximumRadius:s}=this._options,o=this.spherical.theta-this.goalSpherical.theta;return Math.abs(o)>Math.PI&&!isFinite(this._options.minimumAzimuthalAngle)&&!isFinite(this._options.maximumAzimuthalAngle)&&(this.spherical.theta-=2*Math.sign(o)*Math.PI),this.spherical.theta=this.thetaDamper.update(this.spherical.theta,this.goalSpherical.theta,t,Math.PI),this.spherical.phi=this.phiDamper.update(this.spherical.phi,this.goalSpherical.phi,t,r),this.spherical.radius=this.radiusDamper.update(this.spherical.radius,this.goalSpherical.radius,t,s),this.logFov=this.fovDamper.update(this.logFov,this.goalLogFov,t,1),this.moveCamera(),!0}updateTouchActionStyle(){const{style:e}=this.element;if(this._interactionEnabled){const{touchAction:t}=this._options;this._disableZoom&&"none"!==t?e.touchAction="manipulation":e.touchAction=t}else e.touchAction=""}isStationary(){return this.goalSpherical.theta===this.spherical.theta&&this.goalSpherical.phi===this.spherical.phi&&this.goalSpherical.radius===this.spherical.radius&&this.goalLogFov===this.logFov}moveCamera(){this.spherical.makeSafe(),this.camera.position.setFromSpherical(this.spherical),this.camera.setRotationFromEuler(new Euler(this.spherical.phi-Math.PI/2,this.spherical.theta,0,"YXZ")),this.camera.fov!==Math.exp(this.logFov)&&(this.camera.fov=Math.exp(this.logFov),this.camera.updateProjectionMatrix())}userAdjustOrbit(e,t,r){this.adjustOrbit(e*this.orbitSensitivity*this.inputSensitivity,t*this.orbitSensitivity*this.inputSensitivity,r*this.inputSensitivity)}wrapAngle(e){const t=(e+Math.PI)/(2*Math.PI);return 2*(t-Math.floor(t))*Math.PI-Math.PI}pixelLengthToSphericalAngle(e){return 2*Math.PI*e/this.scene.height}twoTouchDistance(e,t){const{clientX:r,clientY:s}=e,{clientX:o,clientY:l}=t,c=o-r,h=l-s;return Math.sqrt(c*c+h*h)}handleSinglePointerMove(e,t){const r=this.pixelLengthToSphericalAngle(e),s=this.pixelLengthToSphericalAngle(t);!1===this.isUserPointing&&(this.isUserPointing=!0,this.dispatchEvent({type:"pointer-change-start"})),this.userAdjustOrbit(r,s,0)}initializePan(){const{theta:e,phi:t}=this.spherical,r=e-this.scene.yaw;this.panPerPixel=.018*this.panSensitivity/this.scene.height,this.panProjection.set(-Math.cos(r),-Math.cos(t)*Math.sin(r),0,0,Math.sin(t),0,Math.sin(r),-Math.cos(t)*Math.cos(r),0)}movePan(e,t){const{scene:r}=this,s=nh.set(e,t,0).multiplyScalar(this.inputSensitivity),o=this.spherical.radius*Math.exp(this.logFov)*this.panPerPixel;s.multiplyScalar(o);const l=r.getTarget();l.add(s.applyMatrix3(this.panProjection)),r.boundingSphere.clampPoint(l,l),r.setTarget(l.x,l.y,l.z)}recenter(e){if(performance.now()>this.startTime+300||Math.abs(e.clientX-this.startPointerPosition.clientX)>2||Math.abs(e.clientY-this.startPointerPosition.clientY)>2)return;const{scene:t}=this,r=t.positionAndNormalFromPoint(t.getNDC(e.clientX,e.clientY));if(null==r){const{cameraTarget:e}=t.element;t.element.cameraTarget="",t.element.cameraTarget=e,this.userAdjustOrbit(0,0,1)}else t.target.worldToLocal(r.position),t.setTarget(r.position.x,r.position.y,r.position.z)}resetRadius(){const{scene:e}=this,t=e.positionAndNormalFromPoint(ih.set(0,0));if(null==t)return;e.target.worldToLocal(t.position);const r=e.getTarget(),{theta:s,phi:o}=this.spherical,l=s-e.yaw,c=nh.set(Math.sin(o)*Math.sin(l),Math.cos(o),Math.sin(o)*Math.cos(l)),h=c.dot(t.position.sub(r));r.add(c.multiplyScalar(h)),e.setTarget(r.x,r.y,r.z),this.setOrbit(void 0,void 0,this.goalSpherical.radius-h)}onTouchChange(e){if(1===this.pointers.length)this.touchMode=this.touchModeRotate;else{if(this._disableZoom)return this.touchMode=null,void this.element.removeEventListener("touchmove",this.disableScroll);this.touchMode=this.touchDecided&&null===this.touchMode?null:this.touchModeZoom,this.touchDecided=!0,this.element.addEventListener("touchmove",this.disableScroll,{passive:!1}),this.lastSeparation=this.twoTouchDistance(this.pointers[0],this.pointers[1]),this.enablePan&&null!=this.touchMode&&(this.initializePan(),e.altKey||(this.scene.element[Bc].style.opacity=1))}}onMouseDown(e){this.panPerPixel=0,this.enablePan&&(2===e.button||e.ctrlKey||e.metaKey||e.shiftKey)&&(this.initializePan(),this.scene.element[Bc].style.opacity=1),this.element.style.cursor="grabbing"}orbitZoomKeyCodeHandler(e){let t=!0;switch(e.key){case"PageUp":this.userAdjustOrbit(0,0,ah*this.zoomSensitivity);break;case"PageDown":this.userAdjustOrbit(0,0,-.04*this.zoomSensitivity);break;case"ArrowUp":this.userAdjustOrbit(0,-sh,0);break;case"ArrowDown":this.userAdjustOrbit(0,sh,0);break;case"ArrowLeft":this.userAdjustOrbit(-sh,0,0);break;case"ArrowRight":this.userAdjustOrbit(sh,0,0);break;default:t=!1}return t}panKeyCodeHandler(e){this.initializePan();let t=!0;switch(e.key){case"ArrowUp":this.movePan(0,-10);break;case"ArrowDown":this.movePan(0,10);break;case"ArrowLeft":this.movePan(-10,0);break;case"ArrowRight":this.movePan(10,0);break;default:t=!1}return t}}var lh=r(6763);const ch=1/1.3,hh="not-presenting",uh="session-started",dh="object-placed",ph="failed",Ah="tracking",mh="not-tracking",fh=new three_module_Vector3,gh=new three_module_Matrix4,_h=new three_module_Vector3,vh=new PerspectiveCamera(45,1,.1,100);class ARRenderer extends EventDispatcher{constructor(e){super(),this.renderer=e,this.currentSession=null,this.placeOnWall=!1,this.placementBox=null,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.initialHitSource=null,this.transientHitTestSource=null,this.inputSource=null,this._presentedScene=null,this.resolveCleanup=null,this.exitWebXRButtonContainer=null,this.overlay=null,this.xrLight=null,this.tracking=!0,this.frames=0,this.initialized=!1,this.oldTarget=new three_module_Vector3,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.lastDragPosition=new three_module_Vector3,this.firstRatio=0,this.lastAngle=0,this.goalPosition=new three_module_Vector3,this.goalYaw=0,this.goalScale=1,this.xDamper=new Damper,this.yDamper=new Damper,this.zDamper=new Damper,this.yawDamper=new Damper,this.scaleDamper=new Damper,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onUpdateScene=()=>{null!=this.placementBox&&this.isPresenting&&(this.placementBox.dispose(),this.placementBox=new PlacementBox(this.presentedScene,this.placeOnWall?"back":"bottom"))},this.onSelectStart=e=>{const t=this.transientHitTestSource;if(null==t)return;const r=this.frame.getHitTestResultsForTransientInput(t),s=this.presentedScene,o=this.placementBox;if(1===r.length){this.inputSource=e.inputSource;const{axes:t}=this.inputSource.gamepad,r=o.getHit(this.presentedScene,t[0],t[1]);o.show=!0,null!=r?(this.isTranslating=!0,this.lastDragPosition.copy(r)):!1===this.placeOnWall&&(this.isRotating=!0,this.lastAngle=1.5*t[0])}else if(2===r.length){o.show=!0,this.isTwoFingering=!0;const{separation:e}=this.fingerPolar(r);this.firstRatio=e/s.scale.x}},this.onSelectEnd=()=>{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.inputSource=null,this.goalPosition.y+=this.placementBox.offsetHeight*this.presentedScene.scale.x,this.placementBox.show=!1},this.threeRenderer=e.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){assertIsArCandidate();const e=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:["hit-test"],optionalFeatures:["dom-overlay","light-estimation"],domOverlay:this.overlay?{root:this.overlay}:void 0});return this.threeRenderer.xr.setReferenceSpaceType("local"),await this.threeRenderer.xr.setSession(e),this.threeRenderer.xr.cameraAutoUpdate=!1,e}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return assertIsArCandidate(),await navigator.xr.isSessionSupported("immersive-ar")}catch(e){return lh.warn("Request to present in WebXR denied:"),lh.warn(e),lh.warn("Falling back to next ar-mode"),!1}}async present(e,t=!1){this.isPresenting&&lh.warn("Cannot present while a model is already presenting");let r=new Promise(((e,t)=>{requestAnimationFrame((()=>e()))}));e.setHotspotsVisibility(!1),e.queueRender(),await r,this._presentedScene=e,this.overlay=e.element.shadowRoot.querySelector("div.default"),!0===t&&(this.xrLight=new XREstimatedLight(this.threeRenderer),this.xrLight.addEventListener("estimationstart",(()=>{if(!this.isPresenting||null==this.xrLight)return;const e=this.presentedScene;e.add(this.xrLight),e.environment=this.xrLight.environment})));const s=await this.resolveARSession();s.addEventListener("end",(()=>{this.postSessionCleanup()}),{once:!0});const o=e.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");o.classList.add("enabled"),o.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=o;const l=await s.requestReferenceSpace("viewer");this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=e.yaw,this.goalYaw=e.yaw,this.goalScale=1,e.setBackground(null),this.oldShadowIntensity=e.shadowIntensity,e.setShadowIntensity(.01),this.oldTarget.copy(e.getTarget()),e.element.addEventListener("load",this.onUpdateScene);const c=20*Math.PI/180,h=!0===this.placeOnWall?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(c),z:-Math.cos(c)});s.requestHitTestSource({space:l,offsetRay:h}).then((e=>{this.initialHitSource=e})),this.currentSession=s,this.placementBox=new PlacementBox(e,this.placeOnWall?"back":"bottom"),this.placementComplete=!1,this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:uh})}async stopPresenting(){if(!this.isPresenting)return;const e=new Promise((e=>{this.resolveCleanup=e}));try{await this.currentSession.end(),await e}catch(e){lh.warn("Error while trying to end WebXR AR session"),lh.warn(e),this.postSessionCleanup()}}get isPresenting(){return null!=this.presentedScene}get target(){return this.oldTarget}updateTarget(){const e=this.presentedScene;if(null!=e){const t=e.getTarget();this.oldTarget.copy(t),this.placeOnWall?t.z=e.boundingBox.min.z:t.y=e.boundingBox.min.y,e.setTarget(t.x,t.y,t.z)}}postSessionCleanup(){const e=this.currentSession;null!=e&&(e.removeEventListener("selectstart",this.onSelectStart),e.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const t=this.presentedScene;if(this._presentedScene=null,null!=t){const{element:e}=t;null!=this.xrLight&&(t.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),t.position.set(0,0,0),t.scale.set(1,1,1),t.setShadowOffset(0);const r=this.turntableRotation;null!=r&&(t.yaw=r);const s=this.oldShadowIntensity;null!=s&&t.setShadowIntensity(s),t.setEnvironmentAndSkybox(e[fa],e[ga]);const o=this.oldTarget;t.setTarget(o.x,o.y,o.z),t.xrCamera=null,t.element.removeEventListener("load",this.onUpdateScene),t.orientHotspots(0),e.requestUpdate("cameraTarget"),e.requestUpdate("maxCameraOrbit"),e[yp](e.getBoundingClientRect()),requestAnimationFrame((()=>{t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:oh.NONE}}))}))}this.renderer.height=0;const r=this.exitWebXRButtonContainer;null!=r&&(r.classList.remove("enabled"),r.removeEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=null);const s=this.transientHitTestSource;null!=s&&(s.cancel(),this.transientHitTestSource=null);const o=this.initialHitSource;null!=o&&(o.cancel(),this.initialHitSource=null),null!=this.placementBox&&(this.placementBox.dispose(),this.placementBox=null),this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.inputSource=null,this.overlay=null,null!=this.resolveCleanup&&this.resolveCleanup(),this.dispatchEvent({type:"status",status:hh})}updateView(e){const t=this.presentedScene,r=this.threeRenderer.xr;r.updateCamera(vh),t.xrCamera=r.getCamera();const{elements:s}=t.getCamera().matrixWorld;if(t.orientHotspots(Math.atan2(s[1],s[5])),this.initialized||(this.placeInitially(),this.initialized=!0),e.requestViewportScale&&e.recommendedViewportScale){const t=e.recommendedViewportScale;e.requestViewportScale(Math.max(t,.25))}const o=r.getBaseLayer();if(null!=o){const t=o instanceof XRWebGLLayer?o.getViewport(e):r.getBinding().getViewSubImage(o,e).viewport;this.threeRenderer.setViewport(t.x,t.y,t.width,t.height)}}placeInitially(){const e=this.presentedScene,{position:t,element:r}=e,s=e.getCamera(),{width:o,height:l}=this.overlay.getBoundingClientRect();e.setSize(o,l),s.projectionMatrixInverse.copy(s.projectionMatrix).invert();const{theta:c,radius:h}=r.getCameraOrbit(),d=s.getWorldDirection(fh);e.yaw=Math.atan2(-d.x,-d.z)-c,this.goalYaw=e.yaw,t.copy(s.position).add(d.multiplyScalar(h)),this.updateTarget();const p=e.getTarget();t.add(p).sub(this.oldTarget),this.goalPosition.copy(t),e.setHotspotsVisibility(!0);const{session:A}=this.frame;A.addEventListener("selectstart",this.onSelectStart),A.addEventListener("selectend",this.onSelectEnd),A.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then((e=>{this.transientHitTestSource=e}))}getTouchLocation(){const{axes:e}=this.inputSource.gamepad;let t=this.placementBox.getExpandedHit(this.presentedScene,e[0],e[1]);return null!=t&&(fh.copy(t).sub(this.presentedScene.getCamera().position),fh.length()>10)?null:t}getHitPoint(e){const t=this.threeRenderer.xr.getReferenceSpace(),r=e.getPose(t);if(null==r)return null;const s=gh.fromArray(r.transform.matrix);return!0===this.placeOnWall&&(this.goalYaw=Math.atan2(s.elements[4],s.elements[6])),s.elements[5]>.75!==this.placeOnWall?_h.setFromMatrixPosition(s):null}moveToFloor(e){const t=this.initialHitSource;if(null==t)return;const r=e.getHitTestResults(t);if(0==r.length)return;const s=r[0],o=this.getHitPoint(s);null!=o&&(this.placementBox.show=!0,this.isTranslating||(this.placeOnWall?this.goalPosition.copy(o):this.goalPosition.y=o.y),t.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:dh}))}fingerPolar(e){const t=e[0].inputSource.gamepad.axes,r=e[1].inputSource.gamepad.axes,s=r[0]-t[0],o=r[1]-t[1],l=Math.atan2(o,s);let c=this.lastAngle-l;return c>Math.PI?c-=2*Math.PI:c<-Math.PI&&(c+=2*Math.PI),this.lastAngle=l,{separation:Math.sqrt(s*s+o*o),deltaYaw:c}}processInput(e){const t=this.transientHitTestSource;if(null==t)return;if(!this.isTranslating&&!this.isTwoFingering&&!this.isRotating)return;const r=e.getHitTestResultsForTransientInput(t),s=this.presentedScene,o=s.scale.x;if(this.isTwoFingering)if(r.length<2)this.isTwoFingering=!1;else{const{separation:e,deltaYaw:t}=this.fingerPolar(r);if(!1===this.placeOnWall&&(this.goalYaw+=t),s.canScale){const t=e/this.firstRatio;this.goalScale=t<1.3&&t>ch?1:t}}else if(2!==r.length)if(this.isRotating){const e=1.5*this.inputSource.gamepad.axes[0];this.goalYaw+=e-this.lastAngle,this.lastAngle=e}else this.isTranslating&&r.forEach((e=>{if(e.inputSource!==this.inputSource)return;let t=null;if(e.results.length>0&&(t=this.getHitPoint(e.results[0])),null==t&&(t=this.getTouchLocation()),null!=t){if(this.goalPosition.sub(this.lastDragPosition),!1===this.placeOnWall){const e=t.y-this.lastDragPosition.y;if(e<0){this.placementBox.offsetHeight=e/o,this.presentedScene.setShadowOffset(e);const r=fh.copy(s.getCamera().position),l=-e/(r.y-t.y);r.multiplyScalar(l),t.multiplyScalar(1-l).add(r)}}this.goalPosition.add(t),this.lastDragPosition.copy(t)}}));else{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!0;const{separation:e}=this.fingerPolar(r);this.firstRatio=e/o}}moveScene(e){const t=this.presentedScene,{position:r,yaw:s}=t,o=t.boundingSphere.radius,l=this.goalPosition,c=t.scale.x,h=this.placementBox;let d=oh.NONE;if(!l.equals(r)||this.goalScale!==c){d=oh.USER_INTERACTION;let{x:s,y:p,z:A}=r;s=this.xDamper.update(s,l.x,e,o),p=this.yDamper.update(p,l.y,e,o),A=this.zDamper.update(A,l.z,e,o),r.set(s,p,A);const m=this.scaleDamper.update(c,this.goalScale,e,1);if(t.scale.set(m,m,m),!this.isTranslating){const e=l.y-p;this.placementComplete&&!1===this.placeOnWall?(h.offsetHeight=e/m,t.setShadowOffset(e)):0===e&&(this.placementComplete=!0,h.show=!1,t.setShadowIntensity(.8))}}h.updateOpacity(e),t.updateTarget(e),t.yaw=this.yawDamper.update(s,this.goalYaw,e,Math.PI),t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:d}}))}onWebXRFrame(e,t){this.frame=t,++this.frames;const r=this.threeRenderer.xr.getReferenceSpace(),s=t.getViewerPose(r);null==s&&!0===this.tracking&&this.frames>30&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:mh}));const o=this.presentedScene;if(null==s||null==o||!o.element.loaded)return void this.threeRenderer.clear();!1===this.tracking&&(this.tracking=!0,this.dispatchEvent({type:"tracking",status:Ah}));let l=!0;for(const r of s.views){if(this.updateView(r),l){this.moveToFloor(t),this.processInput(t);const r=e-this.lastTick;this.moveScene(r),this.renderer.preRender(o,e,r),this.lastTick=e,o.renderShadow(this.threeRenderer)}this.threeRenderer.render(o,o.getCamera()),l=!1}}}function clone(e){const t=new Map,r=new Map,s=e.clone();return parallelTraverse(e,s,(function(e,s){t.set(s,e),r.set(e,s)})),s.traverse((function(e){if(!e.isSkinnedMesh)return;const s=e,o=t.get(e),l=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=l.map((function(e){return r.get(e)})),s.bind(s.skeleton,s.bindMatrix)})),s}function parallelTraverse(e,t,r){r(e,t);for(let s=0;s<e.children.length;s++)parallelTraverse(e.children[s],t.children[s],r)}const yh=Symbol("prepared"),Eh=Symbol("prepare"),xh=Symbol("preparedGLTF"),Sh=Symbol("clone");class GLTFInstance{constructor(e){this[xh]=e}static prepare(e){if(null==e.scene)throw new Error("Model does not have a scene");if(e[yh])return e;const t=this[Eh](e);return t[yh]=!0,t}static[Eh](e){const{scene:t}=e,r=[t];return Object.assign(Object.assign({},e),{scene:t,scenes:r})}get parser(){return this[xh].parser}get animations(){return this[xh].animations}get scene(){return this[xh].scene}get scenes(){return this[xh].scenes}get cameras(){return this[xh].cameras}get asset(){return this[xh].asset}get userData(){return this[xh].userData}clone(){return new(0,this.constructor)(this[Sh]())}dispose(){this.scenes.forEach((e=>{e.traverse((e=>{const t=e;if(!t.material)return;(Array.isArray(t.material)?t.material:[t.material]).forEach((e=>{for(const t in e){const r=e[t];if(r instanceof Texture){const e=r.source.data;null!=e.close&&e.close(),r.dispose()}}e.dispose()})),t.geometry.dispose()}))}))}[Sh](){const e=this[xh],t=clone(this.scene);cloneVariantMaterials(t,this.scene);const r=[t],s=e.userData?Object.assign({},e.userData):{};return Object.assign(Object.assign({},e),{scene:t,scenes:r,userData:s})}}const cloneVariantMaterials=(e,t)=>{traversePair(e,t,((e,t)=>{void 0!==t.userData.variantMaterials&&(e.userData.variantMaterials=new Map(t.userData.variantMaterials)),void 0!==t.userData.variantData&&(e.userData.variantData=t.userData.variantData),void 0!==t.userData.originalMaterial&&(e.userData.originalMaterial=t.userData.originalMaterial)}))},traversePair=(e,t,r)=>{r(e,t);for(let s=0;s<e.children.length;s++)traversePair(e.children[s],t.children[s],r)},Mh=Symbol("threeGLTF"),Ch=Symbol("gltf"),bh=Symbol("gltfElementMap"),wh=Symbol("threeObjectMap"),Ih=Symbol("parallelTraverseThreeScene"),Th=Symbol("correlateOriginalThreeGLTF"),Bh=Symbol("correlateCloneThreeGLTF");class CorrelatedSceneGraph{constructor(e,t,r,s){this[Mh]=e,this[Ch]=t,this[bh]=s,this[wh]=r}static from(e,t){return null!=t?this[Bh](e,t):this[Th](e)}static[Th](e){const t=e.parser.json,r=e.parser.associations,s=new Map,o={name:"Default"},l={type:"materials",index:-1};for(const e of r.keys())e instanceof Material&&null==r.get(e)&&(l.index<0&&(null==t.materials&&(t.materials=[]),l.index=t.materials.length,t.materials.push(o)),e.name=o.name,r.set(e,{materials:l.index}));for(const[e,o]of r){o&&(e.userData=e.userData||{},e.userData.associations=o);for(const r in o)if(null!=r&&"primitives"!==r){const l=r,c=(t[l]||[])[o[l]];if(null==c)continue;let h=s.get(c);null==h&&(h=new Set,s.set(c,h)),h.add(e)}}return new CorrelatedSceneGraph(e,t,r,s)}static[Bh](e,t){const r=t.threeGLTF,s=t.gltf,o=JSON.parse(JSON.stringify(s)),l=new Map,c=new Map;for(let s=0;s<r.scenes.length;s++)this[Ih](r.scenes[s],e.scenes[s],((e,r)=>{const s=t.threeObjectMap.get(e);if(null!=s)for(const e in s)if(null!=e&&"primitives"!==e){const t=e,h=s[t],d=o[t][h],p=l.get(r)||{};p[t]=h,l.set(r,p);const A=c.get(d)||new Set;A.add(r),c.set(d,A)}}));return new CorrelatedSceneGraph(e,o,l,c)}static[Ih](e,t,r){const traverse=(e,t)=>{if(r(e,t),e.isObject3D){const s=e,o=t;if(s.material)if(Array.isArray(s.material))for(let e=0;e<s.material.length;++e)r(s.material[e],o.material[e]);else r(s.material,o.material);for(let r=0;r<e.children.length;++r)traverse(e.children[r],t.children[r])}};traverse(e,t)}get threeGLTF(){return this[Mh]}get gltf(){return this[Ch]}get gltfElementMap(){return this[bh]}get threeObjectMap(){return this[wh]}}const Rh=Symbol("correlatedSceneGraph");class ModelViewerGLTFInstance extends GLTFInstance{static[Eh](e){const t=super[Eh](e);null==t[Rh]&&(t[Rh]=CorrelatedSceneGraph.from(t));const{scene:r}=t,s=new Sphere(void 0,1/0);return r.traverse((e=>{e.renderOrder=1e3,e.frustumCulled=!1,e.name||(e.name=e.uuid);const r=e;if(r.material){const{geometry:e}=r;r.castShadow=!0,r.isSkinnedMesh&&(e.boundingSphere=s,e.boundingBox=null);const o=r.material;if(!0===o.isMeshBasicMaterial&&(o.toneMapped=!1),o.shadowSide=p,o.aoMap){const{gltf:r,threeObjectMap:s}=t[Rh],l=s.get(o);if(null!=r.materials&&null!=l&&null!=l.materials){const t=r.materials[l.materials];t.occlusionTexture&&0===t.occlusionTexture.texCoord&&null!=e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv)}}}})),t}get correlatedSceneGraph(){return this[xh][Rh]}[Sh](){const e=super[Sh](),t=new Map;return e.scene.traverse((e=>{const r=e;if(r.material){const e=r.material;if(null!=e){if(t.has(e.uuid))return void(r.material=t.get(e.uuid));r.material=e.clone(),t.set(e.uuid,r.material)}}const s=e;void 0!==s.target&&s.add(s.target)})),e[Rh]=CorrelatedSceneGraph.from(e,this.correlatedSceneGraph),e}}var Lh=r(6763);const getBufferForType=(e,t,r)=>{let s;switch(e){case ye:s=new Uint8ClampedArray(t*r*4);break;case Ce:s=new Uint16Array(t*r*4);break;case Se:s=new Uint32Array(t*r*4);break;case 1010:s=new Int8Array(t*r*4);break;case 1011:s=new Int16Array(t*r*4);break;case xe:s=new Int32Array(t*r*4);break;case Me:s=new Float32Array(t*r*4);break;default:throw new Error("Unsupported data type")}return s};let Dh;class QuadRenderer_vDmOC3x_QuadRenderer{constructor(e){var t,r,s,o,l,c,h,d,p,A,m,f,g,_,y,x;this._rendererIsDisposable=!1,this._supportsReadPixels=!0,this.render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(e){throw this._renderer.setRenderTarget(null),e}this._renderer.setRenderTarget(null)},this._width=e.width,this._height=e.height,this._type=e.type,this._colorSpace=e.colorSpace;const S={format:we,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:void 0!==(null===(t=e.renderTargetOptions)||void 0===t?void 0:t.anisotropy)?null===(r=e.renderTargetOptions)||void 0===r?void 0:r.anisotropy:1,generateMipmaps:void 0!==(null===(s=e.renderTargetOptions)||void 0===s?void 0:s.generateMipmaps)&&(null===(o=e.renderTargetOptions)||void 0===o?void 0:o.generateMipmaps),magFilter:void 0!==(null===(l=e.renderTargetOptions)||void 0===l?void 0:l.magFilter)?null===(c=e.renderTargetOptions)||void 0===c?void 0:c.magFilter:ge,minFilter:void 0!==(null===(h=e.renderTargetOptions)||void 0===h?void 0:h.minFilter)?null===(d=e.renderTargetOptions)||void 0===d?void 0:d.minFilter:ge,samples:void 0!==(null===(p=e.renderTargetOptions)||void 0===p?void 0:p.samples)?null===(A=e.renderTargetOptions)||void 0===A?void 0:A.samples:void 0,wrapS:void 0!==(null===(m=e.renderTargetOptions)||void 0===m?void 0:m.wrapS)?null===(f=e.renderTargetOptions)||void 0===f?void 0:f.wrapS:de,wrapT:void 0!==(null===(g=e.renderTargetOptions)||void 0===g?void 0:g.wrapT)?null===(_=e.renderTargetOptions)||void 0===_?void 0:_.wrapT:de};if(this._material=e.material,e.renderer?this._renderer=e.renderer:(this._renderer=QuadRenderer_vDmOC3x_QuadRenderer.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new Scene,this._camera=new OrthographicCamera,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!((e,t,r,s)=>{if(void 0!==Dh)return Dh;const o=new WebGLRenderTarget(1,1,s);t.setRenderTarget(o);const l=new three_module_Mesh(new PlaneGeometry,new MeshBasicMaterial({color:16777215}));t.render(l,r),t.setRenderTarget(null);const c=getBufferForType(e,o.width,o.height);return t.readRenderTargetPixels(o,0,0,o.width,o.height,c),o.dispose(),l.geometry.dispose(),l.material.dispose(),Dh=0!==c[0],Dh})(this._type,this._renderer,this._camera,S)){let e;if(this._type===Ce)e=this._renderer.extensions.has("EXT_color_buffer_float")?Me:void 0;void 0!==e?(Lh.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to 1015`),this._type=e):(this._supportsReadPixels=!1,Lh.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new three_module_Mesh(new PlaneGeometry,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new WebGLRenderTarget(this.width,this.height,S),this._renderTarget.texture.mapping=void 0!==(null===(y=e.renderTargetOptions)||void 0===y?void 0:y.mapping)?null===(x=e.renderTargetOptions)||void 0===x?void 0:x.mapping:se}static instantiateRenderer(){const e=new WebGLRenderer;return e.setSize(128,128),e}toArray(){if(!this._supportsReadPixels)throw new Error("Can't read pixels in this browser");const e=getBufferForType(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){const t=new DataTexture(this.toArray(),this.width,this.height,we,this._type,(null==e?void 0:e.mapping)||se,(null==e?void 0:e.wrapS)||de,(null==e?void 0:e.wrapT)||de,(null==e?void 0:e.magFilter)||ge,(null==e?void 0:e.minFilter)||ge,(null==e?void 0:e.anisotropy)||1,it);return t.generateMipmaps=void 0!==(null==e?void 0:e.generateMipmaps)&&(null==e?void 0:e.generateMipmaps),t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof ShaderMaterial&&Object.values(this.material.uniforms).forEach((e=>{e.value instanceof Texture&&e.value.dispose()})),Object.values(this.material).forEach((e=>{e instanceof Texture&&e.dispose()})),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}var Uh=r(6763);class GainMapDecoderMaterial extends ShaderMaterial{constructor({gamma:e,offsetHdr:t,offsetSdr:r,gainMapMin:s,gainMapMax:o,maxDisplayBoost:l,hdrCapacityMin:c,hdrCapacityMax:h,sdr:d,gainMap:p}){super({name:"GainMapDecoderMaterial",vertexShader:"\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\n// min half float value\n#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )\n// max half float value\n#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )\n\nuniform sampler2D sdr;\nuniform sampler2D gainMap;\nuniform vec3 gamma;\nuniform vec3 offsetHdr;\nuniform vec3 offsetSdr;\nuniform vec3 gainMapMin;\nuniform vec3 gainMapMax;\nuniform float weightFactor;\n\nvarying vec2 vUv;\n\nvoid main() {\n vec3 rgb = texture2D( sdr, vUv ).rgb;\n vec3 recovery = texture2D( gainMap, vUv ).rgb;\n vec3 logRecovery = pow( recovery, gamma );\n vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;\n vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;\n vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));\n gl_FragColor = vec4( clampedHdrColor , 1.0 );\n}\n",uniforms:{sdr:{value:d},gainMap:{value:p},gamma:{value:new three_module_Vector3(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:(new three_module_Vector3).fromArray(t)},offsetSdr:{value:(new three_module_Vector3).fromArray(r)},gainMapMin:{value:(new three_module_Vector3).fromArray(s)},gainMapMax:{value:(new three_module_Vector3).fromArray(o)},weightFactor:{value:(Math.log2(l)-c)/(h-c)}},blending:0,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=l,this._hdrCapacityMin=c,this._hdrCapacityMax=h,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){const e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){const t=this.uniforms.gamma.value;t.x=1/e[0],t.y=1/e[1],t.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){const e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}}class GainMapNotFoundError extends Error{}class XMPMetadataNotFoundError extends Error{}const getAttribute=(e,t,r)=>{var s;let o;const l=null===(s=e.attributes.getNamedItem(t))||void 0===s?void 0:s.nodeValue;if(l)o=l;else{const s=e.getElementsByTagName(t)[0];if(!s){if(r)return r;throw new Error(`Can't find ${t} in gainmap metadata`)}{const e=s.getElementsByTagName("rdf:li");if(3!==e.length)throw new Error(`Gainmap metadata contains an array of items for ${t} but its length is not 3`);o=Array.from(e).map((e=>e.innerHTML))}}return o};class MPFExtractor{constructor(e){this.options={debug:!(!e||void 0===e.debug)&&e.debug,extractFII:!e||void 0===e.extractFII||e.extractFII,extractNonFII:!e||void 0===e.extractNonFII||e.extractNonFII}}extract(e){return new Promise(((t,r)=>{const s=this.options.debug,o=new DataView(e.buffer);if(65496!==o.getUint16(0))return void r(new Error("Not a valid jpeg"));const l=o.byteLength;let c,h=2,d=0;for(;h<l;){if(++d>250)return void r(new Error(`Found no marker after ${d} loops 😵`));if(255!==o.getUint8(h))return void r(new Error(`Not a valid marker at offset 0x${h.toString(16)}, found: 0x${o.getUint8(h).toString(16)}`));if(c=o.getUint8(h+1),s&&Uh.log(`Marker: ${c.toString(16)}`),226===c){s&&Uh.log("Found APP2 marker (0xffe2)");const e=h+4;if(1297106432===o.getUint32(e)){const s=e+4;let l;if(18761===o.getUint16(s))l=!1;else{if(19789!==o.getUint16(s))return void r(new Error("No valid endianness marker found in TIFF header"));l=!0}if(42!==o.getUint16(s+2,!l))return void r(new Error("Not valid TIFF data! (no 0x002A marker)"));const c=o.getUint32(s+4,!l);if(c<8)return void r(new Error("Not valid TIFF data! (First offset less than 8)"));const h=s+c,d=o.getUint16(h,!l),p=h+2;let A=0;for(let e=p;e<p+12*d;e+=12)45057===o.getUint16(e,!l)&&(A=o.getUint32(e+8,!l));const m=h+2+12*d+4,f=[];for(let e=m;e<m+16*A;e+=16){const t={MPType:o.getUint32(e,!l),size:o.getUint32(e+4,!l),dataOffset:o.getUint32(e+8,!l),dependantImages:o.getUint32(e+12,!l),start:-1,end:-1,isFII:!1};t.dataOffset?(t.start=s+t.dataOffset,t.isFII=!1):(t.start=0,t.isFII=!0),t.end=t.start+t.size,f.push(t)}if(this.options.extractNonFII&&f.length){const e=new Blob([o]),r=[];for(const t of f){if(t.isFII&&!this.options.extractFII)continue;const s=e.slice(t.start,t.end+1,"image/jpeg");r.push(s)}t(r)}}}h+=2+o.getUint16(h+2)}}))}}const extractGainmapFromJPEG=async e=>{const t=(e=>{var t,r;let s;s="undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):e.toString();let o=s.indexOf("<x:xmpmeta");const l=new DOMParser;for(;-1!==o;){const e=s.indexOf("x:xmpmeta>",o);s.slice(o,e+10);const c=s.slice(o,e+10);try{const e=l.parseFromString(c,"text/xml").getElementsByTagName("rdf:Description")[0],s=getAttribute(e,"hdrgm:GainMapMin","0"),o=getAttribute(e,"hdrgm:GainMapMax"),h=getAttribute(e,"hdrgm:Gamma","1"),d=getAttribute(e,"hdrgm:OffsetSDR","0.015625"),p=getAttribute(e,"hdrgm:OffsetHDR","0.015625");let A=null===(t=e.attributes.getNamedItem("hdrgm:HDRCapacityMin"))||void 0===t?void 0:t.nodeValue;A||(A="0");const m=null===(r=e.attributes.getNamedItem("hdrgm:HDRCapacityMax"))||void 0===r?void 0:r.nodeValue;if(!m)throw new Error("Incomplete gainmap metadata");return{gainMapMin:Array.isArray(s)?s.map((e=>parseFloat(e))):[parseFloat(s),parseFloat(s),parseFloat(s)],gainMapMax:Array.isArray(o)?o.map((e=>parseFloat(e))):[parseFloat(o),parseFloat(o),parseFloat(o)],gamma:Array.isArray(h)?h.map((e=>parseFloat(e))):[parseFloat(h),parseFloat(h),parseFloat(h)],offsetSdr:Array.isArray(d)?d.map((e=>parseFloat(e))):[parseFloat(d),parseFloat(d),parseFloat(d)],offsetHdr:Array.isArray(p)?p.map((e=>parseFloat(e))):[parseFloat(p),parseFloat(p),parseFloat(p)],hdrCapacityMin:parseFloat(A),hdrCapacityMax:parseFloat(m)}}catch(e){}o=s.indexOf("<x:xmpmeta",e)}})(e);if(!t)throw new XMPMetadataNotFoundError("Gain map XMP metadata not found");const r=new MPFExtractor({extractFII:!0,extractNonFII:!0}),s=await r.extract(e);if(2!==s.length)throw new GainMapNotFoundError("Gain map recovery image not found");return{sdr:new Uint8Array(await s[0].arrayBuffer()),gainMap:new Uint8Array(await s[1].arrayBuffer()),metadata:t}},getHTMLImageFromBlob=e=>new Promise(((t,r)=>{const s=document.createElement("img");s.onload=()=>{t(s)},s.onerror=e=>{r(e)},s.src=URL.createObjectURL(e)}));class LoaderBase extends Loader{constructor(e,t){super(t),this._renderer=e,this._internalLoadingManager=new LoadingManager}setRenderTargetOptions(e){return this._renderTargetOptions=e,this}prepareQuadRenderer(){const e=new GainMapDecoderMaterial({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new Texture,sdr:new Texture});return new QuadRenderer_vDmOC3x_QuadRenderer({width:16,height:16,type:Ce,colorSpace:it,material:e,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async render(e,t,r,s){const o=s?new Blob([s],{type:"image/jpeg"}):void 0,l=new Blob([r],{type:"image/jpeg"});let c,h,d=!1;if("undefined"==typeof createImageBitmap){const e=await Promise.all([o?getHTMLImageFromBlob(o):Promise.resolve(void 0),getHTMLImageFromBlob(l)]);h=e[0],c=e[1],d=!0}else{const e=await Promise.all([o?createImageBitmap(o,{imageOrientation:"flipY"}):Promise.resolve(void 0),createImageBitmap(l,{imageOrientation:"flipY"})]);h=e[0],c=e[1]}const p=new Texture(h||new ImageData(2,2),se,de,de,ge,1008,we,ye,1,it);p.flipY=d,p.needsUpdate=!0;const A=new Texture(c,se,de,de,ge,1008,we,ye,1,tt);A.flipY=d,A.needsUpdate=!0,e.width=c.width,e.height=c.height,e.material.gainMap=p,e.material.sdr=A,e.material.gainMapMin=t.gainMapMin,e.material.gainMapMax=t.gainMapMax,e.material.offsetHdr=t.offsetHdr,e.material.offsetSdr=t.offsetSdr,e.material.gamma=t.gamma,e.material.hdrCapacityMin=t.hdrCapacityMin,e.material.hdrCapacityMax=t.hdrCapacityMax,e.material.maxDisplayBoost=Math.pow(2,t.hdrCapacityMax),e.material.needsUpdate=!0,e.render()}}class HDRJPGLoader extends LoaderBase{load(e,t,r,s){const o=this.prepareQuadRenderer(),l=new three_module_FileLoader(this._internalLoadingManager);return l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setPath(this.path),l.setWithCredentials(this.withCredentials),this.manager.itemStart(e),l.load(e,(async r=>{if("string"==typeof r)throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const l=new Uint8Array(r);let c,h,d;try{const e=await extractGainmapFromJPEG(l);c=e.sdr,h=e.gainMap,d=e.metadata}catch(t){if(!(t instanceof XMPMetadataNotFoundError||t instanceof GainMapNotFoundError))throw t;Uh.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),d={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},c=l}try{await this.render(o,d,c,h)}catch(t){return this.manager.itemError(e),"function"==typeof s&&s(t),void o.disposeOnDemandRenderer()}"function"==typeof t&&t(o),this.manager.itemEnd(e),o.disposeOnDemandRenderer()}),r,(t=>{this.manager.itemError(e),"function"==typeof s&&s(t)})),o}}class RGBELoader extends DataTextureLoader{constructor(e){super(e),this.type=Ce}parse(e){const rgbe_error=function(e,t){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},fgets=function(e,t,r){t=t||1024;let s=e.pos,o=-1,l=0,c="",h=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));for(;0>(o=h.indexOf("\n"))&&l<t&&s<e.byteLength;)c+=h,l+=h.length,s+=128,h+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));return-1<o&&(!1!==r&&(e.pos+=l+o+1),c+h.slice(0,o))},RGBEByteToRGBFloat=function(e,t,r,s){const o=e[t+3],l=Math.pow(2,o-128)/255;r[s+0]=e[t+0]*l,r[s+1]=e[t+1]*l,r[s+2]=e[t+2]*l,r[s+3]=1},RGBEByteToRGBHalf=function(e,t,r,s){const o=e[t+3],l=Math.pow(2,o-128)/255;r[s+0]=$i.toHalfFloat(Math.min(e[t+0]*l,65504)),r[s+1]=$i.toHalfFloat(Math.min(e[t+1]*l,65504)),r[s+2]=$i.toHalfFloat(Math.min(e[t+2]*l,65504)),r[s+3]=$i.toHalfFloat(1)},t=new Uint8Array(e);t.pos=0;const r=function(e){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,l={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let c,h;for((e.pos>=e.byteLength||!(c=fgets(e)))&&rgbe_error(1,"no header found"),(h=c.match(/^#\?(\S+)/))||rgbe_error(3,"bad initial token"),l.valid|=1,l.programtype=h[1],l.string+=c+"\n";c=fgets(e),!1!==c;)if(l.string+=c+"\n","#"!==c.charAt(0)){if((h=c.match(t))&&(l.gamma=parseFloat(h[1])),(h=c.match(r))&&(l.exposure=parseFloat(h[1])),(h=c.match(s))&&(l.valid|=2,l.format=h[1]),(h=c.match(o))&&(l.valid|=4,l.height=parseInt(h[1],10),l.width=parseInt(h[2],10)),2&l.valid&&4&l.valid)break}else l.comments+=c+"\n";return 2&l.valid||rgbe_error(3,"missing format specifier"),4&l.valid||rgbe_error(3,"missing image size specifier"),l}(t),s=r.width,o=r.height,l=function(e,t,r){const s=t;if(s<8||s>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);s!==(e[2]<<8|e[3])&&rgbe_error(3,"wrong scanline width");const o=new Uint8Array(4*t*r);o.length||rgbe_error(4,"unable to allocate buffer space");let l=0,c=0;const h=4*s,d=new Uint8Array(4),p=new Uint8Array(h);let A=r;for(;A>0&&c<e.byteLength;){c+4>e.byteLength&&rgbe_error(1),d[0]=e[c++],d[1]=e[c++],d[2]=e[c++],d[3]=e[c++],2==d[0]&&2==d[1]&&(d[2]<<8|d[3])==s||rgbe_error(3,"bad rgbe scanline format");let t,r=0;for(;r<h&&c<e.byteLength;){t=e[c++];const s=t>128;if(s&&(t-=128),(0===t||r+t>h)&&rgbe_error(3,"bad scanline data"),s){const s=e[c++];for(let e=0;e<t;e++)p[r++]=s}else p.set(e.subarray(c,c+t),r),r+=t,c+=t}const m=s;for(let e=0;e<m;e++){let t=0;o[l]=p[e+t],t+=s,o[l+1]=p[e+t],t+=s,o[l+2]=p[e+t],t+=s,o[l+3]=p[e+t],l+=4}A--}return o}(t.subarray(t.pos),s,o);let c,h,d;switch(this.type){case Me:d=l.length/4;const e=new Float32Array(4*d);for(let t=0;t<d;t++)RGBEByteToRGBFloat(l,4*t,e,4*t);c=e,h=Me;break;case Ce:d=l.length/4;const t=new Uint16Array(4*d);for(let e=0;e<d;e++)RGBEByteToRGBHalf(l,4*e,t,4*e);c=t,h=Ce;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:s,height:o,data:c,header:r.string,gamma:r.gamma,exposure:r.exposure,type:h}}setDataType(e){return this.type=e,this}load(e,t,r,s){return super.load(e,(function onLoadCallback(e,r){switch(e.type){case Me:case Ce:e.colorSpace=it,e.minFilter=ge,e.magFilter=ge,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,r)}),r,s)}}const Ph={topLight:{intensity:500,position:[.418,16.199,.3]},room:{position:[-.757,13.219,.717],scale:[31.713,28.305,28.591]},boxes:[{position:[-10.906,2.009,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,.857,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:50,position:[-16.116,14.37,8.208],scale:[.1,2.428,2.739]},{intensity:50,position:[-16.109,18.021,-8.207],scale:[.1,2.425,2.751]},{intensity:17,position:[14.904,12.198,-1.832],scale:[.15,4.265,6.331]},{intensity:43,position:[-.462,8.89,14.52],scale:[4.38,5.441,.088]},{intensity:20,position:[3.235,11.486,-12.541],scale:[2.5,2,.1]},{intensity:100,position:[0,20,0],scale:[1,.1,1]}]},Fh={topLight:{intensity:400,position:[.5,14,.5]},room:{position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-10.906,-1,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,-.16,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:80,position:[-14,10,8],scale:[.1,2.5,2.5]},{intensity:80,position:[-14,14,-4],scale:[.1,2.5,2.5]},{intensity:23,position:[14,12,0],scale:[.1,5,5]},{intensity:16,position:[0,9,14],scale:[5,5,.1]},{intensity:80,position:[7,8,-14],scale:[2.5,2.5,.1]},{intensity:80,position:[-7,16,-14],scale:[2.5,2.5,.1]},{intensity:1,position:[0,20,0],scale:[.1,.1,.1]}]};class EnvironmentScene extends Scene{constructor(e){super(),this.position.y=-3.5;const t=new BoxGeometry;t.deleteAttribute("uv");const r=new MeshStandardMaterial({metalness:0,side:A}),s=new MeshStandardMaterial({metalness:0}),o="legacy"==e?Ph:Fh,l=new PointLight(16777215,o.topLight.intensity,28,2);l.position.set(...o.topLight.position),this.add(l);const c=new three_module_Mesh(t,r);c.position.set(...o.room.position),c.scale.set(...o.room.scale),this.add(c);for(const e of o.boxes){const r=new three_module_Mesh(t,s);r.position.set(...e.position),r.rotation.set(0,e.rotation,0),r.scale.set(...e.scale),this.add(r)}for(const e of o.lights){const r=new three_module_Mesh(t,this.createAreaLightMaterial(e.intensity));r.position.set(...e.position),r.scale.set(...e.scale),this.add(r)}}createAreaLightMaterial(e){const t=new MeshBasicMaterial;return t.color.setScalar(e),t}}var Nh=r(6763);const Oh=20,Qh=/\.hdr(\.js)?$/;class TextureUtils{constructor(e){this.threeRenderer=e,this.lottieLoaderUrl="",this.withCredentials=!1,this._ldrLoader=null,this._imageLoader=null,this._hdrLoader=null,this._lottieLoader=null,this.generatedEnvironmentMap=null,this.generatedEnvironmentMapAlt=null,this.skyboxCache=new Map,this.blurMaterial=null,this.blurScene=null}get ldrLoader(){return null==this._ldrLoader&&(this._ldrLoader=new TextureLoader),this._ldrLoader.setWithCredentials(this.withCredentials),this._ldrLoader}get imageLoader(){return null==this._imageLoader&&(this._imageLoader=new HDRJPGLoader(this.threeRenderer)),this._imageLoader.setWithCredentials(this.withCredentials),this._imageLoader}get hdrLoader(){return null==this._hdrLoader&&(this._hdrLoader=new RGBELoader,this._hdrLoader.setDataType(Ce)),this._hdrLoader.setWithCredentials(this.withCredentials),this._hdrLoader}async getLottieLoader(){if(null==this._lottieLoader){const{LottieLoader:e}=await import(this.lottieLoaderUrl);this._lottieLoader=new e}return this._lottieLoader.setWithCredentials(this.withCredentials),this._lottieLoader}async loadImage(e){const t=await new Promise(((t,r)=>this.ldrLoader.load(e,t,(()=>{}),r)));return t.name=e,t.flipY=!1,t}async loadLottie(e,t){const r=await this.getLottieLoader();r.setQuality(t);const s=await new Promise(((t,s)=>r.load(e,t,(()=>{}),s)));return s.name=e,s}async loadEquirect(e,t=()=>{}){try{const r=Qh.test(e),s=r?this.hdrLoader:this.imageLoader,o=await new Promise(((r,o)=>s.load(e,(e=>{const{renderTarget:t}=e;if(null!=t){const{texture:s}=t;e.dispose(!1),r(s)}else r(e)}),(e=>{t(e.loaded/e.total*.9)}),o)));return t(1),o.name=e,o.mapping=le,r||(o.colorSpace=tt),o}finally{t&&t(1)}}async generateEnvironmentMapAndSkybox(e=null,t=null,r=()=>{}){const s="legacy"!==t;"legacy"!==t&&"neutral"!==t||(t=null),t=deserializeUrl(t);let o,l=Promise.resolve(null);e&&(l=this.loadEquirectFromUrl(e,r)),o=t?this.loadEquirectFromUrl(t,r):e?this.loadEquirectFromUrl(e,r):s?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[c,h]=await Promise.all([o,l]);if(null==c)throw new Error("Failed to load environment map.");return{environmentMap:c,skybox:h}}async loadEquirectFromUrl(e,t){if(!this.skyboxCache.has(e)){const r=this.loadEquirect(e,t);this.skyboxCache.set(e,r)}return this.skyboxCache.get(e)}async GenerateEnvironmentMap(e,t){await((e=0)=>new Promise((t=>setTimeout(t,e))))();const r=this.threeRenderer,s=new WebGLCubeRenderTarget(256,{generateMipmaps:!1,type:Ce,format:we,colorSpace:it,depthBuffer:!0}),o=new CubeCamera(.1,100,s),l=o.renderTarget.texture;l.name=t;const c=r.outputColorSpace,h=r.toneMapping;return r.toneMapping=K,r.outputColorSpace=it,o.update(r,e),this.blurCubemap(s,.04),r.toneMapping=h,r.outputColorSpace=c,l}async loadGeneratedEnvironmentMap(){return null==this.generatedEnvironmentMap&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new EnvironmentScene("legacy"),"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return null==this.generatedEnvironmentMapAlt&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new EnvironmentScene("neutral"),"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(e,t){if(null==this.blurMaterial){this.blurMaterial=this.getBlurShader(Oh);const e=new BoxGeometry,t=new three_module_Mesh(e,this.blurMaterial);this.blurScene=new Scene,this.blurScene.add(t)}const r=e.clone();this.halfblur(e,r,t,"latitudinal"),this.halfblur(r,e,t,"longitudinal")}halfblur(e,t,r,s){const o=e.width,l=isFinite(r)?Math.PI/(2*o):2*Math.PI/39,c=r/l,h=isFinite(r)?1+Math.floor(3*c):Oh;h>Oh&&Nh.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${h} samples when the maximum is set to 20`);const d=[];let p=0;for(let e=0;e<Oh;++e){const t=e/c,r=Math.exp(-t*t/2);d.push(r),0==e?p+=r:e<h&&(p+=2*r)}for(let e=0;e<d.length;e++)d[e]=d[e]/p;const A=this.blurMaterial.uniforms;A.envMap.value=e.texture,A.samples.value=h,A.weights.value=d,A.latitudinal.value="latitudinal"===s,A.dTheta.value=l;new CubeCamera(.1,100,t).update(this.threeRenderer,this.blurScene)}getBlurShader(e){const t=new Float32Array(e),r=new three_module_Vector3(0,1,0);return new ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},poleAxis:{value:r}},vertexShader:"\n \n varying vec3 vOutputDirection;\n \n void main() {\n \n vOutputDirection = vec3( position );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n \n }\n ",fragmentShader:"\n varying vec3 vOutputDirection;\n \n uniform samplerCube envMap;\n uniform int samples;\n uniform float weights[ n ];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform vec3 poleAxis;\n \n vec3 getSample( float theta, vec3 axis ) {\n \n float cosTheta = cos( theta );\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross( axis, vOutputDirection ) * sin( theta )\n + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n \n return vec3( textureCube( envMap, sampleDirection ) );\n \n }\n \n void main() {\n \n vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n \n if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n \n axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n \n }\n \n axis = normalize( axis );\n \n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n \n for ( int i = 1; i < n; i++ ) {\n \n if ( i >= samples ) {\n \n break;\n \n }\n \n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n \n }\n }\n ",blending:0,depthTest:!1,depthWrite:!1,side:A})}async dispose(){for(const[,e]of this.skyboxCache){(await e).dispose()}null!=this.generatedEnvironmentMap&&((await this.generatedEnvironmentMap).dispose(),this.generatedEnvironmentMap=null),null!=this.generatedEnvironmentMapAlt&&((await this.generatedEnvironmentMapAlt).dispose(),this.generatedEnvironmentMapAlt=null),null!=this.blurMaterial&&this.blurMaterial.dispose()}}var kh=r(6763);const Gh=[1,.79,.62,.5,.4,.31,.25],Vh="high-performance";class Renderer extends EventDispatcher{constructor(e){super(),this.loader=new CachingGLTFLoader(ModelViewerGLTFInstance),this.width=0,this.height=0,this.dpr=1,this.scenes=new Set,this.multipleScenesVisible=!1,this.lastTick=performance.now(),this.renderedLastFrame=!1,this.scaleStep=0,this.lastStep=3,this.avgFrameDuration=50,this.onWebGLContextLost=e=>{this.dispatchEvent({type:"contextlost",sourceEvent:e})},this.onWebGLContextRestored=()=>{var e;null===(e=this.textureUtils)||void 0===e||e.dispose(),this.textureUtils=new TextureUtils(this.threeRenderer);for(const e of this.scenes)e.element[_a]()},this.dpr=Aa(),this.canvas3D=document.createElement("canvas"),this.canvas3D.id="webgl-canvas",this.canvas3D.classList.add("show"),Dn.tonemapping_pars_fragment=Dn.tonemapping_pars_fragment.replace("vec3 CustomToneMapping( vec3 color ) { return color; }","\n float startCompression = 0.8 - 0.04;\n float desaturation = 0.15;\n vec3 CustomToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n\n float x = min(color.r, min(color.g, color.b));\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n\n float peak = max(color.r, max(color.g, color.b));\n if (peak < startCompression) return color;\n\n float d = 1. - startCompression;\n float newPeak = 1. - d * d / (peak + d - startCompression);\n color *= newPeak / peak;\n\n float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n return mix(color, vec3(1, 1, 1), g);\n }");try{this.threeRenderer=new WebGLRenderer({canvas:this.canvas3D,alpha:!0,antialias:!0,powerPreference:e.powerPreference,preserveDrawingBuffer:!0}),this.threeRenderer.autoClear=!0,this.threeRenderer.setPixelRatio(1),this.threeRenderer.debug={checkShaderErrors:!!e.debug,onShaderError:null},this.threeRenderer.toneMapping=te}catch(e){kh.warn(e)}this.arRenderer=new ARRenderer(this),this.textureUtils=this.canRender?new TextureUtils(this.threeRenderer):null,CachingGLTFLoader.initializeKTX2Loader(this.threeRenderer),this.canvas3D.addEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.addEventListener("webglcontextrestored",this.onWebGLContextRestored),this.updateRendererSize()}static get singleton(){return this._singleton}static resetSingleton(){const e=this._singleton.dispose();for(const t of e)t.disconnectedCallback();this._singleton=new Renderer({powerPreference:(self.ModelViewerElement||{}).powerPreference||Vh,debug:ma()});for(const t of e)t.connectedCallback()}get canRender(){return null!=this.threeRenderer}get scaleFactor(){return Gh[this.scaleStep]}set minScale(e){let t=1;for(;t<Gh.length&&!(Gh[t]<e);)++t;this.lastStep=t-1}registerScene(e){this.scenes.add(e),e.forceRescale();const t=new Vector2;this.threeRenderer.getSize(t),e.canvas.width=t.x,e.canvas.height=t.y,this.canRender&&this.scenes.size>0&&this.threeRenderer.setAnimationLoop(((e,t)=>this.render(e,t)))}unregisterScene(e){this.scenes.delete(e),this.canvas3D.parentElement===e.canvas.parentElement&&e.canvas.parentElement.removeChild(this.canvas3D),this.canRender&&0===this.scenes.size&&this.threeRenderer.setAnimationLoop(null)}displayCanvas(e){return this.multipleScenesVisible?e.element[mp]:this.canvas3D}countVisibleScenes(){const{canvas3D:e}=this;let t=0,r=null;for(const s of this.scenes){const{element:o}=s;o.modelIsVisible&&null==s.externalRenderer&&++t,e.parentElement===s.canvas.parentElement&&(r=s)}const s=t>1;if(null!=r){const t=s&&!this.multipleScenesVisible,o=!r.element.modelIsVisible;if(t||o){const{width:t,height:s}=this.sceneSize(r);this.copyPixels(r,t,s),e.parentElement.removeChild(e)}}this.multipleScenesVisible=s}updateRendererSize(){var e;const t=Aa();if(t!==this.dpr)for(const e of this.scenes){const{element:t}=e;t[ip](t.getBoundingClientRect())}let r=0,s=0;for(const e of this.scenes)r=Math.max(r,e.width),s=Math.max(s,e.height);if(r!==this.width||s!==this.height||t!==this.dpr){this.width=r,this.height=s,this.dpr=t,r=Math.ceil(r*t),s=Math.ceil(s*t),this.canRender&&this.threeRenderer.setSize(r,s,!1);for(const t of this.scenes){const{canvas:o}=t;o.width=r,o.height=s,t.forceRescale(),null===(e=t.effectRenderer)||void 0===e||e.setSize(r,s)}}}updateRendererScale(e){const t=this.scaleStep;this.avgFrameDuration+=utilities_clamp(.2*(e-this.avgFrameDuration),-5,5),this.avgFrameDuration>60?++this.scaleStep:this.avgFrameDuration<40&&this.scaleStep>0&&--this.scaleStep,this.scaleStep=Math.min(this.scaleStep,this.lastStep),t!==this.scaleStep&&(this.avgFrameDuration=50)}shouldRender(e){if(e.shouldRender())e.scaleStep!=this.scaleStep&&(e.scaleStep=this.scaleStep,this.rescaleCanvas(e));else{if(0==e.scaleStep)return!1;e.scaleStep=0,this.rescaleCanvas(e)}return!0}rescaleCanvas(e){const t=Gh[e.scaleStep],r=Math.ceil(this.width/t),s=Math.ceil(this.height/t),{style:o}=e.canvas;o.width=`${r}px`,o.height=`${s}px`,this.canvas3D.style.width=`${r}px`,this.canvas3D.style.height=`${s}px`;const l=this.dpr*t,c=t<1?"GPU throttling":this.dpr!==window.devicePixelRatio?"No meta viewport tag":"";e.element.dispatchEvent(new CustomEvent("render-scale",{detail:{reportedDpr:window.devicePixelRatio,renderedDpr:l,minimumDpr:this.dpr*Gh[this.lastStep],pixelWidth:Math.ceil(e.width*l),pixelHeight:Math.ceil(e.height*l),reason:c}}))}sceneSize(e){const{dpr:t}=this,r=Gh[e.scaleStep];return{width:Math.min(Math.ceil(e.width*r*t),this.canvas3D.width),height:Math.min(Math.ceil(e.height*r*t),this.canvas3D.height)}}copyPixels(e,t,r){const s=e.context;null!=s?(s.clearRect(0,0,t,r),s.drawImage(this.canvas3D,0,0,t,r,0,0,t,r),e.canvas.classList.add("show")):kh.log("could not acquire 2d context")}orderedScenes(){const e=[];for(const t of[!1,!0])for(const r of this.scenes)r.element.modelIsVisible===t&&e.push(r);return e}get isPresenting(){return this.arRenderer.isPresenting}preRender(e,t,r){const{element:s,exposure:o,toneMapping:l}=e;s[_p](t,r);const c="number"==typeof o&&!Number.isNaN(o),h=s.environmentImage,d=s.skyboxImage,p=l===ie&&("neutral"===h||"legacy"===h||!h&&!d);this.threeRenderer.toneMappingExposure=(c?o:1)*(p?1.3:1)}render(e,t){if(null!=t)return void this.arRenderer.onWebXRFrame(e,t);const r=e-this.lastTick;if(this.lastTick=e,!this.canRender||this.isPresenting)return;this.countVisibleScenes(),this.updateRendererSize(),this.renderedLastFrame&&(this.updateRendererScale(r),this.renderedLastFrame=!1);const{canvas3D:s}=this;for(const t of this.orderedScenes()){const{element:o}=t;if(!o.loaded||!o.modelIsVisible&&t.renderCount>0)continue;if(this.preRender(t,e,r),!this.shouldRender(t))continue;if(null!=t.externalRenderer){const e=t.getCamera();e.updateMatrix();const{matrix:r,projectionMatrix:s}=e,o=r.elements.slice(),l=t.getTarget();o[12]+=l.x,o[13]+=l.y,o[14]+=l.z,t.externalRenderer.render({viewMatrix:o,projectionMatrix:s.elements});continue}if(!o.modelIsVisible&&!this.multipleScenesVisible)for(const e of this.scenes)e.element.modelIsVisible&&e.queueRender();const{width:l,height:c}=this.sceneSize(t);t.renderShadow(this.threeRenderer),this.threeRenderer.setRenderTarget(null),this.threeRenderer.setViewport(0,Math.ceil(this.height*this.dpr)-c,l,c),null!=t.effectRenderer?t.effectRenderer.render(r):(this.threeRenderer.autoClear=!0,this.threeRenderer.toneMapping=t.toneMapping,this.threeRenderer.render(t,t.camera)),this.multipleScenesVisible||!t.element.modelIsVisible&&0===t.renderCount?this.copyPixels(t,l,c):s.parentElement!==t.canvas.parentElement&&(t.canvas.parentElement.appendChild(s),t.canvas.classList.remove("show")),t.hasRendered(),++t.renderCount,this.renderedLastFrame=!0}}dispose(){null!=this.textureUtils&&this.textureUtils.dispose(),null!=this.threeRenderer&&this.threeRenderer.dispose(),this.textureUtils=null,this.threeRenderer=null;const e=[];for(const t of this.scenes)e.push(t.element);return this.canvas3D.removeEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.removeEventListener("webglcontextrestored",this.onWebGLContextRestored),e}}Renderer._singleton=new Renderer({powerPreference:(self.ModelViewerElement||{}).powerPreference||Vh,debug:ma()});const Hh=Symbol("correlatedObjects"),zh=Symbol("onUpdate");class ThreeDOMElement{constructor(e,t=null){this[zh]=e,this[Hh]=t}}const Wh=new MeshBasicMaterial,qh=new PlaneGeometry(2,2);let jh=0;const Xh=Symbol("threeTexture"),Yh=Symbol("threeTextures");Symbol("applyTexture");class image_Image extends ThreeDOMElement{get[Xh](){var e;return null===(e=this[Hh])||void 0===e?void 0:e.values().next().value}get[Yh](){return this[Hh]}constructor(e,t){super(e,new Set(t?[t]:[])),this[Xh].image.src||(this[Xh].image.src=t.name?t.name:"adhoc_image"+jh++),this[Xh].image.name||(this[Xh].image.name=t&&t.image&&t.image.src?t.image.src.split("/").pop():"adhoc_image")}get name(){return this[Xh].image.name||""}get uri(){return this[Xh].image.src}get bufferView(){return this[Xh].image.bufferView}get element(){const e=this[Xh];if(e&&(e.isCanvasTexture||e.isVideoTexture))return e.image}get animation(){const e=this[Xh];if(e&&e.isCanvasTexture&&e.animation)return e.animation}get type(){return null!=this.uri?"external":"embedded"}set name(e){for(const t of this[Yh])t.image.name=e}update(){const e=this[Xh];e&&e.isCanvasTexture&&!e.animation&&(this[Xh].needsUpdate=!0,this[zh]())}async createThumbnail(e,t){const r=new Scene;Wh.map=this[Xh];const s=new three_module_Mesh(qh,Wh);r.add(s);const o=new OrthographicCamera(-1,1,1,-1,0,1),{threeRenderer:l}=Renderer.singleton,c=new WebGLRenderTarget(e,t);l.setRenderTarget(c),l.render(r,o),l.setRenderTarget(null);const h=new Uint8Array(e*t*4);l.readRenderTargetPixels(c,0,0,e,t,h),qd.width=e,qd.height=t;const d=qd.getContext("2d"),p=d.createImageData(e,t);return p.data.set(h),d.putImageData(p,0,0),new Promise((async(e,t)=>{qd.toBlob((r=>{if(!r)return t("Failed to capture thumbnail.");e(URL.createObjectURL(r))}),"image/png")}))}}var Kh,Jh;!function(e){e[e.Nearest=9728]="Nearest",e[e.Linear=9729]="Linear",e[e.NearestMipmapNearest=9984]="NearestMipmapNearest",e[e.LinearMipmapNearest=9985]="LinearMipmapNearest",e[e.NearestMipmapLinear=9986]="NearestMipmapLinear",e[e.LinearMipmapLinear=9987]="LinearMipmapLinear"}(Kh||(Kh={})),function(e){e[e.ClampToEdge=33071]="ClampToEdge",e[e.MirroredRepeat=33648]="MirroredRepeat",e[e.Repeat=10497]="Repeat"}(Jh||(Jh={}));const $h=new Map([[Jh.Repeat,ue],[Jh.ClampToEdge,de],[Jh.MirroredRepeat,pe]]),Zh=new Map([[ue,Jh.Repeat],[de,Jh.ClampToEdge],[pe,Jh.MirroredRepeat]]),eu=new Map([[Kh.Nearest,Ae],[Kh.Linear,ge],[Kh.NearestMipmapNearest,me],[Kh.LinearMipmapNearest,_e],[Kh.NearestMipmapLinear,fe],[Kh.LinearMipmapLinear,ve]]),tu=new Map([[Ae,Kh.Nearest],[ge,Kh.Linear],[me,Kh.NearestMipmapNearest],[_e,Kh.LinearMipmapNearest],[fe,Kh.NearestMipmapLinear],[ve,Kh.LinearMipmapLinear]]),iu=new Map([[Kh.Nearest,Ae],[Kh.Linear,ge]]),nu=new Map([[Ae,Kh.Nearest],[ge,Kh.Linear]]),isMinFilter=e=>tu.has(e),isMagFilter=e=>nu.has(e),isWrapping=e=>Zh.has(e),ru=Symbol("threeTexture"),su=Symbol("threeTextures"),au=Symbol("setProperty");class Sampler extends ThreeDOMElement{get[ru](){var e;return null===(e=this[Hh])||void 0===e?void 0:e.values().next().value}get[su](){return this[Hh]}constructor(e,t){super(e,new Set(t?[t]:[]))}get name(){return this[ru].name||""}get minFilter(){return tu.get(this[ru].minFilter)}get magFilter(){return nu.get(this[ru].magFilter)}get wrapS(){return Zh.get(this[ru].wrapS)}get wrapT(){return Zh.get(this[ru].wrapT)}get rotation(){return this[ru].rotation}get scale(){return toVector2D(this[ru].repeat)}get offset(){return toVector2D(this[ru].offset)}setMinFilter(e){this[au]("minFilter",eu.get(e))}setMagFilter(e){this[au]("magFilter",iu.get(e))}setWrapS(e){this[au]("wrapS",$h.get(e))}setWrapT(e){this[au]("wrapT",$h.get(e))}setRotation(e){null==e&&(e=0),this[au]("rotation",e)}setScale(e){null==e&&(e={u:1,v:1}),this[au]("repeat",new Vector2(e.u,e.v))}setOffset(e){null==e&&(e={u:0,v:0}),this[au]("offset",new Vector2(e.u,e.v))}[au](e,t){if(((e,t)=>{switch(e){case"minFilter":return isMinFilter(t);case"magFilter":return isMagFilter(t);case"wrapS":case"wrapT":return isWrapping(t);case"rotation":case"repeat":case"offset":return!0;default:throw new Error(`Cannot configure property "${e}" on Sampler`)}})(e,t))for(const r of this[su])r[e]=t,r.needsUpdate=!0;this[zh]()}}const ou=Symbol("image"),lu=Symbol("sampler"),cu=Symbol("threeTexture");class texture_Texture extends ThreeDOMElement{constructor(e,t){super(e,new Set(t?[t]:[])),this[lu]=new Sampler(e,t),this[ou]=new image_Image(e,t)}get[cu](){var e;return null===(e=this[Hh])||void 0===e?void 0:e.values().next().value}get name(){return this[cu].name||""}set name(e){for(const t of this[Hh])t.name=e}get sampler(){return this[lu]}get source(){return this[ou]}}var hu,uu,du;const pu=Symbol("texture"),Au=Symbol("transform"),mu=Symbol("materials"),fu=Symbol("usage"),gu=Symbol("onUpdate"),_u=Symbol("activeVideo");var vu;!function(e){e[e.Base=0]="Base",e[e.MetallicRoughness=1]="MetallicRoughness",e[e.Normal=2]="Normal",e[e.Occlusion=3]="Occlusion",e[e.Emissive=4]="Emissive",e[e.Clearcoat=5]="Clearcoat",e[e.ClearcoatRoughness=6]="ClearcoatRoughness",e[e.ClearcoatNormal=7]="ClearcoatNormal",e[e.SheenColor=8]="SheenColor",e[e.SheenRoughness=9]="SheenRoughness",e[e.Transmission=10]="Transmission",e[e.Thickness=11]="Thickness",e[e.Specular=12]="Specular",e[e.SpecularColor=13]="SpecularColor",e[e.Iridescence=14]="Iridescence",e[e.IridescenceThickness=15]="IridescenceThickness",e[e.Anisotropy=16]="Anisotropy"}(vu||(vu={}));class TextureInfo{constructor(e,t,r,s){this[hu]=null,this[uu]={rotation:0,scale:new Vector2(1,1),offset:new Vector2(0,0)},this[du]=!1,r&&(this[Au].rotation=r.rotation,this[Au].scale.copy(r.repeat),this[Au].offset.copy(r.offset),this[pu]=new texture_Texture(e,r)),this[gu]=e,this[mu]=s,this[fu]=t}get texture(){return this[pu]}setTexture(e){var t,r;const s=null!=e?e.source[Xh]:null,o=null===(t=this[pu])||void 0===t?void 0:t.source[Xh];if(null!=o&&o.isVideoTexture?this[_u]=!1:(null===(r=this[pu])||void 0===r?void 0:r.source.animation)&&this[pu].source.animation.removeEventListener("enterFrame",this[gu]),this[pu]=e,null!=s&&s.isVideoTexture){const e=s.image;if(this[_u]=!0,null!=e.requestVideoFrameCallback){const update=()=>{this[_u]&&(this[gu](),e.requestVideoFrameCallback(update))};e.requestVideoFrameCallback(update)}else{const update=()=>{this[_u]&&(this[gu](),requestAnimationFrame(update))};requestAnimationFrame(update)}}else null!=(null==e?void 0:e.source.animation)&&e.source.animation.addEventListener("enterFrame",this[gu]);let l=tt;if(this[mu])for(const e of this[mu]){switch(this[fu]){case vu.Base:e.map=s;break;case vu.MetallicRoughness:l=it,e.metalnessMap=s,e.roughnessMap=s;break;case vu.Normal:l=it,e.normalMap=s;break;case vu.Occlusion:l=it,e.aoMap=s;break;case vu.Emissive:e.emissiveMap=s;break;case vu.Clearcoat:e.clearcoatMap=s;break;case vu.ClearcoatRoughness:e.clearcoatRoughnessMap=s;break;case vu.ClearcoatNormal:e.clearcoatNormalMap=s;break;case vu.SheenColor:e.sheenColorMap=s;break;case vu.SheenRoughness:e.sheenRoughnessMap=s;break;case vu.Transmission:e.transmissionMap=s;break;case vu.Thickness:e.thicknessMap=s;break;case vu.Specular:e.specularIntensityMap=s;break;case vu.SpecularColor:e.specularColorMap=s;break;case vu.Iridescence:e.iridescenceMap=s;break;case vu.IridescenceThickness:e.iridescenceThicknessMap=s;break;case vu.Anisotropy:e.anisotropyMap=s}e.needsUpdate=!0}s&&(s.colorSpace=l,s.rotation=this[Au].rotation,s.repeat=this[Au].scale,s.offset=this[Au].offset),this[gu]()}}hu=pu,uu=Au,du=_u;const yu=Symbol("threeMaterial"),Eu=Symbol("threeMaterials"),xu=Symbol("baseColorTexture"),Su=Symbol("metallicRoughnessTexture");class PBRMetallicRoughness extends ThreeDOMElement{constructor(e,t){super(e,t);const{map:r,metalnessMap:s}=t.values().next().value;this[xu]=new TextureInfo(e,vu.Base,r,t),this[Su]=new TextureInfo(e,vu.MetallicRoughness,s,t)}get[Eu](){return this[Hh]}get[yu](){var e;return null===(e=this[Hh])||void 0===e?void 0:e.values().next().value}get baseColorFactor(){const e=[0,0,0,this[yu].opacity];return this[yu].color.toArray(e),e}get metallicFactor(){return this[yu].metalness}get roughnessFactor(){return this[yu].roughness}get baseColorTexture(){return this[xu]}get metallicRoughnessTexture(){return this[Su]}setBaseColorFactor(e){const t=new Color;e instanceof Array?t.fromArray(e):t.set(e);for(const r of this[Eu])r.color.set(t),e instanceof Array?r.opacity=e[3]:(e=[0,0,0,r.opacity],t.toArray(e));this[zh]()}setMetallicFactor(e){for(const t of this[Eu])t.metalness=e;this[zh]()}setRoughnessFactor(e){for(const t of this[Eu])t.roughness=e;this[zh]()}}var Mu,Cu;const bu=Symbol("pbrMetallicRoughness"),wu=Symbol("normalTexture"),Iu=Symbol("occlusionTexture"),Tu=Symbol("emissiveTexture"),Bu=Symbol("backingThreeMaterial"),Ru=Symbol("applyAlphaCutoff"),Lu=Symbol("getAlphaMode"),Du=Symbol("lazyLoadGLTFInfo"),Uu=Symbol("initialize"),Pu=Symbol("getLoadedMaterial"),Fu=Symbol("ensureMaterialIsLoaded"),Nu=Symbol("gltfIndex"),Ou=Symbol("setActive"),Qu=Symbol("variantIndices"),ku=Symbol("isActive"),Gu=Symbol("variantSet"),Vu=Symbol("modelVariants"),Hu=Symbol("name"),zu=Symbol("pbrTextures");class material_Material extends ThreeDOMElement{constructor(e,t,r,s,o,l,c=void 0){super(e,o),this[Mu]=new Set,this[Cu]=new Map,this[Nu]=t,this[ku]=r,this[Vu]=s,this[Hu]=l,null==c?this[Uu]():this[Du]=c}get[(Mu=Gu,Cu=zu,Bu)](){return this[Hh].values().next().value}[Uu](){const e=this[zh],t=this[Hh];this[bu]=new PBRMetallicRoughness(e,t);const{normalMap:r,aoMap:s,emissiveMap:o}=t.values().next().value;this[wu]=new TextureInfo(e,vu.Normal,r,t),this[Iu]=new TextureInfo(e,vu.Occlusion,s,t),this[Tu]=new TextureInfo(e,vu.Emissive,o,t);const createTextureInfo=r=>{this[zu].set(r,new TextureInfo(e,r,null,t))};createTextureInfo(vu.Clearcoat),createTextureInfo(vu.ClearcoatRoughness),createTextureInfo(vu.ClearcoatNormal),createTextureInfo(vu.SheenColor),createTextureInfo(vu.SheenRoughness),createTextureInfo(vu.Transmission),createTextureInfo(vu.Thickness),createTextureInfo(vu.Specular),createTextureInfo(vu.SpecularColor),createTextureInfo(vu.Iridescence),createTextureInfo(vu.IridescenceThickness),createTextureInfo(vu.Anisotropy)}async[Pu](){if(null!=this[Du]){const{set:e,material:t}=await this[Du].doLazyLoad();return this[Hh]=e,this[Uu](),this[Du]=void 0,this.ensureLoaded=async()=>{},t}return this[Hh].values().next().value}colorFromRgb(e){const t=new Color;return e instanceof Array?t.fromArray(e):t.set(e),t}[Fu](){if(null!=this[Du])throw new Error(`Material "${this.name}" has not been loaded, call 'await\n myMaterial.ensureLoaded()' before using an unloaded material.`)}async ensureLoaded(){await this[Pu]()}get isLoaded(){return null==this[Du]}get isActive(){return this[ku]}[Ou](e){this[ku]=e}get name(){return this[Hu]||""}set name(e){if(this[Hu]=e,null!=this[Hh])for(const t of this[Hh])t.name=e}get pbrMetallicRoughness(){return this[Fu](),this[bu]}get normalTexture(){return this[Fu](),this[wu]}get occlusionTexture(){return this[Fu](),this[Iu]}get emissiveTexture(){return this[Fu](),this[Tu]}get emissiveFactor(){return this[Fu](),this[Bu].emissive.toArray()}get index(){return this[Nu]}[Qu](){return this[Gu]}hasVariant(e){const t=this[Vu].get(e);return null!=t&&this[Gu].has(t.index)}setEmissiveFactor(e){this[Fu]();const t=this.colorFromRgb(e);for(const e of this[Hh])e.emissive.set(t);this[zh]()}[Lu](){return this[Bu].transparent?"BLEND":this[Bu].alphaTest>0?"MASK":"OPAQUE"}[Ru](){this[Fu]();for(const e of this[Hh])"MASK"===this[Lu]()?null==e.alphaTest&&(e.alphaTest=.5):e.alphaTest=void 0,e.needsUpdate=!0}setAlphaCutoff(e){this[Fu]();for(const t of this[Hh])t.alphaTest=e,t.needsUpdate=!0;this[Ru](),this[zh]()}getAlphaCutoff(){return this[Fu](),this[Bu].alphaTest}setDoubleSided(e){this[Fu]();for(const t of this[Hh])t.side=e?m:p,t.needsUpdate=!0;this[zh]()}getDoubleSided(){return this[Fu](),this[Bu].side==m}setAlphaMode(e){this[Fu]();const enableTransparency=(e,t)=>{e.transparent=t,e.depthWrite=!t};for(const t of this[Hh])enableTransparency(t,"BLEND"===e),t.alphaTest="MASK"===e?.5:void 0,t.needsUpdate=!0;this[zh]()}getAlphaMode(){return this[Fu](),this[Lu]()}get emissiveStrength(){return this[Fu](),this[Bu].emissiveIntensity}setEmissiveStrength(e){this[Fu]();for(const t of this[Hh])t.emissiveIntensity=e;this[zh]()}get clearcoatFactor(){return this[Fu](),this[Bu].clearcoat}get clearcoatRoughnessFactor(){return this[Fu](),this[Bu].clearcoatRoughness}get clearcoatTexture(){return this[Fu](),this[zu].get(vu.Clearcoat)}get clearcoatRoughnessTexture(){return this[Fu](),this[zu].get(vu.ClearcoatRoughness)}get clearcoatNormalTexture(){return this[Fu](),this[zu].get(vu.ClearcoatNormal)}get clearcoatNormalScale(){return this[Fu](),this[Bu].clearcoatNormalScale.x}setClearcoatFactor(e){this[Fu]();for(const t of this[Hh])t.clearcoat=e;this[zh]()}setClearcoatRoughnessFactor(e){this[Fu]();for(const t of this[Hh])t.clearcoatRoughness=e;this[zh]()}setClearcoatNormalScale(e){this[Fu]();for(const t of this[Hh])t.clearcoatNormalScale=new Vector2(e,e);this[zh]()}get ior(){return this[Fu](),this[Bu].ior}setIor(e){this[Fu]();for(const t of this[Hh])t.ior=e;this[zh]()}get sheenColorFactor(){return this[Fu](),this[Bu].sheenColor.toArray()}get sheenColorTexture(){return this[Fu](),this[zu].get(vu.SheenColor)}get sheenRoughnessFactor(){return this[Fu](),this[Bu].sheenRoughness}get sheenRoughnessTexture(){return this[Fu](),this[zu].get(vu.SheenRoughness)}setSheenColorFactor(e){this[Fu]();const t=this.colorFromRgb(e);for(const e of this[Hh])e.sheenColor.set(t),e.sheen=1;this[zh]()}setSheenRoughnessFactor(e){this[Fu]();for(const t of this[Hh])t.sheenRoughness=e,t.sheen=1;this[zh]()}get transmissionFactor(){return this[Fu](),this[Bu].transmission}get transmissionTexture(){return this[Fu](),this[zu].get(vu.Transmission)}setTransmissionFactor(e){this[Fu]();for(const t of this[Hh])t.transmission=e;this[zh]()}get thicknessFactor(){return this[Fu](),this[Bu].thickness}get thicknessTexture(){return this[Fu](),this[zu].get(vu.Thickness)}get attenuationDistance(){return this[Fu](),this[Bu].attenuationDistance}get attenuationColor(){return this[Fu](),this[Bu].attenuationColor.toArray()}setThicknessFactor(e){this[Fu]();for(const t of this[Hh])t.thickness=e;this[zh]()}setAttenuationDistance(e){this[Fu]();for(const t of this[Hh])t.attenuationDistance=e;this[zh]()}setAttenuationColor(e){this[Fu]();const t=this.colorFromRgb(e);for(const e of this[Hh])e.attenuationColor.set(t);this[zh]()}get specularFactor(){return this[Fu](),this[Bu].specularIntensity}get specularTexture(){return this[Fu](),this[zu].get(vu.Specular)}get specularColorFactor(){return this[Fu](),this[Bu].specularColor.toArray()}get specularColorTexture(){return this[Fu](),this[zu].get(vu.SheenColor)}setSpecularFactor(e){this[Fu]();for(const t of this[Hh])t.specularIntensity=e;this[zh]()}setSpecularColorFactor(e){this[Fu]();const t=this.colorFromRgb(e);for(const e of this[Hh])e.specularColor.set(t);this[zh]()}get iridescenceFactor(){return this[Fu](),this[Bu].iridescence}get iridescenceTexture(){return this[Fu](),this[zu].get(vu.Iridescence)}get iridescenceIor(){return this[Fu](),this[Bu].iridescenceIOR}get iridescenceThicknessMinimum(){return this[Fu](),this[Bu].iridescenceThicknessRange[0]}get iridescenceThicknessMaximum(){return this[Fu](),this[Bu].iridescenceThicknessRange[1]}get iridescenceThicknessTexture(){return this[Fu](),this[zu].get(vu.IridescenceThickness)}setIridescenceFactor(e){this[Fu]();for(const t of this[Hh])t.iridescence=e;this[zh]()}setIridescenceIor(e){this[Fu]();for(const t of this[Hh])t.iridescenceIOR=e;this[zh]()}setIridescenceThicknessMinimum(e){this[Fu]();for(const t of this[Hh])t.iridescenceThicknessRange[0]=e;this[zh]()}setIridescenceThicknessMaximum(e){this[Fu]();for(const t of this[Hh])t.iridescenceThicknessRange[1]=e;this[zh]()}get anisotropyStrength(){return this[Fu](),this[Bu].anisotropy}get anisotropyRotation(){return this[Fu](),this[Bu].anisotropyRotation}get anisotropyTexture(){return this[Fu](),this[zu].get(vu.Anisotropy)}setAnisotropyStrength(e){this[Fu]();for(const t of this[Hh])t.anisotropy=e;this[zh]()}setAnisotropyRotation(e){this[Fu]();for(const t of this[Hh])t.anisotropyRotation=e;this[zh]()}}var Wu=r(6763);class primitive_node_Node{constructor(e){this.name="",this.children=new Array,this.name=e}}class PrimitiveNode extends primitive_node_Node{constructor(e,t,r,s){super(e.name),this.materials=new Map,this.variantToMaterialMap=new Map,this.initialMaterialIdx=0,this.activeMaterialIdx=0,this.mesh=e;const{gltf:o,threeGLTF:l,threeObjectMap:c}=s;this.parser=l.parser,this.modelVariants=r,this.mesh.userData.variantData=r;const h=c.get(e.material);null!=h.materials?this.initialMaterialIdx=this.activeMaterialIdx=h.materials:Wu.error(`Primitive (${e.name}) missing initial material reference.`);const d=e.userData.associations||{};if(null==d.meshes)return void Wu.error("Mesh is missing primitive index association");const p=((o.meshes||[])[d.meshes].primitives||[])[d.primitives];if(null!=p){if(null!=p.material)this.materials.set(p.material,t[p.material]);else{const e=t.findIndex((e=>"Default"===e.name));e>=0?this.materials.set(e,t[e]):Wu.warn("gltfPrimitive has no material!")}if(p.extensions&&p.extensions.KHR_materials_variants){const e=p.extensions.KHR_materials_variants,s=l.parser.json.extensions.KHR_materials_variants.variants;for(const o of e.mappings){const e=t[o.material];this.materials.set(o.material,e);for(const t of o.variants){const{name:o}=s[t];this.variantToMaterialMap.set(t,e),e[Qu]().add(t),r.has(o)||r.set(o,{name:o,index:t})}}}}else Wu.error("Mesh primitive definition is missing.")}async setActiveMaterial(e){const t=this.materials.get(e);if(null!=t&&e!==this.activeMaterialIdx){this.mesh.material=await t[Pu]();const{normalScale:r}=this.mesh.material;null!=r&&r.y*r.x<0!=(null==this.mesh.geometry.attributes.tangent)&&this.parser.assignFinalMaterial(this.mesh),this.activeMaterialIdx=e}return this.mesh.material}getActiveMaterial(){return this.materials.get(this.activeMaterialIdx)}getMaterial(e){return this.materials.get(e)}async enableVariant(e){if(null==e)return this.setActiveMaterial(this.initialMaterialIdx);if(null!=this.variantToMaterialMap&&this.modelVariants.has(e)){const t=this.modelVariants.get(e);return this.enableVariantHelper(t.index)}return null}async enableVariantHelper(e){if(null!=this.variantToMaterialMap&&null!=e){const t=this.variantToMaterialMap.get(e);if(null!=t)return this.setActiveMaterial(t.index)}return null}async instantiateVariants(){if(null!=this.variantToMaterialMap)for(const e of this.variantToMaterialMap.keys()){const t=this.mesh.userData.variantMaterials.get(e);if(null!=t.material)continue;const r=await this.enableVariantHelper(e);null!=r&&(t.material=r)}}get variantInfo(){return this.variantToMaterialMap}addVariant(e,t){if(!this.ensureVariantIsUnused(t))return!1;this.modelVariants.has(t)||this.modelVariants.set(t,{name:t,index:this.modelVariants.size});const r=this.modelVariants.get(t).index;return e[Qu]().add(r),this.variantToMaterialMap.set(r,e),this.materials.set(e.index,e),this.updateVariantUserData(r,e),!0}deleteVariant(e){if(this.variantInfo.has(e)){this.variantInfo.delete(e);const t=this.mesh.userData.variantMaterials;null!=t&&t.delete(e)}}updateVariantUserData(e,t){t[Qu]().add(e),this.mesh.userData.variantData=this.modelVariants,this.mesh.userData.variantMaterials=this.mesh.userData.variantMaterials||new Map;this.mesh.userData.variantMaterials.set(e,{material:t[Hh].values().next().value,gltfMaterialIndex:t.index})}ensureVariantIsUnused(e){const t=this.modelVariants.get(e);return null==t||!this.variantInfo.has(t.index)||(Wu.warn(`Primitive cannot add variant '${e}' for this material, it already exists.`),!1)}}var qu,ju,Xu,Yu,Ku,Ju,$u=r(6763);const Zu=Symbol("materials"),ed=Symbol("hierarchy"),td=Symbol("roots"),id=Symbol("primitives"),nd=(Symbol("loadVariant"),Symbol("prepareVariantsForExport")),rd=Symbol("switchVariant"),sd=Symbol("materialFromPoint"),ad=Symbol("nodeFromPoint"),od=Symbol("nodeFromIndex"),ld=Symbol("variantData"),cd=Symbol("availableVariants"),hd=Symbol("modelOnUpdate"),ud=Symbol("cloneMaterial");class LazyLoader{constructor(e,t,r,s){this.gltf=e,this.gltfElementMap=t,this.mapKey=r,this.doLazyLoad=s}}class Model{constructor(e,t=()=>{}){this[qu]=new Array,this[ju]=new Array,this[Xu]=new Array,this[Yu]=new Array,this[Ku]=()=>{},this[Ju]=new Map,this[hd]=t;const{gltf:r,threeGLTF:s,gltfElementMap:o}=e;for(const[e,l]of r.materials.entries()){const c=o.get(l);if(null!=c)this[Zu].push(new material_Material(t,e,!0,this[ld],c,l.name));else{const h=(r.materials||[])[e],d=e,materialLoadCallback=async()=>{const e=await s.parser.getDependency("material",d),t=new Set;return o.set(h,t),t.add(e),{set:t,material:e}};this[Zu].push(new material_Material(t,e,!1,this[ld],c,l.name,new LazyLoader(r,o,h,materialLoadCallback)))}}const l=new Map,c=new Array;for(const e of s.scene.children)c.push(e);for(;c.length>0;){const t=c.pop();let r=null;t instanceof three_module_Mesh?(r=new PrimitiveNode(t,this.materials,this[ld],e),this[id].push(r)):r=new primitive_node_Node(t.name);const s=l.get(t);null!=s?s.children.push(r):this[td].push(r),this[ed].push(r);for(const e of t.children)c.push(e),l.set(t,r)}}get materials(){return this[Zu]}[(qu=Zu,ju=ed,Xu=td,Yu=id,Ku=hd,Ju=ld,cd)](){const e=Array.from(this[ld].values());return e.sort(((e,t)=>e.index-t.index)),e.map((e=>e.name))}getMaterialByName(e){const t=this[Zu].filter((t=>t.name===e));return t.length>0?t[0]:null}[od](e,t){const r=this[ed].find((r=>{if(r instanceof PrimitiveNode){const{meshes:s,primitives:o}=r.mesh.userData.associations;if(s==e&&o==t)return!0}return!1}));return null==r?null:r}[ad](e){return this[ed].find((t=>{if(t instanceof PrimitiveNode){if(t.mesh===e.object)return!0}return!1}))}[sd](e){return this[ad](e).getActiveMaterial()}async[rd](e){for(const t of this[id])await t.enableVariant(e);for(const e of this.materials)e[Ou](!1);for(const e of this[id])this.materials[e.getActiveMaterial().index][Ou](!0)}async[nd](){const e=new Array;for(const t of this[id])e.push(t.instantiateVariants());await Promise.all(e)}[ud](e,t){const r=this.materials[e];r.isLoaded||$u.error("Cloning an unloaded material,\n call 'material.ensureLoaded() before cloning the material.");const s=r[Hh],o=new Set;for(const[e,r]of s.entries()){const l=r.clone();l.name=t+(s.size>1?"_inst"+e:""),o.add(l)}const l=new material_Material(this[hd],this[Zu].length,!1,this[ld],o,t);return this[Zu].push(l),l}createMaterialInstanceForVariant(e,t,r,s=!0){let o=null;for(const s of this[id]){const l=this[ld].get(r);null!=l&&s.variantInfo.has(l.index)||null!=s.getMaterial(e)&&(this.hasVariant(r)||this.createVariant(r),null==o&&(o=this[ud](e,t)),s.addVariant(o,r))}if(s&&null!=o){o[Ou](!0),this.materials[e][Ou](!1);for(const e of this[id])e.enableVariant(r)}return o}createVariant(e){this[ld].has(e)?$u.warn(`Variant '${e}'' already exists`):this[ld].set(e,{name:e,index:this[ld].size})}hasVariant(e){return this[ld].has(e)}setMaterialToVariant(e,t){if(null!=this[cd]().find((e=>e===t)))if(e<0||e>=this.materials.length)$u.error("setMaterialToVariant(): materialIndex is out of bounds.");else for(const r of this[id]){const s=r.getMaterial(e);null!=s&&r.addVariant(s,t)}else $u.warn(`Can't add material to '${t}', the variant does not exist.'`)}updateVariantName(e,t){const r=this[ld].get(e);null!=r&&(r.name=t,this[ld].set(t,r),this[ld].delete(e))}deleteVariant(e){const t=this[ld].get(e);if(null!=t){for(const r of this.materials)r.hasVariant(e)&&r[Gu].delete(t.index);for(const e of this[id])e.deleteVariant(t.index);this[ld].delete(e)}}}var scene_graph_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const dd=Symbol("currentGLTF"),pd=Symbol("originalGltfJson"),Ad=Symbol("model"),md=Symbol("getOnUpdateMethod"),fd=Symbol("buildTexture");class GroundedSkybox extends three_module_Mesh{constructor(){super(void 0,new MeshBasicMaterial({depthWrite:!1})),this.height=0,this.radius=0,this.resolution=0,this.userData.noHit=!0}get map(){return this.material.map}set map(e){this.material.map=e}isUsable(){return this.height>0&&this.radius>0&&null!=this.geometry&&null!=this.map}updateGeometry(e=this.height,t=this.radius,r=128){e==this.height&&t==this.radius&&r==this.resolution||(this.height=e,this.radius=t,this.resolution=r,e>0&&t>0&&(this.geometry.dispose(),this.geometry=function makeGeometry(e,t,r){const s=new SphereGeometry(t,2*r,r);s.scale(1,1,-1);const o=s.getAttribute("position"),l=new three_module_Vector3;for(let t=0;t<o.count;++t)if(l.fromBufferAttribute(o,t),l.y<0){const r=3*-e/2,s=l.y<r?-e/l.y:1-l.y*l.y/(3*r*r);l.multiplyScalar(s),l.toArray(o.array,3*t)}return o.needsUpdate=!0,s}(e,t,r)))}}const gd=new three_module_Vector3,_d=new three_module_Vector3,vd=new three_module_Vector3,yd=new Matrix3,Ed=new Triangle,xd=new three_module_Quaternion;class Hotspot extends CSS2DObject{constructor(e){super(document.createElement("div")),this.normal=new three_module_Vector3(0,1,0),this.initialized=!1,this.referenceCount=1,this.pivot=document.createElement("div"),this.slot=document.createElement("slot"),this.element.classList.add("annotation-wrapper"),this.slot.name=e.name,this.element.appendChild(this.pivot),this.pivot.appendChild(this.slot),this.updatePosition(e.position),this.updateNormal(e.normal),this.surface=e.surface}get facingCamera(){return!this.element.classList.contains("hide")}show(){this.facingCamera&&this.initialized||this.updateVisibility(!0)}hide(){!this.facingCamera&&this.initialized||this.updateVisibility(!1)}increment(){this.referenceCount++}decrement(){return this.referenceCount>0&&--this.referenceCount,0===this.referenceCount}updatePosition(e){if(null==e)return;const t=Bl(e)[0].terms;for(let e=0;e<3;++e)this.position.setComponent(e,Nl(t[e]).number);this.updateMatrixWorld()}updateNormal(e){if(null==e)return;const t=Bl(e)[0].terms;for(let e=0;e<3;++e)this.normal.setComponent(e,t[e].number)}updateSurface(e){if(!e&&this.initialized)return;const{mesh:t,tri:r,bary:s}=this;if(null==t||null==r||null==s)return;t.getVertexPosition(r.x,gd),t.getVertexPosition(r.y,_d),t.getVertexPosition(r.z,vd),gd.toArray(yd.elements,0),_d.toArray(yd.elements,3),vd.toArray(yd.elements,6),this.position.copy(s).applyMatrix3(yd);const o=this.parent;o.worldToLocal(t.localToWorld(this.position)),Ed.set(gd,_d,vd),Ed.getNormal(this.normal).transformDirection(t.matrixWorld);const l=o.parent;xd.setFromAxisAngle(gd.set(0,1,0),-l.yaw),this.normal.applyQuaternion(xd)}orient(e){this.pivot.style.transform=`rotate(${e}rad)`}updateVisibility(e){this.element.classList.toggle("hide",!e),this.slot.assignedNodes().forEach((t=>{if(t.nodeType!==Node.ELEMENT_NODE)return;const r=t,s=r.dataset.visibilityAttribute;if(null!=s){const t=`data-${s}`;r.toggleAttribute(t,e)}r.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:e}}))})),this.initialized=!0}}const Sd={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float h;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"},Md={name:"VerticalBlurShader",uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float v;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"};r(6763);Math.PI,Math.PI;function MathUtils_lerp(e,t,r){return(1-r)*e+r*t}class Shadow extends Object3D{constructor(e,t,r){super(),this.camera=new OrthographicCamera,this.renderTarget=null,this.renderTargetBlur=null,this.depthMaterial=new MeshDepthMaterial,this.horizontalBlurMaterial=new ShaderMaterial(Sd),this.verticalBlurMaterial=new ShaderMaterial(Md),this.intensity=0,this.softness=1,this.boundingBox=new Box3,this.size=new three_module_Vector3,this.maxDimension=0,this.isAnimated=!1,this.needsUpdate=!1;const{camera:s}=this;s.rotation.x=Math.PI/2,s.left=-.5,s.right=.5,s.bottom=-.5,s.top=.5,this.add(s);const o=new PlaneGeometry,l=new MeshBasicMaterial({opacity:1,transparent:!0,side:A});this.floor=new three_module_Mesh(o,l),this.floor.userData.noHit=!0,s.add(this.floor),this.blurPlane=new three_module_Mesh(o),this.blurPlane.visible=!1,s.add(this.blurPlane),e.target.add(this),this.depthMaterial.onBeforeCompile=function(e){e.fragmentShader=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * opacity );")},this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial.depthTest=!1,this.setScene(e,t,r)}setScene(e,t,r){const{boundingBox:s,size:o,rotation:l,position:c}=this;if(this.isAnimated=e.animationNames.length>0,this.boundingBox.copy(e.boundingBox),this.size.copy(e.size),this.maxDimension=Math.max(o.x,o.y,o.z)*(this.isAnimated?2:1),this.boundingBox.getCenter(c),"back"===r){const{min:e,max:t}=s;[e.y,e.z]=[e.z,e.y],[t.y,t.z]=[t.z,t.y],[o.y,o.z]=[o.z,o.y],l.x=Math.PI/2,l.y=Math.PI}else l.x=0,l.y=0;if(this.isAnimated){const e=s.min.y,t=s.max.y;o.y=this.maxDimension,s.expandByVector(o.subScalar(this.maxDimension).multiplyScalar(-.5)),s.min.y=e,s.max.y=t,o.set(this.maxDimension,t-e,this.maxDimension)}"bottom"===r?c.y=s.min.y:c.z=s.min.y,this.setSoftness(t)}setSoftness(e){this.softness=e;const{size:t,camera:r}=this,s=this.isAnimated?2:1,o=s*Math.pow(2,9-3*e);this.setMapSize(o);const l=t.y/2,c=t.y*s;r.near=0,r.far=MathUtils_lerp(c,l,e),this.depthMaterial.opacity=1/e,r.updateProjectionMatrix(),this.setIntensity(this.intensity),this.setOffset(0)}setMapSize(e){const{size:t}=this;this.isAnimated&&(e*=2);const r=Math.floor(t.x>t.z?e:e*t.x/t.z),s=Math.floor(t.x>t.z?e*t.z/t.x:e),o=10+r,l=10+s;if(null==this.renderTarget||this.renderTarget.width===o&&this.renderTarget.height===l||(this.renderTarget.dispose(),this.renderTarget=null,this.renderTargetBlur.dispose(),this.renderTargetBlur=null),null==this.renderTarget){const e={format:we};this.renderTarget=new WebGLRenderTarget(o,l,e),this.renderTargetBlur=new WebGLRenderTarget(o,l,e),this.floor.material.map=this.renderTarget.texture}this.camera.scale.set(t.x*(1+10/r),t.z*(1+10/s),1),this.needsUpdate=!0}setIntensity(e){this.intensity=e,e>0?(this.visible=!0,this.floor.visible=!0,this.floor.material.opacity=e*MathUtils_lerp(.3,1,this.softness*this.softness)):(this.visible=!1,this.floor.visible=!1)}getIntensity(){return this.intensity}setOffset(e){this.floor.position.z=-e+this.gap()}gap(){return.001*this.maxDimension}render(e,t){t.overrideMaterial=this.depthMaterial;const r=e.getClearAlpha();e.setClearAlpha(0),this.floor.visible=!1;const s=e.xr.enabled;e.xr.enabled=!1;const o=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.render(t,this.camera),t.overrideMaterial=null,this.floor.visible=!0,this.blurShadow(e),e.xr.enabled=s,e.setRenderTarget(o),e.setClearAlpha(r)}blurShadow(e){const{camera:t,horizontalBlurMaterial:r,verticalBlurMaterial:s,renderTarget:o,renderTargetBlur:l,blurPlane:c}=this;c.visible=!0,c.material=r,r.uniforms.h.value=1/this.renderTarget.width,r.uniforms.tDiffuse.value=this.renderTarget.texture,e.setRenderTarget(l),e.render(c,t),c.material=s,s.uniforms.v.value=1/this.renderTarget.height,s.uniforms.tDiffuse.value=this.renderTargetBlur.texture,e.setRenderTarget(o),e.render(c,t),c.visible=!1}dispose(){null!=this.renderTarget&&this.renderTarget.dispose(),null!=this.renderTargetBlur&&this.renderTargetBlur.dispose(),this.depthMaterial.dispose(),this.horizontalBlurMaterial.dispose(),this.verticalBlurMaterial.dispose(),this.floor.material.dispose(),this.floor.geometry.dispose(),this.blurPlane.geometry.dispose(),this.removeFromParent()}}var Cd=r(6763);const bd=new three_module_Vector3,wd=new three_module_Vector3,Id=new three_module_Vector3,Td=new class Raycaster{constructor(e,t,r=0,s=1/0){this.ray=new Ray(e,t),this.near=r,this.far=s,this.camera=null,this.layers=new Layers,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):o.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,r=[]){return intersectObject(e,this,r,t),r.sort(ascSort),r}intersectObjects(e,t=!0,r=[]){for(let s=0,o=e.length;s<o;s++)intersectObject(e[s],this,r,t);return r.sort(ascSort),r}},Bd=new three_module_Vector3,Rd=new Vector2;class ModelScene extends Scene{constructor({canvas:e,element:t,width:r,height:s}){super(),this.annotationRenderer=new CSS2DRenderer,this.effectRenderer=null,this.schemaElement=document.createElement("script"),this.width=1,this.height=1,this.aspect=1,this.scaleStep=0,this.renderCount=0,this.externalRenderer=null,this.camera=new PerspectiveCamera(45,1,.1,100),this.xrCamera=null,this.url=null,this.target=new Object3D,this.animationNames=[],this.boundingBox=new Box3,this.boundingSphere=new Sphere,this.size=new three_module_Vector3,this.idealAspect=0,this.framedFoVDeg=0,this.shadow=null,this.shadowIntensity=0,this.shadowSoftness=1,this.bakedShadows=new Set,this.exposure=1,this.toneMapping=te,this.canScale=!0,this.isDirty=!1,this.goalTarget=new three_module_Vector3,this.targetDamperX=new Damper,this.targetDamperY=new Damper,this.targetDamperZ=new Damper,this._currentGLTF=null,this._model=null,this.cancelPendingSourceChange=null,this.animationsByName=new Map,this.currentAnimationAction=null,this.groundedSkybox=new GroundedSkybox,this.name="ModelScene",this.element=t,this.canvas=e,this.camera=new PerspectiveCamera(45,1,.1,100),this.camera.name="MainCamera",this.add(this.target),this.setSize(r,s),this.target.name="Target",this.mixer=new three_module_AnimationMixer(this.target);const{domElement:o}=this.annotationRenderer,{style:l}=o;l.display="none",l.pointerEvents="none",l.position="absolute",l.top="0",this.element.shadowRoot.querySelector(".default").appendChild(o),this.schemaElement.setAttribute("type","application/ld+json")}get context(){return this.canvas.getContext("2d")}getCamera(){return null!=this.xrCamera?this.xrCamera:this.camera}queueRender(){this.isDirty=!0}shouldRender(){return this.isDirty}hasRendered(){this.isDirty=!1}forceRescale(){this.scaleStep=-1,this.queueRender()}async setObject(e){this.reset(),this._model=e,this.target.add(e),await this.setupScene()}async setSource(e,t=()=>{}){if(!e||e===this.url)return void t(1);if(this.reset(),this.url=e,null!=this.externalRenderer){const e=await this.externalRenderer.load(t);return this.boundingSphere.radius=e.framedRadius,void(this.idealAspect=e.fieldOfViewAspect)}let r;null!=this.cancelPendingSourceChange&&(this.cancelPendingSourceChange(),this.cancelPendingSourceChange=null);try{r=await new Promise((async(r,s)=>{this.cancelPendingSourceChange=()=>s();try{r(await this.element[Ep].loader.load(e,this.element,t))}catch(e){s(e)}}))}catch(e){if(null==e)return;throw e}this.cancelPendingSourceChange=null,this.reset(),this.url=e,this._currentGLTF=r,null!=r&&(this._model=r.scene,this.target.add(r.scene));const{animations:s}=r,o=new Map,l=[];for(const e of s)o.set(e.name,e),l.push(e.name);this.animations=s,this.animationsByName=o,this.animationNames=l,await this.setupScene()}async setupScene(){this.applyTransform(),this.updateBoundingBox(),await this.updateFraming(),this.updateShadow(),this.setShadowIntensity(this.shadowIntensity),this.setGroundedSkybox()}reset(){this.url=null,this.renderCount=0,this.queueRender(),null!=this.shadow&&this.shadow.setIntensity(0),this.bakedShadows.clear();const{_model:e}=this;null!=e&&(e.removeFromParent(),this._model=null);const t=this._currentGLTF;null!=t&&(t.dispose(),this._currentGLTF=null),null!=this.currentAnimationAction&&(this.currentAnimationAction.stop(),this.currentAnimationAction=null),this.mixer.stopAllAction(),this.mixer.uncacheRoot(this)}dispose(){this.reset(),null!=this.shadow&&(this.shadow.dispose(),this.shadow=null),this.element[dd]=null,this.element[pd]=null,this.element[Ad]=null}get currentGLTF(){return this._currentGLTF}setSize(e,t){if(this.width!==e||this.height!==t){if(this.width=Math.max(e,1),this.height=Math.max(t,1),this.annotationRenderer.setSize(e,t),this.aspect=this.width/this.height,null!=this.externalRenderer){const r=Aa();this.externalRenderer.resize(e*r,t*r)}this.queueRender()}}markBakedShadow(e){e.userData.noHit=!0,this.bakedShadows.add(e)}unmarkBakedShadow(e){e.userData.noHit=!1,e.visible=!0,this.bakedShadows.delete(e),this.boundingBox.expandByObject(e)}findBakedShadows(e){const t=new Box3;e.traverse((e=>{const r=e;if(!r.material)return;if(!r.material.transparent)return;t.setFromObject(r);const s=t.getSize(Bd),o=Math.min(s.x,s.y,s.z);Math.max(s.x,s.y,s.z)<100*o||this.markBakedShadow(r)}))}checkBakedShadows(){const{min:e,max:t}=this.boundingBox,r=new Box3;this.boundingBox.getSize(this.size);for(const s of this.bakedShadows)r.setFromObject(s),r.min.y<e.y+this.size.y/100&&r.min.x<=e.x&&r.max.x>=t.x&&r.min.z<=e.z&&r.max.z>=t.z||r.min.z<e.z+this.size.z/100&&r.min.x<=e.x&&r.max.x>=t.x&&r.min.y<=e.y&&r.max.y>=t.y||this.unmarkBakedShadow(s)}applyTransform(){const{model:e}=this;if(null==e)return;const t=Bl(this.element.orientation)[0].terms,r=Nl(t[0]).number,s=Nl(t[1]).number,o=Nl(t[2]).number;e.quaternion.setFromEuler(new Euler(s,o,r,"YXZ"));const l=Bl(this.element.scale)[0].terms;e.scale.set(l[0].number,l[1].number,l[2].number)}updateBoundingBox(){const{model:e}=this;if(null==e)return;this.target.remove(e),this.findBakedShadows(e);const bound=(e,t)=>e.expandByPoint(t);this.setBakedShadowVisibility(!1),this.boundingBox=reduceVertices(e,bound,new Box3),this.boundingBox.isEmpty()&&(this.setBakedShadowVisibility(!0),this.bakedShadows.forEach((e=>this.unmarkBakedShadow(e))),this.boundingBox=reduceVertices(e,bound,new Box3)),this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size),this.target.add(e)}async updateFraming(){const{model:e}=this;if(null==e)return;this.target.remove(e),this.setBakedShadowVisibility(!1);const{center:t}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,t.copy(this.getTarget());this.boundingSphere.radius=Math.sqrt(reduceVertices(e,((e,r)=>Math.max(e,t.distanceToSquared(r))),0));this.idealAspect=reduceVertices(e,((e,r)=>{r.sub(t);const s=Math.sqrt(r.x*r.x+r.z*r.z);return Math.max(e,s/(this.idealCameraDistance()-Math.abs(r.y)))}),0)/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility(),this.target.add(e)}setBakedShadowVisibility(e=this.shadowIntensity<=0){for(const t of this.bakedShadows)t.visible=e}idealCameraDistance(){const e=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(e)}adjustedFoV(e){const t=Math.tan(e/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(t)*180/Math.PI}getNDC(e,t){if(null!=this.xrCamera)Rd.set(e/window.screen.width,t/window.screen.height);else{const r=this.element.getBoundingClientRect();Rd.set((e-r.x)/this.width,(t-r.y)/this.height)}return Rd.multiplyScalar(2).subScalar(1),Rd.y*=-1,Rd}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(e,t){this.element[Ep].arRenderer.presentedScene!==this&&(this.environment=e,this.setBackground(t),this.queueRender())}setBackground(e){this.groundedSkybox.map=e,this.groundedSkybox.isUsable()?(this.target.add(this.groundedSkybox),this.background=null):(this.target.remove(this.groundedSkybox),this.background=e)}farRadius(){return this.boundingSphere.radius*(null!=this.groundedSkybox.parent?10:1)}setGroundedSkybox(){const e=Bl(this.element.skyboxHeight)[0].terms[0],t=Nl(e).number,r=10*this.boundingSphere.radius;this.groundedSkybox.updateGeometry(t,r),this.groundedSkybox.position.y=t-(this.shadow?2*this.shadow.gap():0),this.setBackground(this.groundedSkybox.map)}setTarget(e,t,r){this.goalTarget.set(-e,-t,-r)}setTargetDamperDecayTime(e){this.targetDamperX.setDecayTime(e),this.targetDamperY.setDecayTime(e),this.targetDamperZ.setDecayTime(e)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget(1e4)}updateTarget(e){const t=this.goalTarget,r=this.target.position;if(t.equals(r))return!1;{const s=this.boundingSphere.radius/10;let{x:o,y:l,z:c}=r;return o=this.targetDamperX.update(o,t.x,e,s),l=this.targetDamperY.update(l,t.y,e,s),c=this.targetDamperZ.update(c,t.z,e,s),this.target.position.set(o,l,c),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(e,t){const{x:r,z:s}=this.position;this.yaw=Math.atan2(e-r,t-s)}get model(){return this._model}set yaw(e){this.rotation.y=e,this.queueRender()}get yaw(){return this.rotation.y}set animationTime(e){this.mixer.setTime(e),this.queueShadowRender()}get animationTime(){if(null!=this.currentAnimationAction){const e=Math.max(this.currentAnimationAction._loopCount,0);return this.currentAnimationAction.loop!==We||1&~e?this.currentAnimationAction.time:this.duration-this.currentAnimationAction.time}return 0}set animationTimeScale(e){this.mixer.timeScale=e}get animationTimeScale(){return this.mixer.timeScale}get duration(){return null!=this.currentAnimationAction&&this.currentAnimationAction.getClip()?this.currentAnimationAction.getClip().duration:0}get hasActiveAnimation(){return null!=this.currentAnimationAction}playAnimation(e=null,t=0,r=2201,s=1/0){if(null==this._currentGLTF)return;const{animations:o}=this;if(null==o||0===o.length)return;let l=null;if(null!=e&&(l=this.animationsByName.get(e),null==l)){const t=parseInt(e);!isNaN(t)&&t>=0&&t<o.length&&(l=o[t])}null==l&&(l=o[0]);try{const{currentAnimationAction:e}=this,o=this.mixer.clipAction(l,this);this.currentAnimationAction=o,this.element.paused?this.mixer.stopAllAction():(o.paused=!1,null!=e&&o!==e?o.crossFadeFrom(e,t,!1):this.animationTimeScale>0&&this.animationTime==this.duration&&(this.animationTime=0)),o.setLoop(r,s),o.enabled=!0,o.clampWhenFinished=!0,o.play()}catch(e){Cd.error(e)}}stopAnimation(){this.currentAnimationAction=null,this.mixer.stopAllAction()}updateAnimation(e){this.mixer.update(e),this.queueShadowRender()}subscribeMixerEvent(e,t){this.mixer.addEventListener(e,t)}updateShadow(){const e=this.shadow;if(null!=e){const t="wall"===this.element.arPlacement?"back":"bottom";e.setScene(this,this.shadowSoftness,t),e.needsUpdate=!0}}renderShadow(e){const t=this.shadow;null!=t&&1==t.needsUpdate&&(t.render(e,this),t.needsUpdate=!1)}queueShadowRender(){null!=this.shadow&&(this.shadow.needsUpdate=!0)}setShadowIntensity(e){if(this.shadowIntensity=e,null!=this._currentGLTF&&(this.setBakedShadowVisibility(),!(e<=0&&null==this.shadow))){if(null==this.shadow){const e="wall"===this.element.arPlacement?"back":"bottom";this.shadow=new Shadow(this,this.shadowSoftness,e)}this.shadow.setIntensity(e)}}setShadowSoftness(e){this.shadowSoftness=e;const t=this.shadow;null!=t&&t.setSoftness(e)}setShadowOffset(e){const t=this.shadow;null!=t&&t.setOffset(e)}hitFromPoint(e,t=this){Td.setFromCamera(e,this.getCamera());return Td.intersectObject(t,!0).find((e=>e.object.visible&&!e.object.userData.noHit))}positionAndNormalFromPoint(e,t=this){var r;const s=this.hitFromPoint(e,t);if(null==s)return null;return{position:s.point,normal:null!=s.face?s.face.normal.clone().applyNormalMatrix((new Matrix3).getNormalMatrix(s.object.matrixWorld)):Td.ray.direction.clone().multiplyScalar(-1),uv:null!==(r=s.uv)&&void 0!==r?r:null}}surfaceFromPoint(e,t=this){const r=this.element.model;if(null==r)return null;const s=this.hitFromPoint(e,t);if(null==s||null==s.face)return null;const o=r[ad](s),{meshes:l,primitives:c}=o.mesh.userData.associations,h=new three_module_Vector3,d=new three_module_Vector3,p=new three_module_Vector3,{a:A,b:m,c:f}=s.face,g=s.object;g.getVertexPosition(A,h),g.getVertexPosition(m,d),g.getVertexPosition(f,p);const _=new Triangle(h,d,p),y=new three_module_Vector3;return _.getBarycoord(g.worldToLocal(s.point),y),`${l} ${c} ${A} ${m} ${f} ${y.x.toFixed(3)} ${y.y.toFixed(3)} ${y.z.toFixed(3)}`}addHotspot(e){this.target.add(e),this.annotationRenderer.domElement.appendChild(e.element)}removeHotspot(e){this.target.remove(e)}forHotspots(e){const{children:t}=this.target;for(let r=0,s=t.length;r<s;r++){const s=t[r];s instanceof Hotspot&&e(s)}}initializeSurface(e){if(null!=e.surface&&null==e.mesh){const t=Bl(e.surface)[0].terms;if(8!=t.length)return void Cd.warn(e.surface+" does not have exactly 8 numbers.");const r=this.element.model[od](t[0].number,t[1].number),s=new three_module_Vector3(t[2].number,t[3].number,t[4].number);if(null==r)return void Cd.warn(e.surface+" does not match a node/primitive in this glTF! Skipping this hotspot.");const o=r.mesh.geometry.attributes.position.count;if(s.x>=o||s.y>=o||s.z>=o)return void Cd.warn(e.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");const l=new three_module_Vector3(t[5].number,t[6].number,t[7].number);e.mesh=r.mesh,e.tri=s,e.bary=l}}updateSurfaceHotspots(){const e=!this.element.paused;this.forHotspots((t=>{this.initializeSurface(t),t.updateSurface(e)}))}updateHotspotsVisibility(e){this.forHotspots((t=>{bd.copy(e),wd.setFromMatrixPosition(t.matrixWorld),bd.sub(wd),Id.copy(t.normal).transformDirection(this.target.matrixWorld),bd.dot(Id)<0?t.hide():t.show()}))}orientHotspots(e){this.forHotspots((t=>{t.orient(e)}))}setHotspotsVisibility(e){this.forHotspots((t=>{t.visible=e}))}updateSchema(e){var t;const{schemaElement:r,element:s}=this,{alt:o,poster:l,iosSrc:c}=s;if(null!=e){const s=[{"@type":"MediaObject",contentUrl:e,encodingFormat:"gltf"===(null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase())?"model/gltf+json":"model/gltf-binary"}];c&&s.push({"@type":"MediaObject",contentUrl:c,encodingFormat:"model/vnd.usdz+zip"});const h={"@context":"http://schema.org/","@type":"3DModel",image:null!=l?l:void 0,name:null!=o?o:void 0,encoding:s};r.textContent=JSON.stringify(h),document.head.appendChild(r)}else null!=r.parentElement&&r.parentElement.removeChild(r)}}class ProgressTracker extends EventTarget{constructor(){super(...arguments),this.ongoingActivities=new Set,this.totalProgress=0}get ongoingActivityCount(){return this.ongoingActivities.size}beginActivity(e){const t={progress:0,completed:!1};return this.ongoingActivities.add(t),1===this.ongoingActivityCount&&this.announceTotalProgress(t,0,e),r=>{let s;return s=Math.max(utilities_clamp(r,0,1),t.progress),s!==t.progress&&this.announceTotalProgress(t,s,e),t.progress}}announceTotalProgress(e,t,r){let s=0,o=0;1==t&&(e.completed=!0);for(const e of this.ongoingActivities){const{progress:t}=e;s+=1-t,e.completed&&o++}const l=e.progress;e.progress=t,this.totalProgress+=(t-l)*(1-this.totalProgress)/s;const c=o===this.ongoingActivityCount?1:this.totalProgress;this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:c,reason:r}})),o===this.ongoingActivityCount&&(this.totalProgress=0,this.ongoingActivities.clear())}}var Ld,Dd,Ud,Pd,Fd,Nd,Od,Qd,kd,Gd,Vd,Hd,zd,Wd=r(6763),model_viewer_base_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const qd=document.createElement("canvas"),jd=Symbol("fallbackResizeHandler"),Xd=Symbol("defaultAriaLabel"),Yd=Symbol("resizeObserver"),Kd=Symbol("clearModelTimeout"),Jd=Symbol("onContextLost"),$d=Symbol("loaded"),Zd=Symbol("status"),ep=Symbol("onFocus"),tp=Symbol("onBlur"),ip=Symbol("updateSize"),np=Symbol("intersectionObserver"),rp=Symbol("isElementInViewport"),sp=Symbol("announceModelVisibility"),ap=Symbol("ariaLabel"),op=Symbol("altDefaulted"),lp=Symbol("statusElement"),cp=Symbol("updateStatus"),hp=Symbol("loadedTime"),up=Symbol("updateSource"),dp=Symbol("markLoaded"),pp=Symbol("container"),Ap=Symbol("input"),mp=Symbol("canvas"),fp=Symbol("scene"),gp=Symbol("needsRender"),_p=Symbol("tick"),vp=Symbol("onModelLoad"),yp=Symbol("onResize"),Ep=Symbol("renderer"),xp=Symbol("progressTracker"),Sp=Symbol("getLoaded"),Mp=Symbol("getModelIsVisible"),Cp=Symbol("shouldAttemptPreload"),toVector3D=e=>({x:e.x,y:e.y,z:e.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),toVector2D=e=>({u:e.x,v:e.y,toString(){return`${this.u} ${this.v}`}});class ModelViewerElementBase extends reactive_element_a{constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[Ld]=!1,this[Dd]=!1,this[Ud]=0,this[Pd]="",this[Fd]=null,this[Nd]=debounce((()=>{const e=this.getBoundingClientRect();this[ip](e)}),50),this[Od]=debounce((e=>{const t=this.modelIsVisible;t!==e&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:t}}))}),0),this[Qd]=null,this[kd]=null,this[Gd]=new ProgressTracker,this[Vd]=()=>{this[lp].textContent=this[Zd]},this[Hd]=()=>{this[lp].textContent=""},this[zd]=e=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:e.sourceEvent}}))},this.attachShadow({mode:"open"});const e=this.shadowRoot;let t,r;if((e=>{D(ya,e)})(e),this[pp]=e.querySelector(".container"),this[Ap]=e.querySelector(".userInput"),this[mp]=e.querySelector("canvas"),this[lp]=e.querySelector("#status"),this[Xd]=this[Ap].getAttribute("aria-label"),this.isConnected){const e=this.getBoundingClientRect();t=e.width,r=e.height}else t=300,r=150;this[fp]=new ModelScene({canvas:this[mp],element:this,width:t,height:r}),Promise.resolve().then((()=>{this[ip](this.getBoundingClientRect())})),na&&(this[Yd]=new ResizeObserver((e=>{if(!this[Ep].isPresenting)for(let t of e)t.target===this&&this[ip](t.contentRect)}))),ra?this[np]=new IntersectionObserver((e=>{for(let t of e)if(t.target===this){const e=this.modelIsVisible;this[rp]=t.isIntersecting,this[sp](e),this[rp]&&!this.loaded&&this[up]()}}),{root:null,rootMargin:"0px",threshold:1e-5}):this[rp]=!0}static get is(){return"model-viewer"}static set modelCacheSize(e){CachingGLTFLoader[Go].evictionThreshold=e}static get modelCacheSize(){return CachingGLTFLoader[Go].evictionThreshold}static set minimumRenderScale(e){e>1&&Wd.warn("<model-viewer> minimumRenderScale has been clamped to a maximum value of 1."),e<=0&&Wd.warn("<model-viewer> minimumRenderScale has been clamped to a minimum value of 0.25."),Renderer.singleton.minScale=e}static get minimumRenderScale(){return Renderer.singleton.minScale}get loaded(){return this[Sp]()}get[(Ld=rp,Dd=$d,Ud=hp,Pd=Zd,Fd=Kd,Nd=jd,Od=sp,Qd=Yd,kd=np,Gd=xp,Ep)](){return Renderer.singleton}get modelIsVisible(){return this[Mp]()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),na?this[Yd].observe(this):self.addEventListener("resize",this[jd]),ra&&this[np].observe(this),this.addEventListener("focus",this[ep]),this.addEventListener("blur",this[tp]);const e=this[Ep];e.addEventListener("contextlost",this[Jd]),e.registerScene(this[fp]),null!=this[Kd]&&(self.clearTimeout(this[Kd]),this[Kd]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),na?this[Yd].unobserve(this):self.removeEventListener("resize",this[jd]),ra&&this[np].unobserve(this),this.removeEventListener("focus",this[ep]),this.removeEventListener("blur",this[tp]);const e=this[Ep];e.removeEventListener("contextlost",this[Jd]),e.unregisterScene(this[fp]),this[Kd]=self.setTimeout((()=>{this[fp].dispose(),this[Kd]=null}),10)}updated(e){super.updated(e),e.has("src")&&(null==this.src?(this[$d]=!1,this[hp]=0,this[fp].reset()):this.src!==this[fp].url&&(this[$d]=!1,this[hp]=0,this[up]())),e.has("alt")&&this[Ap].setAttribute("aria-label",this[ap]),e.has("withCredentials")&&(CachingGLTFLoader.withCredentials=this.withCredentials,this[Ep].textureUtils.withCredentials=this.withCredentials),e.has("generateSchema")&&(this.generateSchema?this[fp].updateSchema(this.src):this[fp].updateSchema(null))}toDataURL(e,t){return this[Ep].displayCanvas(this[fp]).toDataURL(e,t)}async toBlob(e){const t=e?e.mimeType:void 0,r=e?e.qualityArgument:void 0,s=e?e.idealAspect:void 0,{width:o,height:l,idealAspect:c,aspect:h}=this[fp],{dpr:d,scaleFactor:p}=this[Ep];let A=o*p*d,m=l*p*d,f=0,g=0;if(!0===s)if(c>h){const e=m;m=Math.round(A/c),g=(e-m)/2}else{const e=A;A=Math.round(m*c),f=(e-A)/2}qd.width=A,qd.height=m;try{return new Promise((async(e,s)=>{qd.getContext("2d").drawImage(this[Ep].displayCanvas(this[fp]),f,g,A,m,0,0,A,m),qd.toBlob((t=>{if(!t)return s(new Error("Unable to retrieve canvas blob"));e(t)}),t,r)}))}finally{this[ip]({width:o,height:l})}}registerEffectComposer(e){e.setRenderer(this[Ep].threeRenderer),e.setMainCamera(this[fp].getCamera()),e.setMainScene(this[fp]),this[fp].effectRenderer=e}unregisterEffectComposer(){this[fp].effectRenderer=null}registerRenderer(e){this[fp].externalRenderer=e}unregisterRenderer(){this[fp].externalRenderer=null}get[ap](){return this[op]}get[op](){return null==this.alt||"null"===this.alt?this[Xd]:this.alt}[Sp](){return this[$d]}[Mp](){return this.loaded&&this[rp]}[Cp](){return!!this.src&&this[rp]}[ip]({width:e,height:t}){0!==e&&0!==t&&(this[pp].style.width=`${e}px`,this[pp].style.height=`${t}px`,this[yp]({width:e,height:t}))}[_p](e,t){var r;null===(r=this[fp].effectRenderer)||void 0===r||r.beforeRender(e,t)}[dp](){this[$d]||(this[$d]=!0,this[hp]=performance.now())}[gp](){this[fp].queueRender()}[vp](){}[cp](e){this[Zd]=e;const t=this.getRootNode();null!=t&&t.activeElement===this&&this[lp].textContent!=e&&(this[lp].textContent=e)}[(Vd=ep,Hd=tp,yp)](e){this[fp].setSize(e.width,e.height)}async[(zd=Jd,up)](){const e=this[fp];if(this.loaded||!this[Cp]()||this.src===e.url)return;this.generateSchema&&e.updateSchema(this.src),this[cp]("Loading"),e.stopAnimation();const t=this[xp].beginActivity("model-load"),r=this.src;try{const s=e.setSource(r,(e=>t(.95*utilities_clamp(e,0,1)))),o=this[_a]();await Promise.all([s,o]),this[dp](),this[vp](),this.updateComplete.then((()=>{this.dispatchEvent(new CustomEvent("before-render"))})),await new Promise((e=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.dispatchEvent(new CustomEvent("load",{detail:{url:r}})),e()}))}))}))}catch(e){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:e}}))}finally{t(1)}}}model_viewer_base_decorate([n({type:String})],ModelViewerElementBase.prototype,"alt",void 0),model_viewer_base_decorate([n({type:String})],ModelViewerElementBase.prototype,"src",void 0),model_viewer_base_decorate([n({type:Boolean,attribute:"with-credentials"})],ModelViewerElementBase.prototype,"withCredentials",void 0),model_viewer_base_decorate([n({type:Boolean,attribute:"generate-schema"})],ModelViewerElementBase.prototype,"generateSchema",void 0);var animation_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const bp=Symbol("changeAnimation"),wp=Symbol("paused"),Ip={repetitions:1/0,pingpong:!1},Tp=Symbol("hotspotMap"),Bp=Symbol("mutationCallback"),Rp=Symbol("observer"),Lp=Symbol("addHotspot"),Dp=Symbol("removeHotspot"),Up=new three_module_Matrix4;var durl=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(durl(""))}catch(e){durl=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},function(e){return new Worker(e,{type:"module"})}}var Pp=Uint8Array,Fp=Uint16Array,Np=Uint32Array,Op=new Pp([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Qp=new Pp([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kp=new Pp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(e,t){for(var r=new Fp(31),s=0;s<31;++s)r[s]=t+=1<<e[s-1];var o=new Np(r[30]);for(s=1;s<30;++s)for(var l=r[s];l<r[s+1];++l)o[l]=l-r[s]<<5|s;return[r,o]},Gp=freb(Op,2),Vp=Gp[0],Hp=Gp[1];Vp[28]=258,Hp[258]=28;for(var zp=freb(Qp,0),Wp=(zp[0],zp[1]),qp=new Fp(32768),jp=0;jp<32768;++jp){var Xp=(43690&jp)>>>1|(21845&jp)<<1;Xp=(61680&(Xp=(52428&Xp)>>>2|(13107&Xp)<<2))>>>4|(3855&Xp)<<4,qp[jp]=((65280&Xp)>>>8|(255&Xp)<<8)>>>1}var hMap=function(e,t,r){for(var s=e.length,o=0,l=new Fp(t);o<s;++o)++l[e[o]-1];var c,h=new Fp(t);for(o=0;o<t;++o)h[o]=h[o-1]+l[o-1]<<1;if(r){c=new Fp(1<<t);var d=15-t;for(o=0;o<s;++o)if(e[o])for(var p=o<<4|e[o],A=t-e[o],m=h[e[o]-1]++<<A,f=m|(1<<A)-1;m<=f;++m)c[qp[m]>>>d]=p}else for(c=new Fp(s),o=0;o<s;++o)e[o]&&(c[o]=qp[h[e[o]-1]++]>>>15-e[o]);return c},Yp=new Pp(288);for(jp=0;jp<144;++jp)Yp[jp]=8;for(jp=144;jp<256;++jp)Yp[jp]=9;for(jp=256;jp<280;++jp)Yp[jp]=7;for(jp=280;jp<288;++jp)Yp[jp]=8;var Kp=new Pp(32);for(jp=0;jp<32;++jp)Kp[jp]=5;var Jp=hMap(Yp,9,0),$p=hMap(Kp,5,0),shft=function(e){return(e/8|0)+(7&e&&1)},slc=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var s=new(e instanceof Fp?Fp:e instanceof Np?Np:Pp)(r-t);return s.set(e.subarray(t,r)),s},wbits=function(e,t,r){r<<=7&t;var s=t/8|0;e[s]|=r,e[s+1]|=r>>>8},wbits16=function(e,t,r){r<<=7&t;var s=t/8|0;e[s]|=r,e[s+1]|=r>>>8,e[s+2]|=r>>>16},hTree=function(e,t){for(var r=[],s=0;s<e.length;++s)e[s]&&r.push({s,f:e[s]});var o=r.length,l=r.slice();if(!o)return[eA,0];if(1==o){var c=new Pp(r[0].s+1);return c[r[0].s]=1,[c,1]}r.sort((function(e,t){return e.f-t.f})),r.push({s:-1,f:25001});var h=r[0],d=r[1],p=0,A=1,m=2;for(r[0]={s:-1,f:h.f+d.f,l:h,r:d};A!=o-1;)h=r[r[p].f<r[m].f?p++:m++],d=r[p!=A&&r[p].f<r[m].f?p++:m++],r[A++]={s:-1,f:h.f+d.f,l:h,r:d};var f=l[0].s;for(s=1;s<o;++s)l[s].s>f&&(f=l[s].s);var g=new Fp(f+1),_=fflate_module_ln(r[A-1],g,0);if(_>t){s=0;var y=0,x=_-t,S=1<<x;for(l.sort((function(e,t){return g[t.s]-g[e.s]||e.f-t.f}));s<o;++s){var C=l[s].s;if(!(g[C]>t))break;y+=S-(1<<_-g[C]),g[C]=t}for(y>>>=x;y>0;){var b=l[s].s;g[b]<t?y-=1<<t-g[b]++-1:++s}for(;s>=0&&y;--s){var I=l[s].s;g[I]==t&&(--g[I],++y)}_=t}return[new Pp(g),_]},fflate_module_ln=function(e,t,r){return-1==e.s?Math.max(fflate_module_ln(e.l,t,r+1),fflate_module_ln(e.r,t,r+1)):t[e.s]=r},lc=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new Fp(++t),s=0,o=e[0],l=1,w=function(e){r[s++]=e},c=1;c<=t;++c)if(e[c]==o&&c!=t)++l;else{if(!o&&l>2){for(;l>138;l-=138)w(32754);l>2&&(w(l>10?l-11<<5|28690:l-3<<5|12305),l=0)}else if(l>3){for(w(o),--l;l>6;l-=6)w(8304);l>2&&(w(l-3<<5|8208),l=0)}for(;l--;)w(o);l=1,o=e[c]}return[r.subarray(0,s),t]},clen=function(e,t){for(var r=0,s=0;s<t.length;++s)r+=e[s]*t[s];return r},wfblk=function(e,t,r){var s=r.length,o=shft(t+2);e[o]=255&s,e[o+1]=s>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var l=0;l<s;++l)e[o+l+4]=r[l];return 8*(o+4+s)},wblk=function(e,t,r,s,o,l,c,h,d,p,A){wbits(t,A++,r),++o[256];for(var m=hTree(o,15),f=m[0],g=m[1],_=hTree(l,15),y=_[0],x=_[1],S=lc(f),C=S[0],b=S[1],I=lc(y),T=I[0],B=I[1],U=new Fp(19),F=0;F<C.length;++F)U[31&C[F]]++;for(F=0;F<T.length;++F)U[31&T[F]]++;for(var O=hTree(U,7),Q=O[0],G=O[1],W=19;W>4&&!Q[kp[W-1]];--W);var q,j,X,Y,K=p+5<<3,J=clen(o,Yp)+clen(l,Kp)+c,$=clen(o,f)+clen(l,y)+c+14+3*W+clen(U,Q)+(2*U[16]+3*U[17]+7*U[18]);if(K<=J&&K<=$)return wfblk(t,A,e.subarray(d,d+p));if(wbits(t,A,1+($<J)),A+=2,$<J){q=hMap(f,g,0),j=f,X=hMap(y,x,0),Y=y;var ee=hMap(Q,G,0);wbits(t,A,b-257),wbits(t,A+5,B-1),wbits(t,A+10,W-4),A+=14;for(F=0;F<W;++F)wbits(t,A+3*F,Q[kp[F]]);A+=3*W;for(var te=[C,T],ie=0;ie<2;++ie){var ne=te[ie];for(F=0;F<ne.length;++F){var re=31&ne[F];wbits(t,A,ee[re]),A+=Q[re],re>15&&(wbits(t,A,ne[F]>>>5&127),A+=ne[F]>>>12)}}}else q=Jp,j=Yp,X=$p,Y=Kp;for(F=0;F<h;++F)if(s[F]>255){re=s[F]>>>18&31;wbits16(t,A,q[re+257]),A+=j[re+257],re>7&&(wbits(t,A,s[F]>>>23&31),A+=Op[re]);var se=31&s[F];wbits16(t,A,X[se]),A+=Y[se],se>3&&(wbits16(t,A,s[F]>>>5&8191),A+=Qp[se])}else wbits16(t,A,q[s[F]]),A+=j[s[F]];return wbits16(t,A,q[256]),A+j[256]},Zp=new Np([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),eA=new Pp(0),dflt=function(e,t,r,s,o,l){var c=e.length,h=new Pp(s+c+5*(1+Math.ceil(c/7e3))+o),d=h.subarray(s,h.length-o),p=0;if(!t||c<8)for(var A=0;A<=c;A+=65535){var m=A+65535;m<c?p=wfblk(d,p,e.subarray(A,m)):(d[A]=l,p=wfblk(d,p,e.subarray(A,c)))}else{for(var f=Zp[t-1],g=f>>>13,_=8191&f,y=(1<<r)-1,x=new Fp(32768),S=new Fp(y+1),C=Math.ceil(r/3),b=2*C,hsh=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<b)&y},I=new Np(25e3),T=new Fp(288),B=new Fp(32),U=0,F=0,O=(A=0,0),Q=0,G=0;A<c;++A){var W=hsh(A),q=32767&A,j=S[W];if(x[q]=j,S[W]=q,Q<=A){var X=c-A;if((U>7e3||O>24576)&&X>423){p=wblk(e,d,0,I,T,B,F,O,G,A-G,p),O=U=F=0,G=A;for(var Y=0;Y<286;++Y)T[Y]=0;for(Y=0;Y<30;++Y)B[Y]=0}var K=2,J=0,$=_,ee=q-j&32767;if(X>2&&W==hsh(A-ee))for(var te=Math.min(g,X)-1,ie=Math.min(32767,A),ne=Math.min(258,X);ee<=ie&&--$&&q!=j;){if(e[A+K]==e[A+K-ee]){for(var re=0;re<ne&&e[A+re]==e[A+re-ee];++re);if(re>K){if(K=re,J=ee,re>te)break;var se=Math.min(ee,re-2),ae=0;for(Y=0;Y<se;++Y){var oe=A-ee+Y+32768&32767,le=oe-x[oe]+32768&32767;le>ae&&(ae=le,j=oe)}}}ee+=(q=j)-(j=x[q])+32768&32767}if(J){I[O++]=268435456|Hp[K]<<18|Wp[J];var ce=31&Hp[K],he=31&Wp[J];F+=Op[ce]+Qp[he],++T[257+ce],++B[he],Q=A+K,++U}else I[O++]=e[A],++T[e[A]]}}p=wblk(e,d,l,I,T,B,F,O,G,A-G,p),!l&&7&p&&(p=wfblk(d,p+1,eA))}return slc(h,0,s+shft(p)+o)},tA=function(){for(var e=new Np(256),t=0;t<256;++t){for(var r=t,s=9;--s;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),crc=function(){var e=-1;return{p:function(t){for(var r=e,s=0;s<t.length;++s)r=tA[255&r^t[s]]^r>>>8;e=r},d:function(){return~e}}},dopt=function(e,t,r,s,o){return dflt(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,r,s,!o)},mrg=function(e,t){var r={};for(var s in e)r[s]=e[s];for(var s in t)r[s]=t[s];return r},wbytes=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8};function deflateSync(e,t){return dopt(e,t||{},0,0)}var fltn=function(e,t,r,s){for(var o in e){var l=e[o],c=t+o;l instanceof Pp?r[c]=[l,s]:Array.isArray(l)?r[c]=[l[0],mrg(s,l[1])]:fltn(l,c+"/",r,s)}},iA="undefined"!=typeof TextEncoder&&new TextEncoder,nA="undefined"!=typeof TextDecoder&&new TextDecoder;try{nA.decode(eA,{stream:!0}),1}catch(e){}function strToU8(e,t){if(t){for(var r=new Pp(e.length),s=0;s<e.length;++s)r[s]=e.charCodeAt(s);return r}if(iA)return iA.encode(e);var o=e.length,l=new Pp(e.length+(e.length>>1)),c=0,w=function(e){l[c++]=e};for(s=0;s<o;++s){if(c+5>l.length){var h=new Pp(c+8+(o-s<<1));h.set(l),l=h}var d=e.charCodeAt(s);d<128||t?w(d):d<2048?(w(192|d>>6),w(128|63&d)):d>55295&&d<57344?(w(240|(d=65536+(1047552&d)|1023&e.charCodeAt(++s))>>18),w(128|d>>12&63),w(128|d>>6&63),w(128|63&d)):(w(224|d>>12),w(128|d>>6&63),w(128|63&d))}return slc(l,0,c)}var exfl=function(e){var t=0;if(e)for(var r in e){var s=e[r].length;if(s>65535)throw"extra field too long";t+=s+4}return t},wzh=function(e,t,r,s,o,l,c,h){var d=s.length,p=r.extra,A=h&&h.length,m=exfl(p);wbytes(e,t,null!=c?33639248:67324752),t+=4,null!=c&&(e[t++]=20,e[t++]=r.os),e[t]=20,t+=2,e[t++]=r.flag<<1|(null==l&&8),e[t++]=o&&8,e[t++]=255&r.compression,e[t++]=r.compression>>8;var f=new Date(null==r.mtime?Date.now():r.mtime),g=f.getFullYear()-1980;if(g<0||g>119)throw"date not in range 1980-2099";if(wbytes(e,t,g<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),t+=4,null!=l&&(wbytes(e,t,r.crc),wbytes(e,t+4,l),wbytes(e,t+8,r.size)),wbytes(e,t+12,d),wbytes(e,t+14,m),t+=16,null!=c&&(wbytes(e,t,A),wbytes(e,t+6,r.attrs),wbytes(e,t+10,c),t+=14),e.set(s,t),t+=d,m)for(var _ in p){var y=p[_],x=y.length;wbytes(e,t,+_),wbytes(e,t+2,x),e.set(y,t+4),t+=4+x}return A&&(e.set(h,t),t+=A),t},wzf=function(e,t,r,s,o){wbytes(e,t,101010256),wbytes(e,t+8,r),wbytes(e,t+10,r),wbytes(e,t+12,s),wbytes(e,t+16,o)};var rA=r(6763);class USDZExporter{async parse(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1},t);const r={},s="model.usda";r[s]=null;let o=buildHeader();o+=function buildSceneStart(e){return`def Xform "Root"\n{\n\tdef Scope "Scenes" (\n\t\tkind = "sceneLibrary"\n\t)\n\t{\n\t\tdef Xform "Scene" (\n\t\t\tcustomData = {\n\t\t\t\tbool preliminary_collidesWithEnvironment = 0\n\t\t\t\tstring sceneName = "Scene"\n\t\t\t}\n\t\t\tsceneName = "Scene"\n\t\t)\n\t\t{\n\t\ttoken preliminary:anchoring:type = "${e.ar.anchoring.type}"\n\t\ttoken preliminary:planeAnchoring:alignment = "${e.ar.planeAnchoring.alignment}"\n\n`}(t);const l={},c={};e.traverseVisible((e=>{if(e.isMesh){const t=e.geometry,s=e.material;if(s.isMeshStandardMaterial){const c="geometries/Geometry_"+t.id+".usda";if(!(c in r)){const e=function buildMeshObject(e){const t=function buildMesh(e){const t="Geometry",r=e.attributes,s=r.position.count;return`\n\tdef Mesh "${t}"\n\t{\n\t\tint[] faceVertexCounts = [${function buildMeshVertexCount(e){const t=null!==e.index?e.index.count:e.attributes.position.count;return Array(t/3).fill(3).join(", ")}(e)}]\n\t\tint[] faceVertexIndices = [${function buildMeshVertexIndices(e){const t=e.index,r=[];if(null!==t)for(let e=0;e<t.count;e++)r.push(t.getX(e));else{const t=e.attributes.position.count;for(let e=0;e<t;e++)r.push(e)}return r.join(", ")}(e)}]\n\t\tnormal3f[] normals = [${buildVector3Array(r.normal,s)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)\n\t\tpoint3f[] points = [${buildVector3Array(r.position,s)}]\n${function buildPrimvars(e){let t="";for(let r=0;r<4;r++){const s=r>0?r:"",o=e["uv"+s];void 0!==o&&(t+=`\n\t\ttexCoord2f[] primvars:st${s} = [${buildVector2Array(o)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}return t}(r)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(e);return`\ndef "Geometry"\n{\n${t}\n}\n`}(t);r[c]=function buildUSDFileAsString(e){let t=buildHeader();return t+=e,strToU8(t)}(e)}s.uuid in l||(l[s.uuid]=s),o+=function buildXform(e,t,r){const s="Object_"+e.id,o=buildMatrix(e.matrixWorld);e.matrixWorld.determinant()<0&&rA.warn("THREE.USDZExporter: USDZ does not support negative scales",e);return`def Xform "${s}" (\n\tprepend references = @./geometries/Geometry_${t.id}.usda@</Geometry>\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${o}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = </Materials/Material_${r.id}>\n}\n\n`}(e,t,s)}else rA.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",e)}else e.isCamera&&(o+=function buildCamera(e){const t=e.name?e.name:"Camera_"+e.id,r=buildMatrix(e.matrixWorld);e.matrixWorld.determinant()<0&&rA.warn("THREE.USDZExporter: USDZ does not support negative scales",e);return e.isOrthographicCamera?`def Camera "${t}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${r}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${e.near.toPrecision(sA)}, ${e.far.toPrecision(sA)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(e.left)+Math.abs(e.right))).toPrecision(sA)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(e.top)+Math.abs(e.bottom))).toPrecision(sA)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${t}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${r}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${e.near.toPrecision(sA)}, ${e.far.toPrecision(sA)})\n\t\t\tfloat focalLength = ${e.getFocalLength().toPrecision(sA)}\n\t\t\tfloat focusDistance = ${e.focus.toPrecision(sA)}\n\t\t\tfloat horizontalAperture = ${e.getFilmWidth().toPrecision(sA)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${e.getFilmHeight().toPrecision(sA)}\n\t\t}\n\t\n\t`}(e))})),o+="\n\t\t}\n\t}\n}\n\n",o+=function buildMaterials(e,t,r=!1){const s=[];for(const o in e){const l=e[o];s.push(buildMaterial(l,t,r))}return`def "Materials"\n{\n${s.join("")}\n}\n\n`}(l,c,t.quickLookCompatible),r[s]=strToU8(o),o=null;for(const e in c){let t=c[e];!0===t.isCompressedTexture&&(t=decompress(t));const s=imageToCanvas(t.image,t.flipY),o=await new Promise((e=>s.toBlob(e,"image/png",1)));r[`textures/Texture_${e}.png`]=new Uint8Array(await o.arrayBuffer())}let h=0;for(const e in r){const t=r[e];h+=34+e.length;const s=63&h;if(4!==s){const o=new Uint8Array(64-s);r[e]=[t,{extra:{12345:o}}]}h=t.length}return function zipSync(e,t){t||(t={});var r={},s=[];fltn(e,"",r,t);var o=0,l=0;for(var c in r){var h=r[c],d=h[0],p=h[1],A=0==p.level?0:8,m=(U=strToU8(c)).length,f=p.comment,g=f&&strToU8(f),_=g&&g.length,y=exfl(p.extra);if(m>65535)throw"filename too long";var x=A?deflateSync(d,p):d,S=x.length,C=crc();C.p(d),s.push(mrg(p,{size:d.length,crc:C.d(),c:x,f:U,m:g,u:m!=c.length||g&&f.length!=_,o,compression:A})),o+=30+m+y+S,l+=76+2*(m+y)+(_||0)+S}for(var b=new Pp(l+22),I=o,T=l-o,B=0;B<s.length;++B){var U=s[B];wzh(b,U.o,U,U.f,U.u,U.c.length);var F=30+U.f.length+exfl(U.extra);b.set(U.c,U.o+F),wzh(b,o,U,U.f,U.u,U.c.length,U.o,U.m),o+=16+F+(U.m?U.m.length:0)}return wzf(b,o,s.length,T,I),b}(r,{level:0})}}function imageToCanvas(e,t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=1024/Math.max(e.width,e.height),s=document.createElement("canvas");s.width=e.width*Math.min(1,r),s.height=e.height*Math.min(1,r);const o=s.getContext("2d");return!0===t&&(o.translate(0,s.height),o.scale(1,-1)),o.drawImage(e,0,0,s.width,s.height),s}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const sA=7;function buildHeader(){return'#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n'}function buildMatrix(e){const t=e.elements;return`( ${buildMatrixRow(t,0)}, ${buildMatrixRow(t,4)}, ${buildMatrixRow(t,8)}, ${buildMatrixRow(t,12)} )`}function buildMatrixRow(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function buildVector3Array(e,t){if(void 0===e)return rA.warn("USDZExporter: Normals missing."),Array(t).fill("(0, 0, 0)").join(", ");const r=[];for(let t=0;t<e.count;t++){const s=e.getX(t),o=e.getY(t),l=e.getZ(t);r.push(`(${s.toPrecision(sA)}, ${o.toPrecision(sA)}, ${l.toPrecision(sA)})`)}return r.join(", ")}function buildVector2Array(e){const t=[];for(let r=0;r<e.count;r++){const s=e.getX(r),o=e.getY(r);t.push(`(${s.toPrecision(sA)}, ${1-o.toPrecision(sA)})`)}return t.join(", ")}function buildMaterial(e,t,r=!1){const s="\t\t\t",o=[],l=[];function buildTexture(s,o,l){const c=s.source.id+"_"+s.flipY;t[c]=s;const h=s.channel>0?"st"+s.channel:"st",d={1e3:"repeat",1001:"clamp",1002:"mirror"},p=s.repeat.clone(),A=s.offset.clone(),m=s.rotation,f=Math.sin(m),g=Math.cos(m);return A.y=1-A.y-p.y,r?(A.x=A.x/p.x,A.y=A.y/p.y,A.x+=f/p.x,A.y+=g-1):(A.x+=f*p.x,A.y+=(1-g)*p.y),`\n\t\tdef Shader "PrimvarReader_${o}"\n\t\t{\n\t\t\tuniform token info:id = "UsdPrimvarReader_float2"\n\t\t\tfloat2 inputs:fallback = (0.0, 0.0)\n\t\t\ttoken inputs:varname = "${h}"\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Transform2d_${o}"\n\t\t{\n\t\t\tuniform token info:id = "UsdTransform2d"\n\t\t\ttoken inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${o}.outputs:result>\n\t\t\tfloat inputs:rotation = ${(m*(180/Math.PI)).toFixed(sA)}\n\t\t\tfloat2 inputs:scale = ${buildVector2(p)}\n\t\t\tfloat2 inputs:translation = ${buildVector2(A)}\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Texture_${s.id}_${o}"\n\t\t{\n\t\t\tuniform token info:id = "UsdUVTexture"\n\t\t\tasset inputs:file = @textures/Texture_${c}.png@\n\t\t\tfloat2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${o}.outputs:result>\n\t\t\t${void 0!==l?"float4 inputs:scale = "+function buildColor4(e){return`(${e.r}, ${e.g}, ${e.b}, 1.0)`}(l):""}\n\t\t\ttoken inputs:sourceColorSpace = "${s.colorSpace===et?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${d[s.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${d[s.wrapT]}"\n\t\t\tfloat outputs:r\n\t\t\tfloat outputs:g\n\t\t\tfloat outputs:b\n\t\t\tfloat3 outputs:rgb\n\t\t\t${e.transparent||e.alphaTest>0?"float outputs:a":""}\n\t\t}`}return e.side===m&&rA.warn("THREE.USDZExporter: USDZ does not support double sided materials",e),null!==e.map?(o.push(`${s}color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`),e.transparent?o.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`):e.alphaTest>0&&(o.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`),o.push(`${s}float inputs:opacityThreshold = ${e.alphaTest}`)),l.push(buildTexture(e.map,"diffuse",e.color))):o.push(`${s}color3f inputs:diffuseColor = ${buildColor(e.color)}`),null!==e.emissiveMap?(o.push(`${s}color3f inputs:emissiveColor.connect = </Materials/Material_${e.id}/Texture_${e.emissiveMap.id}_emissive.outputs:rgb>`),l.push(buildTexture(e.emissiveMap,"emissive"))):e.emissive.getHex()>0&&o.push(`${s}color3f inputs:emissiveColor = ${buildColor(e.emissive)}`),null!==e.normalMap&&(o.push(`${s}normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`),l.push(buildTexture(e.normalMap,"normal"))),null!==e.aoMap&&(o.push(`${s}float inputs:occlusion.connect = </Materials/Material_${e.id}/Texture_${e.aoMap.id}_occlusion.outputs:r>`),l.push(buildTexture(e.aoMap,"occlusion"))),null!==e.roughnessMap&&1===e.roughness?(o.push(`${s}float inputs:roughness.connect = </Materials/Material_${e.id}/Texture_${e.roughnessMap.id}_roughness.outputs:g>`),l.push(buildTexture(e.roughnessMap,"roughness"))):o.push(`${s}float inputs:roughness = ${e.roughness}`),null!==e.metalnessMap&&1===e.metalness?(o.push(`${s}float inputs:metallic.connect = </Materials/Material_${e.id}/Texture_${e.metalnessMap.id}_metallic.outputs:b>`),l.push(buildTexture(e.metalnessMap,"metallic"))):o.push(`${s}float inputs:metallic = ${e.metalness}`),null!==e.alphaMap?(o.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`),o.push(`${s}float inputs:opacityThreshold = 0.0001`),l.push(buildTexture(e.alphaMap,"opacity"))):o.push(`${s}float inputs:opacity = ${e.opacity}`),e.isMeshPhysicalMaterial&&(o.push(`${s}float inputs:clearcoat = ${e.clearcoat}`),o.push(`${s}float inputs:clearcoatRoughness = ${e.clearcoatRoughness}`),o.push(`${s}float inputs:ior = ${e.ior}`)),`\n\tdef Material "Material_${e.id}"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n${o.join("\n")}\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = </Materials/Material_${e.id}/PreviewSurface.outputs:surface>\n\n${l.join("\n")}\n\n\t}\n`}function buildColor(e){return`(${e.r}, ${e.g}, ${e.b})`}function buildVector2(e){return`(${e.x}, ${e.y})`}var aA=r(6763),ar_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};let oA=!1,lA=!1;const cA="#model-viewer-no-ar-fallback",hA=(uA=["quick-look","scene-viewer","webxr","none"],e=>{try{const t=Bl(e),r=(t.length?t[0].terms:[]).filter((e=>e&&"ident"===e.type)).map((e=>e.value)).filter((e=>uA.indexOf(e)>-1));return new Set(r)}catch(e){}return new Set});var uA;const dA="quick-look",pA="scene-viewer",AA="webxr",mA="none",fA=Symbol("arButtonContainer"),gA=Symbol("enterARWithWebXR"),_A=Symbol("openSceneViewer"),vA=Symbol("openIOSARQuickLook"),yA=Symbol("canActivateAR"),EA=Symbol("arMode"),xA=Symbol("arModes"),SA=Symbol("arAnchor"),MA=Symbol("preload"),CA=Symbol("onARButtonContainerClick"),bA=Symbol("onARStatus"),wA=Symbol("onARTracking"),IA=Symbol("onARTap"),TA=Symbol("selectARMode"),BA=Symbol("triggerLoad");var loading_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const RA="auto",LA="auto",DA="eager",UA=Symbol("defaultProgressBarElement"),PA=Symbol("posterContainerElement"),FA=Symbol("defaultPosterElement"),NA=Symbol("shouldDismissPoster"),OA=Symbol("hidePoster"),QA=Symbol("modelIsRevealed"),kA=Symbol("updateProgressBar"),GA=Symbol("ariaLabelCallToAction"),VA=Symbol("onProgress");var staging_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const HA=Math.PI/32,zA={basis:[degreesToRadians(numberNode(HA,"rad"))],keywords:{auto:[null]}},WA=Symbol("autoRotateStartTime"),qA=Symbol("radiansPerSecond"),jA=Symbol("syncRotationRate"),XA=Symbol("onCameraChange"),YA=(e=>{var t,r,s;class AnnotationModelViewerElement extends e{constructor(){super(...arguments),this[t]=new Map,this[r]=e=>{e.forEach((e=>{e instanceof MutationRecord&&"childList"!==e.type||(e.addedNodes.forEach((e=>{this[Lp](e)})),e.removedNodes.forEach((e=>{this[Dp](e)})),this[gp]())}))},this[s]=new MutationObserver(this[Bp])}connectedCallback(){super.connectedCallback();for(let e=0;e<this.children.length;++e)this[Lp](this.children[e]);const{ShadyDOM:e}=self;null==e?this[Rp].observe(this,{childList:!0}):this[Rp]=e.observeChildren(this,this[Bp])}disconnectedCallback(){super.disconnectedCallback();const{ShadyDOM:e}=self;null==e?this[Rp].disconnect():e.unobserveChildren(this[Rp])}[(t=Tp,r=Bp,s=Rp,_p)](e,t){super[_p](e,t);const r=this[fp],{annotationRenderer:s}=r,o=r.getCamera();r.shouldRender()&&(r.updateSurfaceHotspots(),r.updateHotspotsVisibility(o.position),s.domElement.style.display="",s.render(r,o))}updateHotspot(e){const t=this[Tp].get(e.name);null!=t&&(t.updatePosition(e.position),t.updateNormal(e.normal),t.surface=e.surface,this[gp]())}queryHotspot(e){const t=this[Tp].get(e);if(null==t)return null;const r=toVector3D(t.position),s=toVector3D(t.normal),o=t.facingCamera,l=this[fp],c=l.getCamera(),h=new three_module_Vector3;h.setFromMatrixPosition(t.matrixWorld),h.project(c);const d=l.width/2,p=l.height/2;h.x=h.x*d+d,h.y=-h.y*p+p;const A=toVector3D(new three_module_Vector3(h.x,h.y,h.z));return Number.isFinite(A.x)&&Number.isFinite(A.y)?{position:r,normal:s,canvasPosition:A,facingCamera:o}:null}positionAndNormalFromPoint(e,t){const r=this[fp],s=r.getNDC(e,t),o=r.positionAndNormalFromPoint(s);if(null==o)return null;Up.copy(r.target.matrixWorld).invert();const l=toVector3D(o.position.applyMatrix4(Up)),c=toVector3D(o.normal.transformDirection(Up));let h=null;return null!=o.uv&&(h=toVector2D(o.uv)),{position:l,normal:c,uv:h}}surfaceFromPoint(e,t){const r=this[fp],s=r.getNDC(e,t);return r.surfaceFromPoint(s)}[Lp](e){if(!(e instanceof HTMLElement&&0===e.slot.indexOf("hotspot")))return;let t=this[Tp].get(e.slot);null!=t?t.increment():(t=new Hotspot({name:e.slot,position:e.dataset.position,normal:e.dataset.normal,surface:e.dataset.surface}),this[Tp].set(e.slot,t),this[fp].addHotspot(t)),this[fp].queueRender()}[Dp](e){if(!(e instanceof HTMLElement))return;const t=this[Tp].get(e.slot);t&&(t.decrement()&&(this[fp].removeHotspot(t),this[Tp].delete(e.slot)),this[fp].queueRender())}}return AnnotationModelViewerElement})((e=>{var t,r,s;class SceneGraphModelViewerElement extends e{constructor(){super(...arguments),this[t]=void 0,this[r]=null,this[s]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[Ad]}get availableVariants(){return this.model?this.model[cd]():[]}get originalGltfJson(){return this[pd]}[(t=Ad,r=dd,s=pd,md)](){return()=>{this[gp]()}}[fd](e){return e.colorSpace=tt,e.wrapS=ue,e.wrapT=ue,new texture_Texture(this[md](),e)}async createTexture(e,t="image/png"){const{textureUtils:r}=this[Ep],s=await r.loadImage(e);return s.userData.mimeType=t,this[fd](s)}async createLottieTexture(e,t=1){const{textureUtils:r}=this[Ep],s=await r.loadLottie(e,t);return this[fd](s)}createVideoTexture(e){const t=document.createElement("video");t.crossOrigin=this.withCredentials?"use-credentials":"anonymous",t.src=e,t.muted=!0,t.playsInline=!0,t.loop=!0,t.play();const r=new VideoTexture(t);return this[fd](r)}createCanvasTexture(){const e=document.createElement("canvas"),t=new CanvasTexture(e);return this[fd](t)}async updated(e){if(super.updated(e),e.has("variantName")){const e=this[xp].beginActivity("variant-update");e(.1);const t=this[Ad],{variantName:r}=this;null!=t&&(await t[rd](r),this[gp](),this.dispatchEvent(new CustomEvent("variant-applied"))),e(1)}if(e.has("orientation")||e.has("scale")){if(!this.loaded)return;const e=this[fp];e.applyTransform(),e.updateBoundingBox(),e.updateShadow(),this[Ep].arRenderer.onUpdateScene(),this[gp]()}}[vp](){super[vp]();const{currentGLTF:e}=this[fp];if(null!=e){const{correlatedSceneGraph:t}=e;null!=t&&e!==this[dd]&&(this[Ad]=new Model(t,this[md]()),this[pd]=JSON.parse(JSON.stringify(t.gltf))),"variants"in e.userData&&this.requestUpdate("variantName")}this[dd]=e}async exportScene(e){const t=this[fp];return new Promise((async(r,s)=>{const o={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(o,e),o.animations=t.animations,o.truncateDrawRange=!0;const l=t.shadow;let c=!1;null!=l&&(c=l.visible,l.visible=!1),await this[Ad][nd]();(new GLTFExporter).register((e=>new GLTFExporterMaterialsVariantsExtension(e))).parse(t.model,(e=>r(new Blob([o.binary?e:JSON.stringify(e)],{type:o.binary?"application/octet-stream":"application/json"}))),(()=>s("glTF export failed")),o),null!=l&&(l.visible=c)}))}materialFromPoint(e,t){const r=this[Ad];if(null==r)return null;const s=this[fp],o=s.getNDC(e,t),l=s.hitFromPoint(o);return null==l||null==l.face?null:r[sd](l)}}return scene_graph_decorate([n({type:String,attribute:"variant-name"})],SceneGraphModelViewerElement.prototype,"variantName",void 0),scene_graph_decorate([n({type:String,attribute:"orientation"})],SceneGraphModelViewerElement.prototype,"orientation",void 0),scene_graph_decorate([n({type:String,attribute:"scale"})],SceneGraphModelViewerElement.prototype,"scale",void 0),SceneGraphModelViewerElement})((e=>{var t,r,s;class StagingModelViewerElement extends e{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=3e3,this.rotationPerSecond="auto",this[t]=performance.now(),this[r]=0,this[s]=e=>{this.autoRotate&&"user-interaction"===e.detail.source&&(this[WA]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[XA]),this[WA]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[XA]),this[WA]=performance.now()}updated(e){super.updated(e),e.has("autoRotate")&&(this[WA]=performance.now())}[(t=WA,r=qA,jA)](e){this[qA]=e[0]}[_p](e,t){if(super[_p](e,t),!this.autoRotate||!this[Mp]()||this[Ep].isPresenting)return;const r=Math.min(t,e-this[WA]-this.autoRotateDelay);r>0&&(this[fp].yaw=this.turntableRotation+this[qA]*r*.001)}get turntableRotation(){return this[fp].yaw}resetTurntableRotation(e=0){this[fp].yaw=e}}return s=XA,staging_decorate([n({type:Boolean,attribute:"auto-rotate"})],StagingModelViewerElement.prototype,"autoRotate",void 0),staging_decorate([n({type:Number,attribute:"auto-rotate-delay"})],StagingModelViewerElement.prototype,"autoRotateDelay",void 0),staging_decorate([style({intrinsics:zA,updateHandler:jA}),n({type:String,attribute:"rotation-per-second"})],StagingModelViewerElement.prototype,"rotationPerSecond",void 0),StagingModelViewerElement})((e=>{var t,r,s;class EnvironmentModelViewerElement extends e{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=0,this.shadowSoftness=1,this.exposure=1,this.toneMapping="auto",this.skyboxHeight="0",this[t]=null,this[r]=null,this[s]=null}updated(e){super.updated(e),e.has("shadowIntensity")&&(this[fp].setShadowIntensity(.5*this.shadowIntensity),this[gp]()),e.has("shadowSoftness")&&(this[fp].setShadowSoftness(this.shadowSoftness),this[gp]()),e.has("exposure")&&(this[fp].exposure=this.exposure,this[gp]()),e.has("toneMapping")&&(this[fp].toneMapping="commerce"===this.toneMapping?ie:"agx"===this.toneMapping?ne:te,this[gp]()),(e.has("environmentImage")||e.has("skyboxImage"))&&this[Cp]()&&this[_a](),e.has("skyboxHeight")&&(this[fp].setGroundedSkybox(),this[gp]())}hasBakedShadow(){return this[fp].bakedShadows.size>0}async[(t=fa,r=ga,s=va,_a)](){const{skyboxImage:e,environmentImage:t}=this;null!=this[va]&&(this[va](),this[va]=null);const{textureUtils:r}=this[Ep];if(null==r)return;const s=this[xp].beginActivity("environment-update");try{const{environmentMap:o,skybox:l}=await r.generateEnvironmentMapAndSkybox(deserializeUrl(e),t,(e=>s(utilities_clamp(e,0,1))));this[fa]!==o&&(this[fa]=o,this.dispatchEvent(new CustomEvent("environment-change"))),this[ga]=null!=l?l.name===o.name?o:l:null,this[fp].setEnvironmentAndSkybox(this[fa],this[ga])}catch(e){if(e instanceof Error)throw this[fp].setEnvironmentAndSkybox(null,null),e}finally{s(1)}}}return __decorate([n({type:String,attribute:"environment-image"})],EnvironmentModelViewerElement.prototype,"environmentImage",void 0),__decorate([n({type:String,attribute:"skybox-image"})],EnvironmentModelViewerElement.prototype,"skyboxImage",void 0),__decorate([n({type:Number,attribute:"shadow-intensity"})],EnvironmentModelViewerElement.prototype,"shadowIntensity",void 0),__decorate([n({type:Number,attribute:"shadow-softness"})],EnvironmentModelViewerElement.prototype,"shadowSoftness",void 0),__decorate([n({type:Number})],EnvironmentModelViewerElement.prototype,"exposure",void 0),__decorate([n({type:String,attribute:"tone-mapping"})],EnvironmentModelViewerElement.prototype,"toneMapping",void 0),__decorate([n({type:String,attribute:"skybox-height"})],EnvironmentModelViewerElement.prototype,"skyboxHeight",void 0),EnvironmentModelViewerElement})((e=>{var t,r,s,o,l,c,h,d,p,A,m,f,g,_,y,x,S;class ControlsModelViewerElement extends e{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=gc,this.cameraTarget="auto auto auto",this.fieldOfView="auto",this.minCameraOrbit="auto",this.maxCameraOrbit="auto",this.minFieldOfView="auto",this.maxFieldOfView="auto",this.interactionPromptThreshold=3e3,this.interactionPrompt=yc,this.interactionPromptStyle=xc,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.touchAction=Sc,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=50,this[t]=this.shadowRoot.querySelector(".interaction-prompt"),this[r]=this.shadowRoot.querySelector("#prompt"),this[s]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[o]=this.shadowRoot.querySelector(".pan-target"),this[l]=0,this[c]=1/0,this[h]=!1,this[d]=!1,this[p]=oh.AUTOMATIC,this[A]=new SmoothControls(this[fp].camera,this[Ap],this[fp]),this[m]=new Spherical,this[f]=!1,this[g]=!1,this[_]=!1,this[y]=()=>{const e=this[Tc].changeSource;this[zc]=e,e===oh.USER_INTERACTION&&(this[Gc]=!0,this[Uc]())},this[x]=()=>{this[Pc](),this[gp]();const e=this[Tc].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:e}}))},this[S]=e=>{this[pp].classList.toggle("pointer-tumbling","pointer-change-start"===e.type)}}get inputSensitivity(){return this[Tc].inputSensitivity}set inputSensitivity(e){this[Tc].inputSensitivity=e}getCameraOrbit(){const{theta:e,phi:t,radius:r}=this[Wc];return{theta:e,phi:t,radius:r,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return toVector3D(this[Ep].isPresenting?this[Ep].arRenderer.target:this[fp].getTarget())}getFieldOfView(){return this[Tc].getFieldOfView()}getMinimumFieldOfView(){return this[Tc].options.minimumFieldOfView}getMaximumFieldOfView(){return this[Tc].options.maximumFieldOfView}getIdealAspect(){return this[fp].idealAspect}jumpCameraToGoal(){this[qc]=!0,this.requestUpdate(qc,!1)}resetInteractionPrompt(){this[Hc]=0,this[Vc]=1/0,this[Gc]=!1,this[kc]=this.interactionPrompt===yc&&this.cameraControls}zoom(e){const t=new WheelEvent("wheel",{deltaY:-30*e});this[Ap].dispatchEvent(t)}connectedCallback(){super.connectedCallback(),this[Tc].addEventListener("user-interaction",this[Nc]),this[Tc].addEventListener("pointer-change-start",this[Qc]),this[Tc].addEventListener("pointer-change-end",this[Qc])}disconnectedCallback(){super.disconnectedCallback(),this[Tc].removeEventListener("user-interaction",this[Nc]),this[Tc].removeEventListener("pointer-change-start",this[Qc]),this[Tc].removeEventListener("pointer-change-end",this[Qc])}updated(e){super.updated(e);const t=this[Tc],r=this[fp];if(e.has("cameraControls")&&(this.cameraControls?(t.enableInteraction(),this.interactionPrompt===yc&&(this[kc]=!0)):(t.disableInteraction(),this[Uc]()),this[Ap].setAttribute("aria-label",this[ap])),e.has("disableZoom")&&(t.disableZoom=this.disableZoom),e.has("disablePan")&&(t.enablePan=!this.disablePan),e.has("disableTap")&&(t.enableTap=!this.disableTap),(e.has("interactionPrompt")||e.has("cameraControls")||e.has("src"))&&(this.interactionPrompt===yc&&this.cameraControls&&!this[Gc]?this[kc]=!0:this[Uc]()),e.has("interactionPromptStyle")&&(this[Lc].style.opacity=this.interactionPromptStyle==Ec?"1":"0"),e.has("touchAction")){const e=this.touchAction;t.applyOptions({touchAction:e}),t.updateTouchActionStyle()}e.has("orbitSensitivity")&&(t.orbitSensitivity=this.orbitSensitivity),e.has("zoomSensitivity")&&(t.zoomSensitivity=this.zoomSensitivity),e.has("panSensitivity")&&(t.panSensitivity=this.panSensitivity),e.has("interpolationDecay")&&(t.setDamperDecayTime(this.interpolationDecay),r.setTargetDamperDecayTime(this.interpolationDecay)),!0===this[qc]&&Promise.resolve().then((()=>{t.jumpToGoal(),r.jumpToGoal(),this[Oc](),this[qc]=!1}))}async updateFraming(){const e=this[fp],t=e.adjustedFoV(e.framedFoVDeg);await e.updateFraming();const r=e.adjustedFoV(e.framedFoVDeg),s=this[Tc].getFieldOfView()/t;this[Tc].setFieldOfView(r*s),this[Xc]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(e,t,r){const s=this[Ap],o=this[Dc];if("1"===o[0].style.opacity)return void Ac.warn("interact() failed because an existing interaction is running.");const l=new Array;l.push({x:timeline(t.x),y:timeline(t.y)});const c=[{x:l[0].x(0),y:l[0].y(0)}];null!=r&&(l.push({x:timeline(r.x),y:timeline(r.y)}),c.push({x:l[1].x(0),y:l[1].y(0)}));let h=performance.now();const{width:d,height:p}=this[fp],A=this.getBoundingClientRect(),dispatchTouches=e=>{for(const[t,r]of c.entries()){const{style:l}=o[t];l.transform=`translateX(${d*r.x}px) translateY(${p*r.y}px)`,"pointerdown"===e?l.opacity="1":"pointerup"===e&&(l.opacity="0");const c={pointerId:t-5678,pointerType:"touch",target:s,clientX:d*r.x+A.x,clientY:p*r.y+A.y,altKey:!0};s.dispatchEvent(new PointerEvent(e,c))}},moveTouches=()=>{const t=this[zc];if(t!==oh.AUTOMATIC||!s.isConnected){for(const e of this[Dc])e.style.opacity="0";return dispatchTouches("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:t}})),void document.removeEventListener("visibilitychange",onVisibilityChange)}const r=Math.min(1,(performance.now()-h)/e);for(const[e,t]of c.entries())t.x=l[e].x(r),t.y=l[e].y(r);dispatchTouches("pointermove"),r<1?requestAnimationFrame(moveTouches):(dispatchTouches("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:oh.AUTOMATIC}})),document.removeEventListener("visibilitychange",onVisibilityChange))},onVisibilityChange=()=>{let e=0;"hidden"===document.visibilityState?e=performance.now()-h:h=performance.now()-e};document.addEventListener("visibilitychange",onVisibilityChange),dispatchTouches("pointerdown"),this[zc]=oh.AUTOMATIC,requestAnimationFrame(moveTouches)}[(t=Rc,r=Lc,s=Dc,o=Bc,l=Hc,c=Vc,h=Gc,d=kc,p=zc,A=Tc,m=Wc,f=qc,g=jc,_=Xc,Kc)](e){const t=this[Tc],r=this[fp];r.framedFoVDeg=180*e[0]/Math.PI,t.changeSource=oh.NONE,t.setFieldOfView(r.adjustedFoV(r.framedFoVDeg)),this[Nc]()}[Yc](e){const t=this[Tc];if(this[Xc]){const{theta:t,phi:r}=this.getCameraOrbit();e[0]=t,e[1]=r,this[Xc]=!1}t.changeSource=oh.NONE,t.setOrbit(e[0],e[1],e[2]),this[Nc]()}[$c](e){this[Tc].applyOptions({minimumAzimuthalAngle:e[0],minimumPolarAngle:e[1],minimumRadius:e[2]}),this.jumpCameraToGoal()}[Zc](e){this[Tc].applyOptions({maximumAzimuthalAngle:e[0],maximumPolarAngle:e[1],maximumRadius:e[2]}),this[Fc](e[2]),this.jumpCameraToGoal()}[eh](e){this[Tc].applyOptions({minimumFieldOfView:180*e[0]/Math.PI}),this.jumpCameraToGoal()}[th](e){const t=this[fp].adjustedFoV(180*e[0]/Math.PI);this[Tc].applyOptions({maximumFieldOfView:t}),this.jumpCameraToGoal()}[Jc](e){const[t,r,s]=e;this[Ep].arRenderer.isPresenting||this[fp].setTarget(t,r,s),this[Tc].changeSource=oh.NONE,this[Ep].arRenderer.updateTarget(),this[Nc]()}[_p](e,t){if(super[_p](e,t),this[Ep].isPresenting||!this[Mp]())return;const r=this[Tc],s=this[fp],o=performance.now();if(this[kc]&&this.loaded&&o>this[hp]+this.interactionPromptThreshold&&(this[kc]=!1,this[Vc]=o,this[Rc].classList.add("visible")),isFinite(this[Vc])&&this.interactionPromptStyle===xc){const e=(o-this[Vc])/5e3%1,t=mc(e),l=fc(e);if(this[Lc].style.opacity=`${l}`,t!==this[Hc]){const e=t*s.width*.05,o=(t-this[Hc])*Math.PI/16;this[Lc].style.transform=`translateX(${e}px)`,r.changeSource=oh.AUTOMATIC,r.adjustOrbit(o,0,0),this[Hc]=t}}const l=r.update(e,t),c=s.updateTarget(t);(l||c)&&this[Oc]()}[Uc](){this[kc]=!1,this[Rc].classList.remove("visible"),this[Vc]=1/0}[Fc](e){const t=Math.max(this[fp].farRadius(),e),r=Math.abs(2*t);this[Tc].updateNearFar(0,r)}[Pc](){const{theta:e,phi:t}=this[Tc].getCameraSpherical(this[Wc]),r=(4+Math.floor((e%Ic+wc)/Cc))%4,s=Math.floor(t/bc),o=_c[r],l=vc[s];this[cp](`View from stage ${l}${o}`)}get[ap](){return super[ap].replace(/\.$/,"")+(this.cameraControls?". Use mouse, touch or arrow keys to move.":"")}async[yp](e){const t=this[Tc],r=this[fp],s=r.adjustedFoV(r.framedFoVDeg);super[yp](e);const o=r.adjustedFoV(r.framedFoVDeg)/s,l=t.getFieldOfView()*(isFinite(o)?o:1);t.updateAspect(this[fp].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[Tc].setFieldOfView(l),this.jumpCameraToGoal()}[vp](){super[vp](),this[jc]?this[Xc]=!0:this[jc]=!0,this.requestUpdate("maxFieldOfView",this.maxFieldOfView),this.requestUpdate("fieldOfView",this.fieldOfView),this.requestUpdate("minCameraOrbit",this.minCameraOrbit),this.requestUpdate("maxCameraOrbit",this.maxCameraOrbit),this.requestUpdate("cameraOrbit",this.cameraOrbit),this.requestUpdate("cameraTarget",this.cameraTarget),this.jumpCameraToGoal()}}return y=Nc,x=Oc,S=Qc,controls_decorate([n({type:Boolean,attribute:"camera-controls"})],ControlsModelViewerElement.prototype,"cameraControls",void 0),controls_decorate([style({intrinsics:Mc,observeEffects:!0,updateHandler:Yc}),n({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"cameraOrbit",void 0),controls_decorate([style({intrinsics:cameraTargetIntrinsics,observeEffects:!0,updateHandler:Jc}),n({type:String,attribute:"camera-target",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"cameraTarget",void 0),controls_decorate([style({intrinsics:fieldOfViewIntrinsics,observeEffects:!0,updateHandler:Kc}),n({type:String,attribute:"field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"fieldOfView",void 0),controls_decorate([style({intrinsics:minCameraOrbitIntrinsics,updateHandler:$c}),n({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"minCameraOrbit",void 0),controls_decorate([style({intrinsics:maxCameraOrbitIntrinsics,updateHandler:Zc}),n({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"maxCameraOrbit",void 0),controls_decorate([style({intrinsics:minFieldOfViewIntrinsics,updateHandler:eh}),n({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"minFieldOfView",void 0),controls_decorate([style({intrinsics:fieldOfViewIntrinsics,updateHandler:th}),n({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"maxFieldOfView",void 0),controls_decorate([n({type:Number,attribute:"interaction-prompt-threshold"})],ControlsModelViewerElement.prototype,"interactionPromptThreshold",void 0),controls_decorate([n({type:String,attribute:"interaction-prompt"})],ControlsModelViewerElement.prototype,"interactionPrompt",void 0),controls_decorate([n({type:String,attribute:"interaction-prompt-style"})],ControlsModelViewerElement.prototype,"interactionPromptStyle",void 0),controls_decorate([n({type:Number,attribute:"orbit-sensitivity"})],ControlsModelViewerElement.prototype,"orbitSensitivity",void 0),controls_decorate([n({type:Number,attribute:"zoom-sensitivity"})],ControlsModelViewerElement.prototype,"zoomSensitivity",void 0),controls_decorate([n({type:Number,attribute:"pan-sensitivity"})],ControlsModelViewerElement.prototype,"panSensitivity",void 0),controls_decorate([n({type:String,attribute:"touch-action"})],ControlsModelViewerElement.prototype,"touchAction",void 0),controls_decorate([n({type:Boolean,attribute:"disable-zoom"})],ControlsModelViewerElement.prototype,"disableZoom",void 0),controls_decorate([n({type:Boolean,attribute:"disable-pan"})],ControlsModelViewerElement.prototype,"disablePan",void 0),controls_decorate([n({type:Boolean,attribute:"disable-tap"})],ControlsModelViewerElement.prototype,"disableTap",void 0),controls_decorate([n({type:Number,attribute:"interpolation-decay"})],ControlsModelViewerElement.prototype,"interpolationDecay",void 0),ControlsModelViewerElement})((e=>{var t,r,s,o,l,c,h,d,p,A;class ARModelViewerElement extends e{constructor(){super(...arguments),this.ar=!1,this.arScale="auto",this.arPlacement="floor",this.arModes="webxr scene-viewer quick-look",this.iosSrc=null,this.xrEnvironment=!1,this[t]=!1,this[r]=this.shadowRoot.querySelector(".ar-button"),this[s]=document.createElement("a"),this[o]=new Set,this[l]=mA,this[c]=!1,this[h]=e=>{e.preventDefault(),this.activateAR()},this[d]=({status:e})=>{e!==hh&&this[Ep].arRenderer.presentedScene!==this[fp]||(this.setAttribute("ar-status",e),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:e}})),e===hh?this.removeAttribute("ar-tracking"):e===uh&&this.setAttribute("ar-tracking",Ah))},this[p]=({status:e})=>{this.setAttribute("ar-tracking",e),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:e}}))},this[A]=e=>{"_apple_ar_quicklook_button_tapped"==e.data&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[EA]!==mA}connectedCallback(){super.connectedCallback(),this[Ep].arRenderer.addEventListener("status",this[bA]),this.setAttribute("ar-status",hh),this[Ep].arRenderer.addEventListener("tracking",this[wA]),this[SA].addEventListener("message",this[IA])}disconnectedCallback(){super.disconnectedCallback(),this[Ep].arRenderer.removeEventListener("status",this[bA]),this[Ep].arRenderer.removeEventListener("tracking",this[wA]),this[SA].removeEventListener("message",this[IA])}update(e){super.update(e),e.has("arScale")&&(this[fp].canScale="fixed"!==this.arScale),e.has("arPlacement")&&(this[fp].updateShadow(),this[gp]()),e.has("arModes")&&(this[xA]=hA(this.arModes)),(e.has("ar")||e.has("arModes")||e.has("src")||e.has("iosSrc"))&&this[TA]()}async activateAR(){switch(this[EA]){case dA:await this[vA]();break;case AA:await this[gA]();break;case pA:this[_A]();break;default:aA.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities")}}async[(t=yA,r=fA,s=SA,o=xA,l=EA,c=MA,h=CA,d=bA,p=wA,A=IA,TA)](){let e=mA;if(this.ar){if(null!=this.src)for(const t of this[xA]){if("webxr"===t&&sa&&!oA&&await this[Ep].arRenderer.supportsPresentation()){e=AA;break}if("scene-viewer"===t&&ha&&!lA){e=pA;break}if("quick-look"===t&&da){e=dA;break}}e===mA&&null!=this.iosSrc&&da&&(e=dA)}if(e!==mA)this[fA].classList.add("enabled"),this[fA].addEventListener("click",this[CA]);else if(this[fA].classList.contains("enabled")){this[fA].removeEventListener("click",this[CA]),this[fA].classList.remove("enabled");const e=ph;this.setAttribute("ar-status",e),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:e}}))}this[EA]=e}async[gA](){aA.log("Attempting to present in AR with WebXR..."),await this[BA]();try{this[fA].removeEventListener("click",this[CA]);const{arRenderer:e}=this[Ep];e.placeOnWall="wall"===this.arPlacement,await e.present(this[fp],this.xrEnvironment)}catch(e){aA.warn("Error while trying to present in AR with WebXR"),aA.error(e),await this[Ep].arRenderer.stopPresenting(),oA=!0,aA.warn("Falling back to next ar-mode"),await this[TA](),this.activateAR()}finally{this[TA]()}}async[BA](){this.loaded||(this[MA]=!0,this[up](),await((e,t,r=null)=>new Promise((s=>{e.addEventListener(t,(function handler(o){r&&!r(o)||(s(o),e.removeEventListener(t,handler))}))})))(this,"load"),this[MA]=!1)}[Cp](){return super[Cp]()||this[MA]}[_A](){const e=self.location.toString(),t=new URL(e),r=new URL(this.src,e);r.hash&&(r.hash="");const s=new URLSearchParams(r.search);if(t.hash=cA,s.set("mode","ar_preferred"),s.has("disable_occlusion")||s.set("disable_occlusion","true"),"fixed"===this.arScale&&s.set("resizable","false"),"wall"===this.arPlacement&&s.set("enable_vertical_placement","true"),s.has("sound")){const t=new URL(s.get("sound"),e);s.set("sound",t.toString())}if(s.has("link")){const t=new URL(s.get("link"),e);s.set("link",t.toString())}const o=`intent://arvr.google.com/scene-viewer/1.0?${s.toString()+"&file="+encodeURIComponent(r.toString())}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(t.toString())};end;`;self.addEventListener("hashchange",(()=>{self.location.hash===cA&&(lA=!0,self.history.back(),aA.warn("Error while trying to present in AR with Scene Viewer"),aA.warn("Falling back to next ar-mode"),this[TA]())}),{once:!0}),this[SA].setAttribute("href",o),aA.log("Attempting to present in AR with Scene Viewer..."),this[SA].click()}async[vA](){const e=!this.iosSrc;this[fA].classList.remove("enabled");const t=e?await this.prepareUSDZ():this.iosSrc,r=new URL(t,self.location.toString());if(e){const e=self.location.toString(),t=new URL(e),s=new URL(this.src,t);s.hash&&(r.hash=s.hash)}"fixed"===this.arScale&&(r.hash&&(r.hash+="&"),r.hash+="allowsContentScaling=0");const s=this[SA];s.setAttribute("rel","ar");const o=document.createElement("img");s.appendChild(o),s.setAttribute("href",r.toString()),e&&s.setAttribute("download","model.usdz"),s.style.display="none",s.isConnected||this.shadowRoot.appendChild(s),aA.log("Attempting to present in AR with Quick Look..."),s.click(),s.removeChild(o),e&&URL.revokeObjectURL(t),this[fA].classList.add("enabled")}async prepareUSDZ(){const e=this[xp].beginActivity("usdz-conversion");await this[BA]();const{model:t,shadow:r}=this[fp];if(null==t)return"";let s=!1;null!=r&&(s=r.visible,r.visible=!1),e(.2);const o=new USDZExporter,l=await o.parse(t),c=new Blob([l],{type:"model/vnd.usdz+zip"}),h=URL.createObjectURL(c);return e(1),null!=r&&(r.visible=s),h}}return ar_decorate([n({type:Boolean,attribute:"ar"})],ARModelViewerElement.prototype,"ar",void 0),ar_decorate([n({type:String,attribute:"ar-scale"})],ARModelViewerElement.prototype,"arScale",void 0),ar_decorate([n({type:String,attribute:"ar-placement"})],ARModelViewerElement.prototype,"arPlacement",void 0),ar_decorate([n({type:String,attribute:"ar-modes"})],ARModelViewerElement.prototype,"arModes",void 0),ar_decorate([n({type:String,attribute:"ios-src"})],ARModelViewerElement.prototype,"iosSrc",void 0),ar_decorate([n({type:Boolean,attribute:"xr-environment"})],ARModelViewerElement.prototype,"xrEnvironment",void 0),ARModelViewerElement})((e=>{var t,r,s,o,l,c,h,d;class LoadingModelViewerElement extends e{constructor(...e){super(...e),this.poster=null,this.reveal=RA,this.loading=LA,this[t]=!1,this[r]=!1,this[s]=this.shadowRoot.querySelector(".slot.poster"),this[o]=this.shadowRoot.querySelector("#default-poster"),this[l]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[c]=this[FA].getAttribute("aria-label"),this[h]=((e,t)=>{let r=null;const throttled=(...s)=>{null==r&&(e(...s),r=self.setTimeout((()=>r=null),t))};return throttled.flush=()=>{null!=r&&(self.clearTimeout(r),r=null)},throttled})((e=>{const t=this[UA].parentNode;requestAnimationFrame((()=>{this[UA].style.transform=`scaleX(${e})`,0===e&&(t.removeChild(this[UA]),t.appendChild(this[UA])),this[UA].classList.toggle("hide",1===e)}))}),100),this[d]=e=>{const t=e.detail.totalProgress;1===t&&(this[kA].flush(),this.loaded&&(this[NA]||this.reveal===RA)&&this[OA]()),this[kA](t),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:t}}))};const p=self.ModelViewerElement||{},A=p.dracoDecoderLocation||"https://www.gstatic.com/draco/versioned/decoders/1.5.6/";CachingGLTFLoader.setDRACODecoderLocation(A);const m=p.ktx2TranscoderLocation||"https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";CachingGLTFLoader.setKTX2TranscoderLocation(m),p.meshoptDecoderLocation&&CachingGLTFLoader.setMeshoptDecoderLocation(p.meshoptDecoderLocation);const f=p.lottieLoaderLocation||"https://cdn.jsdelivr.net/npm/three@0.149.0/examples/jsm/loaders/LottieLoader.js";Renderer.singleton.textureUtils.lottieLoaderUrl=f}static set dracoDecoderLocation(e){CachingGLTFLoader.setDRACODecoderLocation(e)}static get dracoDecoderLocation(){return CachingGLTFLoader.getDRACODecoderLocation()}static set ktx2TranscoderLocation(e){CachingGLTFLoader.setKTX2TranscoderLocation(e)}static get ktx2TranscoderLocation(){return CachingGLTFLoader.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(e){CachingGLTFLoader.setMeshoptDecoderLocation(e)}static get meshoptDecoderLocation(){return CachingGLTFLoader.getMeshoptDecoderLocation()}static set lottieLoaderLocation(e){Renderer.singleton.textureUtils.lottieLoaderUrl=e}static get lottieLoaderLocation(){return Renderer.singleton.textureUtils.lottieLoaderUrl}static mapURLs(e){Renderer.singleton.loader[ko].manager.setURLModifier(e)}dismissPoster(){this.loaded?this[OA]():(this[NA]=!0,this[up]())}showPoster(){const e=this[PA];if(e.classList.contains("show"))return;e.classList.add("show"),this[Ap].classList.remove("show");const t=this[FA];t.removeAttribute("tabindex"),t.removeAttribute("aria-hidden");const r=this.modelIsVisible;this[QA]=!1,this[sp](r)}getDimensions(){return toVector3D(this[fp].size)}getBoundingBoxCenter(){return toVector3D(this[fp].boundingBox.getCenter(new three_module_Vector3))}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[xp].addEventListener("progress",this[VA])}disconnectedCallback(){super.disconnectedCallback(),this[xp].removeEventListener("progress",this[VA])}async updated(e){super.updated(e),e.has("poster")&&null!=this.poster&&(this[FA].style.backgroundImage=`url(${this.poster})`),e.has("alt")&&this[FA].setAttribute("aria-label",this[op]),(e.has("reveal")||e.has("loading"))&&this[up]()}[(t=QA,r=NA,s=PA,o=FA,l=UA,c=GA,h=kA,d=VA,Cp)](){return!!this.src&&(this[NA]||this.loading===DA||this.reveal===RA&&this[rp])}[OA](){this[NA]=!1;const e=this[PA];if(!e.classList.contains("show"))return;e.classList.remove("show"),this[Ap].classList.add("show");const t=this.modelIsVisible;this[QA]=!0,this[sp](t);const r=this.getRootNode();r&&r.activeElement===this&&this[Ap].focus();const s=this[FA];s.setAttribute("aria-hidden","true"),s.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[Mp](){return super[Mp]()&&this[QA]}}return loading_decorate([n({type:String})],LoadingModelViewerElement.prototype,"poster",void 0),loading_decorate([n({type:String})],LoadingModelViewerElement.prototype,"reveal",void 0),loading_decorate([n({type:String})],LoadingModelViewerElement.prototype,"loading",void 0),LoadingModelViewerElement})((e=>{var t;class AnimationModelViewerElement extends e{constructor(...e){super(e),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[t]=!0,this[fp].subscribeMixerEvent("loop",(e=>{const t=e.action._loopCount;this.dispatchEvent(new CustomEvent("loop",{detail:{count:t}}))})),this[fp].subscribeMixerEvent("finished",(()=>{this[wp]=!0,this.dispatchEvent(new CustomEvent("finished"))}))}get availableAnimations(){return this.loaded?this[fp].animationNames:[]}get duration(){return this[fp].duration}get paused(){return this[wp]}get currentTime(){return this[fp].animationTime}set currentTime(e){this[fp].animationTime=e,this[gp]()}get timeScale(){return this[fp].animationTimeScale}set timeScale(e){this[fp].animationTimeScale=e}pause(){this[wp]||(this[wp]=!0,this.dispatchEvent(new CustomEvent("pause")))}play(e){this.availableAnimations.length>0&&(this[wp]=!1,this[bp](e),this.dispatchEvent(new CustomEvent("play")))}[(t=wp,vp)](){super[vp](),this[wp]=!0,null!=this.animationName&&this[bp](),this.autoplay&&this.play()}[_p](e,t){super[_p](e,t),this[wp]||!this[Mp]()&&!this[Ep].isPresenting||(this[fp].updateAnimation(t/1e3),this[gp]())}updated(e){super.updated(e),e.has("autoplay")&&this.autoplay&&this.play(),e.has("animationName")&&this[bp]()}[bp](e=Ip){var t;const r=null!==(t=e.repetitions)&&void 0!==t?t:1/0,s=e.pingpong?We:1===r?2200:ze;this[fp].playAnimation(this.animationName,this.animationCrossfadeDuration/1e3,s,r),this[wp]&&(this[fp].updateAnimation(0),this[gp]())}}return animation_decorate([n({type:Boolean})],AnimationModelViewerElement.prototype,"autoplay",void 0),animation_decorate([n({type:String,attribute:"animation-name"})],AnimationModelViewerElement.prototype,"animationName",void 0),animation_decorate([n({type:Number,attribute:"animation-crossfade-duration"})],AnimationModelViewerElement.prototype,"animationCrossfadeDuration",void 0),AnimationModelViewerElement})(ModelViewerElementBase))))))));customElements.define("model-viewer",YA)}}]);
408
+ </div>`;var oa=r(6763);const la=new WeakMap;function DRACOWorker(){let e,t;function decodeAttribute(e,t,r,s,o,l){const c=l.num_components(),h=r.num_points()*c,d=h*o.BYTES_PER_ELEMENT,p=function getDracoDataType(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,o),A=e._malloc(d);t.GetAttributeDataArrayForAllPoints(r,l,p,d,A);const m=new o(e.HEAPF32.buffer,A,h).slice();return e._free(A),{name:s,array:m,itemSize:c}}onmessage=function(r){const s=r.data;switch(s.type){case"init":e=s.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=s.buffer,o=s.taskConfig;t.then((e=>{const t=e.draco,l=new t.Decoder;try{const e=function decodeGeometry(e,t,r,s){const o=s.attributeIDs,l=s.attributeTypes;let c,h;const d=t.GetEncodedGeometryType(r);if(d===e.TRIANGULAR_MESH)c=new e.Mesh,h=t.DecodeArrayToMesh(r,r.byteLength,c);else{if(d!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");c=new e.PointCloud,h=t.DecodeArrayToPointCloud(r,r.byteLength,c)}if(!h.ok()||0===c.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+h.error_msg());const p={index:null,attributes:[]};for(const r in o){const h=self[l[r]];let d,A;if(s.useUniqueIDs)A=o[r],d=t.GetAttributeByUniqueId(c,A);else{if(A=t.GetAttributeId(c,e[o[r]]),-1===A)continue;d=t.GetAttribute(c,A)}const m=decodeAttribute(e,t,c,r,h,d);"color"===r&&(m.vertexColorSpace=s.vertexColorSpace),p.attributes.push(m)}d===e.TRIANGULAR_MESH&&(p.index=function decodeIndex(e,t,r){const s=r.num_faces(),o=3*s,l=4*o,c=e._malloc(l);t.GetTrianglesUInt32Array(r,l,c);const h=new Uint32Array(e.HEAPF32.buffer,c,o).slice();return e._free(c),{array:h,itemSize:1}}(e,t,c));return e.destroy(c),p}(t,l,new Int8Array(r),o),c=e.attributes.map((e=>e.array.buffer));e.index&&c.push(e.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:e},c)}catch(e){oa.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(l)}}))}}}var ca=r(6763);function toTrianglesDrawMode(e,t){if(0===t)return ca.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let r=e.getIndex();if(null===r){const t=[],s=e.getAttribute("position");if(void 0===s)return ca.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<s.count;e++)t.push(e);e.setIndex(t),r=e.getIndex()}const s=r.count-2,o=[];if(2===t)for(let e=1;e<=s;e++)o.push(r.getX(0)),o.push(r.getX(e)),o.push(r.getX(e+1));else for(let e=0;e<s;e++)e%2==0?(o.push(r.getX(e)),o.push(r.getX(e+1)),o.push(r.getX(e+2))):(o.push(r.getX(e+2)),o.push(r.getX(e+1)),o.push(r.getX(e)));o.length/3!==s&&ca.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const l=e.clone();return l.setIndex(o),l.clearGroups(),l}return ca.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}var ha=r(6763);class GLTFLoader extends Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFTextureAVIFExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)}))}load(e,t,r,s){const o=this;let l;if(""!==this.resourcePath)l=this.resourcePath;else if(""!==this.path){const t=LoaderUtils.extractUrlBase(e);l=LoaderUtils.resolveURL(t,this.path)}else l=LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const _onError=function(t){s?s(t):ha.error(t),o.manager.itemError(e),o.manager.itemEnd(e)},c=new three_module_FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,(function(r){try{o.parse(r,l,(function(r){t(r),o.manager.itemEnd(e)}),_onError)}catch(e){_onError(e)}}),r,_onError)}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,r,s){let o;const l={},c={},h=new TextDecoder;if("string"==typeof e)o=JSON.parse(e);else if(e instanceof ArrayBuffer){if(h.decode(new Uint8Array(e,0,4))===da){try{l[ua.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(s&&s(e))}o=JSON.parse(l[ua.KHR_BINARY_GLTF].content)}else o=JSON.parse(h.decode(e))}else o=e;if(void 0===o.asset||o.asset.version[0]<2)return void(s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const d=new GLTFParser(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](d);t.name||ha.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[t.name]=t,l[t.name]=!0}if(o.extensionsUsed)for(let e=0;e<o.extensionsUsed.length;++e){const t=o.extensionsUsed[e],r=o.extensionsRequired||[];switch(t){case ua.KHR_MATERIALS_UNLIT:l[t]=new GLTFMaterialsUnlitExtension;break;case ua.KHR_DRACO_MESH_COMPRESSION:l[t]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case ua.KHR_TEXTURE_TRANSFORM:l[t]=new GLTFTextureTransformExtension;break;case ua.KHR_MESH_QUANTIZATION:l[t]=new GLTFMeshQuantizationExtension;break;default:r.indexOf(t)>=0&&void 0===c[t]&&ha.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}d.setExtensions(l),d.setPlugins(c),d.parse(r,s)}parseAsync(e,t){const r=this;return new Promise((function(s,o){r.parse(e,t,s,o)}))}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const ua={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_MATERIALS_BUMP:"EXT_materials_bump",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 GLTFLightsExtension{constructor(e){this.parser=e,this.name=ua.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,s=t.length;r<s;r++){const s=t[r];s.extensions&&s.extensions[this.name]&&void 0!==s.extensions[this.name].light&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let s=t.cache.get(r);if(s)return s;const o=t.json,l=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let c;const h=new Color(16777215);void 0!==l.color&&h.setRGB(l.color[0],l.color[1],l.color[2],He);const d=void 0!==l.range?l.range:0;switch(l.type){case"directional":c=new DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new PointLight(h),c.distance=d;break;case"spot":c=new SpotLight(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=void 0!==l.spot.innerConeAngle?l.spot.innerConeAngle:0,l.spot.outerConeAngle=void 0!==l.spot.outerConeAngle?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),c.decay=2,assignExtrasToUserData(c,l),void 0!==l.intensity&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(c),t.cache.add(r,s),s}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,s=r.json.nodes[e],o=(s.extensions&&s.extensions[this.name]||{}).light;return void 0===o?null:this._loadLight(o).then((function(e){return r._getNodeRef(t.cache,o,e)}))}}class GLTFMaterialsUnlitExtension{constructor(){this.name=ua.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(e,t,r){const s=[];e.color=new Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const t=o.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],He),e.opacity=t[3]}void 0!==o.baseColorTexture&&s.push(r.assignTexture(e,"map",o.baseColorTexture,Ve))}return Promise.all(s)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name].emissiveStrength;return void 0!==s&&(t.emissiveIntensity=s),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];if(void 0!==l.clearcoatFactor&&(t.clearcoat=l.clearcoatFactor),void 0!==l.clearcoatTexture&&o.push(r.assignTexture(t,"clearcoatMap",l.clearcoatTexture)),void 0!==l.clearcoatRoughnessFactor&&(t.clearcoatRoughness=l.clearcoatRoughnessFactor),void 0!==l.clearcoatRoughnessTexture&&o.push(r.assignTexture(t,"clearcoatRoughnessMap",l.clearcoatRoughnessTexture)),void 0!==l.clearcoatNormalTexture&&(o.push(r.assignTexture(t,"clearcoatNormalMap",l.clearcoatNormalTexture)),void 0!==l.clearcoatNormalTexture.scale)){const e=l.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Vector2(e,e)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return void 0!==l.iridescenceFactor&&(t.iridescence=l.iridescenceFactor),void 0!==l.iridescenceTexture&&o.push(r.assignTexture(t,"iridescenceMap",l.iridescenceTexture)),void 0!==l.iridescenceIor&&(t.iridescenceIOR=l.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==l.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=l.iridescenceThicknessMinimum),void 0!==l.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=l.iridescenceThicknessMaximum),void 0!==l.iridescenceThicknessTexture&&o.push(r.assignTexture(t,"iridescenceThicknessMap",l.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const l=s.extensions[this.name];if(void 0!==l.sheenColorFactor){const e=l.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],He)}return void 0!==l.sheenRoughnessFactor&&(t.sheenRoughness=l.sheenRoughnessFactor),void 0!==l.sheenColorTexture&&o.push(r.assignTexture(t,"sheenColorMap",l.sheenColorTexture,Ve)),void 0!==l.sheenRoughnessTexture&&o.push(r.assignTexture(t,"sheenRoughnessMap",l.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return void 0!==l.transmissionFactor&&(t.transmission=l.transmissionFactor),void 0!==l.transmissionTexture&&o.push(r.assignTexture(t,"transmissionMap",l.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];t.thickness=void 0!==l.thicknessFactor?l.thicknessFactor:0,void 0!==l.thicknessTexture&&o.push(r.assignTexture(t,"thicknessMap",l.thicknessTexture)),t.attenuationDistance=l.attenuationDistance||1/0;const c=l.attenuationColor||[1,1,1];return t.attenuationColor=(new Color).setRGB(c[0],c[1],c[2],He),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name];return t.ior=void 0!==s.ior?s.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];t.specularIntensity=void 0!==l.specularFactor?l.specularFactor:1,void 0!==l.specularTexture&&o.push(r.assignTexture(t,"specularIntensityMap",l.specularTexture));const c=l.specularColorFactor||[1,1,1];return t.specularColor=(new Color).setRGB(c[0],c[1],c[2],He),void 0!==l.specularColorTexture&&o.push(r.assignTexture(t,"specularColorMap",l.specularColorTexture,Ve)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=ua.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return t.bumpScale=void 0!==l.bumpFactor?l.bumpFactor:1,void 0!==l.bumpTexture&&o.push(r.assignTexture(t,"bumpMap",l.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=ua.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],l=s.extensions[this.name];return void 0!==l.anisotropyStrength&&(t.anisotropy=l.anisotropyStrength),void 0!==l.anisotropyRotation&&(t.anisotropyRotation=l.anisotropyRotation),void 0!==l.anisotropyTexture&&o.push(r.assignTexture(t,"anisotropyMap",l.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=ua.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,s=r.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.extensions[this.name],l=t.options.ktx2Loader;if(!l){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,l)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=ua.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,s=r.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const l=o.extensions[t],c=s.images[l.source];let h=r.textureLoader;if(c.uri){const e=r.options.manager.getHandler(c.uri);null!==e&&(h=e)}return this.detectSupport().then((function(o){if(o)return r.loadTextureImage(e,l.source,h);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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 GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=ua.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,s=r.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const l=o.extensions[t],c=s.images[l.source];let h=r.textureLoader;if(c.uri){const e=r.options.manager.getHandler(c.uri);null!==e&&(h=e)}return this.detectSupport().then((function(o){if(o)return r.loadTextureImage(e,l.source,h);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.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 GLTFMeshoptCompression{constructor(e){this.name=ua.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const e=r.extensions[this.name],s=this.parser.getDependency("buffer",e.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then((function(t){const r=e.byteOffset||0,s=e.byteLength||0,l=e.count,c=e.byteStride,h=new Uint8Array(t,r,s);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(l,c,h,e.mode,e.filter).then((function(e){return e.buffer})):o.ready.then((function(){const t=new ArrayBuffer(l*c);return o.decodeGltfBuffer(new Uint8Array(t),l,c,h,e.mode,e.filter),t}))}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=ua.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;const s=t.meshes[r.mesh];for(const e of s.primitives)if(e.mode!==fa.TRIANGLES&&e.mode!==fa.TRIANGLE_STRIP&&e.mode!==fa.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=r.extensions[this.name].attributes,l=[],c={};for(const e in o)l.push(this.parser.getDependency("accessor",o[e]).then((t=>(c[e]=t,c[e]))));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then((e=>{const t=e.pop(),r=t.isGroup?t.children:[t],s=e[0].count,o=[];for(const e of r){const t=new three_module_Matrix4,r=new three_module_Vector3,l=new three_module_Quaternion,h=new three_module_Vector3(1,1,1),d=new InstancedMesh(e.geometry,e.material,s);for(let e=0;e<s;e++)c.TRANSLATION&&r.fromBufferAttribute(c.TRANSLATION,e),c.ROTATION&&l.fromBufferAttribute(c.ROTATION,e),c.SCALE&&h.fromBufferAttribute(c.SCALE,e),d.setMatrixAt(e,t.compose(r,l,h));for(const t in c)if("_COLOR_0"===t){const e=c[t];d.instanceColor=new three_module_InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,c[t]);Object3D.prototype.copy.call(d,e),this.parser.assignFinalMaterial(d),o.push(d)}return t.isGroup?(t.clear(),t.add(...o),t):o[0]})))}}const da="glTF",pa=1313821514,Aa=5130562;class GLTFBinaryExtension{constructor(e){this.name=ua.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==da)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,o=new DataView(e,12);let l=0;for(;l<s;){const t=o.getUint32(l,!0);l+=4;const s=o.getUint32(l,!0);if(l+=4,s===pa){const s=new Uint8Array(e,12+l,t);this.content=r.decode(s)}else if(s===Aa){const r=12+l;this.body=e.slice(r,r+t)}l+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ua.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,s=this.dracoLoader,o=e.extensions[this.name].bufferView,l=e.extensions[this.name].attributes,c={},h={},d={};for(const e in l){const t=Ea[e]||e.toLowerCase();c[t]=l[e]}for(const t in e.attributes){const s=Ea[t]||t.toLowerCase();if(void 0!==l[t]){const o=r.accessors[e.attributes[t]],l=ga[o.componentType];d[s]=l.name,h[s]=!0===o.normalized}}return t.getDependency("bufferView",o).then((function(e){return new Promise((function(t,r){s.decodeDracoFile(e,(function(e){for(const t in e.attributes){const r=e.attributes[t],s=h[t];void 0!==s&&(r.normalized=s)}t(e)}),c,d,He,r)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=ua.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class GLTFMeshQuantizationExtension{constructor(){this.name=ua.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(e,t,r,s){super(e,t,r,s)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let e=0;e!==s;e++)t[e]=r[o+e];return t}interpolate_(e,t,r,s){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=2*c,d=3*c,p=s-t,A=(r-t)/p,m=A*A,f=m*A,g=e*d,_=g-d,y=-2*f+3*m,x=f-m,S=1-y,C=x-m+A;for(let e=0;e!==c;e++){const t=l[_+e+c],r=l[_+e+h]*p,s=l[g+e+c],d=l[g+e]*p;o[e]=S*t+C*r+y*s+x*d}return o}}const ma=new three_module_Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,r,s){const o=super.interpolate_(e,t,r,s);return ma.fromArray(o).normalize().toArray(o),o}}const fa={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ga={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},_a={9728:te,9729:re,9984:ie,9985:se,9986:ne,9987:ae},va={33071:$,33648:ee,10497:J},ya={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ea={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},xa={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Sa={CUBICSPLINE:void 0,LINEAR:Ue,STEP:De},Ma="OPAQUE",Ca="MASK",ba="BLEND";function createDefaultMaterial(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function addUnknownExtensionsToUserData(e,t,r){for(const s in r.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=r.extensions[s])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):ha.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function updateMorphTargets(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,s=t.weights.length;r<s;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){const r=t.extras.targetNames;if(e.morphTargetInfluences.length===r.length){e.morphTargetDictionary={};for(let t=0,s=r.length;t<s;t++)e.morphTargetDictionary[r[t]]=t}else ha.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const r=e.extensions&&e.extensions[ua.KHR_DRACO_MESH_COMPRESSION];if(t=r?"draco:"+r.bufferView+":"+r.indices+":"+createAttributesKey(r.attributes):e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,s=e.targets.length;r<s;r++)t+=":"+createAttributesKey(e.targets[r]);return t}function createAttributesKey(e){let t="";const r=Object.keys(e).sort();for(let s=0,o=r.length;s<o;s++)t+=r[s]+":"+e[r[s]]+";";return t}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const wa=new three_module_Matrix4;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,s=!1,o=-1;"undefined"!=typeof navigator&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||r||s&&o<98?this.textureLoader=new TextureLoader(this.options.manager):this.textureLoader=new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three_module_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 r=this,s=this.json,o=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([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])})).then((function(t){const l={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:r,userData:{}};return addUnknownExtensionsToUserData(o,l,s),assignExtrasToUserData(l,s),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(l)}))).then((function(){e(l)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){const s=t[r].joints;for(let t=0,r=s.length;t<r;t++)e[s[t]].isBone=!0}for(let t=0,s=e.length;t<s;t++){const s=e[t];void 0!==s.mesh&&(this._addNodeRef(this.meshCache,s.mesh),void 0!==s.skin&&(r[s.mesh].isSkinnedMesh=!0)),void 0!==s.camera&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const s=r.clone(),updateMappings=(e,t)=>{const r=this.associations.get(e);null!=r&&this.associations.set(t,r);for(const[r,s]of e.children.entries())updateMappings(s,t.children[r])};return updateMappings(r,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const s=e(t[r]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let s=0;s<t.length;s++){const o=e(t[s]);o&&r.push(o)}return r}getDependency(e,t){const r=e+":"+t;let s=this.cache.get(r);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":s=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne((function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)})),!s)throw new Error("Unknown type: "+e)}this.cache.add(r,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return r.getDependency(e,s)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[ua.KHR_BINARY_GLTF].body);const s=this.options;return new Promise((function(e,o){r.load(LoaderUtils.resolveURL(t.uri,s.path),e,void 0,(function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const r=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+r)}))}loadAccessor(e){const t=this,r=this.json,s=this.json.accessors[e];if(void 0===s.bufferView&&void 0===s.sparse){const e=ya[s.type],t=ga[s.componentType],r=!0===s.normalized,o=new t(s.count*e);return Promise.resolve(new three_module_BufferAttribute(o,e,r))}const o=[];return void 0!==s.bufferView?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),void 0!==s.sparse&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then((function(e){const o=e[0],l=ya[s.type],c=ga[s.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,p=s.byteOffset||0,A=void 0!==s.bufferView?r.bufferViews[s.bufferView].byteStride:void 0,m=!0===s.normalized;let f,g;if(A&&A!==d){const e=Math.floor(p/A),r="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+e+":"+s.count;let d=t.cache.get(r);d||(f=new c(o,e*A,s.count*A/h),d=new three_module_InterleavedBuffer(f,A/h),t.cache.add(r,d)),g=new three_module_InterleavedBufferAttribute(d,l,p%A/h,m)}else f=null===o?new c(s.count*l):new c(o,p,s.count*l),g=new three_module_BufferAttribute(f,l,m);if(void 0!==s.sparse){const t=ya.SCALAR,r=ga[s.sparse.indices.componentType],h=s.sparse.indices.byteOffset||0,d=s.sparse.values.byteOffset||0,p=new r(e[1],h,s.sparse.count*t),A=new c(e[2],d,s.sparse.count*l);null!==o&&(g=new three_module_BufferAttribute(g.array.slice(),g.itemSize,g.normalized));for(let e=0,t=p.length;e<t;e++){const t=p[e];if(g.setX(t,A[e*l]),l>=2&&g.setY(t,A[e*l+1]),l>=3&&g.setZ(t,A[e*l+2]),l>=4&&g.setW(t,A[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g}))}loadTexture(e){const t=this.json,r=this.options,s=t.textures[e].source,o=t.images[s];let l=this.textureLoader;if(o.uri){const e=r.manager.getHandler(o.uri);null!==e&&(l=e)}return this.loadTextureImage(e,s,l)}loadTextureImage(e,t,r){const s=this,o=this.json,l=o.textures[e],c=o.images[t],h=(c.uri||c.bufferView)+":"+l.sampler;if(this.textureCache[h])return this.textureCache[h];const d=this.loadImageSource(t,r).then((function(t){t.flipY=!1,t.name=l.name||c.name||"",""===t.name&&"string"==typeof c.uri&&!1===c.uri.startsWith("data:image/")&&(t.name=c.uri);const r=(o.samplers||{})[l.sampler]||{};return t.magFilter=_a[r.magFilter]||re,t.minFilter=_a[r.minFilter]||ae,t.wrapS=va[r.wrapS]||J,t.wrapT=va[r.wrapT]||J,s.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[h]=d,d}loadImageSource(e,t){const r=this,s=this.json,o=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=s.images[e],c=self.URL||self.webkitURL;let h=l.uri||"",d=!1;if(void 0!==l.bufferView)h=r.getDependency("bufferView",l.bufferView).then((function(e){d=!0;const t=new Blob([e],{type:l.mimeType});return h=c.createObjectURL(t),h}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(h).then((function(e){return new Promise((function(r,s){let l=r;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,r(t)}),t.load(LoaderUtils.resolveURL(e,o.path),l,void 0,s)}))})).then((function(e){return!0===d&&c.revokeObjectURL(h),e.userData.mimeType=l.mimeType||function getImageURIMimeType(e){return e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"}(l.uri),e})).catch((function(e){throw ha.error("THREE.GLTFLoader: Couldn't load texture",h),e}));return this.sourceCache[e]=p,p}assignTexture(e,t,r,s){const o=this;return this.getDependency("texture",r.index).then((function(l){if(!l)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((l=l.clone()).channel=r.texCoord),o.extensions[ua.KHR_TEXTURE_TRANSFORM]){const e=void 0!==r.extensions?r.extensions[ua.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=o.associations.get(l);l=o.extensions[ua.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),o.associations.set(l,t)}}return void 0!==s&&(l.colorSpace=s),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const s=void 0===t.attributes.tangent,o=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){const e="LineBasicMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(s||o||l){let e="ClonedMaterial:"+r.uuid+":";s&&(e+="derivative-tangents:"),o&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),o&&(t.vertexColors=!0),l&&(t.flatShading=!0),s&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,s=this.extensions,o=r.materials[e];let l;const c={},h=[];if((o.extensions||{})[ua.KHR_MATERIALS_UNLIT]){const e=s[ua.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),h.push(e.extendParams(c,o,t))}else{const r=o.pbrMetallicRoughness||{};if(c.color=new Color(1,1,1),c.opacity=1,Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;c.color.setRGB(e[0],e[1],e[2],He),c.opacity=e[3]}void 0!==r.baseColorTexture&&h.push(t.assignTexture(c,"map",r.baseColorTexture,Ve)),c.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,c.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(h.push(t.assignTexture(c,"metalnessMap",r.metallicRoughnessTexture)),h.push(t.assignTexture(c,"roughnessMap",r.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),h.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,c)}))))}!0===o.doubleSided&&(c.side=2);const d=o.alphaMode||Ma;if(d===ba?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,d===Ca&&(c.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&l!==MeshBasicMaterial&&(h.push(t.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;c.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&l!==MeshBasicMaterial&&(h.push(t.assignTexture(c,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(c.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&l!==MeshBasicMaterial){const e=o.emissiveFactor;c.emissive=(new Color).setRGB(e[0],e[1],e[2],He)}return void 0!==o.emissiveTexture&&l!==MeshBasicMaterial&&h.push(t.assignTexture(c,"emissiveMap",o.emissiveTexture,Ve)),Promise.all(h).then((function(){const r=new l(c);return o.name&&(r.name=o.name),assignExtrasToUserData(r,o),t.associations.set(r,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(s,r,o),r}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,s=this.primitiveCache;function createDracoPrimitive(e){return r[ua.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return addPrimitiveAttributes(r,e,t)}))}const o=[];for(let r=0,l=e.length;r<l;r++){const l=e[r],c=createPrimitiveKey(l),h=s[c];if(h)o.push(h.promise);else{let e;e=l.extensions&&l.extensions[ua.KHR_DRACO_MESH_COMPRESSION]?createDracoPrimitive(l):addPrimitiveAttributes(new three_module_BufferGeometry,l,t),s[c]={primitive:l,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const t=this,r=this.json,s=this.extensions,o=r.meshes[e],l=o.primitives,c=[];for(let e=0,t=l.length;e<t;e++){const t=void 0===l[e].material?createDefaultMaterial(this.cache):this.getDependency("material",l[e].material);c.push(t)}return c.push(t.loadGeometries(l)),Promise.all(c).then((function(r){const c=r.slice(0,r.length-1),h=r[r.length-1],d=[];for(let r=0,p=h.length;r<p;r++){const p=h[r],A=l[r];let m;const f=c[r];if(A.mode===fa.TRIANGLES||A.mode===fa.TRIANGLE_STRIP||A.mode===fa.TRIANGLE_FAN||void 0===A.mode)m=!0===o.isSkinnedMesh?new SkinnedMesh(p,f):new three_module_Mesh(p,f),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),A.mode===fa.TRIANGLE_STRIP?m.geometry=toTrianglesDrawMode(m.geometry,1):A.mode===fa.TRIANGLE_FAN&&(m.geometry=toTrianglesDrawMode(m.geometry,2));else if(A.mode===fa.LINES)m=new LineSegments(p,f);else if(A.mode===fa.LINE_STRIP)m=new Line(p,f);else if(A.mode===fa.LINE_LOOP)m=new LineLoop(p,f);else{if(A.mode!==fa.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);m=new Points(p,f)}Object.keys(m.geometry.morphAttributes).length>0&&updateMorphTargets(m,o),m.name=t.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(m,o),A.extensions&&addUnknownExtensionsToUserData(s,m,A),t.assignFinalMaterial(m),d.push(m)}for(let r=0,s=d.length;r<s;r++)t.associations.set(d[r],{meshes:e,primitives:r});if(1===d.length)return o.extensions&&addUnknownExtensionsToUserData(s,d[0],o),d[0];const p=new three_module_Group;o.extensions&&addUnknownExtensionsToUserData(s,p,o),t.associations.set(p,{meshes:e});for(let e=0,t=d.length;e<t;e++)p.add(d[e]);return p}))}loadCamera(e){let t;const r=this.json.cameras[e],s=r[r.type];if(s)return"perspective"===r.type?t=new PerspectiveCamera(At.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===r.type&&(t=new OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),assignExtrasToUserData(t,r),Promise.resolve(t);ha.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],r=[];for(let e=0,s=t.joints.length;e<s;e++)r.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then((function(e){const r=e.pop(),s=e,o=[],l=[];for(let e=0,c=s.length;e<c;e++){const c=s[e];if(c){o.push(c);const t=new three_module_Matrix4;null!==r&&t.fromArray(r.array,16*e),l.push(t)}else ha.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Skeleton(o,l)}))}loadAnimation(e){const t=this.json,r=this,s=t.animations[e],o=s.name?s.name:"animation_"+e,l=[],c=[],h=[],d=[],p=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],r=s.samplers[t.sampler],o=t.target,A=o.node,m=void 0!==s.parameters?s.parameters[r.input]:r.input,f=void 0!==s.parameters?s.parameters[r.output]:r.output;void 0!==o.node&&(l.push(this.getDependency("node",A)),c.push(this.getDependency("accessor",m)),h.push(this.getDependency("accessor",f)),d.push(r),p.push(o))}return Promise.all([Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d),Promise.all(p)]).then((function(e){const t=e[0],s=e[1],l=e[2],c=e[3],h=e[4],d=[];for(let e=0,o=t.length;e<o;e++){const o=t[e],p=s[e],A=l[e],m=c[e],f=h[e];if(void 0===o)continue;o.updateMatrix&&o.updateMatrix();const g=r._createAnimationTracks(o,p,A,m,f);if(g)for(let e=0;e<g.length;e++)d.push(g[e])}return new three_module_AnimationClip(o,void 0,d)}))}createNodeMesh(e){const t=this.json,r=this,s=t.nodes[e];return void 0===s.mesh?null:r.getDependency("mesh",s.mesh).then((function(e){const t=r._getNodeRef(r.meshCache,s.mesh,e);return void 0!==s.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,r=s.weights.length;t<r;t++)e.morphTargetInfluences[t]=s.weights[t]})),t}))}loadNode(e){const t=this,r=this.json.nodes[e],s=t._loadNodeShallow(e),o=[],l=r.children||[];for(let e=0,r=l.length;e<r;e++)o.push(t.getDependency("node",l[e]));const c=void 0===r.skin?Promise.resolve(null):t.getDependency("skin",r.skin);return Promise.all([s,Promise.all(o),c]).then((function(e){const t=e[0],r=e[1],s=e[2];null!==s&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(s,wa)}));for(let e=0,s=r.length;e<s;e++)t.add(r[e]);return t}))}_loadNodeShallow(e){const t=this.json,r=this.extensions,s=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const o=t.nodes[e],l=o.name?s.createUniqueName(o.name):"",c=[],h=s._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return h&&c.push(h),void 0!==o.camera&&c.push(s.getDependency("camera",o.camera).then((function(e){return s._getNodeRef(s.cameraCache,o.camera,e)}))),s._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){c.push(e)})),this.nodeCache[e]=Promise.all(c).then((function(t){let c;if(c=!0===o.isBone?new Bone:t.length>1?new three_module_Group:1===t.length?t[0]:new Object3D,c!==t[0])for(let e=0,r=t.length;e<r;e++)c.add(t[e]);if(o.name&&(c.userData.name=o.name,c.name=l),assignExtrasToUserData(c,o),o.extensions&&addUnknownExtensionsToUserData(r,c,o),void 0!==o.matrix){const e=new three_module_Matrix4;e.fromArray(o.matrix),c.applyMatrix4(e)}else void 0!==o.translation&&c.position.fromArray(o.translation),void 0!==o.rotation&&c.quaternion.fromArray(o.rotation),void 0!==o.scale&&c.scale.fromArray(o.scale);return s.associations.has(c)||s.associations.set(c,{}),s.associations.get(c).nodes=e,c})),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],s=this,o=new three_module_Group;r.name&&(o.name=s.createUniqueName(r.name)),assignExtrasToUserData(o,r),r.extensions&&addUnknownExtensionsToUserData(t,o,r);const l=r.nodes||[],c=[];for(let e=0,t=l.length;e<t;e++)c.push(s.getDependency("node",l[e]));return Promise.all(c).then((function(e){for(let t=0,r=e.length;t<r;t++)o.add(e[t]);return s.associations=(e=>{const t=new Map;for(const[e,r]of s.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,r);return e.traverse((e=>{const r=s.associations.get(e);null!=r&&t.set(e,r)})),t})(o),o}))}_createAnimationTracks(e,t,r,s,o){const l=[],c=e.name?e.name:e.uuid,h=[];let d;switch(xa[o.path]===xa.weights?e.traverse((function(e){e.morphTargetInfluences&&h.push(e.name?e.name:e.uuid)})):h.push(c),xa[o.path]){case xa.weights:d=NumberKeyframeTrack;break;case xa.rotation:d=three_module_QuaternionKeyframeTrack;break;case xa.position:case xa.scale:d=three_module_VectorKeyframeTrack;break;default:if(1===r.itemSize)d=NumberKeyframeTrack;else d=three_module_VectorKeyframeTrack}const p=void 0!==s.interpolation?Sa[s.interpolation]:Ue,A=this._getArrayFromAccessor(r);for(let e=0,r=h.length;e<r;e++){const r=new d(h[e]+"."+xa[o.path],t.array,A,p);"CUBICSPLINE"===s.interpolation&&this._createCubicSplineTrackInterpolant(r),l.push(r)}return l}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=getNormalizedComponentScale(t.constructor),r=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)r[s]=t[s]*e;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function InterpolantFactoryMethodGLTFCubicSpline(e){return new(this instanceof three_module_QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function addPrimitiveAttributes(e,t,r){const s=t.attributes,o=[];function assignAttributeAccessor(t,s){return r.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}for(const t in s){const r=Ea[t]||t.toLowerCase();r in e.attributes||o.push(assignAttributeAccessor(s[t],r))}if(void 0!==t.indices&&!e.index){const s=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));o.push(s)}return Et.workingColorSpace!==He&&"COLOR_0"in s&&ha.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Et.workingColorSpace}" not supported.`),assignExtrasToUserData(e,t),function computeBounds(e,t,r){const s=t.attributes,o=new Box3;if(void 0===s.POSITION)return;{const e=r.json.accessors[s.POSITION],t=e.min,l=e.max;if(void 0===t||void 0===l)return void ha.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new three_module_Vector3(t[0],t[1],t[2]),new three_module_Vector3(l[0],l[1],l[2])),e.normalized){const t=getNormalizedComponentScale(ga[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const l=t.targets;if(void 0!==l){const e=new three_module_Vector3,t=new three_module_Vector3;for(let s=0,o=l.length;s<o;s++){const o=l[s];if(void 0!==o.POSITION){const s=r.json.accessors[o.POSITION],l=s.min,c=s.max;if(void 0!==l&&void 0!==c){if(t.setX(Math.max(Math.abs(l[0]),Math.abs(c[0]))),t.setY(Math.max(Math.abs(l[1]),Math.abs(c[1]))),t.setZ(Math.max(Math.abs(l[2]),Math.abs(c[2]))),s.normalized){const e=getNormalizedComponentScale(ga[s.componentType]);t.multiplyScalar(e)}e.max(t)}else ha.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const c=new Sphere;o.getCenter(c.center),c.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=c}(e,t,r),Promise.all(o).then((function(){return void 0!==t.targets?function addMorphTargets(e,t,r){let s=!1,o=!1,l=!1;for(let e=0,r=t.length;e<r;e++){const r=t[e];if(void 0!==r.POSITION&&(s=!0),void 0!==r.NORMAL&&(o=!0),void 0!==r.COLOR_0&&(l=!0),s&&o&&l)break}if(!s&&!o&&!l)return Promise.resolve(e);const c=[],h=[],d=[];for(let p=0,A=t.length;p<A;p++){const A=t[p];if(s){const t=void 0!==A.POSITION?r.getDependency("accessor",A.POSITION):e.attributes.position;c.push(t)}if(o){const t=void 0!==A.NORMAL?r.getDependency("accessor",A.NORMAL):e.attributes.normal;h.push(t)}if(l){const t=void 0!==A.COLOR_0?r.getDependency("accessor",A.COLOR_0):e.attributes.color;d.push(t)}}return Promise.all([Promise.all(c),Promise.all(h),Promise.all(d)]).then((function(t){const r=t[0],c=t[1],h=t[2];return s&&(e.morphAttributes.position=r),o&&(e.morphAttributes.normal=c),l&&(e.morphAttributes.color=h),e.morphTargetsRelative=!0,e}))}(e,t.targets,r):e}))}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const r=this.workersResolve[e];if(r&&r(t),this.queue.length){const{resolve:t,msg:r,transfer:s}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(r,s)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((r=>{const s=this._getIdleWorker();-1!==s?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=r,this.workers[s].postMessage(e,t)):this.queue.push({resolve:r,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}var Ia=r(8287).hp;const Ta=9,Ba=15,Ra=16,La=22,Da=37,Ua=43,Pa=76,Fa=83,Na=97,Oa=100,Qa=103,ka=109,Ga=165,Va=166;class Si{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Ii{constructor(e,t,r,s){this._dataView=new DataView(e.buffer,e.byteOffset+t,r),this._littleEndian=s,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const r=this._offset;let s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,s)}}new Uint8Array([0]);const Ha=[171,75,84,88,32,50,48,187,13,10,26,10];function Ei(e){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):Ia.from(e).toString("utf8")}var za=r(8287).hp;let Wa,qa,ja;const Xa={env:{emscripten_notify_memory_growth:function(e){ja=new Uint8Array(qa.exports.memory.buffer)}}};class zstddec_module_Q{init(){return Wa||(Wa="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+Ya).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,Xa))).then(this._init):WebAssembly.instantiate(za.from(Ya,"base64"),Xa).then(this._init),Wa)}_init(e){qa=e.instance,Xa.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!qa)throw new Error("ZSTDDecoder: Await .init() before decoding.");const r=e.byteLength,s=qa.exports.malloc(r);ja.set(e,s),t=t||Number(qa.exports.ZSTD_findDecompressedSize(s,r));const o=qa.exports.malloc(t),l=qa.exports.ZSTD_decompress(o,t,s,r),c=ja.slice(o,o+l);return qa.exports.free(s),qa.exports.free(o),c}}const Ya="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ";var Ka=r(6763);const Ja=new WeakMap;let $a,Za=0;class KTX2Loader extends Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&Ka.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return!0===e.isWebGPURenderer?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new three_module_FileLoader(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),r=new three_module_FileLoader(this.manager);r.setPath(this.transcoderPath),r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials);const s=r.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then((([e,t])=>{const r=KTX2Loader.BasisWorker.toString(),s=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([s])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),Za>0&&Ka.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),Za++}return this.transcoderPending}load(e,t,r,s){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const o=new three_module_FileLoader(this.manager);o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials),o.load(e,(e=>{if(Ja.has(e)){return Ja.get(e).promise.then(t).catch(s)}this._createTexture(e).then((e=>t?t(e):null)).catch(s)}),r,s)}_createTextureFrom(e,t){const{faces:r,width:s,height:o,format:l,type:c,error:h,dfdFlags:d}=e;if("error"===c)return Promise.reject(h);let p;if(6===t.faceCount)p=new CompressedCubeTexture(r,l,oe);else{const e=r[0].mipmaps;p=t.layerCount>1?new CompressedArrayTexture(e,s,o,t.layerCount,l,oe):new CompressedTexture(e,s,o,l,oe)}return p.minFilter=1===r[0].mipmaps.length?re:ae,p.magFilter=re,p.generateMipmaps=!1,p.needsUpdate=!0,p.colorSpace=parseColorSpace(t),p.premultiplyAlpha=!!(1&d),p}async _createTexture(e,t={}){const r=function Pi(e){const t=new Uint8Array(e.buffer,e.byteOffset,Ha.length);if(t[0]!==Ha[0]||t[1]!==Ha[1]||t[2]!==Ha[2]||t[3]!==Ha[3]||t[4]!==Ha[4]||t[5]!==Ha[5]||t[6]!==Ha[6]||t[7]!==Ha[7]||t[8]!==Ha[8]||t[9]!==Ha[9]||t[10]!==Ha[10]||t[11]!==Ha[11])throw new Error("Missing KTX 2.0 identifier.");const r=new Si,s=17*Uint32Array.BYTES_PER_ELEMENT,o=new Ii(e,Ha.length,s,!0);r.vkFormat=o._nextUint32(),r.typeSize=o._nextUint32(),r.pixelWidth=o._nextUint32(),r.pixelHeight=o._nextUint32(),r.pixelDepth=o._nextUint32(),r.layerCount=o._nextUint32(),r.faceCount=o._nextUint32();const l=o._nextUint32();r.supercompressionScheme=o._nextUint32();const c=o._nextUint32(),h=o._nextUint32(),d=o._nextUint32(),p=o._nextUint32(),A=o._nextUint64(),m=o._nextUint64(),f=new Ii(e,Ha.length+s,3*l*8,!0);for(let t=0;t<l;t++)r.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});const g=new Ii(e,c,h,!0),_={vendorId:g._skip(4)._nextUint16(),descriptorType:g._nextUint16(),versionNumber:g._nextUint16(),descriptorBlockSize:g._nextUint16(),colorModel:g._nextUint8(),colorPrimaries:g._nextUint8(),transferFunction:g._nextUint8(),flags:g._nextUint8(),texelBlockDimension:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],bytesPlane:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],samples:[]},y=(_.descriptorBlockSize/4-6)/4;for(let e=0;e<y;e++){const t={bitOffset:g._nextUint16(),bitLength:g._nextUint8(),channelType:g._nextUint8(),samplePosition:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&t.channelType?(t.sampleLower=g._nextInt32(),t.sampleUpper=g._nextInt32()):(t.sampleLower=g._nextUint32(),t.sampleUpper=g._nextUint32()),_.samples[e]=t}r.dataFormatDescriptor.length=0,r.dataFormatDescriptor.push(_);const x=new Ii(e,d,p,!0);for(;x._offset<p;){const e=x._nextUint32(),t=x._scan(e),s=Ei(t),o=x._scan(e-t.byteLength);r.keyValue[s]=s.match(/^ktx/i)?Ei(o):o,x._offset%4&&x._skip(4-x._offset%4)}if(m<=0)return r;const S=new Ii(e,A,m,!0),C=S._nextUint16(),b=S._nextUint16(),I=S._nextUint32(),T=S._nextUint32(),B=S._nextUint32(),U=S._nextUint32(),F=[];for(let e=0;e<l;e++)F.push({imageFlags:S._nextUint32(),rgbSliceByteOffset:S._nextUint32(),rgbSliceByteLength:S._nextUint32(),alphaSliceByteOffset:S._nextUint32(),alphaSliceByteLength:S._nextUint32()});const O=A+S._offset,Q=O+I,G=Q+T,W=G+B,q=new Uint8Array(e.buffer,e.byteOffset+O,I),j=new Uint8Array(e.buffer,e.byteOffset+Q,T),X=new Uint8Array(e.buffer,e.byteOffset+G,B),Y=new Uint8Array(e.buffer,e.byteOffset+W,U);return r.globalData={endpointCount:C,selectorCount:b,imageDescs:F,endpointsData:q,selectorsData:j,tablesData:X,extendedData:Y},r}(new Uint8Array(e));if(0!==r.vkFormat)return async function createRawTexture(e){const{vkFormat:t}=e;if(void 0===to[t])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let r;2===e.supercompressionScheme&&($a||($a=new Promise((async e=>{const t=new zstddec_module_Q;await t.init(),e(t)}))),r=await $a);const s=[];for(let o=0;o<e.levels.length;o++){const l=Math.max(1,e.pixelWidth>>o),c=Math.max(1,e.pixelHeight>>o),h=e.pixelDepth?Math.max(1,e.pixelDepth>>o):0,d=e.levels[o];let p,A;if(0===e.supercompressionScheme)p=d.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");p=r.decode(d.levelData,d.uncompressedByteLength)}A=io[t]===ue?new Float32Array(p.buffer,p.byteOffset,p.byteLength/Float32Array.BYTES_PER_ELEMENT):io[t]===de?new Uint16Array(p.buffer,p.byteOffset,p.byteLength/Uint16Array.BYTES_PER_ELEMENT):p,s.push({data:A,width:l,height:c,depth:h})}let o;if(eo.has(to[t]))o=0===e.pixelDepth?new DataTexture(s[0].data,e.pixelWidth,e.pixelHeight):new Data3DTexture(s[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth);else{if(e.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");o=new CompressedTexture(s,e.pixelWidth,e.pixelHeight)}return o.mipmaps=s,o.type=io[t],o.format=to[t],o.colorSpace=parseColorSpace(e),o.needsUpdate=!0,Promise.resolve(o)}(r);const s=t,o=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:s},[e]))).then((e=>this._createTextureFrom(e.data,r)));return Ja.set(e,{promise:o}),o}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Za--,this}}KTX2Loader.BasisFormat={ETC1S:0,UASTC_4x4:1},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},KTX2Loader.EngineFormat={RGBAFormat:Ae,RGBA_ASTC_4x4_Format:Ie,RGBA_BPTC_Format:Be,RGBA_ETC2_EAC_Format:we,RGBA_PVRTC_4BPPV1_Format:Me,RGBA_S3TC_DXT5_Format:xe,RGB_ETC1_Format:Ce,RGB_ETC2_Format:be,RGB_PVRTC_4BPPV1_Format:Se,RGB_S3TC_DXT1_Format:ve},KTX2Loader.BasisWorker=function(){let e,t,r;const s=_EngineFormat,o=_TranscoderFormat,l=_BasisFormat;self.addEventListener("message",(function(c){const p=c.data;switch(p.type){case"init":e=p.config,function init(e){t=new Promise((t=>{r={wasmBinary:e,onRuntimeInitialized:t},BASIS(r)})).then((()=>{r.initializeBasis(),void 0===r.KTX2File&&Ka.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}))}(p.transcoderBinary);break;case"transcode":t.then((()=>{try{const{faces:t,buffers:c,width:A,height:m,hasAlpha:f,format:g,dfdFlags:_}=function transcode(t){const c=new r.KTX2File(new Uint8Array(t));function cleanup(){c.close(),c.delete()}if(!c.isValid())throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const p=c.isUASTC()?l.UASTC_4x4:l.ETC1S,A=c.getWidth(),m=c.getHeight(),f=c.getLayers()||1,g=c.getLevels(),_=c.getFaces(),y=c.getHasAlpha(),x=c.getDFDFlags(),{transcoderFormat:S,engineFormat:C}=function getTranscoderFormat(t,r,c,p){let A,m;const f=t===l.ETC1S?h:d;for(let s=0;s<f.length;s++){const o=f[s];if(e[o.if]&&(o.basisFormat.includes(t)&&!(p&&o.transcoderFormat.length<2)&&(!o.needsPowerOfTwo||isPowerOfTwo(r)&&isPowerOfTwo(c))))return A=o.transcoderFormat[p?1:0],m=o.engineFormat[p?1:0],{transcoderFormat:A,engineFormat:m}}return Ka.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),A=o.RGBA32,m=s.RGBAFormat,{transcoderFormat:A,engineFormat:m}}(p,A,m,y);if(!A||!m||!g)throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!c.startTranscoding())throw cleanup(),new Error("THREE.KTX2Loader: .startTranscoding failed");const b=[],I=[];for(let e=0;e<_;e++){const t=[];for(let r=0;r<g;r++){const s=[];let o,l;for(let t=0;t<f;t++){const h=c.getImageLevelInfo(r,t,e);0!==e||0!==r||0!==t||h.origWidth%4==0&&h.origHeight%4==0||Ka.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),g>1?(o=h.origWidth,l=h.origHeight):(o=h.width,l=h.height);const d=new Uint8Array(c.getImageTranscodedSizeInBytes(r,t,0,S));if(!c.transcodeImage(d,r,t,e,S,0,-1,-1))throw cleanup(),new Error("THREE.KTX2Loader: .transcodeImage failed.");s.push(d)}const h=concat(s);t.push({data:h,width:o,height:l}),I.push(h.buffer)}b.push({mipmaps:t,width:A,height:m,format:C})}return cleanup(),{faces:b,buffers:I,width:A,height:m,hasAlpha:y,format:C,dfdFlags:x}}(p.buffer);self.postMessage({type:"transcode",id:p.id,faces:t,width:A,height:m,hasAlpha:f,format:g,dfdFlags:_},c)}catch(e){Ka.error(e),self.postMessage({type:"error",id:p.id,error:e.message})}}))}}));const c=[{if:"astcSupported",basisFormat:[l.UASTC_4x4],transcoderFormat:[o.ASTC_4x4,o.ASTC_4x4],engineFormat:[s.RGBA_ASTC_4x4_Format,s.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.BC7_M5,o.BC7_M5],engineFormat:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.BC1,o.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.ETC1,o.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.ETC1],engineFormat:[s.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[l.ETC1S,l.UASTC_4x4],transcoderFormat:[o.PVRTC1_4_RGB,o.PVRTC1_4_RGBA],engineFormat:[s.RGB_PVRTC_4BPPV1_Format,s.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],h=c.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),d=c.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function isPowerOfTwo(e){return e<=2||!(e&e-1)&&0!==e}function concat(e){if(1===e.length)return e[0];let t=0;for(let r=0;r<e.length;r++){t+=e[r].byteLength}const r=new Uint8Array(t);let s=0;for(let t=0;t<e.length;t++){const o=e[t];r.set(o,s),s+=o.byteLength}return r}};const eo=new Set([Ae,_e,ge]),to={[ka]:Ae,[Na]:Ae,[Da]:Ae,[Ua]:Ae,[Qa]:_e,[Fa]:_e,[Ra]:_e,[La]:_e,[Oa]:ge,[Pa]:ge,[Ba]:ge,[Ta]:ge,[Va]:Te,[Ga]:Te},io={[ka]:ue,[Na]:de,[Da]:oe,[Ua]:oe,[Qa]:ue,[Fa]:de,[Ra]:oe,[La]:oe,[Oa]:ue,[Pa]:de,[Ba]:oe,[Ta]:oe,[Va]:oe,[Ga]:oe};function parseColorSpace(e){const t=e.dataFormatDescriptor[0];return 1===t.colorPrimaries?2===t.transferFunction?Ve:He:10===t.colorPrimaries?2===t.transferFunction?ze:We:(0===t.colorPrimaries||Ka.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),Ge)}var no,ro;const so=Symbol("retainerCount"),ao=Symbol("recentlyUsed"),oo=Symbol("evict"),lo=Symbol("evictionThreshold"),co=Symbol("cache");class CacheEvictionPolicy{constructor(e,t=5){this[no]=new Map,this[ro]=[],this[co]=e,this[lo]=t}set evictionThreshold(e){this[lo]=e,this[oo]()}get evictionThreshold(){return this[lo]}get cache(){return this[co]}retainerCount(e){return this[so].get(e)||0}reset(){this[so].clear(),this[ao]=[]}retain(e){this[so].has(e)||this[so].set(e,0),this[so].set(e,this[so].get(e)+1);const t=this[ao].indexOf(e);-1!==t&&this[ao].splice(t,1),this[ao].unshift(e),this[oo]()}release(e){this[so].has(e)&&this[so].set(e,Math.max(this[so].get(e)-1,0)),this[oo]()}[(no=so,ro=ao,oo)](){if(!(this[ao].length<this[lo]))for(let e=this[ao].length-1;e>=this[lo];--e){const t=this[ao][e];0===this[so].get(t)&&(this[co].delete(t),this[ao].splice(e,1))}}}const mappingsArrayToTable=e=>{const t=new Map;for(const r of e.mappings)for(const e of r.variants)t.set(e,{material:null,gltfMaterialIndex:r.material});return t};class GLTFMaterialsVariantsExtension{constructor(e){this.parser=e,this.name="KHR_materials_variants"}afterRoot(e){const t=this.parser,r=t.json;if(void 0===r.extensions||void 0===r.extensions[this.name])return null;const s=(e=>{const t=[],r=new Set;for(const s of e){let e=s,o=0;for(;r.has(e);)e=s+"."+ ++o;r.add(e),t.push(e)}return t})((r.extensions[this.name].variants||[]).map((e=>e.name)));for(const s of e.scenes)s.traverse((e=>{const s=e;if(!s.material)return;const o=t.associations.get(s);if(null==o||null==o.meshes||null==o.primitives)return;const l=r.meshes[o.meshes].primitives[o.primitives].extensions;l&&l[this.name]&&(s.userData.variantMaterials=mappingsArrayToTable(l[this.name]))}));return e.userData.variants=s,Promise.resolve()}}var ho,uo,po=r(6763);Texture.DEFAULT_ANISOTROPY=4;const Ao=new Map,mo=new Map;let fo;const go=new class DRACOLoader extends Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,s){const o=new three_module_FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(e=>{this.parse(e,t,s)}),r,s)}parse(e,t,r=()=>{}){this.decodeDracoFile(e,t,null,null,Ve).catch(r)}decodeDracoFile(e,t,r,s,o=He,l=()=>{}){const c={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:o};return this.decodeGeometry(e,c).then(t).catch(l)}decodeGeometry(e,t){const r=JSON.stringify(t);if(la.has(e)){const t=la.get(e);if(t.key===r)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const o=this.workerNextTaskID++,l=e.byteLength,c=this._getWorker(o,l).then((r=>(s=r,new Promise(((r,l)=>{s._callbacks[o]={resolve:r,reject:l},s.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return c.catch((()=>!0)).then((()=>{s&&o&&this._releaseTask(s,o)})),la.set(e,{key:r,promise:c}),c}_createGeometry(e){const t=new three_module_BufferGeometry;e.index&&t.setIndex(new three_module_BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r],o=s.name,l=s.array,c=s.itemSize,h=new three_module_BufferAttribute(l,c);"color"===o&&(this._assignVertexColorSpace(h,s.vertexColorSpace),h.normalized=l instanceof Float32Array==!1),t.setAttribute(o,h)}return t}_assignVertexColorSpace(e,t){if(t!==Ve)return;const r=new Color;for(let t=0,s=e.count;t<s;t++)r.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,r.r,r.g,r.b)}_loadLibrary(e,t){const r=new three_module_FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise(((t,s)=>{r.load(e,t,void 0,s)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const s=DRACOWorker.toString(),o=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([o]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const r=t.data;switch(r.type){case"decode":e._callbacks[r.id].resolve(r);break;case"error":e._callbacks[r.id].reject(r);break;default:oa.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){oa.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}};let _o;const vo=new KTX2Loader;let yo,Eo;const xo=Symbol("loader"),So=Symbol("evictionPolicy"),Mo=Symbol("GLTFInstance");class CachingGLTFLoader extends EventDispatcher{constructor(e){super(),this[uo]=(new GLTFLoader).register((e=>new GLTFMaterialsVariantsExtension(e))),this[Mo]=e,this[xo].setDRACOLoader(go),this[xo].setKTX2Loader(vo)}static setDRACODecoderLocation(e){fo=e,go.setDecoderPath(e)}static getDRACODecoderLocation(){return fo}static setKTX2TranscoderLocation(e){_o=e,vo.setTranscoderPath(e)}static getKTX2TranscoderLocation(){return _o}static setMeshoptDecoderLocation(e){var t;yo!==e&&(yo=e,Eo=(t=e,new Promise(((e,r)=>{const s=document.createElement("script");document.body.appendChild(s),s.onload=e,s.onerror=r,s.async=!0,s.src=t}))).then((()=>MeshoptDecoder.ready)).then((()=>MeshoptDecoder)))}static getMeshoptDecoderLocation(){return yo}static initializeKTX2Loader(e){vo.detectSupport(e)}static get cache(){return Ao}static clearCache(){Ao.forEach(((e,t)=>{this.delete(t)})),this[So].reset()}static has(e){return Ao.has(e)}static async delete(e){if(!this.has(e))return;const t=Ao.get(e);mo.delete(e),Ao.delete(e);(await t).dispose()}static hasFinishedLoading(e){return!!mo.get(e)}get[(ho=So,uo=xo,So)](){return this.constructor[So]}async preload(e,t,r=()=>{}){if(this[xo].setWithCredentials(CachingGLTFLoader.withCredentials),this.dispatchEvent({type:"preload",element:t,src:e}),!Ao.has(e)){null!=Eo&&this[xo].setMeshoptDecoder(await Eo);const t=((e,t,r=()=>{})=>{const onProgress=e=>{const t=e.loaded/e.total;r(Math.max(0,Math.min(1,isFinite(t)?t:1)))};return new Promise(((r,s)=>{t.load(e,r,onProgress,s)}))})(e,this[xo],(e=>{r(.8*e)})),s=this[Mo],o=t.then((e=>s.prepare(e))).then((e=>(r(.9),new s(e)))).catch((e=>(po.error(e),new s)));Ao.set(e,o)}await Ao.get(e),mo.set(e,!0),r&&r(1)}async load(e,t,r=()=>{}){await this.preload(e,t,r);const s=await Ao.get(e),o=await s.clone();return this[So].retain(e),o.dispose=()=>{this[So].release(e)},o}}CachingGLTFLoader[ho]=new CacheEvictionPolicy(CachingGLTFLoader);class CSS2DObject extends Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new Vector2(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const Co=new three_module_Vector3,bo=new three_module_Matrix4,wo=new three_module_Matrix4,Io=new three_module_Vector3,To=new three_module_Vector3;class CSS2DRenderer{constructor(e={}){const t=this;let r,s,o,l;const c={objects:new WeakMap},h=void 0!==e.element?e.element:document.createElement("div");function renderObject(e,r,s){if(e.isCSS2DObject){Co.setFromMatrixPosition(e.matrixWorld),Co.applyMatrix4(wo);const d=!0===e.visible&&Co.z>=-1&&Co.z<=1&&!0===e.layers.test(s.layers);if(e.element.style.display=!0===d?"":"none",!0===d){e.onBeforeRender(t,r,s);const c=e.element;c.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(Co.x*o+o)+"px,"+(-Co.y*l+l)+"px)",c.parentNode!==h&&h.appendChild(c),e.onAfterRender(t,r,s)}const p={distanceToCameraSquared:getDistanceToSquared(s,e)};c.objects.set(e,p)}for(let t=0,o=e.children.length;t<o;t++)renderObject(e.children[t],r,s)}function getDistanceToSquared(e,t){return Io.setFromMatrixPosition(e.matrixWorld),To.setFromMatrixPosition(t.matrixWorld),Io.distanceToSquared(To)}h.style.overflow="hidden",this.domElement=h,this.getSize=function(){return{width:r,height:s}},this.render=function(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),bo.copy(t.matrixWorldInverse),wo.multiplyMatrices(t.projectionMatrix,bo),renderObject(e,e,t),function zOrder(e){const t=function filterAndFlatten(e){const t=[];return e.traverse((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){if(e.renderOrder!==t.renderOrder)return t.renderOrder-e.renderOrder;return c.objects.get(e).distanceToCameraSquared-c.objects.get(t).distanceToCameraSquared})),r=t.length;for(let e=0,s=t.length;e<s;e++)t[e].element.style.zIndex=r-e}(e)},this.setSize=function(e,t){r=e,s=t,o=r/2,l=s/2,h.style.width=e+"px",h.style.height=t+"px"}}}r(6763);function reduceVertices(e,t,r){let s=r;const o=new three_module_Vector3;return e.updateWorldMatrix(!0,!0),e.traverseVisible((e=>{const{geometry:r}=e;if(void 0!==r){const{position:l}=r.attributes;if(void 0!==l)for(let r=0,c=l.count;r<c;r++)e.isMesh?e.getVertexPosition(r,o):o.fromBufferAttribute(l,r),e.isSkinnedMesh||o.applyMatrix4(e.matrixWorld),s=t(s,o)}})),s}let Bo,Ro,Lo,Do;function decompress(e,t=1/0,r=null){Ro||(Ro=new PlaneGeometry(2,2,1,1)),Lo||(Lo=new ShaderMaterial({uniforms:{blitTexture:new Uniform(e)},vertexShader:"\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main(){\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = vec4(position.xy * 1.0,0.,.999999);\n\t\t\t}",fragmentShader:"\n\t\t\tuniform sampler2D blitTexture; \n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main(){ \n\t\t\t\tgl_FragColor = vec4(vUv.xy, 0, 1);\n\t\t\t\t\n\t\t\t\t#ifdef IS_SRGB\n\t\t\t\tgl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n\t\t\t\t#else\n\t\t\t\tgl_FragColor = texture2D( blitTexture, vUv);\n\t\t\t\t#endif\n\t\t\t}"})),Lo.uniforms.blitTexture.value=e,Lo.defines.IS_SRGB=e.colorSpace==Ve,Lo.needsUpdate=!0,Do||(Do=new three_module_Mesh(Ro,Lo),Do.frustrumCulled=!1);const s=new PerspectiveCamera,o=new Scene;o.add(Do),null===r&&(r=Bo=new WebGLRenderer({antialias:!1}));const l=Math.min(e.image.width,t),c=Math.min(e.image.height,t);r.setSize(l,c),r.clear(),r.render(o,s);const h=document.createElement("canvas"),d=h.getContext("2d");h.width=l,h.height=c,d.drawImage(r.domElement,0,0,l,c);const p=new CanvasTexture(h);return p.minFilter=e.minFilter,p.magFilter=e.magFilter,p.wrapS=e.wrapS,p.wrapT=e.wrapT,p.name=e.name,Bo&&(Bo.forceContextLoss(),Bo.dispose(),Bo=null),p}var Uo=r(6763);const Po={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class GLTFExporter{constructor(){this.pluginCallbacks=[],this.register((function(e){return new GLTFLightExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsUnlitExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFExporter_GLTFMeshGpuInstancing(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,s){const o=new GLTFWriter,l=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)l.push(this.pluginCallbacks[e](o));o.setPlugins(l),o.write(e,t,s).catch(r)}parseAsync(e,t){const r=this;return new Promise((function(s,o){r.parse(e,s,o,t)}))}}const Fo=0,No=1,Oo=2,Qo=3,ko=4,Go=5120,Vo=5121,Ho=5122,zo=5123,Wo=5124,qo=5125,jo=5126,Xo=34962,Yo=34963,Ko=9728,Jo=9729,$o=9984,Zo=9985,el=9986,tl=9987,il=33071,nl=33648,rl=10497,sl="KHR_mesh_quantization",al={};al[te]=Ko,al[1004]=$o,al[1005]=el,al[1006]=Jo,al[1007]=Zo,al[1008]=tl,al[1001]=il,al[1e3]=rl,al[1002]=nl;const ol={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},ll=new Color;function equalArray(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function getPaddedBufferSize(e){return 4*Math.ceil(e/4)}function getPaddedArrayBuffer(e,t=0){const r=getPaddedBufferSize(e.byteLength);if(r!==e.byteLength){const s=new Uint8Array(r);if(s.set(new Uint8Array(e)),0!==t)for(let o=e.byteLength;o<r;o++)s[o]=t;return s.buffer}return e}function getCanvas(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function getToBlobPromise(e,t){if(void 0!==e.toBlob)return new Promise((r=>e.toBlob(r,t)));let r;return"image/jpeg"===t?r=.92:"image/webp"===t&&(r=.8),e.convertToBlob({type:t,quality:r})}class GLTFWriter{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,r={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const s=this,o=s.buffers,l=s.json;r=s.options;const c=s.extensionsUsed,h=s.extensionsRequired,d=new Blob(o,{type:"application/octet-stream"}),p=Object.keys(c),A=Object.keys(h);if(p.length>0&&(l.extensionsUsed=p),A.length>0&&(l.extensionsRequired=A),l.buffers&&l.buffers.length>0&&(l.buffers[0].byteLength=d.size),!0===r.binary){const e=new FileReader;e.readAsArrayBuffer(d),e.onloadend=function(){const r=getPaddedArrayBuffer(e.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);const o=getPaddedArrayBuffer(function stringToArrayBuffer(e){return(new TextEncoder).encode(e).buffer}(JSON.stringify(l)),32),c=new DataView(new ArrayBuffer(8));c.setUint32(0,o.byteLength,!0),c.setUint32(4,1313821514,!0);const h=new ArrayBuffer(12),d=new DataView(h);d.setUint32(0,1179937895,!0),d.setUint32(4,2,!0);const p=12+c.byteLength+o.byteLength+s.byteLength+r.byteLength;d.setUint32(8,p,!0);const A=new Blob([h,c,o,s,r],{type:"application/octet-stream"}),m=new FileReader;m.readAsArrayBuffer(A),m.onloadend=function(){t(m.result)}}}else if(l.buffers&&l.buffers.length>0){const e=new FileReader;e.readAsDataURL(d),e.onloadend=function(){const r=e.result;l.buffers[0].uri=r,t(l)}}else t(l)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const r=this.options,s=this.extensionsUsed;try{const o=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&o.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in o.gltfExtensions)t.extensions[e]=o.gltfExtensions[e],s[e]=!0;delete o.gltfExtensions}Object.keys(o).length>0&&(t.extras=o)}catch(t){Uo.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new three_module_Vector3;for(let r=0,s=e.count;r<s;r++)if(Math.abs(t.fromBufferAttribute(e,r).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),s=new three_module_Vector3;for(let e=0,t=r.count;e<t;e++)s.fromBufferAttribute(r,e),0===s.x&&0===s.y&&0===s.z?s.setX(1):s.normalize(),r.setXYZ(e,s.x,s.y,s.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1;const s={};0===t.offset.x&&0===t.offset.y||(s.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(s.rotation=t.rotation,r=!0),1===t.repeat.x&&1===t.repeat.y||(s.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function getEncodingConversion(e){return e.colorSpace===Ve?function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function LinearToLinear(e){return e}}Uo.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof CompressedTexture&&(e=decompress(e)),t instanceof CompressedTexture&&(t=decompress(t));const r=e?e.image:null,s=t?t.image:null,o=Math.max(r?r.width:0,s?s.width:0),l=Math.max(r?r.height:0,s?s.height:0),c=getCanvas();c.width=o,c.height=l;const h=c.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,o,l);const d=h.getImageData(0,0,o,l);if(r){h.drawImage(r,0,0,o,l);const t=getEncodingConversion(e),s=h.getImageData(0,0,o,l).data;for(let e=2;e<s.length;e+=4)d.data[e]=256*t(s[e]/256)}if(s){h.drawImage(s,0,0,o,l);const e=getEncodingConversion(t),r=h.getImageData(0,0,o,l).data;for(let t=1;t<r.length;t+=4)d.data[t]=256*e(r[t]/256)}h.putImageData(d,0,0);const p=(e||t).clone();return p.source=new Source(c),p.colorSpace=Ge,p.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&Uo.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),p}processBuffer(e){const t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,s,o){const l=this.json;let c;switch(l.bufferViews||(l.bufferViews=[]),t){case Go:case Vo:c=1;break;case Ho:case zo:c=2;break;default:c=4}const h=getPaddedBufferSize(s*e.itemSize*c),d=new DataView(new ArrayBuffer(h));let p=0;for(let o=r;o<r+s;o++)for(let r=0;r<e.itemSize;r++){let s;e.itemSize>4?s=e.array[o*e.itemSize+r]:(0===r?s=e.getX(o):1===r?s=e.getY(o):2===r?s=e.getZ(o):3===r&&(s=e.getW(o)),!0===e.normalized&&(s=At.normalize(s,e.array))),t===jo?d.setFloat32(p,s,!0):t===Wo?d.setInt32(p,s,!0):t===qo?d.setUint32(p,s,!0):t===Ho?d.setInt16(p,s,!0):t===zo?d.setUint16(p,s,!0):t===Go?d.setInt8(p,s):t===Vo&&d.setUint8(p,s),p+=c}const A={buffer:this.processBuffer(d.buffer),byteOffset:this.byteOffset,byteLength:h};void 0!==o&&(A.target=o),o===Xo&&(A.byteStride=e.itemSize*c),this.byteOffset+=h,l.bufferViews.push(A);return{id:l.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise((function(s){const o=new FileReader;o.readAsArrayBuffer(e),o.onloadend=function(){const e=getPaddedArrayBuffer(o.result),l={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,s(r.bufferViews.push(l)-1)}}))}processAccessor(e,t,r,s){const o=this.json;let l;if(e.array.constructor===Float32Array)l=jo;else if(e.array.constructor===Int32Array)l=Wo;else if(e.array.constructor===Uint32Array)l=qo;else if(e.array.constructor===Int16Array)l=Ho;else if(e.array.constructor===Uint16Array)l=zo;else if(e.array.constructor===Int8Array)l=Go;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);l=Vo}if(void 0===r&&(r=0),void 0!==s&&s!==1/0||(s=e.count),0===s)return null;const c=function getMinMax(e,t,r){const s={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let o=t;o<t+r;o++)for(let t=0;t<e.itemSize;t++){let r;e.itemSize>4?r=e.array[o*e.itemSize+t]:(0===t?r=e.getX(o):1===t?r=e.getY(o):2===t?r=e.getZ(o):3===t&&(r=e.getW(o)),!0===e.normalized&&(r=At.normalize(r,e.array))),s.min[t]=Math.min(s.min[t],r),s.max[t]=Math.max(s.max[t],r)}return s}(e,r,s);let h;void 0!==t&&(h=e===t.index?Yo:Xo);const d=this.processBufferView(e,l,r,s,h),p={bufferView:d.id,byteOffset:d.byteOffset,componentType:l,count:s,max:c.max,min:c.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(p.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(p)-1}processImage(e,t,r,s="image/png"){if(null!==e){const o=this,l=o.cache,c=o.json,h=o.options,d=o.pending;l.images.has(e)||l.images.set(e,{});const p=l.images.get(e),A=s+":flipY/"+r.toString();if(void 0!==p[A])return p[A];c.images||(c.images=[]);const m={mimeType:s},f=getCanvas();f.width=Math.min(e.width,h.maxTextureSize),f.height=Math.min(e.height,h.maxTextureSize);const g=f.getContext("2d");if(!0===r&&(g.translate(0,f.height),g.scale(1,-1)),void 0!==e.data){t!==Ae&&Uo.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>h.maxTextureSize||e.height>h.maxTextureSize)&&Uo.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const r=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<r.length;t+=4)r[t+0]=e.data[t+0],r[t+1]=e.data[t+1],r[t+2]=e.data[t+2],r[t+3]=e.data[t+3];g.putImageData(new ImageData(r,e.width,e.height),0,0)}else g.drawImage(e,0,0,f.width,f.height);!0===h.binary?d.push(getToBlobPromise(f,s).then((e=>o.processBufferViewImage(e))).then((e=>{m.bufferView=e}))):void 0!==f.toDataURL?m.uri=f.toDataURL(s):d.push(getToBlobPromise(f,s).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{m.uri=e})));const _=c.images.push(m)-1;return p[A]=_,_}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const r={magFilter:al[e.magFilter],minFilter:al[e.minFilter],wrapS:al[e.wrapS],wrapT:al[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){const t=this.options,r=this.cache,s=this.json;if(r.textures.has(e))return r.textures.get(e);s.textures||(s.textures=[]),e instanceof CompressedTexture&&(e=decompress(e,t.maxTextureSize));let o=e.userData.mimeType;"image/webp"===o&&(o="image/png");const l={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,o)};e.name&&(l.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,l)}));const c=s.textures.push(l)-1;return r.textures.set(e,c),c}processMaterial(e){const t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return Uo.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);const s={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&Uo.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const o=e.color.toArray().concat([e.opacity]);if(equalArray(o,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),r={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(r,t),s.pbrMetallicRoughness.metallicRoughnessTexture=r}if(e.map){const t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),s.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),s.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),s.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),s.occlusionTexture=t}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),2===e.side&&(s.doubleSided=!0),""!==e.name&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,s)}));const l=r.materials.push(s)-1;return t.materials.set(e,l),l}processMesh(e){const t=this.cache,r=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,r=e.material.length;t<r;t++)s.push(e.material[t].uuid);else s.push(e.material.uuid);const o=s.join(":");if(t.meshes.has(o))return t.meshes.get(o);const l=e.geometry;let c;c=e.isLineSegments?No:e.isLineLoop?Oo:e.isLine?Qo:e.isPoints?Fo:e.material.wireframe?No:ko;const h={},d={},p=[],A=[],m={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=l.getAttribute("normal");void 0===f||this.isNormalizedNormalAttribute(f)||(Uo.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),l.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let g=null;for(let e in l.attributes){if("morph"===e.slice(0,5))continue;const r=l.attributes[e];e=m[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(r))){d[e]=t.attributes.get(this.getUID(r));continue}g=null;const s=r.array;"JOINTS_0"!==e||s instanceof Uint16Array||s instanceof Uint8Array||(Uo.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),g=new three_module_BufferAttribute(new Uint16Array(s),r.itemSize,r.normalized));const o=this.processAccessor(g||r,l);null!==o&&(e.startsWith("_")||this.detectMeshQuantization(e,r),d[e]=o,t.attributes.set(this.getUID(r),o))}if(void 0!==f&&l.setAttribute("normal",f),0===Object.keys(d).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const r=[],s=[],o={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)o[e.morphTargetDictionary[t]]=t;for(let c=0;c<e.morphTargetInfluences.length;++c){const h={};let d=!1;for(const e in l.morphAttributes){if("position"!==e&&"normal"!==e){d||(Uo.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),d=!0);continue}const r=l.morphAttributes[e][c],s=e.toUpperCase(),o=l.attributes[e];if(t.attributes.has(this.getUID(r,!0))){h[s]=t.attributes.get(this.getUID(r,!0));continue}const p=r.clone();if(!l.morphTargetsRelative)for(let e=0,t=r.count;e<t;e++)for(let t=0;t<r.itemSize;t++)0===t&&p.setX(e,r.getX(e)-o.getX(e)),1===t&&p.setY(e,r.getY(e)-o.getY(e)),2===t&&p.setZ(e,r.getZ(e)-o.getZ(e)),3===t&&p.setW(e,r.getW(e)-o.getW(e));h[s]=this.processAccessor(p,l),t.attributes.set(this.getUID(o,!0),h[s])}A.push(h),r.push(e.morphTargetInfluences[c]),void 0!==e.morphTargetDictionary&&s.push(o[c])}h.weights=r,s.length>0&&(h.extras={},h.extras.targetNames=s)}const _=Array.isArray(e.material);if(_&&0===l.groups.length)return null;let y=!1;if(_&&null===l.index){const e=[];for(let t=0,r=l.attributes.position.count;t<r;t++)e[t]=t;l.setIndex(e),y=!0}const x=_?e.material:[e.material],S=_?l.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,r=S.length;e<r;e++){const r={mode:c,attributes:d};if(this.serializeUserData(l,r),A.length>0&&(r.targets=A),null!==l.index){let s=this.getUID(l.index);void 0===S[e].start&&void 0===S[e].count||(s+=":"+S[e].start+":"+S[e].count),t.attributes.has(s)?r.indices=t.attributes.get(s):(r.indices=this.processAccessor(l.index,l,S[e].start,S[e].count),t.attributes.set(s,r.indices)),null===r.indices&&delete r.indices}const s=this.processMaterial(x[S[e].materialIndex]);null!==s&&(r.material=s),p.push(r)}!0===y&&l.setIndex(null),h.primitives=p,r.meshes||(r.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,h)}));const C=r.meshes.push(h)-1;return t.meshes.set(o,C),C}detectMeshQuantization(e,t){if(this.extensionsUsed[sl])return;let r;switch(t.array.constructor){case Int8Array:r="byte";break;case Uint8Array:r="unsigned byte";break;case Int16Array:r="short";break;case Uint16Array:r="unsigned short";break;default:return}t.normalized&&(r+=" normalized");const s=e.split("_",1)[0];Po[s]&&Po[s].includes(r)&&(this.extensionsUsed[sl]=!0,this.extensionsRequired[sl]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const r=e.isOrthographicCamera,s={type:r?"orthographic":"perspective"};return r?s.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:At.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){const r=this.json,s=this.nodeMap;r.animations||(r.animations=[]);const o=(e=GLTFExporter.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,l=[],c=[];for(let e=0;e<o.length;++e){const r=o[e],h=PropertyBinding.parseTrackName(r.name);let d=PropertyBinding.findNode(t,h.nodeName);const p=ol[h.propertyName];if("bones"===h.objectName&&(d=!0===d.isSkinnedMesh?d.skeleton.getBoneByName(h.objectIndex):void 0),!d||!p)return Uo.warn('THREE.GLTFExporter: Could not export animation track "%s".',r.name),null;const A=1;let m,f=r.values.length/r.times.length;p===ol.morphTargetInfluences&&(f/=d.morphTargetInfluences.length),!0===r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(m="CUBICSPLINE",f/=3):m=r.getInterpolation()===De?"STEP":"LINEAR",c.push({input:this.processAccessor(new three_module_BufferAttribute(r.times,A)),output:this.processAccessor(new three_module_BufferAttribute(r.values,f)),interpolation:m}),l.push({sampler:c.length-1,target:{node:s.get(d),path:p}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:c,channels:l}),r.animations.length-1}processSkin(e){const t=this.json,r=this.nodeMap,s=t.nodes[r.get(e)],o=e.skeleton;if(void 0===o)return null;const l=e.skeleton.bones[0];if(void 0===l)return null;const c=[],h=new Float32Array(16*o.bones.length),d=new three_module_Matrix4;for(let t=0;t<o.bones.length;++t)c.push(r.get(o.bones[t])),d.copy(o.boneInverses[t]),d.multiply(e.bindMatrix).toArray(h,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new three_module_BufferAttribute(h,16)),joints:c,skeleton:r.get(l)});return s.skin=t.skins.length-1}processNode(e){const t=this.json,r=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);const o={};if(r.trs){const t=e.quaternion.toArray(),r=e.position.toArray(),s=e.scale.toArray();equalArray(t,[0,0,0,1])||(o.rotation=t),equalArray(r,[0,0,0])||(o.translation=r),equalArray(s,[1,1,1])||(o.scale=s)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===function isIdentityMatrix(e){return equalArray(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}(e.matrix)&&(o.matrix=e.matrix.elements);if(""!==e.name&&(o.name=String(e.name)),this.serializeUserData(e,o),e.isMesh||e.isLine||e.isPoints){const t=this.processMesh(e);null!==t&&(o.mesh=t)}else e.isCamera&&(o.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let s=0,o=e.children.length;s<o;s++){const o=e.children[s];if(o.visible||!1===r.onlyVisible){const e=this.processNode(o);null!==e&&t.push(e)}}t.length>0&&(o.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,o)}));const l=t.nodes.push(o)-1;return s.set(e,l),l}processScene(e){const t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={};""!==e.name&&(s.name=e.name),t.scenes.push(s);const o=[];for(let t=0,s=e.children.length;t<s;t++){const s=e.children[t];if(s.visible||!1===r.onlyVisible){const e=this.processNode(s);null!==e&&o.push(e)}}o.length>0&&(s.nodes=o),this.serializeUserData(e,s)}processObjects(e){const t=new Scene;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const r=[];for(let t=0;t<e.length;t++)e[t]instanceof Scene?this.processScene(e[t]):r.push(e[t]);r.length>0&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class GLTFLightExtension{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void Uo.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const r=this.writer,s=r.json,o=r.extensionsUsed,l={};e.name&&(l.name=e.name),l.color=e.color.toArray(),l.intensity=e.intensity,e.isDirectionalLight?l.type="directional":e.isPointLight?(l.type="point",e.distance>0&&(l.range=e.distance)):e.isSpotLight&&(l.type="spot",e.distance>0&&(l.range=e.distance),l.spot={},l.spot.innerConeAngle=(1-e.penumbra)*e.angle,l.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&Uo.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||Uo.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),o[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},o[this.name]=!0);const c=s.extensions[this.name].lights;c.push(l),t.extensions=t.extensions||{},t.extensions[this.name]={light:c.length-1}}}class GLTFExporter_GLTFMaterialsUnlitExtension{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class GLTFExporter_GLTFMaterialsClearcoatExtension{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:r.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};r.applyTextureTransform(t,e.clearcoatMap),o.clearcoatTexture=t}if(o.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:r.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};r.applyTextureTransform(t,e.clearcoatRoughnessMap),o.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:r.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};r.applyTextureTransform(t,e.clearcoatNormalMap),o.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsIridescenceExtension{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:r.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};r.applyTextureTransform(t,e.iridescenceMap),o.iridescenceTexture=t}if(o.iridescenceIor=e.iridescenceIOR,o.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],o.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:r.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};r.applyTextureTransform(t,e.iridescenceThicknessMap),o.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsTransmissionExtension{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.transmissionFactor=e.transmission,e.transmissionMap){const t={index:r.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};r.applyTextureTransform(t,e.transmissionMap),o.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsVolumeExtension{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const r=this.writer,s=r.extensionsUsed,o={};if(o.thicknessFactor=e.thickness,e.thicknessMap){const t={index:r.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};r.applyTextureTransform(t,e.thicknessMap),o.thicknessTexture=t}o.attenuationDistance=e.attenuationDistance,o.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsIorExtension{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const r=this.writer.extensionsUsed,s={};s.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}}class GLTFExporter_GLTFMaterialsSpecularExtension{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(ll)&&!e.specularIntensityMap&&!e.specularColorMap)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.specularIntensityMap){const t={index:r.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};r.applyTextureTransform(t,e.specularIntensityMap),o.specularTexture=t}if(e.specularColorMap){const t={index:r.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};r.applyTextureTransform(t,e.specularColorMap),o.specularColorTexture=t}o.specularFactor=e.specularIntensity,o.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsSheenExtension{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.sheenRoughnessMap){const t={index:r.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};r.applyTextureTransform(t,e.sheenRoughnessMap),o.sheenRoughnessTexture=t}if(e.sheenColorMap){const t={index:r.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};r.applyTextureTransform(t,e.sheenColorMap),o.sheenColorTexture=t}o.sheenRoughnessFactor=e.sheenRoughness,o.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsAnisotropyExtension{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.anisotropyMap){const t={index:r.processTexture(e.anisotropyMap)};r.applyTextureTransform(t,e.anisotropyMap),o.anisotropyTexture=t}o.anisotropyStrength=e.anisotropy,o.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;const r=this.writer.extensionsUsed,s={};s.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}}class GLTFExporter_GLTFMaterialsBumpExtension{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;const r=this.writer,s=r.extensionsUsed,o={};if(e.bumpMap){const t={index:r.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};r.applyTextureTransform(t,e.bumpMap),o.bumpTexture=t}o.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=o,s[this.name]=!0}}class GLTFExporter_GLTFMeshGpuInstancing{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const r=this.writer,s=e,o=new Float32Array(3*s.count),l=new Float32Array(4*s.count),c=new Float32Array(3*s.count),h=new three_module_Matrix4,d=new three_module_Vector3,p=new three_module_Quaternion,A=new three_module_Vector3;for(let e=0;e<s.count;e++)s.getMatrixAt(e,h),h.decompose(d,p,A),d.toArray(o,3*e),p.toArray(l,4*e),A.toArray(c,3*e);const m={TRANSLATION:r.processAccessor(new three_module_BufferAttribute(o,3)),ROTATION:r.processAccessor(new three_module_BufferAttribute(l,4)),SCALE:r.processAccessor(new three_module_BufferAttribute(c,3))};s.instanceColor&&(m._COLOR_0=r.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:m},r.extensionsUsed[this.name]=!0,r.extensionsRequired[this.name]=!0}}GLTFExporter.Utils={insertKeyframe:function(e,t){const r=.001,s=e.getValueSize(),o=new e.TimeBufferType(e.times.length+1),l=new e.ValueBufferType(e.values.length+s),c=e.createInterpolant(new e.ValueBufferType(s));let h;if(0===e.times.length){o[0]=t;for(let e=0;e<s;e++)l[e]=0;h=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<r)return 0;o[0]=t,o.set(e.times,1),l.set(c.evaluate(t),0),l.set(e.values,s),h=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<r)return e.times.length-1;o[o.length-1]=t,o.set(e.times,0),l.set(e.values,0),l.set(c.evaluate(t),e.values.length),h=o.length-1}else for(let d=0;d<e.times.length;d++){if(Math.abs(e.times[d]-t)<r)return d;if(e.times[d]<t&&e.times[d+1]>t){o.set(e.times.slice(0,d+1),0),o[d+1]=t,o.set(e.times.slice(d+1),d+2),l.set(e.values.slice(0,(d+1)*s),0),l.set(c.evaluate(t),(d+1)*s),l.set(e.values.slice((d+1)*s),(d+2)*s),h=d+1;break}}return e.times=o,e.values=l,h},mergeMorphTargetTracks:function(e,t){const r=[],s={},o=e.tracks;for(let e=0;e<o.length;++e){let l=o[e];const c=PropertyBinding.parseTrackName(l.name),h=PropertyBinding.findNode(t,c.nodeName);if("morphTargetInfluences"!==c.propertyName||void 0===c.propertyIndex){r.push(l);continue}if(l.createInterpolant!==l.InterpolantFactoryMethodDiscrete&&l.createInterpolant!==l.InterpolantFactoryMethodLinear){if(l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");Uo.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),l=l.clone(),l.setInterpolation(Ue)}const d=h.morphTargetInfluences.length,p=h.morphTargetDictionary[c.propertyIndex];if(void 0===p)throw new Error("THREE.GLTFExporter: Morph target name not found: "+c.propertyIndex);let A;if(void 0===s[h.uuid]){A=l.clone();const e=new A.ValueBufferType(d*A.times.length);for(let t=0;t<A.times.length;t++)e[t*d+p]=A.values[t];A.name=(c.nodeName||"")+".morphTargetInfluences",A.values=e,s[h.uuid]=A,r.push(A);continue}const m=l.createInterpolant(new l.ValueBufferType(1));A=s[h.uuid];for(let e=0;e<A.times.length;e++)A.values[e*d+p]=m.evaluate(A.times[e]);for(let e=0;e<l.times.length;e++){const t=this.insertKeyframe(A,l.times[e]);A.values[t*d+p]=l.values[e]}}return e.tracks=r,e}};const compatibleObject=e=>void 0!==e.material&&e.userData&&e.userData.variantMaterials&&!!Array.from(e.userData.variantMaterials.values()).filter((e=>compatibleMaterial(e.material))),compatibleMaterial=e=>e&&e.isMaterial&&!Array.isArray(e);class GLTFExporterMaterialsVariantsExtension{constructor(e){this.writer=e,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(e){const t=new Set;for(const r of e)r.traverse((e=>{if(!compatibleObject(e))return;const r=e.userData.variantMaterials,s=e.userData.variantData;for(const[e,o]of s){const s=r.get(o.index);s&&compatibleMaterial(s.material)&&t.add(e)}}));t.forEach((e=>this.variantNames.push(e)))}writeMesh(e,t){if(!compatibleObject(e))return;const r=e.userData,s=r.variantMaterials,o=r.variantData,l=new Map,c=new Map,h=Array.from(o.values()).sort(((e,t)=>e.index-t.index));for(const[e,t]of h.entries())c.set(t.index,e);for(const e of o.values()){const t=s.get(e.index);if(!t||!compatibleMaterial(t.material))continue;const r=this.writer.processMaterial(t.material);l.has(r)||l.set(r,{material:r,variants:[]}),l.get(r).variants.push(c.get(e.index))}const d=Array.from(l.values()).map((e=>e.variants.sort(((e,t)=>e-t))&&e)).sort(((e,t)=>e.material-t.material));if(0===d.length)return;const p=compatibleMaterial(r.originalMaterial)?this.writer.processMaterial(r.originalMaterial):-1;for(const e of t.primitives)p>=0&&(e.material=p),e.extensions=e.extensions||{},e.extensions[this.name]={mappings:d}}afterParse(){if(0===this.variantNames.length)return;const e=this.writer.json;e.extensions=e.extensions||{};const t=this.variantNames.map((e=>({name:e})));e.extensions[this.name]={variants:t},this.writer.extensionsUsed[this.name]=!0}}class SessionLightProbe{constructor(e,t,r,s,o){this.xrLight=e,this.renderer=t,this.lightProbe=r,this.xrWebGLBinding=null,this.estimationStartCallback=o,this.frameCallback=this.onXRFrame.bind(this);const l=t.xr.getSession();if(s&&"XRWebGLBinding"in window){const r=new WebGLCubeRenderTarget(16);e.environment=r.texture;const s=t.getContext();switch(l.preferredReflectionFormat){case"srgba8":s.getExtension("EXT_sRGB");break;case"rgba16f":s.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(l,s),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}l.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const r=t.getLightEstimate(this.lightProbe);if(r){this.xrLight.lightProbe.sh.fromArray(r.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const e=Math.max(1,Math.max(r.primaryLightIntensity.x,Math.max(r.primaryLightIntensity.y,r.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(r.primaryLightIntensity.x/e,r.primaryLightIntensity.y/e,r.primaryLightIntensity.z/e),this.xrLight.directionalLight.intensity=e,this.xrLight.directionalLight.position.copy(r.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class XREstimatedLight extends three_module_Group{constructor(e,t=!0){super(),this.lightProbe=new LightProbe,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new DirectionalLight,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let r=null,s=!1;e.xr.addEventListener("sessionstart",(()=>{const o=e.xr.getSession();"requestLightProbe"in o&&o.requestLightProbe({reflectionFormat:o.preferredReflectionFormat}).then((o=>{r=new SessionLightProbe(this,e,o,t,(()=>{s=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),e.xr.addEventListener("sessionend",(()=>{r&&(r.dispose(),r=null),s&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{r&&(r.dispose(),r=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}class Damper{constructor(e=50){this.velocity=0,this.naturalFrequency=0,this.setDecayTime(e)}setDecayTime(e){this.naturalFrequency=1/Math.max(.001,e)}update(e,t,r,s){const o=2e-4*this.naturalFrequency;if(null==e||0===s)return t;if(e===t&&0===this.velocity)return t;if(r<0)return e;const l=e-t,c=this.velocity+this.naturalFrequency*l,h=l+r*c,d=Math.exp(-this.naturalFrequency*r),p=(c-this.naturalFrequency*h)*d,A=-this.naturalFrequency*(p+c*d);return Math.abs(p)<o*Math.abs(s)&&A*l>=0?(this.velocity=0,t):(this.velocity=p,t+h*d)}}const cl=.2,hl=Math.PI/24,ul=new Vector2,addCorner=(e,t,r)=>{let s=t>0?r>0?0:-Math.PI/2:r>0?Math.PI/2:Math.PI;for(let o=0;o<=12;++o)e.push(t+.17*Math.cos(s),r+.17*Math.sin(s),0,t+cl*Math.cos(s),r+cl*Math.sin(s),0),s+=hl};class PlacementBox extends three_module_Mesh{constructor(e,t){const r=new three_module_BufferGeometry,s=[],o=[],{size:l,boundingBox:c}=e,h=l.x/2,d=("back"===t?l.y:l.z)/2;addCorner(o,h,d),addCorner(o,-h,d),addCorner(o,-h,-d),addCorner(o,h,-d);const p=o.length/3;for(let e=0;e<p-2;e+=2)s.push(e,e+1,e+3,e,e+3,e+2);const A=p-2;s.push(A,A+1,1,A,1,0),r.setAttribute("position",new three_module_Float32BufferAttribute(o,3)),r.setIndex(s),super(r),this.side=t;const m=this.material;switch(m.side=2,m.transparent=!0,m.opacity=0,this.goalOpacity=0,this.opacityDamper=new Damper,this.hitPlane=new three_module_Mesh(new PlaneGeometry(2*(h+cl),2*(d+cl))),this.hitPlane.visible=!1,this.hitPlane.material.side=2,this.add(this.hitPlane),c.getCenter(this.position),t){case"bottom":this.rotateX(-Math.PI/2),this.shadowHeight=c.min.y,this.position.y=this.shadowHeight;break;case"back":this.shadowHeight=c.min.z,this.position.z=this.shadowHeight}e.target.add(this),this.offsetHeight=0}getHit(e,t,r){ul.set(t,-r),this.hitPlane.visible=!0;const s=e.positionAndNormalFromPoint(ul,this.hitPlane);return this.hitPlane.visible=!1,null==s?null:s.position}getExpandedHit(e,t,r){this.hitPlane.scale.set(1e3,1e3,1e3),this.hitPlane.updateMatrixWorld();const s=this.getHit(e,t,r);return this.hitPlane.scale.set(1,1,1),s}set offsetHeight(e){e-=.001,"back"===this.side?this.position.z=this.shadowHeight+e:this.position.y=this.shadowHeight+e}get offsetHeight(){return"back"===this.side?this.position.z-this.shadowHeight:this.position.y-this.shadowHeight}set show(e){this.goalOpacity=e?.75:0}updateOpacity(e){const t=this.material;t.opacity=this.opacityDamper.update(t.opacity,this.goalOpacity,e,1),this.visible=t.opacity>0}dispose(){var e;const{geometry:t,material:r}=this.hitPlane;t.dispose(),r.dispose(),this.geometry.dispose(),this.material.dispose(),null===(e=this.parent)||void 0===e||e.remove(this)}}const numberNode=(e,t)=>({type:"number",number:e,unit:t}),dl=(()=>{const e={};return t=>{const r=t;if(r in e)return e[r];const s=[];let o=0;for(;t;){if(++o>1e3){t="";break}const e=pl(t),r=e.nodes[0];if(null==r||0===r.terms.length)break;s.push(r),t=e.remainingInput}return e[r]=s}})(),pl=(()=>{const e=/^(\-\-|[a-z\u0240-\uffff])/i,t=/^([\*\+\/]|[\-]\s)/i,r=/^[\),]/;return s=>{const o=[];for(;s.length&&(s=s.trim(),!r.test(s));)if("("===s[0]){const{nodes:e,remainingInput:t}=parseFunctionArguments(s);s=t,o.push({type:"function",name:{type:"ident",value:"calc"},arguments:e})}else if(e.test(s)){const e=Al(s),t=e.nodes[0];if("("===(s=e.remainingInput)[0]){const{nodes:e,remainingInput:r}=parseFunctionArguments(s);o.push({type:"function",name:t,arguments:e}),s=r}else o.push(t)}else if(t.test(s))o.push({type:"operator",value:s[0]}),s=s.slice(1);else{const{nodes:e,remainingInput:t}="#"===s[0]?fl(s):ml(s);if(0===e.length)break;o.push(e[0]),s=t}return{nodes:[{type:"expression",terms:o}],remainingInput:s}}})(),Al=(()=>{const e=/[^a-z0-9_\-\u0240-\uffff]/i;return t=>{const r=t.match(e);return{nodes:[{type:"ident",value:null==r?t:t.substr(0,r.index)}],remainingInput:null==r?"":t.substr(r.index)}}})(),ml=(()=>{const e=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,t=/^[a-z%]+/i,r=/^(m|mm|cm|rad|deg|[%])$/;return s=>{const o=s.match(e),l=null==o?"0":o[0],c=(s=null==l?s:s.slice(l.length)).match(t);let h=null!=c&&""!==c[0]?c[0]:null;const d=null==c?s:s.slice(h.length);return null==h||r.test(h)||(h=null),{nodes:[{type:"number",number:parseFloat(l)||0,unit:h}],remainingInput:d}}})(),fl=(()=>{const e=/^[a-f0-9]*/i;return t=>{const r=(t=t.slice(1).trim()).match(e);return{nodes:null==r?[]:[{type:"hex",value:r[0]}],remainingInput:null==r?t:t.slice(r[0].length)}}})(),parseFunctionArguments=e=>{const t=[];for(e=e.slice(1).trim();e.length;){const r=pl(e);if(t.push(r.nodes[0]),","===(e=r.remainingInput.trim())[0])e=e.slice(1).trim();else if(")"===e[0]){e=e.slice(1);break}}return{nodes:t,remainingInput:e}},gl=Symbol("visitedTypes");class ASTWalker{constructor(e){this[gl]=e}walk(e,t){const r=e.slice();for(;r.length;){const e=r.shift();switch(this[gl].indexOf(e.type)>-1&&t(e),e.type){case"expression":r.unshift(...e.terms);break;case"function":r.unshift(e.name,...e.arguments)}}}}const _l=Object.freeze({type:"number",number:0,unit:null}),degreesToRadians=(e,t=0)=>{let{number:r,unit:s}=e;if(isFinite(r)){if("rad"===e.unit||null==e.unit)return e}else r=t,s="rad";return{type:"number",number:("deg"===s&&null!=r?r:0)*Math.PI/180,unit:"rad"}},lengthToBaseMeters=(e,t=0)=>{let r,{number:s,unit:o}=e;if(isFinite(s)){if("m"===e.unit)return e}else s=t,o="m";switch(o){default:r=1;break;case"cm":r=.01;break;case"mm":r=.001}return{type:"number",number:r*s,unit:"m"}},vl=(()=>{const identity=e=>e,e={rad:identity,deg:degreesToRadians,m:identity,mm:lengthToBaseMeters,cm:lengthToBaseMeters};return(t,r=_l)=>{isFinite(t.number)||(t.number=r.number,t.unit=r.unit);const{unit:s}=t;if(null==s)return t;const o=e[s];return null==o?r:o(t)}})();var yl,El,xl;const Sl=Symbol("evaluate"),Ml=Symbol("lastValue");class Evaluator{constructor(){this[yl]=null}static evaluatableFor(e,t=_l){if(e instanceof Evaluator)return e;if("number"===e.type)return"%"===e.unit?new PercentageEvaluator(e,t):e;switch(e.name.value){case"calc":return new CalcEvaluator(e,t);case"env":return new EnvEvaluator(e)}return _l}static evaluate(e){return e instanceof Evaluator?e.evaluate():e}static isConstant(e){return!(e instanceof Evaluator)||e.isConstant}static applyIntrinsics(e,t){const{basis:r,keywords:s}=t,{auto:o}=s;return r.map(((t,r)=>{const l=null==o[r]?t:o[r];let c=e[r]?e[r]:l;if("ident"===c.type){const e=c.value;e in s&&(c=s[e][r])}return null!=c&&"ident"!==c.type||(c=l),"%"===c.unit?numberNode(c.number/100*t.number,t.unit):(c=vl(c,t),c.unit!==t.unit?t:c)}))}get isConstant(){return!1}evaluate(){return this.isConstant&&null!=this[Ml]||(this[Ml]=this[Sl]()),this[Ml]}}yl=Ml;const Cl=Symbol("percentage"),bl=Symbol("basis");class PercentageEvaluator extends Evaluator{constructor(e,t){super(),this[Cl]=e,this[bl]=t}get isConstant(){return!0}[Sl](){return numberNode(this[Cl].number/100*this[bl].number,this[bl].unit)}}const wl=Symbol("identNode");class EnvEvaluator extends Evaluator{constructor(e){super(),this[El]=null;const t=e.arguments.length?e.arguments[0].terms[0]:null;null!=t&&"ident"===t.type&&(this[wl]=t)}get isConstant(){return!1}[(El=wl,Sl)](){if(null!=this[wl]&&"window-scroll-y"===this[wl].value){return{type:"number",number:window.pageYOffset/(Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)-window.innerHeight)||0,unit:null}}return _l}}const Il=/[\*\/]/,Tl=Symbol("evaluator");class CalcEvaluator extends Evaluator{constructor(e,t=_l){if(super(),this[xl]=null,1!==e.arguments.length)return;const r=e.arguments[0].terms.slice(),s=[];for(;r.length;){const e=r.shift();if(s.length>0){const r=s[s.length-1];if("operator"===r.type&&Il.test(r.value)){const r=s.pop(),o=s.pop();if(null==o)return;s.push(new OperatorEvaluator(r,Evaluator.evaluatableFor(o,t),Evaluator.evaluatableFor(e,t)));continue}}s.push("operator"===e.type?e:Evaluator.evaluatableFor(e,t))}for(;s.length>2;){const[e,r,o]=s.splice(0,3);if("operator"!==r.type)return;s.unshift(new OperatorEvaluator(r,Evaluator.evaluatableFor(e,t),Evaluator.evaluatableFor(o,t)))}1===s.length&&(this[Tl]=s[0])}get isConstant(){return null==this[Tl]||Evaluator.isConstant(this[Tl])}[(xl=Tl,Sl)](){return null!=this[Tl]?Evaluator.evaluate(this[Tl]):_l}}const Bl=Symbol("operator"),Rl=Symbol("left"),Ll=Symbol("right");class OperatorEvaluator extends Evaluator{constructor(e,t,r){super(),this[Bl]=e,this[Rl]=t,this[Ll]=r}get isConstant(){return Evaluator.isConstant(this[Rl])&&Evaluator.isConstant(this[Ll])}[Sl](){const e=vl(Evaluator.evaluate(this[Rl])),t=vl(Evaluator.evaluate(this[Ll])),{number:r,unit:s}=e,{number:o,unit:l}=t;if(null!=l&&null!=s&&l!=s)return _l;const c=s||l;let h;switch(this[Bl].value){case"+":h=r+o;break;case"-":h=r-o;break;case"/":h=r/o;break;case"*":h=r*o;break;default:return _l}return{type:"number",number:h,unit:c}}}const Dl=Symbol("evaluatables"),Ul=Symbol("intrinsics");class StyleEvaluator extends Evaluator{constructor(e,t){super(),this[Ul]=t;const r=e[0],s=null!=r?r.terms:[];this[Dl]=t.basis.map(((e,t)=>{const r=s[t];return null==r?{type:"ident",value:"auto"}:"ident"===r.type?r:Evaluator.evaluatableFor(r,e)}))}get isConstant(){for(const e of this[Dl])if(!Evaluator.isConstant(e))return!1;return!0}[Sl](){const e=this[Dl].map((e=>Evaluator.evaluate(e)));return Evaluator.applyIntrinsics(e,this[Ul]).map((e=>e.number))}}var Pl,Fl,Nl,Ol;const Ql=Symbol("instances"),kl=Symbol("activateListener"),Gl=Symbol("deactivateListener"),Vl=Symbol("notifyInstances"),Hl=Symbol("notify"),zl=Symbol("callback");class ScrollObserver{constructor(e){this[zl]=e}static[Vl](){for(const e of ScrollObserver[Ql])e[Hl]()}static[(Pl=Ql,kl)](){window.addEventListener("scroll",this[Vl],{passive:!0})}static[Gl](){window.removeEventListener("scroll",this[Vl])}observe(){0===ScrollObserver[Ql].size&&ScrollObserver[kl](),ScrollObserver[Ql].add(this)}disconnect(){ScrollObserver[Ql].delete(this),0===ScrollObserver[Ql].size&&ScrollObserver[Gl]()}[Hl](){this[zl]()}}ScrollObserver[Pl]=new Set;const Wl=Symbol("computeStyleCallback"),ql=Symbol("astWalker"),jl=Symbol("dependencies"),Xl=Symbol("onScroll");class StyleEffector{constructor(e){this[Fl]={},this[Nl]=new ASTWalker(["function"]),this[Ol]=()=>{this[Wl]({relatedState:"window-scroll"})},this[Wl]=e}observeEffectsFor(e){const t={},r=this[jl];this[ql].walk(e,(e=>{const{name:s}=e,o=e.arguments[0].terms[0];if("env"===s.value&&null!=o&&"ident"===o.type&&"window-scroll-y"===o.value)if(null==t["window-scroll"]){const e="window-scroll"in r?r["window-scroll"]:new ScrollObserver(this[Xl]);e.observe(),delete r["window-scroll"],t["window-scroll"]=e}}));for(const e in r){r[e].disconnect()}this[jl]=t}dispose(){for(const e in this[jl]){this[jl][e].disconnect()}}}Fl=jl,Nl=ql,Ol=Xl;const style=e=>{const t=e.observeEffects||!1,r=e.intrinsics instanceof Function?e.intrinsics:()=>e.intrinsics;return(s,o)=>{const l=s.updated,c=s.connectedCallback,h=s.disconnectedCallback,d=Symbol(`${o}StyleEffector`),p=Symbol(`${o}StyleEvaluator`),A=Symbol(`${o}UpdateEvaluator`),m=Symbol(`${o}EvaluateAndSync`);Object.defineProperties(s,{[d]:{value:null,writable:!0},[p]:{value:null,writable:!0},[A]:{value:function(){const e=dl(this[o]);this[p]=new StyleEvaluator(e,r(this)),null==this[d]&&t&&(this[d]=new StyleEffector((()=>this[m]()))),null!=this[d]&&this[d].observeEffectsFor(e)}},[m]:{value:function(){if(null==this[p])return;const t=this[p].evaluate();this[e.updateHandler](t)}},updated:{value:function(e){e.has(o)&&(this[A](),this[m]()),l.call(this,e)}},connectedCallback:{value:function(){c.call(this),this.requestUpdate(o,this[o])}},disconnectedCallback:{value:function(){h.call(this),null!=this[d]&&(this[d].dispose(),this[d]=null)}}})}},easeInOutQuad=e=>e<.5?2*e*e:(4-2*e)*e-1,interpolate=(e,t,r=easeInOutQuad)=>s=>e+(t-e)*r(s),timeline=e=>{const t=[],r=[];let s=e.initialValue;for(let o=0;o<e.keyframes.length;++o){const l=e.keyframes[o],{value:c,frames:h}=l,d=l.ease||easeInOutQuad,p=interpolate(s,c,d);t.push(p),r.push(h),s=c}return((e,t)=>{const r=t.map((s=0,e=>s+=e));var s;return t=>{t=utilities_clamp(t,0,1),t*=r[r.length-1];const s=r.findIndex((e=>e>=t)),o=s<1?0:r[s-1],l=r[s];return e[s]((t-o)/(l-o))}})(t,r)};var Yl=r(6763),controls_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const Kl=timeline({initialValue:0,keyframes:[{frames:5,value:-1},{frames:1,value:-1},{frames:8,value:1},{frames:1,value:1},{frames:5,value:0},{frames:18,value:0}]}),Jl=timeline({initialValue:0,keyframes:[{frames:1,value:1},{frames:5,value:1},{frames:1,value:0},{frames:6,value:0}]}),$l="0deg 75deg 105%",Zl=["front","right","back","left"],ec=["upper-","","lower-"],tc="auto",ic="basic",nc="wiggle",rc="none",fieldOfViewIntrinsics=()=>({basis:[degreesToRadians(numberNode(30,"deg"))],keywords:{auto:[null]}}),minFieldOfViewIntrinsics=()=>({basis:[degreesToRadians(numberNode(12,"deg"))],keywords:{auto:[null]}}),sc=(()=>{const e=dl($l)[0].terms,t=vl(e[0]),r=vl(e[1]);return e=>{const s=e[$d].idealCameraDistance();return{basis:[t,r,numberNode(s,"m")],keywords:{auto:[null,null,numberNode(105,"%")]}}}})(),minCameraOrbitIntrinsics=e=>{const t=2.2*e[$d].boundingSphere.radius;return{basis:[numberNode(-1/0,"rad"),numberNode(Math.PI/8,"rad"),numberNode(t,"m")],keywords:{auto:[null,null,null]}}},maxCameraOrbitIntrinsics=e=>{const t=sc(e),r=new StyleEvaluator([],t).evaluate()[2];return{basis:[numberNode(1/0,"rad"),numberNode(Math.PI-Math.PI/8,"rad"),numberNode(r,"m")],keywords:{auto:[null,null,null]}}},cameraTargetIntrinsics=e=>{const t=e[$d].boundingBox.getCenter(new three_module_Vector3);return{basis:[numberNode(t.x,"m"),numberNode(t.y,"m"),numberNode(t.z,"m")],keywords:{auto:[null,null,null]}}},ac=Math.PI/2,oc=Math.PI/3,cc=ac/2,hc=2*Math.PI,uc=Symbol("controls"),dc=Symbol("panElement"),pc=Symbol("promptElement"),Ac=Symbol("promptAnimatedContainer"),mc=Symbol("fingerAnimatedContainers"),fc=Symbol("deferInteractionPrompt"),gc=Symbol("updateAria"),_c=Symbol("updateCameraForRadius"),vc=Symbol("cancelPrompts"),yc=Symbol("onChange"),Ec=Symbol("onPointerChange"),xc=Symbol("waitingToPromptUser"),Sc=Symbol("userHasInteracted"),Mc=Symbol("promptElementVisibleTime"),Cc=Symbol("lastPromptOffset"),bc=Symbol("cancellationSource"),wc=Symbol("lastSpherical"),Ic=Symbol("jumpCamera"),Tc=Symbol("initialized"),Bc=Symbol("maintainThetaPhi"),Rc=Symbol("syncCameraOrbit"),Lc=Symbol("syncFieldOfView"),Dc=Symbol("syncCameraTarget"),Uc=Symbol("syncMinCameraOrbit"),Pc=Symbol("syncMaxCameraOrbit"),Fc=Symbol("syncMinFieldOfView"),Nc=Symbol("syncMaxFieldOfView"),Oc=new Vector2,Qc=new three_module_Vector3,kc=Object.freeze({minimumRadius:0,maximumRadius:1/0,minimumPolarAngle:Math.PI/8,maximumPolarAngle:Math.PI-Math.PI/8,minimumAzimuthalAngle:-1/0,maximumAzimuthalAngle:1/0,minimumFieldOfView:10,maximumFieldOfView:45,touchAction:"none"}),Gc=Math.PI/8,Vc=.04,Hc={USER_INTERACTION:"user-interaction",NONE:"none",AUTOMATIC:"automatic"};class SmoothControls extends EventDispatcher{constructor(e,t,r){super(),this.camera=e,this.element=t,this.scene=r,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.inputSensitivity=1,this.changeSource=Hc.NONE,this._interactionEnabled=!1,this._disableZoom=!1,this.isUserPointing=!1,this.enablePan=!0,this.enableTap=!0,this.panProjection=new Matrix3,this.panPerPixel=0,this.spherical=new Spherical,this.goalSpherical=new Spherical,this.thetaDamper=new Damper,this.phiDamper=new Damper,this.radiusDamper=new Damper,this.logFov=Math.log(kc.maximumFieldOfView),this.goalLogFov=this.logFov,this.fovDamper=new Damper,this.touchMode=null,this.pointers=[],this.startTime=0,this.startPointerPosition={clientX:0,clientY:0},this.lastSeparation=0,this.touchDecided=!1,this.onContext=e=>{if(this.enablePan)e.preventDefault();else for(const e of this.pointers)this.onPointerUp(new PointerEvent("pointercancel",Object.assign(Object.assign({},this.startPointerPosition),{pointerId:e.id})))},this.touchModeZoom=(e,t)=>{if(!this._disableZoom){const e=this.twoTouchDistance(this.pointers[0],this.pointers[1]),t=Vc*this.zoomSensitivity*(this.lastSeparation-e)*50/this.scene.height;this.lastSeparation=e,this.userAdjustOrbit(0,0,t)}this.panPerPixel>0&&this.movePan(e,t)},this.disableScroll=e=>{e.preventDefault()},this.touchModeRotate=(e,t)=>{const{touchAction:r}=this._options;if(!this.touchDecided&&"none"!==r){this.touchDecided=!0;const s=Math.abs(e),o=Math.abs(t);if(this.changeSource===Hc.USER_INTERACTION&&("pan-y"===r&&o>s||"pan-x"===r&&s>o))return void(this.touchMode=null);this.element.addEventListener("touchmove",this.disableScroll,{passive:!1})}this.handleSinglePointerMove(e,t)},this.onPointerDown=e=>{if(this.pointers.length>2)return;const{element:t}=this;0===this.pointers.length&&(t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.touchMode=null,this.touchDecided=!1,this.startPointerPosition.clientX=e.clientX,this.startPointerPosition.clientY=e.clientY,this.startTime=performance.now());try{t.setPointerCapture(e.pointerId)}catch(e){}this.pointers.push({clientX:e.clientX,clientY:e.clientY,id:e.pointerId}),this.isUserPointing=!1,"touch"===e.pointerType?(this.changeSource=e.altKey?Hc.AUTOMATIC:Hc.USER_INTERACTION,this.onTouchChange(e)):(this.changeSource=Hc.USER_INTERACTION,this.onMouseDown(e)),this.changeSource===Hc.USER_INTERACTION&&this.dispatchEvent({type:"user-interaction"})},this.onPointerMove=e=>{const t=this.pointers.find((t=>t.id===e.pointerId));if(null==t)return;if("mouse"===e.pointerType&&0===e.buttons)return void this.onPointerUp(e);const r=this.pointers.length,s=(e.clientX-t.clientX)/r,o=(e.clientY-t.clientY)/r;0===s&&0===o||(t.clientX=e.clientX,t.clientY=e.clientY,"touch"===e.pointerType?(this.changeSource=e.altKey?Hc.AUTOMATIC:Hc.USER_INTERACTION,null!==this.touchMode&&this.touchMode(s,o)):(this.changeSource=Hc.USER_INTERACTION,this.panPerPixel>0?this.movePan(s,o):this.handleSinglePointerMove(s,o)))},this.onPointerUp=e=>{const{element:t}=this,r=this.pointers.findIndex((t=>t.id===e.pointerId));-1!==r&&this.pointers.splice(r,1),this.panPerPixel>0&&!e.altKey&&this.resetRadius(),0===this.pointers.length?(t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),t.removeEventListener("touchmove",this.disableScroll),this.enablePan&&this.enableTap&&this.recenter(e)):null!==this.touchMode&&this.onTouchChange(e),this.scene.element[dc].style.opacity=0,t.style.cursor="grab",this.panPerPixel=0,this.isUserPointing&&this.dispatchEvent({type:"pointer-change-end"})},this.onWheel=e=>{this.changeSource=Hc.USER_INTERACTION;const t=e.deltaY*(1==e.deltaMode?18:1)*Vc*this.zoomSensitivity/30;this.userAdjustOrbit(0,0,t),e.preventDefault(),this.dispatchEvent({type:"user-interaction"})},this.onKeyDown=e=>{const{changeSource:t}=this;this.changeSource=Hc.USER_INTERACTION;(e.shiftKey&&this.enablePan?this.panKeyCodeHandler(e):this.orbitZoomKeyCodeHandler(e))?(e.preventDefault(),this.dispatchEvent({type:"user-interaction"})):this.changeSource=t},this._options=Object.assign({},kc),this.setOrbit(0,Math.PI/2,1),this.setFieldOfView(100),this.jumpToGoal()}get interactionEnabled(){return this._interactionEnabled}enableInteraction(){if(!1===this._interactionEnabled){const{element:e}=this;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointercancel",this.onPointerUp),this._disableZoom||e.addEventListener("wheel",this.onWheel),e.addEventListener("keydown",this.onKeyDown),e.addEventListener("touchmove",(()=>{}),{passive:!1}),e.addEventListener("contextmenu",this.onContext),this.element.style.cursor="grab",this._interactionEnabled=!0,this.updateTouchActionStyle()}}disableInteraction(){if(!0===this._interactionEnabled){const{element:e}=this;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),e.removeEventListener("pointercancel",this.onPointerUp),e.removeEventListener("wheel",this.onWheel),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("contextmenu",this.onContext),e.style.cursor="",this.touchMode=null,this._interactionEnabled=!1,this.updateTouchActionStyle()}}get options(){return this._options}set disableZoom(e){this._disableZoom!=e&&(this._disableZoom=e,!0===e?this.element.removeEventListener("wheel",this.onWheel):this.element.addEventListener("wheel",this.onWheel),this.updateTouchActionStyle())}getCameraSpherical(e=new Spherical){return e.copy(this.spherical)}getFieldOfView(){return this.camera.fov}applyOptions(e){Object.assign(this._options,e),this.setOrbit(),this.setFieldOfView(Math.exp(this.goalLogFov))}updateNearFar(e,t){this.camera.far=0===t?2:t,this.camera.near=Math.max(e,this.camera.far/1e3),this.camera.updateProjectionMatrix()}updateAspect(e){this.camera.aspect=e,this.camera.updateProjectionMatrix()}setOrbit(e=this.goalSpherical.theta,t=this.goalSpherical.phi,r=this.goalSpherical.radius){const{minimumAzimuthalAngle:s,maximumAzimuthalAngle:o,minimumPolarAngle:l,maximumPolarAngle:c,minimumRadius:h,maximumRadius:d}=this._options,{theta:p,phi:A,radius:m}=this.goalSpherical,f=utilities_clamp(e,s,o);isFinite(s)||isFinite(o)||(this.spherical.theta=this.wrapAngle(this.spherical.theta-f)+f);const g=utilities_clamp(t,l,c),_=utilities_clamp(r,h,d);return(f!==p||g!==A||_!==m)&&(!!(isFinite(f)&&isFinite(g)&&isFinite(_))&&(this.goalSpherical.theta=f,this.goalSpherical.phi=g,this.goalSpherical.radius=_,this.goalSpherical.makeSafe(),!0))}setRadius(e){this.goalSpherical.radius=e,this.setOrbit()}setFieldOfView(e){const{minimumFieldOfView:t,maximumFieldOfView:r}=this._options;e=utilities_clamp(e,t,r),this.goalLogFov=Math.log(e)}setDamperDecayTime(e){this.thetaDamper.setDecayTime(e),this.phiDamper.setDecayTime(e),this.radiusDamper.setDecayTime(e),this.fovDamper.setDecayTime(e)}adjustOrbit(e,t,r){const{theta:s,phi:o,radius:l}=this.goalSpherical,{minimumRadius:c,maximumRadius:h,minimumFieldOfView:d,maximumFieldOfView:p}=this._options,A=this.spherical.theta-s,m=Math.PI-.001,f=s-utilities_clamp(e,-m-A,m-A),g=o-t,_=0===r?0:((r>0?h:c)-l)/(Math.log(r>0?p:d)-this.goalLogFov),y=l+r*(isFinite(_)?_:2*(h-c));if(this.setOrbit(f,g,y),0!==r){const e=this.goalLogFov+r;this.setFieldOfView(Math.exp(e))}}jumpToGoal(){this.update(0,1e4)}update(e,t){if(this.isStationary())return!1;const{maximumPolarAngle:r,maximumRadius:s}=this._options,o=this.spherical.theta-this.goalSpherical.theta;return Math.abs(o)>Math.PI&&!isFinite(this._options.minimumAzimuthalAngle)&&!isFinite(this._options.maximumAzimuthalAngle)&&(this.spherical.theta-=2*Math.sign(o)*Math.PI),this.spherical.theta=this.thetaDamper.update(this.spherical.theta,this.goalSpherical.theta,t,Math.PI),this.spherical.phi=this.phiDamper.update(this.spherical.phi,this.goalSpherical.phi,t,r),this.spherical.radius=this.radiusDamper.update(this.spherical.radius,this.goalSpherical.radius,t,s),this.logFov=this.fovDamper.update(this.logFov,this.goalLogFov,t,1),this.moveCamera(),!0}updateTouchActionStyle(){const{style:e}=this.element;if(this._interactionEnabled){const{touchAction:t}=this._options;this._disableZoom&&"none"!==t?e.touchAction="manipulation":e.touchAction=t}else e.touchAction=""}isStationary(){return this.goalSpherical.theta===this.spherical.theta&&this.goalSpherical.phi===this.spherical.phi&&this.goalSpherical.radius===this.spherical.radius&&this.goalLogFov===this.logFov}moveCamera(){this.spherical.makeSafe(),this.camera.position.setFromSpherical(this.spherical),this.camera.setRotationFromEuler(new Euler(this.spherical.phi-Math.PI/2,this.spherical.theta,0,"YXZ")),this.camera.fov!==Math.exp(this.logFov)&&(this.camera.fov=Math.exp(this.logFov),this.camera.updateProjectionMatrix())}userAdjustOrbit(e,t,r){this.adjustOrbit(e*this.orbitSensitivity*this.inputSensitivity,t*this.orbitSensitivity*this.inputSensitivity,r*this.inputSensitivity)}wrapAngle(e){const t=(e+Math.PI)/(2*Math.PI);return 2*(t-Math.floor(t))*Math.PI-Math.PI}pixelLengthToSphericalAngle(e){return 2*Math.PI*e/this.scene.height}twoTouchDistance(e,t){const{clientX:r,clientY:s}=e,{clientX:o,clientY:l}=t,c=o-r,h=l-s;return Math.sqrt(c*c+h*h)}handleSinglePointerMove(e,t){const r=this.pixelLengthToSphericalAngle(e),s=this.pixelLengthToSphericalAngle(t);!1===this.isUserPointing&&(this.isUserPointing=!0,this.dispatchEvent({type:"pointer-change-start"})),this.userAdjustOrbit(r,s,0)}initializePan(){const{theta:e,phi:t}=this.spherical,r=e-this.scene.yaw;this.panPerPixel=.018*this.panSensitivity/this.scene.height,this.panProjection.set(-Math.cos(r),-Math.cos(t)*Math.sin(r),0,0,Math.sin(t),0,Math.sin(r),-Math.cos(t)*Math.cos(r),0)}movePan(e,t){const{scene:r}=this,s=Qc.set(e,t,0).multiplyScalar(this.inputSensitivity),o=this.spherical.radius*Math.exp(this.logFov)*this.panPerPixel;s.multiplyScalar(o);const l=r.getTarget();l.add(s.applyMatrix3(this.panProjection)),r.boundingSphere.clampPoint(l,l),r.setTarget(l.x,l.y,l.z)}recenter(e){if(performance.now()>this.startTime+300||Math.abs(e.clientX-this.startPointerPosition.clientX)>2||Math.abs(e.clientY-this.startPointerPosition.clientY)>2)return;const{scene:t}=this,r=t.positionAndNormalFromPoint(t.getNDC(e.clientX,e.clientY));if(null==r){const{cameraTarget:e}=t.element;t.element.cameraTarget="",t.element.cameraTarget=e,this.userAdjustOrbit(0,0,1)}else t.target.worldToLocal(r.position),t.setTarget(r.position.x,r.position.y,r.position.z)}resetRadius(){const{scene:e}=this,t=e.positionAndNormalFromPoint(Oc.set(0,0));if(null==t)return;e.target.worldToLocal(t.position);const r=e.getTarget(),{theta:s,phi:o}=this.spherical,l=s-e.yaw,c=Qc.set(Math.sin(o)*Math.sin(l),Math.cos(o),Math.sin(o)*Math.cos(l)),h=c.dot(t.position.sub(r));r.add(c.multiplyScalar(h)),e.setTarget(r.x,r.y,r.z),this.setOrbit(void 0,void 0,this.goalSpherical.radius-h)}onTouchChange(e){if(1===this.pointers.length)this.touchMode=this.touchModeRotate;else{if(this._disableZoom)return this.touchMode=null,void this.element.removeEventListener("touchmove",this.disableScroll);this.touchMode=this.touchDecided&&null===this.touchMode?null:this.touchModeZoom,this.touchDecided=!0,this.element.addEventListener("touchmove",this.disableScroll,{passive:!1}),this.lastSeparation=this.twoTouchDistance(this.pointers[0],this.pointers[1]),this.enablePan&&null!=this.touchMode&&(this.initializePan(),e.altKey||(this.scene.element[dc].style.opacity=1))}}onMouseDown(e){this.panPerPixel=0,this.enablePan&&(2===e.button||e.ctrlKey||e.metaKey||e.shiftKey)&&(this.initializePan(),this.scene.element[dc].style.opacity=1),this.element.style.cursor="grabbing"}orbitZoomKeyCodeHandler(e){let t=!0;switch(e.key){case"PageUp":this.userAdjustOrbit(0,0,Vc*this.zoomSensitivity);break;case"PageDown":this.userAdjustOrbit(0,0,-.04*this.zoomSensitivity);break;case"ArrowUp":this.userAdjustOrbit(0,-Gc,0);break;case"ArrowDown":this.userAdjustOrbit(0,Gc,0);break;case"ArrowLeft":this.userAdjustOrbit(-Gc,0,0);break;case"ArrowRight":this.userAdjustOrbit(Gc,0,0);break;default:t=!1}return t}panKeyCodeHandler(e){this.initializePan();let t=!0;switch(e.key){case"ArrowUp":this.movePan(0,-10);break;case"ArrowDown":this.movePan(0,10);break;case"ArrowLeft":this.movePan(-10,0);break;case"ArrowRight":this.movePan(10,0);break;default:t=!1}return t}}var zc=r(6763);const Wc=1/1.3,qc="not-presenting",jc="session-started",Xc="object-placed",Yc="failed",Kc="tracking",Jc="not-tracking",$c=new three_module_Vector3,Zc=new three_module_Matrix4,eh=new three_module_Vector3,th=new PerspectiveCamera(45,1,.1,100);class ARRenderer extends EventDispatcher{constructor(e){super(),this.renderer=e,this.currentSession=null,this.placeOnWall=!1,this.placementBox=null,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.initialHitSource=null,this.transientHitTestSource=null,this.inputSource=null,this._presentedScene=null,this.resolveCleanup=null,this.exitWebXRButtonContainer=null,this.overlay=null,this.xrLight=null,this.tracking=!0,this.frames=0,this.initialized=!1,this.oldTarget=new three_module_Vector3,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.lastDragPosition=new three_module_Vector3,this.firstRatio=0,this.lastAngle=0,this.goalPosition=new three_module_Vector3,this.goalYaw=0,this.goalScale=1,this.xDamper=new Damper,this.yDamper=new Damper,this.zDamper=new Damper,this.yawDamper=new Damper,this.scaleDamper=new Damper,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onUpdateScene=()=>{null!=this.placementBox&&this.isPresenting&&(this.placementBox.dispose(),this.placementBox=new PlacementBox(this.presentedScene,this.placeOnWall?"back":"bottom"))},this.onSelectStart=e=>{const t=this.transientHitTestSource;if(null==t)return;const r=this.frame.getHitTestResultsForTransientInput(t),s=this.presentedScene,o=this.placementBox;if(1===r.length){this.inputSource=e.inputSource;const{axes:t}=this.inputSource.gamepad,r=o.getHit(this.presentedScene,t[0],t[1]);o.show=!0,null!=r?(this.isTranslating=!0,this.lastDragPosition.copy(r)):!1===this.placeOnWall&&(this.isRotating=!0,this.lastAngle=1.5*t[0])}else if(2===r.length){o.show=!0,this.isTwoFingering=!0;const{separation:e}=this.fingerPolar(r);this.firstRatio=e/s.scale.x}},this.onSelectEnd=()=>{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.inputSource=null,this.goalPosition.y+=this.placementBox.offsetHeight*this.presentedScene.scale.x,this.placementBox.show=!1},this.threeRenderer=e.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){assertIsArCandidate();const e=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:["hit-test"],optionalFeatures:["dom-overlay","light-estimation"],domOverlay:this.overlay?{root:this.overlay}:void 0});return this.threeRenderer.xr.setReferenceSpaceType("local"),await this.threeRenderer.xr.setSession(e),this.threeRenderer.xr.cameraAutoUpdate=!1,e}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return assertIsArCandidate(),await navigator.xr.isSessionSupported("immersive-ar")}catch(e){return zc.warn("Request to present in WebXR denied:"),zc.warn(e),zc.warn("Falling back to next ar-mode"),!1}}async present(e,t=!1){this.isPresenting&&zc.warn("Cannot present while a model is already presenting");let r=new Promise(((e,t)=>{requestAnimationFrame((()=>e()))}));e.setHotspotsVisibility(!1),e.queueRender(),await r,this._presentedScene=e,this.overlay=e.element.shadowRoot.querySelector("div.default"),!0===t&&(this.xrLight=new XREstimatedLight(this.threeRenderer),this.xrLight.addEventListener("estimationstart",(()=>{if(!this.isPresenting||null==this.xrLight)return;const e=this.presentedScene;e.add(this.xrLight),e.environment=this.xrLight.environment})));const s=await this.resolveARSession();s.addEventListener("end",(()=>{this.postSessionCleanup()}),{once:!0});const o=e.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");o.classList.add("enabled"),o.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=o;const l=await s.requestReferenceSpace("viewer");this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=e.yaw,this.goalYaw=e.yaw,this.goalScale=1,e.setBackground(null),this.oldShadowIntensity=e.shadowIntensity,e.setShadowIntensity(.01),this.oldTarget.copy(e.getTarget()),e.element.addEventListener("load",this.onUpdateScene);const c=20*Math.PI/180,h=!0===this.placeOnWall?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(c),z:-Math.cos(c)});s.requestHitTestSource({space:l,offsetRay:h}).then((e=>{this.initialHitSource=e})),this.currentSession=s,this.placementBox=new PlacementBox(e,this.placeOnWall?"back":"bottom"),this.placementComplete=!1,this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:jc})}async stopPresenting(){if(!this.isPresenting)return;const e=new Promise((e=>{this.resolveCleanup=e}));try{await this.currentSession.end(),await e}catch(e){zc.warn("Error while trying to end WebXR AR session"),zc.warn(e),this.postSessionCleanup()}}get isPresenting(){return null!=this.presentedScene}get target(){return this.oldTarget}updateTarget(){const e=this.presentedScene;if(null!=e){const t=e.getTarget();this.oldTarget.copy(t),this.placeOnWall?t.z=e.boundingBox.min.z:t.y=e.boundingBox.min.y,e.setTarget(t.x,t.y,t.z)}}postSessionCleanup(){const e=this.currentSession;null!=e&&(e.removeEventListener("selectstart",this.onSelectStart),e.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const t=this.presentedScene;if(this._presentedScene=null,null!=t){const{element:e}=t;null!=this.xrLight&&(t.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),t.position.set(0,0,0),t.scale.set(1,1,1),t.setShadowOffset(0);const r=this.turntableRotation;null!=r&&(t.yaw=r);const s=this.oldShadowIntensity;null!=s&&t.setShadowIntensity(s),t.setEnvironmentAndSkybox(e[ia],e[na]);const o=this.oldTarget;t.setTarget(o.x,o.y,o.z),t.xrCamera=null,t.element.removeEventListener("load",this.onUpdateScene),t.orientHotspots(0),e.requestUpdate("cameraTarget"),e.requestUpdate("maxCameraOrbit"),e[ip](e.getBoundingClientRect()),requestAnimationFrame((()=>{t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:Hc.NONE}}))}))}this.renderer.height=0;const r=this.exitWebXRButtonContainer;null!=r&&(r.classList.remove("enabled"),r.removeEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=null);const s=this.transientHitTestSource;null!=s&&(s.cancel(),this.transientHitTestSource=null);const o=this.initialHitSource;null!=o&&(o.cancel(),this.initialHitSource=null),null!=this.placementBox&&(this.placementBox.dispose(),this.placementBox=null),this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.inputSource=null,this.overlay=null,null!=this.resolveCleanup&&this.resolveCleanup(),this.dispatchEvent({type:"status",status:qc})}updateView(e){const t=this.presentedScene,r=this.threeRenderer.xr;r.updateCamera(th),t.xrCamera=r.getCamera();const{elements:s}=t.getCamera().matrixWorld;if(t.orientHotspots(Math.atan2(s[1],s[5])),this.initialized||(this.placeInitially(),this.initialized=!0),e.requestViewportScale&&e.recommendedViewportScale){const t=e.recommendedViewportScale;e.requestViewportScale(Math.max(t,.25))}const o=r.getBaseLayer();if(null!=o){const t=o instanceof XRWebGLLayer?o.getViewport(e):r.getBinding().getViewSubImage(o,e).viewport;this.threeRenderer.setViewport(t.x,t.y,t.width,t.height)}}placeInitially(){const e=this.presentedScene,{position:t,element:r}=e,s=e.getCamera(),{width:o,height:l}=this.overlay.getBoundingClientRect();e.setSize(o,l),s.projectionMatrixInverse.copy(s.projectionMatrix).invert();const{theta:c,radius:h}=r.getCameraOrbit(),d=s.getWorldDirection($c);e.yaw=Math.atan2(-d.x,-d.z)-c,this.goalYaw=e.yaw,t.copy(s.position).add(d.multiplyScalar(h)),this.updateTarget();const p=e.getTarget();t.add(p).sub(this.oldTarget),this.goalPosition.copy(t),e.setHotspotsVisibility(!0);const{session:A}=this.frame;A.addEventListener("selectstart",this.onSelectStart),A.addEventListener("selectend",this.onSelectEnd),A.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then((e=>{this.transientHitTestSource=e}))}getTouchLocation(){const{axes:e}=this.inputSource.gamepad;let t=this.placementBox.getExpandedHit(this.presentedScene,e[0],e[1]);return null!=t&&($c.copy(t).sub(this.presentedScene.getCamera().position),$c.length()>10)?null:t}getHitPoint(e){const t=this.threeRenderer.xr.getReferenceSpace(),r=e.getPose(t);if(null==r)return null;const s=Zc.fromArray(r.transform.matrix);return!0===this.placeOnWall&&(this.goalYaw=Math.atan2(s.elements[4],s.elements[6])),s.elements[5]>.75!==this.placeOnWall?eh.setFromMatrixPosition(s):null}moveToFloor(e){const t=this.initialHitSource;if(null==t)return;const r=e.getHitTestResults(t);if(0==r.length)return;const s=r[0],o=this.getHitPoint(s);null!=o&&(this.placementBox.show=!0,this.isTranslating||(this.placeOnWall?this.goalPosition.copy(o):this.goalPosition.y=o.y),t.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:Xc}))}fingerPolar(e){const t=e[0].inputSource.gamepad.axes,r=e[1].inputSource.gamepad.axes,s=r[0]-t[0],o=r[1]-t[1],l=Math.atan2(o,s);let c=this.lastAngle-l;return c>Math.PI?c-=2*Math.PI:c<-Math.PI&&(c+=2*Math.PI),this.lastAngle=l,{separation:Math.sqrt(s*s+o*o),deltaYaw:c}}processInput(e){const t=this.transientHitTestSource;if(null==t)return;if(!this.isTranslating&&!this.isTwoFingering&&!this.isRotating)return;const r=e.getHitTestResultsForTransientInput(t),s=this.presentedScene,o=s.scale.x;if(this.isTwoFingering)if(r.length<2)this.isTwoFingering=!1;else{const{separation:e,deltaYaw:t}=this.fingerPolar(r);if(!1===this.placeOnWall&&(this.goalYaw+=t),s.canScale){const t=e/this.firstRatio;this.goalScale=t<1.3&&t>Wc?1:t}}else if(2!==r.length)if(this.isRotating){const e=1.5*this.inputSource.gamepad.axes[0];this.goalYaw+=e-this.lastAngle,this.lastAngle=e}else this.isTranslating&&r.forEach((e=>{if(e.inputSource!==this.inputSource)return;let t=null;if(e.results.length>0&&(t=this.getHitPoint(e.results[0])),null==t&&(t=this.getTouchLocation()),null!=t){if(this.goalPosition.sub(this.lastDragPosition),!1===this.placeOnWall){const e=t.y-this.lastDragPosition.y;if(e<0){this.placementBox.offsetHeight=e/o,this.presentedScene.setShadowOffset(e);const r=$c.copy(s.getCamera().position),l=-e/(r.y-t.y);r.multiplyScalar(l),t.multiplyScalar(1-l).add(r)}}this.goalPosition.add(t),this.lastDragPosition.copy(t)}}));else{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!0;const{separation:e}=this.fingerPolar(r);this.firstRatio=e/o}}moveScene(e){const t=this.presentedScene,{position:r,yaw:s}=t,o=t.boundingSphere.radius,l=this.goalPosition,c=t.scale.x,h=this.placementBox;let d=Hc.NONE;if(!l.equals(r)||this.goalScale!==c){d=Hc.USER_INTERACTION;let{x:s,y:p,z:A}=r;s=this.xDamper.update(s,l.x,e,o),p=this.yDamper.update(p,l.y,e,o),A=this.zDamper.update(A,l.z,e,o),r.set(s,p,A);const m=this.scaleDamper.update(c,this.goalScale,e,1);if(t.scale.set(m,m,m),!this.isTranslating){const e=l.y-p;this.placementComplete&&!1===this.placeOnWall?(h.offsetHeight=e/m,t.setShadowOffset(e)):0===e&&(this.placementComplete=!0,h.show=!1,t.setShadowIntensity(.8))}}h.updateOpacity(e),t.updateTarget(e),t.yaw=this.yawDamper.update(s,this.goalYaw,e,Math.PI),t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:d}}))}onWebXRFrame(e,t){this.frame=t,++this.frames;const r=this.threeRenderer.xr.getReferenceSpace(),s=t.getViewerPose(r);null==s&&!0===this.tracking&&this.frames>30&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:Jc}));const o=this.presentedScene;if(null==s||null==o||!o.element.loaded)return void this.threeRenderer.clear();!1===this.tracking&&(this.tracking=!0,this.dispatchEvent({type:"tracking",status:Kc}));let l=!0;for(const r of s.views){if(this.updateView(r),l){this.moveToFloor(t),this.processInput(t);const r=e-this.lastTick;this.moveScene(r),this.renderer.preRender(o,e,r),this.lastTick=e,o.renderShadow(this.threeRenderer)}this.threeRenderer.render(o,o.getCamera()),l=!1}}}function clone(e){const t=new Map,r=new Map,s=e.clone();return parallelTraverse(e,s,(function(e,s){t.set(s,e),r.set(e,s)})),s.traverse((function(e){if(!e.isSkinnedMesh)return;const s=e,o=t.get(e),l=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=l.map((function(e){return r.get(e)})),s.bind(s.skeleton,s.bindMatrix)})),s}function parallelTraverse(e,t,r){r(e,t);for(let s=0;s<e.children.length;s++)parallelTraverse(e.children[s],t.children[s],r)}const ih=Symbol("prepared"),nh=Symbol("prepare"),rh=Symbol("preparedGLTF"),sh=Symbol("clone");class GLTFInstance{constructor(e){this[rh]=e}static prepare(e){if(null==e.scene)throw new Error("Model does not have a scene");if(e[ih])return e;const t=this[nh](e);return t[ih]=!0,t}static[nh](e){const{scene:t}=e,r=[t];return Object.assign(Object.assign({},e),{scene:t,scenes:r})}get parser(){return this[rh].parser}get animations(){return this[rh].animations}get scene(){return this[rh].scene}get scenes(){return this[rh].scenes}get cameras(){return this[rh].cameras}get asset(){return this[rh].asset}get userData(){return this[rh].userData}clone(){return new(0,this.constructor)(this[sh]())}dispose(){this.scenes.forEach((e=>{e.traverse((e=>{const t=e;if(!t.material)return;(Array.isArray(t.material)?t.material:[t.material]).forEach((e=>{for(const t in e){const r=e[t];if(r instanceof Texture){const e=r.source.data;null!=e.close&&e.close(),r.dispose()}}e.dispose()})),t.geometry.dispose()}))}))}[sh](){const e=this[rh],t=clone(this.scene);cloneVariantMaterials(t,this.scene);const r=[t],s=e.userData?Object.assign({},e.userData):{};return Object.assign(Object.assign({},e),{scene:t,scenes:r,userData:s})}}const cloneVariantMaterials=(e,t)=>{traversePair(e,t,((e,t)=>{void 0!==t.userData.variantMaterials&&(e.userData.variantMaterials=new Map(t.userData.variantMaterials)),void 0!==t.userData.variantData&&(e.userData.variantData=t.userData.variantData),void 0!==t.userData.originalMaterial&&(e.userData.originalMaterial=t.userData.originalMaterial)}))},traversePair=(e,t,r)=>{r(e,t);for(let s=0;s<e.children.length;s++)traversePair(e.children[s],t.children[s],r)},ah=Symbol("threeGLTF"),oh=Symbol("gltf"),lh=Symbol("gltfElementMap"),ch=Symbol("threeObjectMap"),hh=Symbol("parallelTraverseThreeScene"),uh=Symbol("correlateOriginalThreeGLTF"),dh=Symbol("correlateCloneThreeGLTF");class CorrelatedSceneGraph{constructor(e,t,r,s){this[ah]=e,this[oh]=t,this[lh]=s,this[ch]=r}static from(e,t){return null!=t?this[dh](e,t):this[uh](e)}static[uh](e){const t=e.parser.json,r=e.parser.associations,s=new Map,o={name:"Default"},l={type:"materials",index:-1};for(const e of r.keys())e instanceof Material&&null==r.get(e)&&(l.index<0&&(null==t.materials&&(t.materials=[]),l.index=t.materials.length,t.materials.push(o)),e.name=o.name,r.set(e,{materials:l.index}));for(const[e,o]of r){o&&(e.userData=e.userData||{},e.userData.associations=o);for(const r in o)if(null!=r&&"primitives"!==r){const l=r,c=(t[l]||[])[o[l]];if(null==c)continue;let h=s.get(c);null==h&&(h=new Set,s.set(c,h)),h.add(e)}}return new CorrelatedSceneGraph(e,t,r,s)}static[dh](e,t){const r=t.threeGLTF,s=t.gltf,o=JSON.parse(JSON.stringify(s)),l=new Map,c=new Map;for(let s=0;s<r.scenes.length;s++)this[hh](r.scenes[s],e.scenes[s],((e,r)=>{const s=t.threeObjectMap.get(e);if(null!=s)for(const e in s)if(null!=e&&"primitives"!==e){const t=e,h=s[t],d=o[t][h],p=l.get(r)||{};p[t]=h,l.set(r,p);const A=c.get(d)||new Set;A.add(r),c.set(d,A)}}));return new CorrelatedSceneGraph(e,o,l,c)}static[hh](e,t,r){const traverse=(e,t)=>{if(r(e,t),e.isObject3D){const s=e,o=t;if(s.material)if(Array.isArray(s.material))for(let e=0;e<s.material.length;++e)r(s.material[e],o.material[e]);else r(s.material,o.material);for(let r=0;r<e.children.length;++r)traverse(e.children[r],t.children[r])}};traverse(e,t)}get threeGLTF(){return this[ah]}get gltf(){return this[oh]}get gltfElementMap(){return this[lh]}get threeObjectMap(){return this[ch]}}const ph=Symbol("correlatedSceneGraph");class ModelViewerGLTFInstance extends GLTFInstance{static[nh](e){const t=super[nh](e);null==t[ph]&&(t[ph]=CorrelatedSceneGraph.from(t));const{scene:r}=t,s=new Sphere(void 0,1/0);return r.traverse((e=>{e.renderOrder=1e3,e.frustumCulled=!1,e.name||(e.name=e.uuid);const r=e;if(r.material){const{geometry:e}=r;r.castShadow=!0,r.isSkinnedMesh&&(e.boundingSphere=s,e.boundingBox=null);const o=r.material;if(!0===o.isMeshBasicMaterial&&(o.toneMapped=!1),o.shadowSide=0,o.aoMap){const{gltf:r,threeObjectMap:s}=t[ph],l=s.get(o);if(null!=r.materials&&null!=l&&null!=l.materials){const t=r.materials[l.materials];t.occlusionTexture&&0===t.occlusionTexture.texCoord&&null!=e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv)}}}})),t}get correlatedSceneGraph(){return this[rh][ph]}[sh](){const e=super[sh](),t=new Map;return e.scene.traverse((e=>{const r=e;if(r.material){const e=r.material;if(null!=e){if(t.has(e.uuid))return void(r.material=t.get(e.uuid));r.material=e.clone(),t.set(e.uuid,r.material)}}const s=e;void 0!==s.target&&s.add(s.target)})),e[ph]=CorrelatedSceneGraph.from(e,this.correlatedSceneGraph),e}}var Ah=r(6763);const getBufferForType=(e,t,r)=>{let s;switch(e){case oe:s=new Uint8ClampedArray(t*r*4);break;case de:s=new Uint16Array(t*r*4);break;case he:s=new Uint32Array(t*r*4);break;case 1010:s=new Int8Array(t*r*4);break;case 1011:s=new Int16Array(t*r*4);break;case ce:s=new Int32Array(t*r*4);break;case ue:s=new Float32Array(t*r*4);break;default:throw new Error("Unsupported data type")}return s};let mh;class QuadRenderer_vDmOC3x_QuadRenderer{constructor(e){var t,r,s,o,l,c,h,d,p,A,m,f,g,_,y,x;this._rendererIsDisposable=!1,this._supportsReadPixels=!0,this.render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(e){throw this._renderer.setRenderTarget(null),e}this._renderer.setRenderTarget(null)},this._width=e.width,this._height=e.height,this._type=e.type,this._colorSpace=e.colorSpace;const S={format:Ae,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:void 0!==(null===(t=e.renderTargetOptions)||void 0===t?void 0:t.anisotropy)?null===(r=e.renderTargetOptions)||void 0===r?void 0:r.anisotropy:1,generateMipmaps:void 0!==(null===(s=e.renderTargetOptions)||void 0===s?void 0:s.generateMipmaps)&&(null===(o=e.renderTargetOptions)||void 0===o?void 0:o.generateMipmaps),magFilter:void 0!==(null===(l=e.renderTargetOptions)||void 0===l?void 0:l.magFilter)?null===(c=e.renderTargetOptions)||void 0===c?void 0:c.magFilter:re,minFilter:void 0!==(null===(h=e.renderTargetOptions)||void 0===h?void 0:h.minFilter)?null===(d=e.renderTargetOptions)||void 0===d?void 0:d.minFilter:re,samples:void 0!==(null===(p=e.renderTargetOptions)||void 0===p?void 0:p.samples)?null===(A=e.renderTargetOptions)||void 0===A?void 0:A.samples:void 0,wrapS:void 0!==(null===(m=e.renderTargetOptions)||void 0===m?void 0:m.wrapS)?null===(f=e.renderTargetOptions)||void 0===f?void 0:f.wrapS:$,wrapT:void 0!==(null===(g=e.renderTargetOptions)||void 0===g?void 0:g.wrapT)?null===(_=e.renderTargetOptions)||void 0===_?void 0:_.wrapT:$};if(this._material=e.material,e.renderer?this._renderer=e.renderer:(this._renderer=QuadRenderer_vDmOC3x_QuadRenderer.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new Scene,this._camera=new OrthographicCamera,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!((e,t,r,s)=>{if(void 0!==mh)return mh;const o=new WebGLRenderTarget(1,1,s);t.setRenderTarget(o);const l=new three_module_Mesh(new PlaneGeometry,new MeshBasicMaterial({color:16777215}));t.render(l,r),t.setRenderTarget(null);const c=getBufferForType(e,o.width,o.height);return t.readRenderTargetPixels(o,0,0,o.width,o.height,c),o.dispose(),l.geometry.dispose(),l.material.dispose(),mh=0!==c[0],mh})(this._type,this._renderer,this._camera,S)){let e;if(this._type===de)e=this._renderer.extensions.has("EXT_color_buffer_float")?ue:void 0;void 0!==e?(Ah.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to 1015`),this._type=e):(this._supportsReadPixels=!1,Ah.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new three_module_Mesh(new PlaneGeometry,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new WebGLRenderTarget(this.width,this.height,S),this._renderTarget.texture.mapping=void 0!==(null===(y=e.renderTargetOptions)||void 0===y?void 0:y.mapping)?null===(x=e.renderTargetOptions)||void 0===x?void 0:x.mapping:W}static instantiateRenderer(){const e=new WebGLRenderer;return e.setSize(128,128),e}toArray(){if(!this._supportsReadPixels)throw new Error("Can't read pixels in this browser");const e=getBufferForType(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){const t=new DataTexture(this.toArray(),this.width,this.height,Ae,this._type,(null==e?void 0:e.mapping)||W,(null==e?void 0:e.wrapS)||$,(null==e?void 0:e.wrapT)||$,(null==e?void 0:e.magFilter)||re,(null==e?void 0:e.minFilter)||re,(null==e?void 0:e.anisotropy)||1,He);return t.generateMipmaps=void 0!==(null==e?void 0:e.generateMipmaps)&&(null==e?void 0:e.generateMipmaps),t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof ShaderMaterial&&Object.values(this.material.uniforms).forEach((e=>{e.value instanceof Texture&&e.value.dispose()})),Object.values(this.material).forEach((e=>{e instanceof Texture&&e.dispose()})),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}var fh=r(6763);class GainMapDecoderMaterial extends ShaderMaterial{constructor({gamma:e,offsetHdr:t,offsetSdr:r,gainMapMin:s,gainMapMax:o,maxDisplayBoost:l,hdrCapacityMin:c,hdrCapacityMax:h,sdr:d,gainMap:p}){super({name:"GainMapDecoderMaterial",vertexShader:"\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\n// min half float value\n#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )\n// max half float value\n#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )\n\nuniform sampler2D sdr;\nuniform sampler2D gainMap;\nuniform vec3 gamma;\nuniform vec3 offsetHdr;\nuniform vec3 offsetSdr;\nuniform vec3 gainMapMin;\nuniform vec3 gainMapMax;\nuniform float weightFactor;\n\nvarying vec2 vUv;\n\nvoid main() {\n vec3 rgb = texture2D( sdr, vUv ).rgb;\n vec3 recovery = texture2D( gainMap, vUv ).rgb;\n vec3 logRecovery = pow( recovery, gamma );\n vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;\n vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;\n vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));\n gl_FragColor = vec4( clampedHdrColor , 1.0 );\n}\n",uniforms:{sdr:{value:d},gainMap:{value:p},gamma:{value:new three_module_Vector3(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:(new three_module_Vector3).fromArray(t)},offsetSdr:{value:(new three_module_Vector3).fromArray(r)},gainMapMin:{value:(new three_module_Vector3).fromArray(s)},gainMapMax:{value:(new three_module_Vector3).fromArray(o)},weightFactor:{value:(Math.log2(l)-c)/(h-c)}},blending:0,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=l,this._hdrCapacityMin=c,this._hdrCapacityMax=h,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){const e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){const t=this.uniforms.gamma.value;t.x=1/e[0],t.y=1/e[1],t.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){const e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}}class GainMapNotFoundError extends Error{}class XMPMetadataNotFoundError extends Error{}const getAttribute=(e,t,r)=>{var s;let o;const l=null===(s=e.attributes.getNamedItem(t))||void 0===s?void 0:s.nodeValue;if(l)o=l;else{const s=e.getElementsByTagName(t)[0];if(!s){if(r)return r;throw new Error(`Can't find ${t} in gainmap metadata`)}{const e=s.getElementsByTagName("rdf:li");if(3!==e.length)throw new Error(`Gainmap metadata contains an array of items for ${t} but its length is not 3`);o=Array.from(e).map((e=>e.innerHTML))}}return o};class MPFExtractor{constructor(e){this.options={debug:!(!e||void 0===e.debug)&&e.debug,extractFII:!e||void 0===e.extractFII||e.extractFII,extractNonFII:!e||void 0===e.extractNonFII||e.extractNonFII}}extract(e){return new Promise(((t,r)=>{const s=this.options.debug,o=new DataView(e.buffer);if(65496!==o.getUint16(0))return void r(new Error("Not a valid jpeg"));const l=o.byteLength;let c,h=2,d=0;for(;h<l;){if(++d>250)return void r(new Error(`Found no marker after ${d} loops 😵`));if(255!==o.getUint8(h))return void r(new Error(`Not a valid marker at offset 0x${h.toString(16)}, found: 0x${o.getUint8(h).toString(16)}`));if(c=o.getUint8(h+1),s&&fh.log(`Marker: ${c.toString(16)}`),226===c){s&&fh.log("Found APP2 marker (0xffe2)");const e=h+4;if(1297106432===o.getUint32(e)){const s=e+4;let l;if(18761===o.getUint16(s))l=!1;else{if(19789!==o.getUint16(s))return void r(new Error("No valid endianness marker found in TIFF header"));l=!0}if(42!==o.getUint16(s+2,!l))return void r(new Error("Not valid TIFF data! (no 0x002A marker)"));const c=o.getUint32(s+4,!l);if(c<8)return void r(new Error("Not valid TIFF data! (First offset less than 8)"));const h=s+c,d=o.getUint16(h,!l),p=h+2;let A=0;for(let e=p;e<p+12*d;e+=12)45057===o.getUint16(e,!l)&&(A=o.getUint32(e+8,!l));const m=h+2+12*d+4,f=[];for(let e=m;e<m+16*A;e+=16){const t={MPType:o.getUint32(e,!l),size:o.getUint32(e+4,!l),dataOffset:o.getUint32(e+8,!l),dependantImages:o.getUint32(e+12,!l),start:-1,end:-1,isFII:!1};t.dataOffset?(t.start=s+t.dataOffset,t.isFII=!1):(t.start=0,t.isFII=!0),t.end=t.start+t.size,f.push(t)}if(this.options.extractNonFII&&f.length){const e=new Blob([o]),r=[];for(const t of f){if(t.isFII&&!this.options.extractFII)continue;const s=e.slice(t.start,t.end+1,"image/jpeg");r.push(s)}t(r)}}}h+=2+o.getUint16(h+2)}}))}}const extractGainmapFromJPEG=async e=>{const t=(e=>{var t,r;let s;s="undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):e.toString();let o=s.indexOf("<x:xmpmeta");const l=new DOMParser;for(;-1!==o;){const e=s.indexOf("x:xmpmeta>",o);s.slice(o,e+10);const c=s.slice(o,e+10);try{const e=l.parseFromString(c,"text/xml").getElementsByTagName("rdf:Description")[0],s=getAttribute(e,"hdrgm:GainMapMin","0"),o=getAttribute(e,"hdrgm:GainMapMax"),h=getAttribute(e,"hdrgm:Gamma","1"),d=getAttribute(e,"hdrgm:OffsetSDR","0.015625"),p=getAttribute(e,"hdrgm:OffsetHDR","0.015625");let A=null===(t=e.attributes.getNamedItem("hdrgm:HDRCapacityMin"))||void 0===t?void 0:t.nodeValue;A||(A="0");const m=null===(r=e.attributes.getNamedItem("hdrgm:HDRCapacityMax"))||void 0===r?void 0:r.nodeValue;if(!m)throw new Error("Incomplete gainmap metadata");return{gainMapMin:Array.isArray(s)?s.map((e=>parseFloat(e))):[parseFloat(s),parseFloat(s),parseFloat(s)],gainMapMax:Array.isArray(o)?o.map((e=>parseFloat(e))):[parseFloat(o),parseFloat(o),parseFloat(o)],gamma:Array.isArray(h)?h.map((e=>parseFloat(e))):[parseFloat(h),parseFloat(h),parseFloat(h)],offsetSdr:Array.isArray(d)?d.map((e=>parseFloat(e))):[parseFloat(d),parseFloat(d),parseFloat(d)],offsetHdr:Array.isArray(p)?p.map((e=>parseFloat(e))):[parseFloat(p),parseFloat(p),parseFloat(p)],hdrCapacityMin:parseFloat(A),hdrCapacityMax:parseFloat(m)}}catch(e){}o=s.indexOf("<x:xmpmeta",e)}})(e);if(!t)throw new XMPMetadataNotFoundError("Gain map XMP metadata not found");const r=new MPFExtractor({extractFII:!0,extractNonFII:!0}),s=await r.extract(e);if(2!==s.length)throw new GainMapNotFoundError("Gain map recovery image not found");return{sdr:new Uint8Array(await s[0].arrayBuffer()),gainMap:new Uint8Array(await s[1].arrayBuffer()),metadata:t}},getHTMLImageFromBlob=e=>new Promise(((t,r)=>{const s=document.createElement("img");s.onload=()=>{t(s)},s.onerror=e=>{r(e)},s.src=URL.createObjectURL(e)}));class LoaderBase extends Loader{constructor(e,t){super(t),this._renderer=e,this._internalLoadingManager=new LoadingManager}setRenderTargetOptions(e){return this._renderTargetOptions=e,this}prepareQuadRenderer(){const e=new GainMapDecoderMaterial({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new Texture,sdr:new Texture});return new QuadRenderer_vDmOC3x_QuadRenderer({width:16,height:16,type:de,colorSpace:He,material:e,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async render(e,t,r,s){const o=s?new Blob([s],{type:"image/jpeg"}):void 0,l=new Blob([r],{type:"image/jpeg"});let c,h,d=!1;if("undefined"==typeof createImageBitmap){const e=await Promise.all([o?getHTMLImageFromBlob(o):Promise.resolve(void 0),getHTMLImageFromBlob(l)]);h=e[0],c=e[1],d=!0}else{const e=await Promise.all([o?createImageBitmap(o,{imageOrientation:"flipY"}):Promise.resolve(void 0),createImageBitmap(l,{imageOrientation:"flipY"})]);h=e[0],c=e[1]}const p=new Texture(h||new ImageData(2,2),W,$,$,re,1008,Ae,oe,1,He);p.flipY=d,p.needsUpdate=!0;const A=new Texture(c,W,$,$,re,1008,Ae,oe,1,Ve);A.flipY=d,A.needsUpdate=!0,e.width=c.width,e.height=c.height,e.material.gainMap=p,e.material.sdr=A,e.material.gainMapMin=t.gainMapMin,e.material.gainMapMax=t.gainMapMax,e.material.offsetHdr=t.offsetHdr,e.material.offsetSdr=t.offsetSdr,e.material.gamma=t.gamma,e.material.hdrCapacityMin=t.hdrCapacityMin,e.material.hdrCapacityMax=t.hdrCapacityMax,e.material.maxDisplayBoost=Math.pow(2,t.hdrCapacityMax),e.material.needsUpdate=!0,e.render()}}class HDRJPGLoader extends LoaderBase{load(e,t,r,s){const o=this.prepareQuadRenderer(),l=new three_module_FileLoader(this._internalLoadingManager);return l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setPath(this.path),l.setWithCredentials(this.withCredentials),this.manager.itemStart(e),l.load(e,(async r=>{if("string"==typeof r)throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const l=new Uint8Array(r);let c,h,d;try{const e=await extractGainmapFromJPEG(l);c=e.sdr,h=e.gainMap,d=e.metadata}catch(t){if(!(t instanceof XMPMetadataNotFoundError||t instanceof GainMapNotFoundError))throw t;fh.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),d={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},c=l}try{await this.render(o,d,c,h)}catch(t){return this.manager.itemError(e),"function"==typeof s&&s(t),void o.disposeOnDemandRenderer()}"function"==typeof t&&t(o),this.manager.itemEnd(e),o.disposeOnDemandRenderer()}),r,(t=>{this.manager.itemError(e),"function"==typeof s&&s(t)})),o}}class RGBELoader extends DataTextureLoader{constructor(e){super(e),this.type=de}parse(e){const rgbe_error=function(e,t){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},fgets=function(e,t,r){t=t||1024;let s=e.pos,o=-1,l=0,c="",h=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));for(;0>(o=h.indexOf("\n"))&&l<t&&s<e.byteLength;)c+=h,l+=h.length,s+=128,h+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(s,s+128)));return-1<o&&(!1!==r&&(e.pos+=l+o+1),c+h.slice(0,o))},RGBEByteToRGBFloat=function(e,t,r,s){const o=e[t+3],l=Math.pow(2,o-128)/255;r[s+0]=e[t+0]*l,r[s+1]=e[t+1]*l,r[s+2]=e[t+2]*l,r[s+3]=1},RGBEByteToRGBHalf=function(e,t,r,s){const o=e[t+3],l=Math.pow(2,o-128)/255;r[s+0]=Qi.toHalfFloat(Math.min(e[t+0]*l,65504)),r[s+1]=Qi.toHalfFloat(Math.min(e[t+1]*l,65504)),r[s+2]=Qi.toHalfFloat(Math.min(e[t+2]*l,65504)),r[s+3]=Qi.toHalfFloat(1)},t=new Uint8Array(e);t.pos=0;const r=function(e){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,l={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let c,h;for((e.pos>=e.byteLength||!(c=fgets(e)))&&rgbe_error(1,"no header found"),(h=c.match(/^#\?(\S+)/))||rgbe_error(3,"bad initial token"),l.valid|=1,l.programtype=h[1],l.string+=c+"\n";c=fgets(e),!1!==c;)if(l.string+=c+"\n","#"!==c.charAt(0)){if((h=c.match(t))&&(l.gamma=parseFloat(h[1])),(h=c.match(r))&&(l.exposure=parseFloat(h[1])),(h=c.match(s))&&(l.valid|=2,l.format=h[1]),(h=c.match(o))&&(l.valid|=4,l.height=parseInt(h[1],10),l.width=parseInt(h[2],10)),2&l.valid&&4&l.valid)break}else l.comments+=c+"\n";return 2&l.valid||rgbe_error(3,"missing format specifier"),4&l.valid||rgbe_error(3,"missing image size specifier"),l}(t),s=r.width,o=r.height,l=function(e,t,r){const s=t;if(s<8||s>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);s!==(e[2]<<8|e[3])&&rgbe_error(3,"wrong scanline width");const o=new Uint8Array(4*t*r);o.length||rgbe_error(4,"unable to allocate buffer space");let l=0,c=0;const h=4*s,d=new Uint8Array(4),p=new Uint8Array(h);let A=r;for(;A>0&&c<e.byteLength;){c+4>e.byteLength&&rgbe_error(1),d[0]=e[c++],d[1]=e[c++],d[2]=e[c++],d[3]=e[c++],2==d[0]&&2==d[1]&&(d[2]<<8|d[3])==s||rgbe_error(3,"bad rgbe scanline format");let t,r=0;for(;r<h&&c<e.byteLength;){t=e[c++];const s=t>128;if(s&&(t-=128),(0===t||r+t>h)&&rgbe_error(3,"bad scanline data"),s){const s=e[c++];for(let e=0;e<t;e++)p[r++]=s}else p.set(e.subarray(c,c+t),r),r+=t,c+=t}const m=s;for(let e=0;e<m;e++){let t=0;o[l]=p[e+t],t+=s,o[l+1]=p[e+t],t+=s,o[l+2]=p[e+t],t+=s,o[l+3]=p[e+t],l+=4}A--}return o}(t.subarray(t.pos),s,o);let c,h,d;switch(this.type){case ue:d=l.length/4;const e=new Float32Array(4*d);for(let t=0;t<d;t++)RGBEByteToRGBFloat(l,4*t,e,4*t);c=e,h=ue;break;case de:d=l.length/4;const t=new Uint16Array(4*d);for(let e=0;e<d;e++)RGBEByteToRGBHalf(l,4*e,t,4*e);c=t,h=de;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:s,height:o,data:c,header:r.string,gamma:r.gamma,exposure:r.exposure,type:h}}setDataType(e){return this.type=e,this}load(e,t,r,s){return super.load(e,(function onLoadCallback(e,r){switch(e.type){case ue:case de:e.colorSpace=He,e.minFilter=re,e.magFilter=re,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,r)}),r,s)}}const gh={topLight:{intensity:500,position:[.418,16.199,.3]},room:{position:[-.757,13.219,.717],scale:[31.713,28.305,28.591]},boxes:[{position:[-10.906,2.009,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,.857,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:50,position:[-16.116,14.37,8.208],scale:[.1,2.428,2.739]},{intensity:50,position:[-16.109,18.021,-8.207],scale:[.1,2.425,2.751]},{intensity:17,position:[14.904,12.198,-1.832],scale:[.15,4.265,6.331]},{intensity:43,position:[-.462,8.89,14.52],scale:[4.38,5.441,.088]},{intensity:20,position:[3.235,11.486,-12.541],scale:[2.5,2,.1]},{intensity:100,position:[0,20,0],scale:[1,.1,1]}]},_h={topLight:{intensity:400,position:[.5,14,.5]},room:{position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-10.906,-1,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,-.16,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:80,position:[-14,10,8],scale:[.1,2.5,2.5]},{intensity:80,position:[-14,14,-4],scale:[.1,2.5,2.5]},{intensity:23,position:[14,12,0],scale:[.1,5,5]},{intensity:16,position:[0,9,14],scale:[5,5,.1]},{intensity:80,position:[7,8,-14],scale:[2.5,2.5,.1]},{intensity:80,position:[-7,16,-14],scale:[2.5,2.5,.1]},{intensity:1,position:[0,20,0],scale:[.1,.1,.1]}]};class EnvironmentScene extends Scene{constructor(e){super(),this.position.y=-3.5;const t=new BoxGeometry;t.deleteAttribute("uv");const r=new MeshStandardMaterial({metalness:0,side:1}),s=new MeshStandardMaterial({metalness:0}),o="legacy"==e?gh:_h,l=new PointLight(16777215,o.topLight.intensity,28,2);l.position.set(...o.topLight.position),this.add(l);const c=new three_module_Mesh(t,r);c.position.set(...o.room.position),c.scale.set(...o.room.scale),this.add(c);for(const e of o.boxes){const r=new three_module_Mesh(t,s);r.position.set(...e.position),r.rotation.set(0,e.rotation,0),r.scale.set(...e.scale),this.add(r)}for(const e of o.lights){const r=new three_module_Mesh(t,this.createAreaLightMaterial(e.intensity));r.position.set(...e.position),r.scale.set(...e.scale),this.add(r)}}createAreaLightMaterial(e){const t=new MeshBasicMaterial;return t.color.setScalar(e),t}}var vh=r(6763);const yh=20,Eh=/\.hdr(\.js)?$/;class TextureUtils{constructor(e){this.threeRenderer=e,this.lottieLoaderUrl="",this.withCredentials=!1,this._ldrLoader=null,this._imageLoader=null,this._hdrLoader=null,this._lottieLoader=null,this.generatedEnvironmentMap=null,this.generatedEnvironmentMapAlt=null,this.skyboxCache=new Map,this.blurMaterial=null,this.blurScene=null}get ldrLoader(){return null==this._ldrLoader&&(this._ldrLoader=new TextureLoader),this._ldrLoader.setWithCredentials(this.withCredentials),this._ldrLoader}get imageLoader(){return null==this._imageLoader&&(this._imageLoader=new HDRJPGLoader(this.threeRenderer)),this._imageLoader.setWithCredentials(this.withCredentials),this._imageLoader}get hdrLoader(){return null==this._hdrLoader&&(this._hdrLoader=new RGBELoader,this._hdrLoader.setDataType(de)),this._hdrLoader.setWithCredentials(this.withCredentials),this._hdrLoader}async getLottieLoader(){if(null==this._lottieLoader){const{LottieLoader:e}=await import(this.lottieLoaderUrl);this._lottieLoader=new e}return this._lottieLoader.setWithCredentials(this.withCredentials),this._lottieLoader}async loadImage(e){const t=await new Promise(((t,r)=>this.ldrLoader.load(e,t,(()=>{}),r)));return t.name=e,t.flipY=!1,t}async loadLottie(e,t){const r=await this.getLottieLoader();r.setQuality(t);const s=await new Promise(((t,s)=>r.load(e,t,(()=>{}),s)));return s.name=e,s}async loadEquirect(e,t=()=>{}){try{const r=Eh.test(e),s=r?this.hdrLoader:this.imageLoader,o=await new Promise(((r,o)=>s.load(e,(e=>{const{renderTarget:t}=e;if(null!=t){const{texture:s}=t;e.dispose(!1),r(s)}else r(e)}),(e=>{t(e.loaded/e.total*.9)}),o)));return t(1),o.name=e,o.mapping=X,r||(o.colorSpace=Ve),o}finally{t&&t(1)}}async generateEnvironmentMapAndSkybox(e=null,t=null,r=()=>{}){const s="legacy"!==t;"legacy"!==t&&"neutral"!==t||(t=null),t=deserializeUrl(t);let o,l=Promise.resolve(null);e&&(l=this.loadEquirectFromUrl(e,r)),o=t?this.loadEquirectFromUrl(t,r):e?this.loadEquirectFromUrl(e,r):s?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[c,h]=await Promise.all([o,l]);if(null==c)throw new Error("Failed to load environment map.");return{environmentMap:c,skybox:h}}async loadEquirectFromUrl(e,t){if(!this.skyboxCache.has(e)){const r=this.loadEquirect(e,t);this.skyboxCache.set(e,r)}return this.skyboxCache.get(e)}async GenerateEnvironmentMap(e,t){await((e=0)=>new Promise((t=>setTimeout(t,e))))();const r=this.threeRenderer,s=new WebGLCubeRenderTarget(256,{generateMipmaps:!1,type:de,format:Ae,colorSpace:He,depthBuffer:!0}),o=new CubeCamera(.1,100,s),l=o.renderTarget.texture;l.name=t;const c=r.outputColorSpace,h=r.toneMapping;return r.toneMapping=0,r.outputColorSpace=He,o.update(r,e),this.blurCubemap(s,.04),r.toneMapping=h,r.outputColorSpace=c,l}async loadGeneratedEnvironmentMap(){return null==this.generatedEnvironmentMap&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new EnvironmentScene("legacy"),"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return null==this.generatedEnvironmentMapAlt&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new EnvironmentScene("neutral"),"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(e,t){if(null==this.blurMaterial){this.blurMaterial=this.getBlurShader(yh);const e=new BoxGeometry,t=new three_module_Mesh(e,this.blurMaterial);this.blurScene=new Scene,this.blurScene.add(t)}const r=e.clone();this.halfblur(e,r,t,"latitudinal"),this.halfblur(r,e,t,"longitudinal")}halfblur(e,t,r,s){const o=e.width,l=isFinite(r)?Math.PI/(2*o):2*Math.PI/39,c=r/l,h=isFinite(r)?1+Math.floor(3*c):yh;h>yh&&vh.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${h} samples when the maximum is set to 20`);const d=[];let p=0;for(let e=0;e<yh;++e){const t=e/c,r=Math.exp(-t*t/2);d.push(r),0==e?p+=r:e<h&&(p+=2*r)}for(let e=0;e<d.length;e++)d[e]=d[e]/p;const A=this.blurMaterial.uniforms;A.envMap.value=e.texture,A.samples.value=h,A.weights.value=d,A.latitudinal.value="latitudinal"===s,A.dTheta.value=l;new CubeCamera(.1,100,t).update(this.threeRenderer,this.blurScene)}getBlurShader(e){const t=new Float32Array(e),r=new three_module_Vector3(0,1,0);return new ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},poleAxis:{value:r}},vertexShader:"\n \n varying vec3 vOutputDirection;\n \n void main() {\n \n vOutputDirection = vec3( position );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n \n }\n ",fragmentShader:"\n varying vec3 vOutputDirection;\n \n uniform samplerCube envMap;\n uniform int samples;\n uniform float weights[ n ];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform vec3 poleAxis;\n \n vec3 getSample( float theta, vec3 axis ) {\n \n float cosTheta = cos( theta );\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross( axis, vOutputDirection ) * sin( theta )\n + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n \n return vec3( textureCube( envMap, sampleDirection ) );\n \n }\n \n void main() {\n \n vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n \n if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n \n axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n \n }\n \n axis = normalize( axis );\n \n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n \n for ( int i = 1; i < n; i++ ) {\n \n if ( i >= samples ) {\n \n break;\n \n }\n \n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n \n }\n }\n ",blending:0,depthTest:!1,depthWrite:!1,side:1})}async dispose(){for(const[,e]of this.skyboxCache){(await e).dispose()}null!=this.generatedEnvironmentMap&&((await this.generatedEnvironmentMap).dispose(),this.generatedEnvironmentMap=null),null!=this.generatedEnvironmentMapAlt&&((await this.generatedEnvironmentMapAlt).dispose(),this.generatedEnvironmentMapAlt=null),null!=this.blurMaterial&&this.blurMaterial.dispose()}}var xh=r(6763);const Sh=[1,.79,.62,.5,.4,.31,.25],Mh="high-performance";class Renderer extends EventDispatcher{constructor(e){super(),this.loader=new CachingGLTFLoader(ModelViewerGLTFInstance),this.width=0,this.height=0,this.dpr=1,this.scenes=new Set,this.multipleScenesVisible=!1,this.lastTick=performance.now(),this.renderedLastFrame=!1,this.scaleStep=0,this.lastStep=3,this.avgFrameDuration=50,this.onWebGLContextLost=e=>{this.dispatchEvent({type:"contextlost",sourceEvent:e})},this.onWebGLContextRestored=()=>{var e;null===(e=this.textureUtils)||void 0===e||e.dispose(),this.textureUtils=new TextureUtils(this.threeRenderer);for(const e of this.scenes)e.element[ra]()},this.dpr=ea(),this.canvas3D=document.createElement("canvas"),this.canvas3D.id="webgl-canvas",this.canvas3D.classList.add("show"),yn.tonemapping_pars_fragment=yn.tonemapping_pars_fragment.replace("vec3 CustomToneMapping( vec3 color ) { return color; }","\n float startCompression = 0.8 - 0.04;\n float desaturation = 0.15;\n vec3 CustomToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n\n float x = min(color.r, min(color.g, color.b));\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n\n float peak = max(color.r, max(color.g, color.b));\n if (peak < startCompression) return color;\n\n float d = 1. - startCompression;\n float newPeak = 1. - d * d / (peak + d - startCompression);\n color *= newPeak / peak;\n\n float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n return mix(color, vec3(1, 1, 1), g);\n }");try{this.threeRenderer=new WebGLRenderer({canvas:this.canvas3D,alpha:!0,antialias:!0,powerPreference:e.powerPreference,preserveDrawingBuffer:!0}),this.threeRenderer.autoClear=!0,this.threeRenderer.setPixelRatio(1),this.threeRenderer.debug={checkShaderErrors:!!e.debug,onShaderError:null},this.threeRenderer.toneMapping=4}catch(e){xh.warn(e)}this.arRenderer=new ARRenderer(this),this.textureUtils=this.canRender?new TextureUtils(this.threeRenderer):null,CachingGLTFLoader.initializeKTX2Loader(this.threeRenderer),this.canvas3D.addEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.addEventListener("webglcontextrestored",this.onWebGLContextRestored),this.updateRendererSize()}static get singleton(){return this._singleton}static resetSingleton(){const e=this._singleton.dispose();for(const t of e)t.disconnectedCallback();this._singleton=new Renderer({powerPreference:(self.ModelViewerElement||{}).powerPreference||Mh,debug:ta()});for(const t of e)t.connectedCallback()}get canRender(){return null!=this.threeRenderer}get scaleFactor(){return Sh[this.scaleStep]}set minScale(e){let t=1;for(;t<Sh.length&&!(Sh[t]<e);)++t;this.lastStep=t-1}registerScene(e){this.scenes.add(e),e.forceRescale();const t=new Vector2;this.threeRenderer.getSize(t),e.canvas.width=t.x,e.canvas.height=t.y,this.canRender&&this.scenes.size>0&&this.threeRenderer.setAnimationLoop(((e,t)=>this.render(e,t)))}unregisterScene(e){this.scenes.delete(e),this.canvas3D.parentElement===e.canvas.parentElement&&e.canvas.parentElement.removeChild(this.canvas3D),this.canRender&&0===this.scenes.size&&this.threeRenderer.setAnimationLoop(null)}displayCanvas(e){return this.multipleScenesVisible?e.element[Jd]:this.canvas3D}countVisibleScenes(){const{canvas3D:e}=this;let t=0,r=null;for(const s of this.scenes){const{element:o}=s;o.modelIsVisible&&null==s.externalRenderer&&++t,e.parentElement===s.canvas.parentElement&&(r=s)}const s=t>1;if(null!=r){const t=s&&!this.multipleScenesVisible,o=!r.element.modelIsVisible;if(t||o){const{width:t,height:s}=this.sceneSize(r);this.copyPixels(r,t,s),e.parentElement.removeChild(e)}}this.multipleScenesVisible=s}updateRendererSize(){var e;const t=ea();if(t!==this.dpr)for(const e of this.scenes){const{element:t}=e;t[Od](t.getBoundingClientRect())}let r=0,s=0;for(const e of this.scenes)r=Math.max(r,e.width),s=Math.max(s,e.height);if(r!==this.width||s!==this.height||t!==this.dpr){this.width=r,this.height=s,this.dpr=t,r=Math.ceil(r*t),s=Math.ceil(s*t),this.canRender&&this.threeRenderer.setSize(r,s,!1);for(const t of this.scenes){const{canvas:o}=t;o.width=r,o.height=s,t.forceRescale(),null===(e=t.effectRenderer)||void 0===e||e.setSize(r,s)}}}updateRendererScale(e){const t=this.scaleStep;this.avgFrameDuration+=utilities_clamp(.2*(e-this.avgFrameDuration),-5,5),this.avgFrameDuration>60?++this.scaleStep:this.avgFrameDuration<40&&this.scaleStep>0&&--this.scaleStep,this.scaleStep=Math.min(this.scaleStep,this.lastStep),t!==this.scaleStep&&(this.avgFrameDuration=50)}shouldRender(e){if(e.shouldRender())e.scaleStep!=this.scaleStep&&(e.scaleStep=this.scaleStep,this.rescaleCanvas(e));else{if(0==e.scaleStep)return!1;e.scaleStep=0,this.rescaleCanvas(e)}return!0}rescaleCanvas(e){const t=Sh[e.scaleStep],r=Math.ceil(this.width/t),s=Math.ceil(this.height/t),{style:o}=e.canvas;o.width=`${r}px`,o.height=`${s}px`,this.canvas3D.style.width=`${r}px`,this.canvas3D.style.height=`${s}px`;const l=this.dpr*t,c=t<1?"GPU throttling":this.dpr!==window.devicePixelRatio?"No meta viewport tag":"";e.element.dispatchEvent(new CustomEvent("render-scale",{detail:{reportedDpr:window.devicePixelRatio,renderedDpr:l,minimumDpr:this.dpr*Sh[this.lastStep],pixelWidth:Math.ceil(e.width*l),pixelHeight:Math.ceil(e.height*l),reason:c}}))}sceneSize(e){const{dpr:t}=this,r=Sh[e.scaleStep];return{width:Math.min(Math.ceil(e.width*r*t),this.canvas3D.width),height:Math.min(Math.ceil(e.height*r*t),this.canvas3D.height)}}copyPixels(e,t,r){const s=e.context;null!=s?(s.clearRect(0,0,t,r),s.drawImage(this.canvas3D,0,0,t,r,0,0,t,r),e.canvas.classList.add("show")):xh.log("could not acquire 2d context")}orderedScenes(){const e=[];for(const t of[!1,!0])for(const r of this.scenes)r.element.modelIsVisible===t&&e.push(r);return e}get isPresenting(){return this.arRenderer.isPresenting}preRender(e,t,r){const{element:s,exposure:o,toneMapping:l}=e;s[ep](t,r);const c="number"==typeof o&&!Number.isNaN(o),h=s.environmentImage,d=s.skyboxImage,p=5===l&&("neutral"===h||"legacy"===h||!h&&!d);this.threeRenderer.toneMappingExposure=(c?o:1)*(p?1.3:1)}render(e,t){if(null!=t)return void this.arRenderer.onWebXRFrame(e,t);const r=e-this.lastTick;if(this.lastTick=e,!this.canRender||this.isPresenting)return;this.countVisibleScenes(),this.updateRendererSize(),this.renderedLastFrame&&(this.updateRendererScale(r),this.renderedLastFrame=!1);const{canvas3D:s}=this;for(const t of this.orderedScenes()){const{element:o}=t;if(!o.loaded||!o.modelIsVisible&&t.renderCount>0)continue;if(this.preRender(t,e,r),!this.shouldRender(t))continue;if(null!=t.externalRenderer){const e=t.getCamera();e.updateMatrix();const{matrix:r,projectionMatrix:s}=e,o=r.elements.slice(),l=t.getTarget();o[12]+=l.x,o[13]+=l.y,o[14]+=l.z,t.externalRenderer.render({viewMatrix:o,projectionMatrix:s.elements});continue}if(!o.modelIsVisible&&!this.multipleScenesVisible)for(const e of this.scenes)e.element.modelIsVisible&&e.queueRender();const{width:l,height:c}=this.sceneSize(t);t.renderShadow(this.threeRenderer),this.threeRenderer.setRenderTarget(null),this.threeRenderer.setViewport(0,Math.ceil(this.height*this.dpr)-c,l,c),null!=t.effectRenderer?t.effectRenderer.render(r):(this.threeRenderer.autoClear=!0,this.threeRenderer.toneMapping=t.toneMapping,this.threeRenderer.render(t,t.camera)),this.multipleScenesVisible||!t.element.modelIsVisible&&0===t.renderCount?this.copyPixels(t,l,c):s.parentElement!==t.canvas.parentElement&&(t.canvas.parentElement.appendChild(s),t.canvas.classList.remove("show")),t.hasRendered(),++t.renderCount,this.renderedLastFrame=!0}}dispose(){null!=this.textureUtils&&this.textureUtils.dispose(),null!=this.threeRenderer&&this.threeRenderer.dispose(),this.textureUtils=null,this.threeRenderer=null;const e=[];for(const t of this.scenes)e.push(t.element);return this.canvas3D.removeEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.removeEventListener("webglcontextrestored",this.onWebGLContextRestored),e}}Renderer._singleton=new Renderer({powerPreference:(self.ModelViewerElement||{}).powerPreference||Mh,debug:ta()});const Ch=Symbol("correlatedObjects"),bh=Symbol("onUpdate");class ThreeDOMElement{constructor(e,t=null){this[bh]=e,this[Ch]=t}}const wh=new MeshBasicMaterial,Ih=new PlaneGeometry(2,2);let Th=0;const Bh=Symbol("threeTexture"),Rh=Symbol("threeTextures");Symbol("applyTexture");class image_Image extends ThreeDOMElement{get[Bh](){var e;return null===(e=this[Ch])||void 0===e?void 0:e.values().next().value}get[Rh](){return this[Ch]}constructor(e,t){super(e,new Set(t?[t]:[])),this[Bh].image.src||(this[Bh].image.src=t.name?t.name:"adhoc_image"+Th++),this[Bh].image.name||(this[Bh].image.name=t&&t.image&&t.image.src?t.image.src.split("/").pop():"adhoc_image")}get name(){return this[Bh].image.name||""}get uri(){return this[Bh].image.src}get bufferView(){return this[Bh].image.bufferView}get element(){const e=this[Bh];if(e&&(e.isCanvasTexture||e.isVideoTexture))return e.image}get animation(){const e=this[Bh];if(e&&e.isCanvasTexture&&e.animation)return e.animation}get type(){return null!=this.uri?"external":"embedded"}set name(e){for(const t of this[Rh])t.image.name=e}update(){const e=this[Bh];e&&e.isCanvasTexture&&!e.animation&&(this[Bh].needsUpdate=!0,this[bh]())}async createThumbnail(e,t){const r=new Scene;wh.map=this[Bh];const s=new three_module_Mesh(Ih,wh);r.add(s);const o=new OrthographicCamera(-1,1,1,-1,0,1),{threeRenderer:l}=Renderer.singleton,c=new WebGLRenderTarget(e,t);l.setRenderTarget(c),l.render(r,o),l.setRenderTarget(null);const h=new Uint8Array(e*t*4);l.readRenderTargetPixels(c,0,0,e,t,h),Id.width=e,Id.height=t;const d=Id.getContext("2d"),p=d.createImageData(e,t);return p.data.set(h),d.putImageData(p,0,0),new Promise((async(e,t)=>{Id.toBlob((r=>{if(!r)return t("Failed to capture thumbnail.");e(URL.createObjectURL(r))}),"image/png")}))}}var Lh,Dh;!function(e){e[e.Nearest=9728]="Nearest",e[e.Linear=9729]="Linear",e[e.NearestMipmapNearest=9984]="NearestMipmapNearest",e[e.LinearMipmapNearest=9985]="LinearMipmapNearest",e[e.NearestMipmapLinear=9986]="NearestMipmapLinear",e[e.LinearMipmapLinear=9987]="LinearMipmapLinear"}(Lh||(Lh={})),function(e){e[e.ClampToEdge=33071]="ClampToEdge",e[e.MirroredRepeat=33648]="MirroredRepeat",e[e.Repeat=10497]="Repeat"}(Dh||(Dh={}));const Uh=new Map([[Dh.Repeat,J],[Dh.ClampToEdge,$],[Dh.MirroredRepeat,ee]]),Ph=new Map([[J,Dh.Repeat],[$,Dh.ClampToEdge],[ee,Dh.MirroredRepeat]]),Fh=new Map([[Lh.Nearest,te],[Lh.Linear,re],[Lh.NearestMipmapNearest,ie],[Lh.LinearMipmapNearest,se],[Lh.NearestMipmapLinear,ne],[Lh.LinearMipmapLinear,ae]]),Nh=new Map([[te,Lh.Nearest],[re,Lh.Linear],[ie,Lh.NearestMipmapNearest],[se,Lh.LinearMipmapNearest],[ne,Lh.NearestMipmapLinear],[ae,Lh.LinearMipmapLinear]]),Oh=new Map([[Lh.Nearest,te],[Lh.Linear,re]]),Qh=new Map([[te,Lh.Nearest],[re,Lh.Linear]]),isMinFilter=e=>Nh.has(e),isMagFilter=e=>Qh.has(e),isWrapping=e=>Ph.has(e),kh=Symbol("threeTexture"),Gh=Symbol("threeTextures"),Vh=Symbol("setProperty");class Sampler extends ThreeDOMElement{get[kh](){var e;return null===(e=this[Ch])||void 0===e?void 0:e.values().next().value}get[Gh](){return this[Ch]}constructor(e,t){super(e,new Set(t?[t]:[]))}get name(){return this[kh].name||""}get minFilter(){return Nh.get(this[kh].minFilter)}get magFilter(){return Qh.get(this[kh].magFilter)}get wrapS(){return Ph.get(this[kh].wrapS)}get wrapT(){return Ph.get(this[kh].wrapT)}get rotation(){return this[kh].rotation}get scale(){return toVector2D(this[kh].repeat)}get offset(){return toVector2D(this[kh].offset)}setMinFilter(e){this[Vh]("minFilter",Fh.get(e))}setMagFilter(e){this[Vh]("magFilter",Oh.get(e))}setWrapS(e){this[Vh]("wrapS",Uh.get(e))}setWrapT(e){this[Vh]("wrapT",Uh.get(e))}setRotation(e){null==e&&(e=0),this[Vh]("rotation",e)}setScale(e){null==e&&(e={u:1,v:1}),this[Vh]("repeat",new Vector2(e.u,e.v))}setOffset(e){null==e&&(e={u:0,v:0}),this[Vh]("offset",new Vector2(e.u,e.v))}[Vh](e,t){if(((e,t)=>{switch(e){case"minFilter":return isMinFilter(t);case"magFilter":return isMagFilter(t);case"wrapS":case"wrapT":return isWrapping(t);case"rotation":case"repeat":case"offset":return!0;default:throw new Error(`Cannot configure property "${e}" on Sampler`)}})(e,t))for(const r of this[Gh])r[e]=t,r.needsUpdate=!0;this[bh]()}}const Hh=Symbol("image"),zh=Symbol("sampler"),Wh=Symbol("threeTexture");class texture_Texture extends ThreeDOMElement{constructor(e,t){super(e,new Set(t?[t]:[])),this[zh]=new Sampler(e,t),this[Hh]=new image_Image(e,t)}get[Wh](){var e;return null===(e=this[Ch])||void 0===e?void 0:e.values().next().value}get name(){return this[Wh].name||""}set name(e){for(const t of this[Ch])t.name=e}get sampler(){return this[zh]}get source(){return this[Hh]}}var qh,jh,Xh;const Yh=Symbol("texture"),Kh=Symbol("transform"),Jh=Symbol("materials"),$h=Symbol("usage"),Zh=Symbol("onUpdate"),eu=Symbol("activeVideo");var tu;!function(e){e[e.Base=0]="Base",e[e.MetallicRoughness=1]="MetallicRoughness",e[e.Normal=2]="Normal",e[e.Occlusion=3]="Occlusion",e[e.Emissive=4]="Emissive",e[e.Clearcoat=5]="Clearcoat",e[e.ClearcoatRoughness=6]="ClearcoatRoughness",e[e.ClearcoatNormal=7]="ClearcoatNormal",e[e.SheenColor=8]="SheenColor",e[e.SheenRoughness=9]="SheenRoughness",e[e.Transmission=10]="Transmission",e[e.Thickness=11]="Thickness",e[e.Specular=12]="Specular",e[e.SpecularColor=13]="SpecularColor",e[e.Iridescence=14]="Iridescence",e[e.IridescenceThickness=15]="IridescenceThickness",e[e.Anisotropy=16]="Anisotropy"}(tu||(tu={}));class TextureInfo{constructor(e,t,r,s){this[qh]=null,this[jh]={rotation:0,scale:new Vector2(1,1),offset:new Vector2(0,0)},this[Xh]=!1,r&&(this[Kh].rotation=r.rotation,this[Kh].scale.copy(r.repeat),this[Kh].offset.copy(r.offset),this[Yh]=new texture_Texture(e,r)),this[Zh]=e,this[Jh]=s,this[$h]=t}get texture(){return this[Yh]}setTexture(e){var t,r;const s=null!=e?e.source[Bh]:null,o=null===(t=this[Yh])||void 0===t?void 0:t.source[Bh];if(null!=o&&o.isVideoTexture?this[eu]=!1:(null===(r=this[Yh])||void 0===r?void 0:r.source.animation)&&this[Yh].source.animation.removeEventListener("enterFrame",this[Zh]),this[Yh]=e,null!=s&&s.isVideoTexture){const e=s.image;if(this[eu]=!0,null!=e.requestVideoFrameCallback){const update=()=>{this[eu]&&(this[Zh](),e.requestVideoFrameCallback(update))};e.requestVideoFrameCallback(update)}else{const update=()=>{this[eu]&&(this[Zh](),requestAnimationFrame(update))};requestAnimationFrame(update)}}else null!=(null==e?void 0:e.source.animation)&&e.source.animation.addEventListener("enterFrame",this[Zh]);let l=Ve;if(this[Jh])for(const e of this[Jh]){switch(this[$h]){case tu.Base:e.map=s;break;case tu.MetallicRoughness:l=He,e.metalnessMap=s,e.roughnessMap=s;break;case tu.Normal:l=He,e.normalMap=s;break;case tu.Occlusion:l=He,e.aoMap=s;break;case tu.Emissive:e.emissiveMap=s;break;case tu.Clearcoat:e.clearcoatMap=s;break;case tu.ClearcoatRoughness:e.clearcoatRoughnessMap=s;break;case tu.ClearcoatNormal:e.clearcoatNormalMap=s;break;case tu.SheenColor:e.sheenColorMap=s;break;case tu.SheenRoughness:e.sheenRoughnessMap=s;break;case tu.Transmission:e.transmissionMap=s;break;case tu.Thickness:e.thicknessMap=s;break;case tu.Specular:e.specularIntensityMap=s;break;case tu.SpecularColor:e.specularColorMap=s;break;case tu.Iridescence:e.iridescenceMap=s;break;case tu.IridescenceThickness:e.iridescenceThicknessMap=s;break;case tu.Anisotropy:e.anisotropyMap=s}e.needsUpdate=!0}s&&(s.colorSpace=l,s.rotation=this[Kh].rotation,s.repeat=this[Kh].scale,s.offset=this[Kh].offset),this[Zh]()}}qh=Yh,jh=Kh,Xh=eu;const iu=Symbol("threeMaterial"),nu=Symbol("threeMaterials"),ru=Symbol("baseColorTexture"),su=Symbol("metallicRoughnessTexture");class PBRMetallicRoughness extends ThreeDOMElement{constructor(e,t){super(e,t);const{map:r,metalnessMap:s}=t.values().next().value;this[ru]=new TextureInfo(e,tu.Base,r,t),this[su]=new TextureInfo(e,tu.MetallicRoughness,s,t)}get[nu](){return this[Ch]}get[iu](){var e;return null===(e=this[Ch])||void 0===e?void 0:e.values().next().value}get baseColorFactor(){const e=[0,0,0,this[iu].opacity];return this[iu].color.toArray(e),e}get metallicFactor(){return this[iu].metalness}get roughnessFactor(){return this[iu].roughness}get baseColorTexture(){return this[ru]}get metallicRoughnessTexture(){return this[su]}setBaseColorFactor(e){const t=new Color;e instanceof Array?t.fromArray(e):t.set(e);for(const r of this[nu])r.color.set(t),e instanceof Array?r.opacity=e[3]:(e=[0,0,0,r.opacity],t.toArray(e));this[bh]()}setMetallicFactor(e){for(const t of this[nu])t.metalness=e;this[bh]()}setRoughnessFactor(e){for(const t of this[nu])t.roughness=e;this[bh]()}}var au,ou;const lu=Symbol("pbrMetallicRoughness"),cu=Symbol("normalTexture"),hu=Symbol("occlusionTexture"),uu=Symbol("emissiveTexture"),du=Symbol("backingThreeMaterial"),pu=Symbol("applyAlphaCutoff"),Au=Symbol("getAlphaMode"),mu=Symbol("lazyLoadGLTFInfo"),fu=Symbol("initialize"),gu=Symbol("getLoadedMaterial"),_u=Symbol("ensureMaterialIsLoaded"),vu=Symbol("gltfIndex"),yu=Symbol("setActive"),Eu=Symbol("variantIndices"),xu=Symbol("isActive"),Su=Symbol("variantSet"),Mu=Symbol("modelVariants"),Cu=Symbol("name"),bu=Symbol("pbrTextures");class material_Material extends ThreeDOMElement{constructor(e,t,r,s,o,l,c=void 0){super(e,o),this[au]=new Set,this[ou]=new Map,this[vu]=t,this[xu]=r,this[Mu]=s,this[Cu]=l,null==c?this[fu]():this[mu]=c}get[(au=Su,ou=bu,du)](){return this[Ch].values().next().value}[fu](){const e=this[bh],t=this[Ch];this[lu]=new PBRMetallicRoughness(e,t);const{normalMap:r,aoMap:s,emissiveMap:o}=t.values().next().value;this[cu]=new TextureInfo(e,tu.Normal,r,t),this[hu]=new TextureInfo(e,tu.Occlusion,s,t),this[uu]=new TextureInfo(e,tu.Emissive,o,t);const createTextureInfo=r=>{this[bu].set(r,new TextureInfo(e,r,null,t))};createTextureInfo(tu.Clearcoat),createTextureInfo(tu.ClearcoatRoughness),createTextureInfo(tu.ClearcoatNormal),createTextureInfo(tu.SheenColor),createTextureInfo(tu.SheenRoughness),createTextureInfo(tu.Transmission),createTextureInfo(tu.Thickness),createTextureInfo(tu.Specular),createTextureInfo(tu.SpecularColor),createTextureInfo(tu.Iridescence),createTextureInfo(tu.IridescenceThickness),createTextureInfo(tu.Anisotropy)}async[gu](){if(null!=this[mu]){const{set:e,material:t}=await this[mu].doLazyLoad();return this[Ch]=e,this[fu](),this[mu]=void 0,this.ensureLoaded=async()=>{},t}return this[Ch].values().next().value}colorFromRgb(e){const t=new Color;return e instanceof Array?t.fromArray(e):t.set(e),t}[_u](){if(null!=this[mu])throw new Error(`Material "${this.name}" has not been loaded, call 'await\n myMaterial.ensureLoaded()' before using an unloaded material.`)}async ensureLoaded(){await this[gu]()}get isLoaded(){return null==this[mu]}get isActive(){return this[xu]}[yu](e){this[xu]=e}get name(){return this[Cu]||""}set name(e){if(this[Cu]=e,null!=this[Ch])for(const t of this[Ch])t.name=e}get pbrMetallicRoughness(){return this[_u](),this[lu]}get normalTexture(){return this[_u](),this[cu]}get occlusionTexture(){return this[_u](),this[hu]}get emissiveTexture(){return this[_u](),this[uu]}get emissiveFactor(){return this[_u](),this[du].emissive.toArray()}get index(){return this[vu]}[Eu](){return this[Su]}hasVariant(e){const t=this[Mu].get(e);return null!=t&&this[Su].has(t.index)}setEmissiveFactor(e){this[_u]();const t=this.colorFromRgb(e);for(const e of this[Ch])e.emissive.set(t);this[bh]()}[Au](){return this[du].transparent?"BLEND":this[du].alphaTest>0?"MASK":"OPAQUE"}[pu](){this[_u]();for(const e of this[Ch])"MASK"===this[Au]()?null==e.alphaTest&&(e.alphaTest=.5):e.alphaTest=void 0,e.needsUpdate=!0}setAlphaCutoff(e){this[_u]();for(const t of this[Ch])t.alphaTest=e,t.needsUpdate=!0;this[pu](),this[bh]()}getAlphaCutoff(){return this[_u](),this[du].alphaTest}setDoubleSided(e){this[_u]();for(const t of this[Ch])t.side=e?2:0,t.needsUpdate=!0;this[bh]()}getDoubleSided(){return this[_u](),2==this[du].side}setAlphaMode(e){this[_u]();const enableTransparency=(e,t)=>{e.transparent=t,e.depthWrite=!t};for(const t of this[Ch])enableTransparency(t,"BLEND"===e),t.alphaTest="MASK"===e?.5:void 0,t.needsUpdate=!0;this[bh]()}getAlphaMode(){return this[_u](),this[Au]()}get emissiveStrength(){return this[_u](),this[du].emissiveIntensity}setEmissiveStrength(e){this[_u]();for(const t of this[Ch])t.emissiveIntensity=e;this[bh]()}get clearcoatFactor(){return this[_u](),this[du].clearcoat}get clearcoatRoughnessFactor(){return this[_u](),this[du].clearcoatRoughness}get clearcoatTexture(){return this[_u](),this[bu].get(tu.Clearcoat)}get clearcoatRoughnessTexture(){return this[_u](),this[bu].get(tu.ClearcoatRoughness)}get clearcoatNormalTexture(){return this[_u](),this[bu].get(tu.ClearcoatNormal)}get clearcoatNormalScale(){return this[_u](),this[du].clearcoatNormalScale.x}setClearcoatFactor(e){this[_u]();for(const t of this[Ch])t.clearcoat=e;this[bh]()}setClearcoatRoughnessFactor(e){this[_u]();for(const t of this[Ch])t.clearcoatRoughness=e;this[bh]()}setClearcoatNormalScale(e){this[_u]();for(const t of this[Ch])t.clearcoatNormalScale=new Vector2(e,e);this[bh]()}get ior(){return this[_u](),this[du].ior}setIor(e){this[_u]();for(const t of this[Ch])t.ior=e;this[bh]()}get sheenColorFactor(){return this[_u](),this[du].sheenColor.toArray()}get sheenColorTexture(){return this[_u](),this[bu].get(tu.SheenColor)}get sheenRoughnessFactor(){return this[_u](),this[du].sheenRoughness}get sheenRoughnessTexture(){return this[_u](),this[bu].get(tu.SheenRoughness)}setSheenColorFactor(e){this[_u]();const t=this.colorFromRgb(e);for(const e of this[Ch])e.sheenColor.set(t),e.sheen=1;this[bh]()}setSheenRoughnessFactor(e){this[_u]();for(const t of this[Ch])t.sheenRoughness=e,t.sheen=1;this[bh]()}get transmissionFactor(){return this[_u](),this[du].transmission}get transmissionTexture(){return this[_u](),this[bu].get(tu.Transmission)}setTransmissionFactor(e){this[_u]();for(const t of this[Ch])t.transmission=e;this[bh]()}get thicknessFactor(){return this[_u](),this[du].thickness}get thicknessTexture(){return this[_u](),this[bu].get(tu.Thickness)}get attenuationDistance(){return this[_u](),this[du].attenuationDistance}get attenuationColor(){return this[_u](),this[du].attenuationColor.toArray()}setThicknessFactor(e){this[_u]();for(const t of this[Ch])t.thickness=e;this[bh]()}setAttenuationDistance(e){this[_u]();for(const t of this[Ch])t.attenuationDistance=e;this[bh]()}setAttenuationColor(e){this[_u]();const t=this.colorFromRgb(e);for(const e of this[Ch])e.attenuationColor.set(t);this[bh]()}get specularFactor(){return this[_u](),this[du].specularIntensity}get specularTexture(){return this[_u](),this[bu].get(tu.Specular)}get specularColorFactor(){return this[_u](),this[du].specularColor.toArray()}get specularColorTexture(){return this[_u](),this[bu].get(tu.SheenColor)}setSpecularFactor(e){this[_u]();for(const t of this[Ch])t.specularIntensity=e;this[bh]()}setSpecularColorFactor(e){this[_u]();const t=this.colorFromRgb(e);for(const e of this[Ch])e.specularColor.set(t);this[bh]()}get iridescenceFactor(){return this[_u](),this[du].iridescence}get iridescenceTexture(){return this[_u](),this[bu].get(tu.Iridescence)}get iridescenceIor(){return this[_u](),this[du].iridescenceIOR}get iridescenceThicknessMinimum(){return this[_u](),this[du].iridescenceThicknessRange[0]}get iridescenceThicknessMaximum(){return this[_u](),this[du].iridescenceThicknessRange[1]}get iridescenceThicknessTexture(){return this[_u](),this[bu].get(tu.IridescenceThickness)}setIridescenceFactor(e){this[_u]();for(const t of this[Ch])t.iridescence=e;this[bh]()}setIridescenceIor(e){this[_u]();for(const t of this[Ch])t.iridescenceIOR=e;this[bh]()}setIridescenceThicknessMinimum(e){this[_u]();for(const t of this[Ch])t.iridescenceThicknessRange[0]=e;this[bh]()}setIridescenceThicknessMaximum(e){this[_u]();for(const t of this[Ch])t.iridescenceThicknessRange[1]=e;this[bh]()}get anisotropyStrength(){return this[_u](),this[du].anisotropy}get anisotropyRotation(){return this[_u](),this[du].anisotropyRotation}get anisotropyTexture(){return this[_u](),this[bu].get(tu.Anisotropy)}setAnisotropyStrength(e){this[_u]();for(const t of this[Ch])t.anisotropy=e;this[bh]()}setAnisotropyRotation(e){this[_u]();for(const t of this[Ch])t.anisotropyRotation=e;this[bh]()}}var wu=r(6763);class primitive_node_Node{constructor(e){this.name="",this.children=new Array,this.name=e}}class PrimitiveNode extends primitive_node_Node{constructor(e,t,r,s){super(e.name),this.materials=new Map,this.variantToMaterialMap=new Map,this.initialMaterialIdx=0,this.activeMaterialIdx=0,this.mesh=e;const{gltf:o,threeGLTF:l,threeObjectMap:c}=s;this.parser=l.parser,this.modelVariants=r,this.mesh.userData.variantData=r;const h=c.get(e.material);null!=h.materials?this.initialMaterialIdx=this.activeMaterialIdx=h.materials:wu.error(`Primitive (${e.name}) missing initial material reference.`);const d=e.userData.associations||{};if(null==d.meshes)return void wu.error("Mesh is missing primitive index association");const p=((o.meshes||[])[d.meshes].primitives||[])[d.primitives];if(null!=p){if(null!=p.material)this.materials.set(p.material,t[p.material]);else{const e=t.findIndex((e=>"Default"===e.name));e>=0?this.materials.set(e,t[e]):wu.warn("gltfPrimitive has no material!")}if(p.extensions&&p.extensions.KHR_materials_variants){const e=p.extensions.KHR_materials_variants,s=l.parser.json.extensions.KHR_materials_variants.variants;for(const o of e.mappings){const e=t[o.material];this.materials.set(o.material,e);for(const t of o.variants){const{name:o}=s[t];this.variantToMaterialMap.set(t,e),e[Eu]().add(t),r.has(o)||r.set(o,{name:o,index:t})}}}}else wu.error("Mesh primitive definition is missing.")}async setActiveMaterial(e){const t=this.materials.get(e);if(null!=t&&e!==this.activeMaterialIdx){this.mesh.material=await t[gu]();const{normalScale:r}=this.mesh.material;null!=r&&r.y*r.x<0!=(null==this.mesh.geometry.attributes.tangent)&&this.parser.assignFinalMaterial(this.mesh),this.activeMaterialIdx=e}return this.mesh.material}getActiveMaterial(){return this.materials.get(this.activeMaterialIdx)}getMaterial(e){return this.materials.get(e)}async enableVariant(e){if(null==e)return this.setActiveMaterial(this.initialMaterialIdx);if(null!=this.variantToMaterialMap&&this.modelVariants.has(e)){const t=this.modelVariants.get(e);return this.enableVariantHelper(t.index)}return null}async enableVariantHelper(e){if(null!=this.variantToMaterialMap&&null!=e){const t=this.variantToMaterialMap.get(e);if(null!=t)return this.setActiveMaterial(t.index)}return null}async instantiateVariants(){if(null!=this.variantToMaterialMap)for(const e of this.variantToMaterialMap.keys()){const t=this.mesh.userData.variantMaterials.get(e);if(null!=t.material)continue;const r=await this.enableVariantHelper(e);null!=r&&(t.material=r)}}get variantInfo(){return this.variantToMaterialMap}addVariant(e,t){if(!this.ensureVariantIsUnused(t))return!1;this.modelVariants.has(t)||this.modelVariants.set(t,{name:t,index:this.modelVariants.size});const r=this.modelVariants.get(t).index;return e[Eu]().add(r),this.variantToMaterialMap.set(r,e),this.materials.set(e.index,e),this.updateVariantUserData(r,e),!0}deleteVariant(e){if(this.variantInfo.has(e)){this.variantInfo.delete(e);const t=this.mesh.userData.variantMaterials;null!=t&&t.delete(e)}}updateVariantUserData(e,t){t[Eu]().add(e),this.mesh.userData.variantData=this.modelVariants,this.mesh.userData.variantMaterials=this.mesh.userData.variantMaterials||new Map;this.mesh.userData.variantMaterials.set(e,{material:t[Ch].values().next().value,gltfMaterialIndex:t.index})}ensureVariantIsUnused(e){const t=this.modelVariants.get(e);return null==t||!this.variantInfo.has(t.index)||(wu.warn(`Primitive cannot add variant '${e}' for this material, it already exists.`),!1)}}var Iu,Tu,Bu,Ru,Lu,Du,Uu=r(6763);const Pu=Symbol("materials"),Fu=Symbol("hierarchy"),Nu=Symbol("roots"),Ou=Symbol("primitives"),Qu=(Symbol("loadVariant"),Symbol("prepareVariantsForExport")),ku=Symbol("switchVariant"),Gu=Symbol("materialFromPoint"),Vu=Symbol("nodeFromPoint"),Hu=Symbol("nodeFromIndex"),zu=Symbol("variantData"),Wu=Symbol("availableVariants"),qu=Symbol("modelOnUpdate"),ju=Symbol("cloneMaterial");class LazyLoader{constructor(e,t,r,s){this.gltf=e,this.gltfElementMap=t,this.mapKey=r,this.doLazyLoad=s}}class Model{constructor(e,t=()=>{}){this[Iu]=new Array,this[Tu]=new Array,this[Bu]=new Array,this[Ru]=new Array,this[Lu]=()=>{},this[Du]=new Map,this[qu]=t;const{gltf:r,threeGLTF:s,gltfElementMap:o}=e;for(const[e,l]of r.materials.entries()){const c=o.get(l);if(null!=c)this[Pu].push(new material_Material(t,e,!0,this[zu],c,l.name));else{const h=(r.materials||[])[e],d=e,materialLoadCallback=async()=>{const e=await s.parser.getDependency("material",d),t=new Set;return o.set(h,t),t.add(e),{set:t,material:e}};this[Pu].push(new material_Material(t,e,!1,this[zu],c,l.name,new LazyLoader(r,o,h,materialLoadCallback)))}}const l=new Map,c=new Array;for(const e of s.scene.children)c.push(e);for(;c.length>0;){const t=c.pop();let r=null;t instanceof three_module_Mesh?(r=new PrimitiveNode(t,this.materials,this[zu],e),this[Ou].push(r)):r=new primitive_node_Node(t.name);const s=l.get(t);null!=s?s.children.push(r):this[Nu].push(r),this[Fu].push(r);for(const e of t.children)c.push(e),l.set(t,r)}}get materials(){return this[Pu]}[(Iu=Pu,Tu=Fu,Bu=Nu,Ru=Ou,Lu=qu,Du=zu,Wu)](){const e=Array.from(this[zu].values());return e.sort(((e,t)=>e.index-t.index)),e.map((e=>e.name))}getMaterialByName(e){const t=this[Pu].filter((t=>t.name===e));return t.length>0?t[0]:null}[Hu](e,t){const r=this[Fu].find((r=>{if(r instanceof PrimitiveNode){const{meshes:s,primitives:o}=r.mesh.userData.associations;if(s==e&&o==t)return!0}return!1}));return null==r?null:r}[Vu](e){return this[Fu].find((t=>{if(t instanceof PrimitiveNode){if(t.mesh===e.object)return!0}return!1}))}[Gu](e){return this[Vu](e).getActiveMaterial()}async[ku](e){for(const t of this[Ou])await t.enableVariant(e);for(const e of this.materials)e[yu](!1);for(const e of this[Ou])this.materials[e.getActiveMaterial().index][yu](!0)}async[Qu](){const e=new Array;for(const t of this[Ou])e.push(t.instantiateVariants());await Promise.all(e)}[ju](e,t){const r=this.materials[e];r.isLoaded||Uu.error("Cloning an unloaded material,\n call 'material.ensureLoaded() before cloning the material.");const s=r[Ch],o=new Set;for(const[e,r]of s.entries()){const l=r.clone();l.name=t+(s.size>1?"_inst"+e:""),o.add(l)}const l=new material_Material(this[qu],this[Pu].length,!1,this[zu],o,t);return this[Pu].push(l),l}createMaterialInstanceForVariant(e,t,r,s=!0){let o=null;for(const s of this[Ou]){const l=this[zu].get(r);null!=l&&s.variantInfo.has(l.index)||null!=s.getMaterial(e)&&(this.hasVariant(r)||this.createVariant(r),null==o&&(o=this[ju](e,t)),s.addVariant(o,r))}if(s&&null!=o){o[yu](!0),this.materials[e][yu](!1);for(const e of this[Ou])e.enableVariant(r)}return o}createVariant(e){this[zu].has(e)?Uu.warn(`Variant '${e}'' already exists`):this[zu].set(e,{name:e,index:this[zu].size})}hasVariant(e){return this[zu].has(e)}setMaterialToVariant(e,t){if(null!=this[Wu]().find((e=>e===t)))if(e<0||e>=this.materials.length)Uu.error("setMaterialToVariant(): materialIndex is out of bounds.");else for(const r of this[Ou]){const s=r.getMaterial(e);null!=s&&r.addVariant(s,t)}else Uu.warn(`Can't add material to '${t}', the variant does not exist.'`)}updateVariantName(e,t){const r=this[zu].get(e);null!=r&&(r.name=t,this[zu].set(t,r),this[zu].delete(e))}deleteVariant(e){const t=this[zu].get(e);if(null!=t){for(const r of this.materials)r.hasVariant(e)&&r[Su].delete(t.index);for(const e of this[Ou])e.deleteVariant(t.index);this[zu].delete(e)}}}var scene_graph_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const Xu=Symbol("currentGLTF"),Yu=Symbol("originalGltfJson"),Ku=Symbol("model"),Ju=Symbol("getOnUpdateMethod"),$u=Symbol("buildTexture");class GroundedSkybox extends three_module_Mesh{constructor(){super(void 0,new MeshBasicMaterial({depthWrite:!1})),this.height=0,this.radius=0,this.resolution=0,this.userData.noHit=!0}get map(){return this.material.map}set map(e){this.material.map=e}isUsable(){return this.height>0&&this.radius>0&&null!=this.geometry&&null!=this.map}updateGeometry(e=this.height,t=this.radius,r=128){e==this.height&&t==this.radius&&r==this.resolution||(this.height=e,this.radius=t,this.resolution=r,e>0&&t>0&&(this.geometry.dispose(),this.geometry=function makeGeometry(e,t,r){const s=new SphereGeometry(t,2*r,r);s.scale(1,1,-1);const o=s.getAttribute("position"),l=new three_module_Vector3;for(let t=0;t<o.count;++t)if(l.fromBufferAttribute(o,t),l.y<0){const r=3*-e/2,s=l.y<r?-e/l.y:1-l.y*l.y/(3*r*r);l.multiplyScalar(s),l.toArray(o.array,3*t)}return o.needsUpdate=!0,s}(e,t,r)))}}const Zu=new three_module_Vector3,ed=new three_module_Vector3,td=new three_module_Vector3,id=new Matrix3,nd=new Triangle,rd=new three_module_Quaternion;class Hotspot extends CSS2DObject{constructor(e){super(document.createElement("div")),this.normal=new three_module_Vector3(0,1,0),this.initialized=!1,this.referenceCount=1,this.pivot=document.createElement("div"),this.slot=document.createElement("slot"),this.element.classList.add("annotation-wrapper"),this.slot.name=e.name,this.element.appendChild(this.pivot),this.pivot.appendChild(this.slot),this.updatePosition(e.position),this.updateNormal(e.normal),this.surface=e.surface}get facingCamera(){return!this.element.classList.contains("hide")}show(){this.facingCamera&&this.initialized||this.updateVisibility(!0)}hide(){!this.facingCamera&&this.initialized||this.updateVisibility(!1)}increment(){this.referenceCount++}decrement(){return this.referenceCount>0&&--this.referenceCount,0===this.referenceCount}updatePosition(e){if(null==e)return;const t=dl(e)[0].terms;for(let e=0;e<3;++e)this.position.setComponent(e,vl(t[e]).number);this.updateMatrixWorld()}updateNormal(e){if(null==e)return;const t=dl(e)[0].terms;for(let e=0;e<3;++e)this.normal.setComponent(e,t[e].number)}updateSurface(e){if(!e&&this.initialized)return;const{mesh:t,tri:r,bary:s}=this;if(null==t||null==r||null==s)return;t.getVertexPosition(r.x,Zu),t.getVertexPosition(r.y,ed),t.getVertexPosition(r.z,td),Zu.toArray(id.elements,0),ed.toArray(id.elements,3),td.toArray(id.elements,6),this.position.copy(s).applyMatrix3(id);const o=this.parent;o.worldToLocal(t.localToWorld(this.position)),nd.set(Zu,ed,td),nd.getNormal(this.normal).transformDirection(t.matrixWorld);const l=o.parent;rd.setFromAxisAngle(Zu.set(0,1,0),-l.yaw),this.normal.applyQuaternion(rd)}orient(e){this.pivot.style.transform=`rotate(${e}rad)`}updateVisibility(e){this.element.classList.toggle("hide",!e),this.slot.assignedNodes().forEach((t=>{if(t.nodeType!==Node.ELEMENT_NODE)return;const r=t,s=r.dataset.visibilityAttribute;if(null!=s){const t=`data-${s}`;r.toggleAttribute(t,e)}r.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:e}}))})),this.initialized=!0}}const sd={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float h;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"},ad={name:"VerticalBlurShader",uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float v;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"};r(6763);Math.PI,Math.PI;function MathUtils_lerp(e,t,r){return(1-r)*e+r*t}class Shadow extends Object3D{constructor(e,t,r){super(),this.camera=new OrthographicCamera,this.renderTarget=null,this.renderTargetBlur=null,this.depthMaterial=new MeshDepthMaterial,this.horizontalBlurMaterial=new ShaderMaterial(sd),this.verticalBlurMaterial=new ShaderMaterial(ad),this.intensity=0,this.softness=1,this.boundingBox=new Box3,this.size=new three_module_Vector3,this.maxDimension=0,this.isAnimated=!1,this.needsUpdate=!1;const{camera:s}=this;s.rotation.x=Math.PI/2,s.left=-.5,s.right=.5,s.bottom=-.5,s.top=.5,this.add(s);const o=new PlaneGeometry,l=new MeshBasicMaterial({opacity:1,transparent:!0,side:1});this.floor=new three_module_Mesh(o,l),this.floor.userData.noHit=!0,s.add(this.floor),this.blurPlane=new three_module_Mesh(o),this.blurPlane.visible=!1,s.add(this.blurPlane),e.target.add(this),this.depthMaterial.onBeforeCompile=function(e){e.fragmentShader=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * opacity );")},this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial.depthTest=!1,this.setScene(e,t,r)}setScene(e,t,r){const{boundingBox:s,size:o,rotation:l,position:c}=this;if(this.isAnimated=e.animationNames.length>0,this.boundingBox.copy(e.boundingBox),this.size.copy(e.size),this.maxDimension=Math.max(o.x,o.y,o.z)*(this.isAnimated?2:1),this.boundingBox.getCenter(c),"back"===r){const{min:e,max:t}=s;[e.y,e.z]=[e.z,e.y],[t.y,t.z]=[t.z,t.y],[o.y,o.z]=[o.z,o.y],l.x=Math.PI/2,l.y=Math.PI}else l.x=0,l.y=0;if(this.isAnimated){const e=s.min.y,t=s.max.y;o.y=this.maxDimension,s.expandByVector(o.subScalar(this.maxDimension).multiplyScalar(-.5)),s.min.y=e,s.max.y=t,o.set(this.maxDimension,t-e,this.maxDimension)}"bottom"===r?c.y=s.min.y:c.z=s.min.y,this.setSoftness(t)}setSoftness(e){this.softness=e;const{size:t,camera:r}=this,s=this.isAnimated?2:1,o=s*Math.pow(2,9-3*e);this.setMapSize(o);const l=t.y/2,c=t.y*s;r.near=0,r.far=MathUtils_lerp(c,l,e),this.depthMaterial.opacity=1/e,r.updateProjectionMatrix(),this.setIntensity(this.intensity),this.setOffset(0)}setMapSize(e){const{size:t}=this;this.isAnimated&&(e*=2);const r=Math.floor(t.x>t.z?e:e*t.x/t.z),s=Math.floor(t.x>t.z?e*t.z/t.x:e),o=10+r,l=10+s;if(null==this.renderTarget||this.renderTarget.width===o&&this.renderTarget.height===l||(this.renderTarget.dispose(),this.renderTarget=null,this.renderTargetBlur.dispose(),this.renderTargetBlur=null),null==this.renderTarget){const e={format:Ae};this.renderTarget=new WebGLRenderTarget(o,l,e),this.renderTargetBlur=new WebGLRenderTarget(o,l,e),this.floor.material.map=this.renderTarget.texture}this.camera.scale.set(t.x*(1+10/r),t.z*(1+10/s),1),this.needsUpdate=!0}setIntensity(e){this.intensity=e,e>0?(this.visible=!0,this.floor.visible=!0,this.floor.material.opacity=e*MathUtils_lerp(.3,1,this.softness*this.softness)):(this.visible=!1,this.floor.visible=!1)}getIntensity(){return this.intensity}setOffset(e){this.floor.position.z=-e+this.gap()}gap(){return.001*this.maxDimension}render(e,t){t.overrideMaterial=this.depthMaterial;const r=e.getClearAlpha();e.setClearAlpha(0),this.floor.visible=!1;const s=e.xr.enabled;e.xr.enabled=!1;const o=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.render(t,this.camera),t.overrideMaterial=null,this.floor.visible=!0,this.blurShadow(e),e.xr.enabled=s,e.setRenderTarget(o),e.setClearAlpha(r)}blurShadow(e){const{camera:t,horizontalBlurMaterial:r,verticalBlurMaterial:s,renderTarget:o,renderTargetBlur:l,blurPlane:c}=this;c.visible=!0,c.material=r,r.uniforms.h.value=1/this.renderTarget.width,r.uniforms.tDiffuse.value=this.renderTarget.texture,e.setRenderTarget(l),e.render(c,t),c.material=s,s.uniforms.v.value=1/this.renderTarget.height,s.uniforms.tDiffuse.value=this.renderTargetBlur.texture,e.setRenderTarget(o),e.render(c,t),c.visible=!1}dispose(){null!=this.renderTarget&&this.renderTarget.dispose(),null!=this.renderTargetBlur&&this.renderTargetBlur.dispose(),this.depthMaterial.dispose(),this.horizontalBlurMaterial.dispose(),this.verticalBlurMaterial.dispose(),this.floor.material.dispose(),this.floor.geometry.dispose(),this.blurPlane.geometry.dispose(),this.removeFromParent()}}var od=r(6763);const ld=new three_module_Vector3,cd=new three_module_Vector3,hd=new three_module_Vector3,ud=new class Raycaster{constructor(e,t,r=0,s=1/0){this.ray=new Ray(e,t),this.near=r,this.far=s,this.camera=null,this.layers=new Layers,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):o.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,r=[]){return intersectObject(e,this,r,t),r.sort(ascSort),r}intersectObjects(e,t=!0,r=[]){for(let s=0,o=e.length;s<o;s++)intersectObject(e[s],this,r,t);return r.sort(ascSort),r}},dd=new three_module_Vector3,pd=new Vector2;class ModelScene extends Scene{constructor({canvas:e,element:t,width:r,height:s}){super(),this.annotationRenderer=new CSS2DRenderer,this.effectRenderer=null,this.schemaElement=document.createElement("script"),this.width=1,this.height=1,this.aspect=1,this.scaleStep=0,this.renderCount=0,this.externalRenderer=null,this.camera=new PerspectiveCamera(45,1,.1,100),this.xrCamera=null,this.url=null,this.target=new Object3D,this.animationNames=[],this.boundingBox=new Box3,this.boundingSphere=new Sphere,this.size=new three_module_Vector3,this.idealAspect=0,this.framedFoVDeg=0,this.shadow=null,this.shadowIntensity=0,this.shadowSoftness=1,this.bakedShadows=new Set,this.exposure=1,this.toneMapping=4,this.canScale=!0,this.isDirty=!1,this.goalTarget=new three_module_Vector3,this.targetDamperX=new Damper,this.targetDamperY=new Damper,this.targetDamperZ=new Damper,this._currentGLTF=null,this._model=null,this.cancelPendingSourceChange=null,this.animationsByName=new Map,this.currentAnimationAction=null,this.groundedSkybox=new GroundedSkybox,this.name="ModelScene",this.element=t,this.canvas=e,this.camera=new PerspectiveCamera(45,1,.1,100),this.camera.name="MainCamera",this.add(this.target),this.setSize(r,s),this.target.name="Target",this.mixer=new three_module_AnimationMixer(this.target);const{domElement:o}=this.annotationRenderer,{style:l}=o;l.display="none",l.pointerEvents="none",l.position="absolute",l.top="0",this.element.shadowRoot.querySelector(".default").appendChild(o),this.schemaElement.setAttribute("type","application/ld+json")}get context(){return this.canvas.getContext("2d")}getCamera(){return null!=this.xrCamera?this.xrCamera:this.camera}queueRender(){this.isDirty=!0}shouldRender(){return this.isDirty}hasRendered(){this.isDirty=!1}forceRescale(){this.scaleStep=-1,this.queueRender()}async setObject(e){this.reset(),this._model=e,this.target.add(e),await this.setupScene()}async setSource(e,t=()=>{}){if(!e||e===this.url)return void t(1);if(this.reset(),this.url=e,null!=this.externalRenderer){const e=await this.externalRenderer.load(t);return this.boundingSphere.radius=e.framedRadius,void(this.idealAspect=e.fieldOfViewAspect)}let r;null!=this.cancelPendingSourceChange&&(this.cancelPendingSourceChange(),this.cancelPendingSourceChange=null);try{r=await new Promise((async(r,s)=>{this.cancelPendingSourceChange=()=>s();try{r(await this.element[np].loader.load(e,this.element,t))}catch(e){s(e)}}))}catch(e){if(null==e)return;throw e}this.cancelPendingSourceChange=null,this.reset(),this.url=e,this._currentGLTF=r,null!=r&&(this._model=r.scene,this.target.add(r.scene));const{animations:s}=r,o=new Map,l=[];for(const e of s)o.set(e.name,e),l.push(e.name);this.animations=s,this.animationsByName=o,this.animationNames=l,await this.setupScene()}async setupScene(){this.applyTransform(),this.updateBoundingBox(),await this.updateFraming(),this.updateShadow(),this.setShadowIntensity(this.shadowIntensity),this.setGroundedSkybox()}reset(){this.url=null,this.renderCount=0,this.queueRender(),null!=this.shadow&&this.shadow.setIntensity(0),this.bakedShadows.clear();const{_model:e}=this;null!=e&&(e.removeFromParent(),this._model=null);const t=this._currentGLTF;null!=t&&(t.dispose(),this._currentGLTF=null),null!=this.currentAnimationAction&&(this.currentAnimationAction.stop(),this.currentAnimationAction=null),this.mixer.stopAllAction(),this.mixer.uncacheRoot(this)}dispose(){this.reset(),null!=this.shadow&&(this.shadow.dispose(),this.shadow=null),this.element[Xu]=null,this.element[Yu]=null,this.element[Ku]=null}get currentGLTF(){return this._currentGLTF}setSize(e,t){if(this.width!==e||this.height!==t){if(this.width=Math.max(e,1),this.height=Math.max(t,1),this.annotationRenderer.setSize(e,t),this.aspect=this.width/this.height,null!=this.externalRenderer){const r=ea();this.externalRenderer.resize(e*r,t*r)}this.queueRender()}}markBakedShadow(e){e.userData.noHit=!0,this.bakedShadows.add(e)}unmarkBakedShadow(e){e.userData.noHit=!1,e.visible=!0,this.bakedShadows.delete(e),this.boundingBox.expandByObject(e)}findBakedShadows(e){const t=new Box3;e.traverse((e=>{const r=e;if(!r.material)return;if(!r.material.transparent)return;t.setFromObject(r);const s=t.getSize(dd),o=Math.min(s.x,s.y,s.z);Math.max(s.x,s.y,s.z)<100*o||this.markBakedShadow(r)}))}checkBakedShadows(){const{min:e,max:t}=this.boundingBox,r=new Box3;this.boundingBox.getSize(this.size);for(const s of this.bakedShadows)r.setFromObject(s),r.min.y<e.y+this.size.y/100&&r.min.x<=e.x&&r.max.x>=t.x&&r.min.z<=e.z&&r.max.z>=t.z||r.min.z<e.z+this.size.z/100&&r.min.x<=e.x&&r.max.x>=t.x&&r.min.y<=e.y&&r.max.y>=t.y||this.unmarkBakedShadow(s)}applyTransform(){const{model:e}=this;if(null==e)return;const t=dl(this.element.orientation)[0].terms,r=vl(t[0]).number,s=vl(t[1]).number,o=vl(t[2]).number;e.quaternion.setFromEuler(new Euler(s,o,r,"YXZ"));const l=dl(this.element.scale)[0].terms;e.scale.set(l[0].number,l[1].number,l[2].number)}updateBoundingBox(){const{model:e}=this;if(null==e)return;this.target.remove(e),this.findBakedShadows(e);const bound=(e,t)=>e.expandByPoint(t);this.setBakedShadowVisibility(!1),this.boundingBox=reduceVertices(e,bound,new Box3),this.boundingBox.isEmpty()&&(this.setBakedShadowVisibility(!0),this.bakedShadows.forEach((e=>this.unmarkBakedShadow(e))),this.boundingBox=reduceVertices(e,bound,new Box3)),this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size),this.target.add(e)}async updateFraming(){const{model:e}=this;if(null==e)return;this.target.remove(e),this.setBakedShadowVisibility(!1);const{center:t}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,t.copy(this.getTarget());this.boundingSphere.radius=Math.sqrt(reduceVertices(e,((e,r)=>Math.max(e,t.distanceToSquared(r))),0));this.idealAspect=reduceVertices(e,((e,r)=>{r.sub(t);const s=Math.sqrt(r.x*r.x+r.z*r.z);return Math.max(e,s/(this.idealCameraDistance()-Math.abs(r.y)))}),0)/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility(),this.target.add(e)}setBakedShadowVisibility(e=this.shadowIntensity<=0){for(const t of this.bakedShadows)t.visible=e}idealCameraDistance(){const e=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(e)}adjustedFoV(e){const t=Math.tan(e/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(t)*180/Math.PI}getNDC(e,t){if(null!=this.xrCamera)pd.set(e/window.screen.width,t/window.screen.height);else{const r=this.element.getBoundingClientRect();pd.set((e-r.x)/this.width,(t-r.y)/this.height)}return pd.multiplyScalar(2).subScalar(1),pd.y*=-1,pd}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(e,t){this.element[np].arRenderer.presentedScene!==this&&(this.environment=e,this.setBackground(t),this.queueRender())}setBackground(e){this.groundedSkybox.map=e,this.groundedSkybox.isUsable()?(this.target.add(this.groundedSkybox),this.background=null):(this.target.remove(this.groundedSkybox),this.background=e)}farRadius(){return this.boundingSphere.radius*(null!=this.groundedSkybox.parent?10:1)}setGroundedSkybox(){const e=dl(this.element.skyboxHeight)[0].terms[0],t=vl(e).number,r=10*this.boundingSphere.radius;this.groundedSkybox.updateGeometry(t,r),this.groundedSkybox.position.y=t-(this.shadow?2*this.shadow.gap():0),this.setBackground(this.groundedSkybox.map)}setTarget(e,t,r){this.goalTarget.set(-e,-t,-r)}setTargetDamperDecayTime(e){this.targetDamperX.setDecayTime(e),this.targetDamperY.setDecayTime(e),this.targetDamperZ.setDecayTime(e)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget(1e4)}updateTarget(e){const t=this.goalTarget,r=this.target.position;if(t.equals(r))return!1;{const s=this.boundingSphere.radius/10;let{x:o,y:l,z:c}=r;return o=this.targetDamperX.update(o,t.x,e,s),l=this.targetDamperY.update(l,t.y,e,s),c=this.targetDamperZ.update(c,t.z,e,s),this.target.position.set(o,l,c),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(e,t){const{x:r,z:s}=this.position;this.yaw=Math.atan2(e-r,t-s)}get model(){return this._model}set yaw(e){this.rotation.y=e,this.queueRender()}get yaw(){return this.rotation.y}set animationTime(e){this.mixer.setTime(e),this.queueShadowRender()}get animationTime(){if(null!=this.currentAnimationAction){const e=Math.max(this.currentAnimationAction._loopCount,0);return this.currentAnimationAction.loop!==Le||1&~e?this.currentAnimationAction.time:this.duration-this.currentAnimationAction.time}return 0}set animationTimeScale(e){this.mixer.timeScale=e}get animationTimeScale(){return this.mixer.timeScale}get duration(){return null!=this.currentAnimationAction&&this.currentAnimationAction.getClip()?this.currentAnimationAction.getClip().duration:0}get hasActiveAnimation(){return null!=this.currentAnimationAction}playAnimation(e=null,t=0,r=2201,s=1/0){if(null==this._currentGLTF)return;const{animations:o}=this;if(null==o||0===o.length)return;let l=null;if(null!=e&&(l=this.animationsByName.get(e),null==l)){const t=parseInt(e);!isNaN(t)&&t>=0&&t<o.length&&(l=o[t])}null==l&&(l=o[0]);try{const{currentAnimationAction:e}=this,o=this.mixer.clipAction(l,this);this.currentAnimationAction=o,this.element.paused?this.mixer.stopAllAction():(o.paused=!1,null!=e&&o!==e?o.crossFadeFrom(e,t,!1):this.animationTimeScale>0&&this.animationTime==this.duration&&(this.animationTime=0)),o.setLoop(r,s),o.enabled=!0,o.clampWhenFinished=!0,o.play()}catch(e){od.error(e)}}stopAnimation(){this.currentAnimationAction=null,this.mixer.stopAllAction()}updateAnimation(e){this.mixer.update(e),this.queueShadowRender()}subscribeMixerEvent(e,t){this.mixer.addEventListener(e,t)}updateShadow(){const e=this.shadow;if(null!=e){const t="wall"===this.element.arPlacement?"back":"bottom";e.setScene(this,this.shadowSoftness,t),e.needsUpdate=!0}}renderShadow(e){const t=this.shadow;null!=t&&1==t.needsUpdate&&(t.render(e,this),t.needsUpdate=!1)}queueShadowRender(){null!=this.shadow&&(this.shadow.needsUpdate=!0)}setShadowIntensity(e){if(this.shadowIntensity=e,null!=this._currentGLTF&&(this.setBakedShadowVisibility(),!(e<=0&&null==this.shadow))){if(null==this.shadow){const e="wall"===this.element.arPlacement?"back":"bottom";this.shadow=new Shadow(this,this.shadowSoftness,e)}this.shadow.setIntensity(e)}}setShadowSoftness(e){this.shadowSoftness=e;const t=this.shadow;null!=t&&t.setSoftness(e)}setShadowOffset(e){const t=this.shadow;null!=t&&t.setOffset(e)}hitFromPoint(e,t=this){ud.setFromCamera(e,this.getCamera());return ud.intersectObject(t,!0).find((e=>e.object.visible&&!e.object.userData.noHit))}positionAndNormalFromPoint(e,t=this){var r;const s=this.hitFromPoint(e,t);if(null==s)return null;return{position:s.point,normal:null!=s.face?s.face.normal.clone().applyNormalMatrix((new Matrix3).getNormalMatrix(s.object.matrixWorld)):ud.ray.direction.clone().multiplyScalar(-1),uv:null!==(r=s.uv)&&void 0!==r?r:null}}surfaceFromPoint(e,t=this){const r=this.element.model;if(null==r)return null;const s=this.hitFromPoint(e,t);if(null==s||null==s.face)return null;const o=r[Vu](s),{meshes:l,primitives:c}=o.mesh.userData.associations,h=new three_module_Vector3,d=new three_module_Vector3,p=new three_module_Vector3,{a:A,b:m,c:f}=s.face,g=s.object;g.getVertexPosition(A,h),g.getVertexPosition(m,d),g.getVertexPosition(f,p);const _=new Triangle(h,d,p),y=new three_module_Vector3;return _.getBarycoord(g.worldToLocal(s.point),y),`${l} ${c} ${A} ${m} ${f} ${y.x.toFixed(3)} ${y.y.toFixed(3)} ${y.z.toFixed(3)}`}addHotspot(e){this.target.add(e),this.annotationRenderer.domElement.appendChild(e.element)}removeHotspot(e){this.target.remove(e)}forHotspots(e){const{children:t}=this.target;for(let r=0,s=t.length;r<s;r++){const s=t[r];s instanceof Hotspot&&e(s)}}initializeSurface(e){if(null!=e.surface&&null==e.mesh){const t=dl(e.surface)[0].terms;if(8!=t.length)return void od.warn(e.surface+" does not have exactly 8 numbers.");const r=this.element.model[Hu](t[0].number,t[1].number),s=new three_module_Vector3(t[2].number,t[3].number,t[4].number);if(null==r)return void od.warn(e.surface+" does not match a node/primitive in this glTF! Skipping this hotspot.");const o=r.mesh.geometry.attributes.position.count;if(s.x>=o||s.y>=o||s.z>=o)return void od.warn(e.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");const l=new three_module_Vector3(t[5].number,t[6].number,t[7].number);e.mesh=r.mesh,e.tri=s,e.bary=l}}updateSurfaceHotspots(){const e=!this.element.paused;this.forHotspots((t=>{this.initializeSurface(t),t.updateSurface(e)}))}updateHotspotsVisibility(e){this.forHotspots((t=>{ld.copy(e),cd.setFromMatrixPosition(t.matrixWorld),ld.sub(cd),hd.copy(t.normal).transformDirection(this.target.matrixWorld),ld.dot(hd)<0?t.hide():t.show()}))}orientHotspots(e){this.forHotspots((t=>{t.orient(e)}))}setHotspotsVisibility(e){this.forHotspots((t=>{t.visible=e}))}updateSchema(e){var t;const{schemaElement:r,element:s}=this,{alt:o,poster:l,iosSrc:c}=s;if(null!=e){const s=[{"@type":"MediaObject",contentUrl:e,encodingFormat:"gltf"===(null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase())?"model/gltf+json":"model/gltf-binary"}];c&&s.push({"@type":"MediaObject",contentUrl:c,encodingFormat:"model/vnd.usdz+zip"});const h={"@context":"http://schema.org/","@type":"3DModel",image:null!=l?l:void 0,name:null!=o?o:void 0,encoding:s};r.textContent=JSON.stringify(h),document.head.appendChild(r)}else null!=r.parentElement&&r.parentElement.removeChild(r)}}class ProgressTracker extends EventTarget{constructor(){super(...arguments),this.ongoingActivities=new Set,this.totalProgress=0}get ongoingActivityCount(){return this.ongoingActivities.size}beginActivity(e){const t={progress:0,completed:!1};return this.ongoingActivities.add(t),1===this.ongoingActivityCount&&this.announceTotalProgress(t,0,e),r=>{let s;return s=Math.max(utilities_clamp(r,0,1),t.progress),s!==t.progress&&this.announceTotalProgress(t,s,e),t.progress}}announceTotalProgress(e,t,r){let s=0,o=0;1==t&&(e.completed=!0);for(const e of this.ongoingActivities){const{progress:t}=e;s+=1-t,e.completed&&o++}const l=e.progress;e.progress=t,this.totalProgress+=(t-l)*(1-this.totalProgress)/s;const c=o===this.ongoingActivityCount?1:this.totalProgress;this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:c,reason:r}})),o===this.ongoingActivityCount&&(this.totalProgress=0,this.ongoingActivities.clear())}}var Ad,md,fd,gd,_d,vd,yd,Ed,xd,Sd,Md,Cd,bd,wd=r(6763),model_viewer_base_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const Id=document.createElement("canvas"),Td=Symbol("fallbackResizeHandler"),Bd=Symbol("defaultAriaLabel"),Rd=Symbol("resizeObserver"),Ld=Symbol("clearModelTimeout"),Dd=Symbol("onContextLost"),Ud=Symbol("loaded"),Pd=Symbol("status"),Fd=Symbol("onFocus"),Nd=Symbol("onBlur"),Od=Symbol("updateSize"),Qd=Symbol("intersectionObserver"),kd=Symbol("isElementInViewport"),Gd=Symbol("announceModelVisibility"),Vd=Symbol("ariaLabel"),Hd=Symbol("altDefaulted"),zd=Symbol("statusElement"),Wd=Symbol("updateStatus"),qd=Symbol("loadedTime"),jd=Symbol("updateSource"),Xd=Symbol("markLoaded"),Yd=Symbol("container"),Kd=Symbol("input"),Jd=Symbol("canvas"),$d=Symbol("scene"),Zd=Symbol("needsRender"),ep=Symbol("tick"),tp=Symbol("onModelLoad"),ip=Symbol("onResize"),np=Symbol("renderer"),rp=Symbol("progressTracker"),sp=Symbol("getLoaded"),ap=Symbol("getModelIsVisible"),op=Symbol("shouldAttemptPreload"),toVector3D=e=>({x:e.x,y:e.y,z:e.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),toVector2D=e=>({u:e.x,v:e.y,toString(){return`${this.u} ${this.v}`}});class ModelViewerElementBase extends reactive_element_a{constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[Ad]=!1,this[md]=!1,this[fd]=0,this[gd]="",this[_d]=null,this[vd]=debounce((()=>{const e=this.getBoundingClientRect();this[Od](e)}),50),this[yd]=debounce((e=>{const t=this.modelIsVisible;t!==e&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:t}}))}),0),this[Ed]=null,this[xd]=null,this[Sd]=new ProgressTracker,this[Md]=()=>{this[zd].textContent=this[Pd]},this[Cd]=()=>{this[zd].textContent=""},this[bd]=e=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:e.sourceEvent}}))},this.attachShadow({mode:"open"});const e=this.shadowRoot;let t,r;if((e=>{D(aa,e)})(e),this[Yd]=e.querySelector(".container"),this[Kd]=e.querySelector(".userInput"),this[Jd]=e.querySelector("canvas"),this[zd]=e.querySelector("#status"),this[Bd]=this[Kd].getAttribute("aria-label"),this.isConnected){const e=this.getBoundingClientRect();t=e.width,r=e.height}else t=300,r=150;this[$d]=new ModelScene({canvas:this[Jd],element:this,width:t,height:r}),Promise.resolve().then((()=>{this[Od](this.getBoundingClientRect())})),Hs&&(this[Rd]=new ResizeObserver((e=>{if(!this[np].isPresenting)for(let t of e)t.target===this&&this[Od](t.contentRect)}))),zs?this[Qd]=new IntersectionObserver((e=>{for(let t of e)if(t.target===this){const e=this.modelIsVisible;this[kd]=t.isIntersecting,this[Gd](e),this[kd]&&!this.loaded&&this[jd]()}}),{root:null,rootMargin:"0px",threshold:1e-5}):this[kd]=!0}static get is(){return"model-viewer"}static set modelCacheSize(e){CachingGLTFLoader[So].evictionThreshold=e}static get modelCacheSize(){return CachingGLTFLoader[So].evictionThreshold}static set minimumRenderScale(e){e>1&&wd.warn("<model-viewer> minimumRenderScale has been clamped to a maximum value of 1."),e<=0&&wd.warn("<model-viewer> minimumRenderScale has been clamped to a minimum value of 0.25."),Renderer.singleton.minScale=e}static get minimumRenderScale(){return Renderer.singleton.minScale}get loaded(){return this[sp]()}get[(Ad=kd,md=Ud,fd=qd,gd=Pd,_d=Ld,vd=Td,yd=Gd,Ed=Rd,xd=Qd,Sd=rp,np)](){return Renderer.singleton}get modelIsVisible(){return this[ap]()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),Hs?this[Rd].observe(this):self.addEventListener("resize",this[Td]),zs&&this[Qd].observe(this),this.addEventListener("focus",this[Fd]),this.addEventListener("blur",this[Nd]);const e=this[np];e.addEventListener("contextlost",this[Dd]),e.registerScene(this[$d]),null!=this[Ld]&&(self.clearTimeout(this[Ld]),this[Ld]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),Hs?this[Rd].unobserve(this):self.removeEventListener("resize",this[Td]),zs&&this[Qd].unobserve(this),this.removeEventListener("focus",this[Fd]),this.removeEventListener("blur",this[Nd]);const e=this[np];e.removeEventListener("contextlost",this[Dd]),e.unregisterScene(this[$d]),this[Ld]=self.setTimeout((()=>{this[$d].dispose(),this[Ld]=null}),10)}updated(e){super.updated(e),e.has("src")&&(null==this.src?(this[Ud]=!1,this[qd]=0,this[$d].reset()):this.src!==this[$d].url&&(this[Ud]=!1,this[qd]=0,this[jd]())),e.has("alt")&&this[Kd].setAttribute("aria-label",this[Vd]),e.has("withCredentials")&&(CachingGLTFLoader.withCredentials=this.withCredentials,this[np].textureUtils.withCredentials=this.withCredentials),e.has("generateSchema")&&(this.generateSchema?this[$d].updateSchema(this.src):this[$d].updateSchema(null))}toDataURL(e,t){return this[np].displayCanvas(this[$d]).toDataURL(e,t)}async toBlob(e){const t=e?e.mimeType:void 0,r=e?e.qualityArgument:void 0,s=e?e.idealAspect:void 0,{width:o,height:l,idealAspect:c,aspect:h}=this[$d],{dpr:d,scaleFactor:p}=this[np];let A=o*p*d,m=l*p*d,f=0,g=0;if(!0===s)if(c>h){const e=m;m=Math.round(A/c),g=(e-m)/2}else{const e=A;A=Math.round(m*c),f=(e-A)/2}Id.width=A,Id.height=m;try{return new Promise((async(e,s)=>{Id.getContext("2d").drawImage(this[np].displayCanvas(this[$d]),f,g,A,m,0,0,A,m),Id.toBlob((t=>{if(!t)return s(new Error("Unable to retrieve canvas blob"));e(t)}),t,r)}))}finally{this[Od]({width:o,height:l})}}registerEffectComposer(e){e.setRenderer(this[np].threeRenderer),e.setMainCamera(this[$d].getCamera()),e.setMainScene(this[$d]),this[$d].effectRenderer=e}unregisterEffectComposer(){this[$d].effectRenderer=null}registerRenderer(e){this[$d].externalRenderer=e}unregisterRenderer(){this[$d].externalRenderer=null}get[Vd](){return this[Hd]}get[Hd](){return null==this.alt||"null"===this.alt?this[Bd]:this.alt}[sp](){return this[Ud]}[ap](){return this.loaded&&this[kd]}[op](){return!!this.src&&this[kd]}[Od]({width:e,height:t}){0!==e&&0!==t&&(this[Yd].style.width=`${e}px`,this[Yd].style.height=`${t}px`,this[ip]({width:e,height:t}))}[ep](e,t){var r;null===(r=this[$d].effectRenderer)||void 0===r||r.beforeRender(e,t)}[Xd](){this[Ud]||(this[Ud]=!0,this[qd]=performance.now())}[Zd](){this[$d].queueRender()}[tp](){}[Wd](e){this[Pd]=e;const t=this.getRootNode();null!=t&&t.activeElement===this&&this[zd].textContent!=e&&(this[zd].textContent=e)}[(Md=Fd,Cd=Nd,ip)](e){this[$d].setSize(e.width,e.height)}async[(bd=Dd,jd)](){const e=this[$d];if(this.loaded||!this[op]()||this.src===e.url)return;this.generateSchema&&e.updateSchema(this.src),this[Wd]("Loading"),e.stopAnimation();const t=this[rp].beginActivity("model-load"),r=this.src;try{const s=e.setSource(r,(e=>t(.95*utilities_clamp(e,0,1)))),o=this[ra]();await Promise.all([s,o]),this[Xd](),this[tp](),this.updateComplete.then((()=>{this.dispatchEvent(new CustomEvent("before-render"))})),await new Promise((e=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.dispatchEvent(new CustomEvent("load",{detail:{url:r}})),e()}))}))}))}catch(e){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:e}}))}finally{t(1)}}}model_viewer_base_decorate([n({type:String})],ModelViewerElementBase.prototype,"alt",void 0),model_viewer_base_decorate([n({type:String})],ModelViewerElementBase.prototype,"src",void 0),model_viewer_base_decorate([n({type:Boolean,attribute:"with-credentials"})],ModelViewerElementBase.prototype,"withCredentials",void 0),model_viewer_base_decorate([n({type:Boolean,attribute:"generate-schema"})],ModelViewerElementBase.prototype,"generateSchema",void 0);var animation_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const lp=Symbol("changeAnimation"),cp=Symbol("paused"),hp={repetitions:1/0,pingpong:!1},up=Symbol("hotspotMap"),dp=Symbol("mutationCallback"),pp=Symbol("observer"),Ap=Symbol("addHotspot"),mp=Symbol("removeHotspot"),fp=new three_module_Matrix4;var durl=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(durl(""))}catch(e){durl=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},function(e){return new Worker(e,{type:"module"})}}var gp=Uint8Array,_p=Uint16Array,vp=Uint32Array,yp=new gp([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ep=new gp([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xp=new gp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(e,t){for(var r=new _p(31),s=0;s<31;++s)r[s]=t+=1<<e[s-1];var o=new vp(r[30]);for(s=1;s<30;++s)for(var l=r[s];l<r[s+1];++l)o[l]=l-r[s]<<5|s;return[r,o]},Sp=freb(yp,2),Mp=Sp[0],Cp=Sp[1];Mp[28]=258,Cp[258]=28;for(var bp=freb(Ep,0),wp=(bp[0],bp[1]),Ip=new _p(32768),Tp=0;Tp<32768;++Tp){var Bp=(43690&Tp)>>>1|(21845&Tp)<<1;Bp=(61680&(Bp=(52428&Bp)>>>2|(13107&Bp)<<2))>>>4|(3855&Bp)<<4,Ip[Tp]=((65280&Bp)>>>8|(255&Bp)<<8)>>>1}var hMap=function(e,t,r){for(var s=e.length,o=0,l=new _p(t);o<s;++o)++l[e[o]-1];var c,h=new _p(t);for(o=0;o<t;++o)h[o]=h[o-1]+l[o-1]<<1;if(r){c=new _p(1<<t);var d=15-t;for(o=0;o<s;++o)if(e[o])for(var p=o<<4|e[o],A=t-e[o],m=h[e[o]-1]++<<A,f=m|(1<<A)-1;m<=f;++m)c[Ip[m]>>>d]=p}else for(c=new _p(s),o=0;o<s;++o)e[o]&&(c[o]=Ip[h[e[o]-1]++]>>>15-e[o]);return c},Rp=new gp(288);for(Tp=0;Tp<144;++Tp)Rp[Tp]=8;for(Tp=144;Tp<256;++Tp)Rp[Tp]=9;for(Tp=256;Tp<280;++Tp)Rp[Tp]=7;for(Tp=280;Tp<288;++Tp)Rp[Tp]=8;var Lp=new gp(32);for(Tp=0;Tp<32;++Tp)Lp[Tp]=5;var Dp=hMap(Rp,9,0),Up=hMap(Lp,5,0),shft=function(e){return(e/8|0)+(7&e&&1)},slc=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var s=new(e instanceof _p?_p:e instanceof vp?vp:gp)(r-t);return s.set(e.subarray(t,r)),s},wbits=function(e,t,r){r<<=7&t;var s=t/8|0;e[s]|=r,e[s+1]|=r>>>8},wbits16=function(e,t,r){r<<=7&t;var s=t/8|0;e[s]|=r,e[s+1]|=r>>>8,e[s+2]|=r>>>16},hTree=function(e,t){for(var r=[],s=0;s<e.length;++s)e[s]&&r.push({s,f:e[s]});var o=r.length,l=r.slice();if(!o)return[Fp,0];if(1==o){var c=new gp(r[0].s+1);return c[r[0].s]=1,[c,1]}r.sort((function(e,t){return e.f-t.f})),r.push({s:-1,f:25001});var h=r[0],d=r[1],p=0,A=1,m=2;for(r[0]={s:-1,f:h.f+d.f,l:h,r:d};A!=o-1;)h=r[r[p].f<r[m].f?p++:m++],d=r[p!=A&&r[p].f<r[m].f?p++:m++],r[A++]={s:-1,f:h.f+d.f,l:h,r:d};var f=l[0].s;for(s=1;s<o;++s)l[s].s>f&&(f=l[s].s);var g=new _p(f+1),_=fflate_module_ln(r[A-1],g,0);if(_>t){s=0;var y=0,x=_-t,S=1<<x;for(l.sort((function(e,t){return g[t.s]-g[e.s]||e.f-t.f}));s<o;++s){var C=l[s].s;if(!(g[C]>t))break;y+=S-(1<<_-g[C]),g[C]=t}for(y>>>=x;y>0;){var b=l[s].s;g[b]<t?y-=1<<t-g[b]++-1:++s}for(;s>=0&&y;--s){var I=l[s].s;g[I]==t&&(--g[I],++y)}_=t}return[new gp(g),_]},fflate_module_ln=function(e,t,r){return-1==e.s?Math.max(fflate_module_ln(e.l,t,r+1),fflate_module_ln(e.r,t,r+1)):t[e.s]=r},lc=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new _p(++t),s=0,o=e[0],l=1,w=function(e){r[s++]=e},c=1;c<=t;++c)if(e[c]==o&&c!=t)++l;else{if(!o&&l>2){for(;l>138;l-=138)w(32754);l>2&&(w(l>10?l-11<<5|28690:l-3<<5|12305),l=0)}else if(l>3){for(w(o),--l;l>6;l-=6)w(8304);l>2&&(w(l-3<<5|8208),l=0)}for(;l--;)w(o);l=1,o=e[c]}return[r.subarray(0,s),t]},clen=function(e,t){for(var r=0,s=0;s<t.length;++s)r+=e[s]*t[s];return r},wfblk=function(e,t,r){var s=r.length,o=shft(t+2);e[o]=255&s,e[o+1]=s>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var l=0;l<s;++l)e[o+l+4]=r[l];return 8*(o+4+s)},wblk=function(e,t,r,s,o,l,c,h,d,p,A){wbits(t,A++,r),++o[256];for(var m=hTree(o,15),f=m[0],g=m[1],_=hTree(l,15),y=_[0],x=_[1],S=lc(f),C=S[0],b=S[1],I=lc(y),T=I[0],B=I[1],U=new _p(19),F=0;F<C.length;++F)U[31&C[F]]++;for(F=0;F<T.length;++F)U[31&T[F]]++;for(var O=hTree(U,7),Q=O[0],G=O[1],W=19;W>4&&!Q[xp[W-1]];--W);var q,j,X,Y,K=p+5<<3,J=clen(o,Rp)+clen(l,Lp)+c,$=clen(o,f)+clen(l,y)+c+14+3*W+clen(U,Q)+(2*U[16]+3*U[17]+7*U[18]);if(K<=J&&K<=$)return wfblk(t,A,e.subarray(d,d+p));if(wbits(t,A,1+($<J)),A+=2,$<J){q=hMap(f,g,0),j=f,X=hMap(y,x,0),Y=y;var ee=hMap(Q,G,0);wbits(t,A,b-257),wbits(t,A+5,B-1),wbits(t,A+10,W-4),A+=14;for(F=0;F<W;++F)wbits(t,A+3*F,Q[xp[F]]);A+=3*W;for(var te=[C,T],ie=0;ie<2;++ie){var ne=te[ie];for(F=0;F<ne.length;++F){var re=31&ne[F];wbits(t,A,ee[re]),A+=Q[re],re>15&&(wbits(t,A,ne[F]>>>5&127),A+=ne[F]>>>12)}}}else q=Dp,j=Rp,X=Up,Y=Lp;for(F=0;F<h;++F)if(s[F]>255){re=s[F]>>>18&31;wbits16(t,A,q[re+257]),A+=j[re+257],re>7&&(wbits(t,A,s[F]>>>23&31),A+=yp[re]);var se=31&s[F];wbits16(t,A,X[se]),A+=Y[se],se>3&&(wbits16(t,A,s[F]>>>5&8191),A+=Ep[se])}else wbits16(t,A,q[s[F]]),A+=j[s[F]];return wbits16(t,A,q[256]),A+j[256]},Pp=new vp([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Fp=new gp(0),dflt=function(e,t,r,s,o,l){var c=e.length,h=new gp(s+c+5*(1+Math.ceil(c/7e3))+o),d=h.subarray(s,h.length-o),p=0;if(!t||c<8)for(var A=0;A<=c;A+=65535){var m=A+65535;m<c?p=wfblk(d,p,e.subarray(A,m)):(d[A]=l,p=wfblk(d,p,e.subarray(A,c)))}else{for(var f=Pp[t-1],g=f>>>13,_=8191&f,y=(1<<r)-1,x=new _p(32768),S=new _p(y+1),C=Math.ceil(r/3),b=2*C,hsh=function(t){return(e[t]^e[t+1]<<C^e[t+2]<<b)&y},I=new vp(25e3),T=new _p(288),B=new _p(32),U=0,F=0,O=(A=0,0),Q=0,G=0;A<c;++A){var W=hsh(A),q=32767&A,j=S[W];if(x[q]=j,S[W]=q,Q<=A){var X=c-A;if((U>7e3||O>24576)&&X>423){p=wblk(e,d,0,I,T,B,F,O,G,A-G,p),O=U=F=0,G=A;for(var Y=0;Y<286;++Y)T[Y]=0;for(Y=0;Y<30;++Y)B[Y]=0}var K=2,J=0,$=_,ee=q-j&32767;if(X>2&&W==hsh(A-ee))for(var te=Math.min(g,X)-1,ie=Math.min(32767,A),ne=Math.min(258,X);ee<=ie&&--$&&q!=j;){if(e[A+K]==e[A+K-ee]){for(var re=0;re<ne&&e[A+re]==e[A+re-ee];++re);if(re>K){if(K=re,J=ee,re>te)break;var se=Math.min(ee,re-2),ae=0;for(Y=0;Y<se;++Y){var oe=A-ee+Y+32768&32767,le=oe-x[oe]+32768&32767;le>ae&&(ae=le,j=oe)}}}ee+=(q=j)-(j=x[q])+32768&32767}if(J){I[O++]=268435456|Cp[K]<<18|wp[J];var ce=31&Cp[K],he=31&wp[J];F+=yp[ce]+Ep[he],++T[257+ce],++B[he],Q=A+K,++U}else I[O++]=e[A],++T[e[A]]}}p=wblk(e,d,l,I,T,B,F,O,G,A-G,p),!l&&7&p&&(p=wfblk(d,p+1,Fp))}return slc(h,0,s+shft(p)+o)},Np=function(){for(var e=new vp(256),t=0;t<256;++t){for(var r=t,s=9;--s;)r=(1&r&&3988292384)^r>>>1;e[t]=r}return e}(),crc=function(){var e=-1;return{p:function(t){for(var r=e,s=0;s<t.length;++s)r=Np[255&r^t[s]]^r>>>8;e=r},d:function(){return~e}}},dopt=function(e,t,r,s,o){return dflt(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,r,s,!o)},mrg=function(e,t){var r={};for(var s in e)r[s]=e[s];for(var s in t)r[s]=t[s];return r},wbytes=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8};function deflateSync(e,t){return dopt(e,t||{},0,0)}var fltn=function(e,t,r,s){for(var o in e){var l=e[o],c=t+o;l instanceof gp?r[c]=[l,s]:Array.isArray(l)?r[c]=[l[0],mrg(s,l[1])]:fltn(l,c+"/",r,s)}},Op="undefined"!=typeof TextEncoder&&new TextEncoder,Qp="undefined"!=typeof TextDecoder&&new TextDecoder;try{Qp.decode(Fp,{stream:!0}),1}catch(e){}function strToU8(e,t){if(t){for(var r=new gp(e.length),s=0;s<e.length;++s)r[s]=e.charCodeAt(s);return r}if(Op)return Op.encode(e);var o=e.length,l=new gp(e.length+(e.length>>1)),c=0,w=function(e){l[c++]=e};for(s=0;s<o;++s){if(c+5>l.length){var h=new gp(c+8+(o-s<<1));h.set(l),l=h}var d=e.charCodeAt(s);d<128||t?w(d):d<2048?(w(192|d>>6),w(128|63&d)):d>55295&&d<57344?(w(240|(d=65536+(1047552&d)|1023&e.charCodeAt(++s))>>18),w(128|d>>12&63),w(128|d>>6&63),w(128|63&d)):(w(224|d>>12),w(128|d>>6&63),w(128|63&d))}return slc(l,0,c)}var exfl=function(e){var t=0;if(e)for(var r in e){var s=e[r].length;if(s>65535)throw"extra field too long";t+=s+4}return t},wzh=function(e,t,r,s,o,l,c,h){var d=s.length,p=r.extra,A=h&&h.length,m=exfl(p);wbytes(e,t,null!=c?33639248:67324752),t+=4,null!=c&&(e[t++]=20,e[t++]=r.os),e[t]=20,t+=2,e[t++]=r.flag<<1|(null==l&&8),e[t++]=o&&8,e[t++]=255&r.compression,e[t++]=r.compression>>8;var f=new Date(null==r.mtime?Date.now():r.mtime),g=f.getFullYear()-1980;if(g<0||g>119)throw"date not in range 1980-2099";if(wbytes(e,t,g<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),t+=4,null!=l&&(wbytes(e,t,r.crc),wbytes(e,t+4,l),wbytes(e,t+8,r.size)),wbytes(e,t+12,d),wbytes(e,t+14,m),t+=16,null!=c&&(wbytes(e,t,A),wbytes(e,t+6,r.attrs),wbytes(e,t+10,c),t+=14),e.set(s,t),t+=d,m)for(var _ in p){var y=p[_],x=y.length;wbytes(e,t,+_),wbytes(e,t+2,x),e.set(y,t+4),t+=4+x}return A&&(e.set(h,t),t+=A),t},wzf=function(e,t,r,s,o){wbytes(e,t,101010256),wbytes(e,t+8,r),wbytes(e,t+10,r),wbytes(e,t+12,s),wbytes(e,t+16,o)};var kp=r(6763);class USDZExporter{async parse(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1},t);const r={},s="model.usda";r[s]=null;let o=buildHeader();o+=function buildSceneStart(e){return`def Xform "Root"\n{\n\tdef Scope "Scenes" (\n\t\tkind = "sceneLibrary"\n\t)\n\t{\n\t\tdef Xform "Scene" (\n\t\t\tcustomData = {\n\t\t\t\tbool preliminary_collidesWithEnvironment = 0\n\t\t\t\tstring sceneName = "Scene"\n\t\t\t}\n\t\t\tsceneName = "Scene"\n\t\t)\n\t\t{\n\t\ttoken preliminary:anchoring:type = "${e.ar.anchoring.type}"\n\t\ttoken preliminary:planeAnchoring:alignment = "${e.ar.planeAnchoring.alignment}"\n\n`}(t);const l={},c={};e.traverseVisible((e=>{if(e.isMesh){const t=e.geometry,s=e.material;if(s.isMeshStandardMaterial){const c="geometries/Geometry_"+t.id+".usda";if(!(c in r)){const e=function buildMeshObject(e){const t=function buildMesh(e){const t="Geometry",r=e.attributes,s=r.position.count;return`\n\tdef Mesh "${t}"\n\t{\n\t\tint[] faceVertexCounts = [${function buildMeshVertexCount(e){const t=null!==e.index?e.index.count:e.attributes.position.count;return Array(t/3).fill(3).join(", ")}(e)}]\n\t\tint[] faceVertexIndices = [${function buildMeshVertexIndices(e){const t=e.index,r=[];if(null!==t)for(let e=0;e<t.count;e++)r.push(t.getX(e));else{const t=e.attributes.position.count;for(let e=0;e<t;e++)r.push(e)}return r.join(", ")}(e)}]\n\t\tnormal3f[] normals = [${buildVector3Array(r.normal,s)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)\n\t\tpoint3f[] points = [${buildVector3Array(r.position,s)}]\n${function buildPrimvars(e){let t="";for(let r=0;r<4;r++){const s=r>0?r:"",o=e["uv"+s];void 0!==o&&(t+=`\n\t\ttexCoord2f[] primvars:st${s} = [${buildVector2Array(o)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}return t}(r)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(e);return`\ndef "Geometry"\n{\n${t}\n}\n`}(t);r[c]=function buildUSDFileAsString(e){let t=buildHeader();return t+=e,strToU8(t)}(e)}s.uuid in l||(l[s.uuid]=s),o+=function buildXform(e,t,r){const s="Object_"+e.id,o=buildMatrix(e.matrixWorld);e.matrixWorld.determinant()<0&&kp.warn("THREE.USDZExporter: USDZ does not support negative scales",e);return`def Xform "${s}" (\n\tprepend references = @./geometries/Geometry_${t.id}.usda@</Geometry>\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${o}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = </Materials/Material_${r.id}>\n}\n\n`}(e,t,s)}else kp.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",e)}else e.isCamera&&(o+=function buildCamera(e){const t=e.name?e.name:"Camera_"+e.id,r=buildMatrix(e.matrixWorld);e.matrixWorld.determinant()<0&&kp.warn("THREE.USDZExporter: USDZ does not support negative scales",e);return e.isOrthographicCamera?`def Camera "${t}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${r}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${e.near.toPrecision(Gp)}, ${e.far.toPrecision(Gp)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(e.left)+Math.abs(e.right))).toPrecision(Gp)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(e.top)+Math.abs(e.bottom))).toPrecision(Gp)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${t}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${r}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${e.near.toPrecision(Gp)}, ${e.far.toPrecision(Gp)})\n\t\t\tfloat focalLength = ${e.getFocalLength().toPrecision(Gp)}\n\t\t\tfloat focusDistance = ${e.focus.toPrecision(Gp)}\n\t\t\tfloat horizontalAperture = ${e.getFilmWidth().toPrecision(Gp)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${e.getFilmHeight().toPrecision(Gp)}\n\t\t}\n\t\n\t`}(e))})),o+="\n\t\t}\n\t}\n}\n\n",o+=function buildMaterials(e,t,r=!1){const s=[];for(const o in e){const l=e[o];s.push(buildMaterial(l,t,r))}return`def "Materials"\n{\n${s.join("")}\n}\n\n`}(l,c,t.quickLookCompatible),r[s]=strToU8(o),o=null;for(const e in c){let t=c[e];!0===t.isCompressedTexture&&(t=decompress(t));const s=imageToCanvas(t.image,t.flipY),o=await new Promise((e=>s.toBlob(e,"image/png",1)));r[`textures/Texture_${e}.png`]=new Uint8Array(await o.arrayBuffer())}let h=0;for(const e in r){const t=r[e];h+=34+e.length;const s=63&h;if(4!==s){const o=new Uint8Array(64-s);r[e]=[t,{extra:{12345:o}}]}h=t.length}return function zipSync(e,t){t||(t={});var r={},s=[];fltn(e,"",r,t);var o=0,l=0;for(var c in r){var h=r[c],d=h[0],p=h[1],A=0==p.level?0:8,m=(U=strToU8(c)).length,f=p.comment,g=f&&strToU8(f),_=g&&g.length,y=exfl(p.extra);if(m>65535)throw"filename too long";var x=A?deflateSync(d,p):d,S=x.length,C=crc();C.p(d),s.push(mrg(p,{size:d.length,crc:C.d(),c:x,f:U,m:g,u:m!=c.length||g&&f.length!=_,o,compression:A})),o+=30+m+y+S,l+=76+2*(m+y)+(_||0)+S}for(var b=new gp(l+22),I=o,T=l-o,B=0;B<s.length;++B){var U=s[B];wzh(b,U.o,U,U.f,U.u,U.c.length);var F=30+U.f.length+exfl(U.extra);b.set(U.c,U.o+F),wzh(b,o,U,U.f,U.u,U.c.length,U.o,U.m),o+=16+F+(U.m?U.m.length:0)}return wzf(b,o,s.length,T,I),b}(r,{level:0})}}function imageToCanvas(e,t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=1024/Math.max(e.width,e.height),s=document.createElement("canvas");s.width=e.width*Math.min(1,r),s.height=e.height*Math.min(1,r);const o=s.getContext("2d");return!0===t&&(o.translate(0,s.height),o.scale(1,-1)),o.drawImage(e,0,0,s.width,s.height),s}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const Gp=7;function buildHeader(){return'#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n'}function buildMatrix(e){const t=e.elements;return`( ${buildMatrixRow(t,0)}, ${buildMatrixRow(t,4)}, ${buildMatrixRow(t,8)}, ${buildMatrixRow(t,12)} )`}function buildMatrixRow(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function buildVector3Array(e,t){if(void 0===e)return kp.warn("USDZExporter: Normals missing."),Array(t).fill("(0, 0, 0)").join(", ");const r=[];for(let t=0;t<e.count;t++){const s=e.getX(t),o=e.getY(t),l=e.getZ(t);r.push(`(${s.toPrecision(Gp)}, ${o.toPrecision(Gp)}, ${l.toPrecision(Gp)})`)}return r.join(", ")}function buildVector2Array(e){const t=[];for(let r=0;r<e.count;r++){const s=e.getX(r),o=e.getY(r);t.push(`(${s.toPrecision(Gp)}, ${1-o.toPrecision(Gp)})`)}return t.join(", ")}function buildMaterial(e,t,r=!1){const s="\t\t\t",o=[],l=[];function buildTexture(s,o,l){const c=s.source.id+"_"+s.flipY;t[c]=s;const h=s.channel>0?"st"+s.channel:"st",d={1e3:"repeat",1001:"clamp",1002:"mirror"},p=s.repeat.clone(),A=s.offset.clone(),m=s.rotation,f=Math.sin(m),g=Math.cos(m);return A.y=1-A.y-p.y,r?(A.x=A.x/p.x,A.y=A.y/p.y,A.x+=f/p.x,A.y+=g-1):(A.x+=f*p.x,A.y+=(1-g)*p.y),`\n\t\tdef Shader "PrimvarReader_${o}"\n\t\t{\n\t\t\tuniform token info:id = "UsdPrimvarReader_float2"\n\t\t\tfloat2 inputs:fallback = (0.0, 0.0)\n\t\t\ttoken inputs:varname = "${h}"\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Transform2d_${o}"\n\t\t{\n\t\t\tuniform token info:id = "UsdTransform2d"\n\t\t\ttoken inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${o}.outputs:result>\n\t\t\tfloat inputs:rotation = ${(m*(180/Math.PI)).toFixed(Gp)}\n\t\t\tfloat2 inputs:scale = ${buildVector2(p)}\n\t\t\tfloat2 inputs:translation = ${buildVector2(A)}\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Texture_${s.id}_${o}"\n\t\t{\n\t\t\tuniform token info:id = "UsdUVTexture"\n\t\t\tasset inputs:file = @textures/Texture_${c}.png@\n\t\t\tfloat2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${o}.outputs:result>\n\t\t\t${void 0!==l?"float4 inputs:scale = "+function buildColor4(e){return`(${e.r}, ${e.g}, ${e.b}, 1.0)`}(l):""}\n\t\t\ttoken inputs:sourceColorSpace = "${s.colorSpace===Ge?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${d[s.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${d[s.wrapT]}"\n\t\t\tfloat outputs:r\n\t\t\tfloat outputs:g\n\t\t\tfloat outputs:b\n\t\t\tfloat3 outputs:rgb\n\t\t\t${e.transparent||e.alphaTest>0?"float outputs:a":""}\n\t\t}`}return 2===e.side&&kp.warn("THREE.USDZExporter: USDZ does not support double sided materials",e),null!==e.map?(o.push(`${s}color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`),e.transparent?o.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`):e.alphaTest>0&&(o.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`),o.push(`${s}float inputs:opacityThreshold = ${e.alphaTest}`)),l.push(buildTexture(e.map,"diffuse",e.color))):o.push(`${s}color3f inputs:diffuseColor = ${buildColor(e.color)}`),null!==e.emissiveMap?(o.push(`${s}color3f inputs:emissiveColor.connect = </Materials/Material_${e.id}/Texture_${e.emissiveMap.id}_emissive.outputs:rgb>`),l.push(buildTexture(e.emissiveMap,"emissive"))):e.emissive.getHex()>0&&o.push(`${s}color3f inputs:emissiveColor = ${buildColor(e.emissive)}`),null!==e.normalMap&&(o.push(`${s}normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`),l.push(buildTexture(e.normalMap,"normal"))),null!==e.aoMap&&(o.push(`${s}float inputs:occlusion.connect = </Materials/Material_${e.id}/Texture_${e.aoMap.id}_occlusion.outputs:r>`),l.push(buildTexture(e.aoMap,"occlusion"))),null!==e.roughnessMap&&1===e.roughness?(o.push(`${s}float inputs:roughness.connect = </Materials/Material_${e.id}/Texture_${e.roughnessMap.id}_roughness.outputs:g>`),l.push(buildTexture(e.roughnessMap,"roughness"))):o.push(`${s}float inputs:roughness = ${e.roughness}`),null!==e.metalnessMap&&1===e.metalness?(o.push(`${s}float inputs:metallic.connect = </Materials/Material_${e.id}/Texture_${e.metalnessMap.id}_metallic.outputs:b>`),l.push(buildTexture(e.metalnessMap,"metallic"))):o.push(`${s}float inputs:metallic = ${e.metalness}`),null!==e.alphaMap?(o.push(`${s}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`),o.push(`${s}float inputs:opacityThreshold = 0.0001`),l.push(buildTexture(e.alphaMap,"opacity"))):o.push(`${s}float inputs:opacity = ${e.opacity}`),e.isMeshPhysicalMaterial&&(o.push(`${s}float inputs:clearcoat = ${e.clearcoat}`),o.push(`${s}float inputs:clearcoatRoughness = ${e.clearcoatRoughness}`),o.push(`${s}float inputs:ior = ${e.ior}`)),`\n\tdef Material "Material_${e.id}"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n${o.join("\n")}\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = </Materials/Material_${e.id}/PreviewSurface.outputs:surface>\n\n${l.join("\n")}\n\n\t}\n`}function buildColor(e){return`(${e.r}, ${e.g}, ${e.b})`}function buildVector2(e){return`(${e.x}, ${e.y})`}var Vp=r(6763),ar_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};let Hp=!1,zp=!1;const Wp="#model-viewer-no-ar-fallback",qp=(jp=["quick-look","scene-viewer","webxr","none"],e=>{try{const t=dl(e),r=(t.length?t[0].terms:[]).filter((e=>e&&"ident"===e.type)).map((e=>e.value)).filter((e=>jp.indexOf(e)>-1));return new Set(r)}catch(e){}return new Set});var jp;const Xp="quick-look",Yp="scene-viewer",Kp="webxr",Jp="none",$p=Symbol("arButtonContainer"),Zp=Symbol("enterARWithWebXR"),eA=Symbol("openSceneViewer"),tA=Symbol("openIOSARQuickLook"),iA=Symbol("canActivateAR"),nA=Symbol("arMode"),rA=Symbol("arModes"),sA=Symbol("arAnchor"),aA=Symbol("preload"),oA=Symbol("onARButtonContainerClick"),lA=Symbol("onARStatus"),cA=Symbol("onARTracking"),hA=Symbol("onARTap"),uA=Symbol("selectARMode"),dA=Symbol("triggerLoad");var loading_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const pA="auto",AA="auto",mA="eager",fA=Symbol("defaultProgressBarElement"),gA=Symbol("posterContainerElement"),_A=Symbol("defaultPosterElement"),vA=Symbol("shouldDismissPoster"),yA=Symbol("hidePoster"),EA=Symbol("modelIsRevealed"),xA=Symbol("updateProgressBar"),SA=Symbol("ariaLabelCallToAction"),MA=Symbol("onProgress");var staging_decorate=function(e,t,r,s){var o,l=arguments.length,c=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var h=e.length-1;h>=0;h--)(o=e[h])&&(c=(l<3?o(c):l>3?o(t,r,c):o(t,r))||c);return l>3&&c&&Object.defineProperty(t,r,c),c};const CA=Math.PI/32,bA={basis:[degreesToRadians(numberNode(CA,"rad"))],keywords:{auto:[null]}},wA=Symbol("autoRotateStartTime"),IA=Symbol("radiansPerSecond"),TA=Symbol("syncRotationRate"),BA=Symbol("onCameraChange"),RA=(e=>{var t,r,s;class AnnotationModelViewerElement extends e{constructor(){super(...arguments),this[t]=new Map,this[r]=e=>{e.forEach((e=>{e instanceof MutationRecord&&"childList"!==e.type||(e.addedNodes.forEach((e=>{this[Ap](e)})),e.removedNodes.forEach((e=>{this[mp](e)})),this[Zd]())}))},this[s]=new MutationObserver(this[dp])}connectedCallback(){super.connectedCallback();for(let e=0;e<this.children.length;++e)this[Ap](this.children[e]);const{ShadyDOM:e}=self;null==e?this[pp].observe(this,{childList:!0}):this[pp]=e.observeChildren(this,this[dp])}disconnectedCallback(){super.disconnectedCallback();const{ShadyDOM:e}=self;null==e?this[pp].disconnect():e.unobserveChildren(this[pp])}[(t=up,r=dp,s=pp,ep)](e,t){super[ep](e,t);const r=this[$d],{annotationRenderer:s}=r,o=r.getCamera();r.shouldRender()&&(r.updateSurfaceHotspots(),r.updateHotspotsVisibility(o.position),s.domElement.style.display="",s.render(r,o))}updateHotspot(e){const t=this[up].get(e.name);null!=t&&(t.updatePosition(e.position),t.updateNormal(e.normal),t.surface=e.surface,this[Zd]())}queryHotspot(e){const t=this[up].get(e);if(null==t)return null;const r=toVector3D(t.position),s=toVector3D(t.normal),o=t.facingCamera,l=this[$d],c=l.getCamera(),h=new three_module_Vector3;h.setFromMatrixPosition(t.matrixWorld),h.project(c);const d=l.width/2,p=l.height/2;h.x=h.x*d+d,h.y=-h.y*p+p;const A=toVector3D(new three_module_Vector3(h.x,h.y,h.z));return Number.isFinite(A.x)&&Number.isFinite(A.y)?{position:r,normal:s,canvasPosition:A,facingCamera:o}:null}positionAndNormalFromPoint(e,t){const r=this[$d],s=r.getNDC(e,t),o=r.positionAndNormalFromPoint(s);if(null==o)return null;fp.copy(r.target.matrixWorld).invert();const l=toVector3D(o.position.applyMatrix4(fp)),c=toVector3D(o.normal.transformDirection(fp));let h=null;return null!=o.uv&&(h=toVector2D(o.uv)),{position:l,normal:c,uv:h}}surfaceFromPoint(e,t){const r=this[$d],s=r.getNDC(e,t);return r.surfaceFromPoint(s)}[Ap](e){if(!(e instanceof HTMLElement&&0===e.slot.indexOf("hotspot")))return;let t=this[up].get(e.slot);null!=t?t.increment():(t=new Hotspot({name:e.slot,position:e.dataset.position,normal:e.dataset.normal,surface:e.dataset.surface}),this[up].set(e.slot,t),this[$d].addHotspot(t)),this[$d].queueRender()}[mp](e){if(!(e instanceof HTMLElement))return;const t=this[up].get(e.slot);t&&(t.decrement()&&(this[$d].removeHotspot(t),this[up].delete(e.slot)),this[$d].queueRender())}}return AnnotationModelViewerElement})((e=>{var t,r,s;class SceneGraphModelViewerElement extends e{constructor(){super(...arguments),this[t]=void 0,this[r]=null,this[s]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[Ku]}get availableVariants(){return this.model?this.model[Wu]():[]}get originalGltfJson(){return this[Yu]}[(t=Ku,r=Xu,s=Yu,Ju)](){return()=>{this[Zd]()}}[$u](e){return e.colorSpace=Ve,e.wrapS=J,e.wrapT=J,new texture_Texture(this[Ju](),e)}async createTexture(e,t="image/png"){const{textureUtils:r}=this[np],s=await r.loadImage(e);return s.userData.mimeType=t,this[$u](s)}async createLottieTexture(e,t=1){const{textureUtils:r}=this[np],s=await r.loadLottie(e,t);return this[$u](s)}createVideoTexture(e){const t=document.createElement("video");t.crossOrigin=this.withCredentials?"use-credentials":"anonymous",t.src=e,t.muted=!0,t.playsInline=!0,t.loop=!0,t.play();const r=new VideoTexture(t);return this[$u](r)}createCanvasTexture(){const e=document.createElement("canvas"),t=new CanvasTexture(e);return this[$u](t)}async updated(e){if(super.updated(e),e.has("variantName")){const e=this[rp].beginActivity("variant-update");e(.1);const t=this[Ku],{variantName:r}=this;null!=t&&(await t[ku](r),this[Zd](),this.dispatchEvent(new CustomEvent("variant-applied"))),e(1)}if(e.has("orientation")||e.has("scale")){if(!this.loaded)return;const e=this[$d];e.applyTransform(),e.updateBoundingBox(),e.updateShadow(),this[np].arRenderer.onUpdateScene(),this[Zd]()}}[tp](){super[tp]();const{currentGLTF:e}=this[$d];if(null!=e){const{correlatedSceneGraph:t}=e;null!=t&&e!==this[Xu]&&(this[Ku]=new Model(t,this[Ju]()),this[Yu]=JSON.parse(JSON.stringify(t.gltf))),"variants"in e.userData&&this.requestUpdate("variantName")}this[Xu]=e}async exportScene(e){const t=this[$d];return new Promise((async(r,s)=>{const o={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(o,e),o.animations=t.animations,o.truncateDrawRange=!0;const l=t.shadow;let c=!1;null!=l&&(c=l.visible,l.visible=!1),await this[Ku][Qu]();(new GLTFExporter).register((e=>new GLTFExporterMaterialsVariantsExtension(e))).parse(t.model,(e=>r(new Blob([o.binary?e:JSON.stringify(e)],{type:o.binary?"application/octet-stream":"application/json"}))),(()=>s("glTF export failed")),o),null!=l&&(l.visible=c)}))}materialFromPoint(e,t){const r=this[Ku];if(null==r)return null;const s=this[$d],o=s.getNDC(e,t),l=s.hitFromPoint(o);return null==l||null==l.face?null:r[Gu](l)}}return scene_graph_decorate([n({type:String,attribute:"variant-name"})],SceneGraphModelViewerElement.prototype,"variantName",void 0),scene_graph_decorate([n({type:String,attribute:"orientation"})],SceneGraphModelViewerElement.prototype,"orientation",void 0),scene_graph_decorate([n({type:String,attribute:"scale"})],SceneGraphModelViewerElement.prototype,"scale",void 0),SceneGraphModelViewerElement})((e=>{var t,r,s;class StagingModelViewerElement extends e{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=3e3,this.rotationPerSecond="auto",this[t]=performance.now(),this[r]=0,this[s]=e=>{this.autoRotate&&"user-interaction"===e.detail.source&&(this[wA]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[BA]),this[wA]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[BA]),this[wA]=performance.now()}updated(e){super.updated(e),e.has("autoRotate")&&(this[wA]=performance.now())}[(t=wA,r=IA,TA)](e){this[IA]=e[0]}[ep](e,t){if(super[ep](e,t),!this.autoRotate||!this[ap]()||this[np].isPresenting)return;const r=Math.min(t,e-this[wA]-this.autoRotateDelay);r>0&&(this[$d].yaw=this.turntableRotation+this[IA]*r*.001)}get turntableRotation(){return this[$d].yaw}resetTurntableRotation(e=0){this[$d].yaw=e}}return s=BA,staging_decorate([n({type:Boolean,attribute:"auto-rotate"})],StagingModelViewerElement.prototype,"autoRotate",void 0),staging_decorate([n({type:Number,attribute:"auto-rotate-delay"})],StagingModelViewerElement.prototype,"autoRotateDelay",void 0),staging_decorate([style({intrinsics:bA,updateHandler:TA}),n({type:String,attribute:"rotation-per-second"})],StagingModelViewerElement.prototype,"rotationPerSecond",void 0),StagingModelViewerElement})((e=>{var t,r,s;class EnvironmentModelViewerElement extends e{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=0,this.shadowSoftness=1,this.exposure=1,this.toneMapping="auto",this.skyboxHeight="0",this[t]=null,this[r]=null,this[s]=null}updated(e){super.updated(e),e.has("shadowIntensity")&&(this[$d].setShadowIntensity(.5*this.shadowIntensity),this[Zd]()),e.has("shadowSoftness")&&(this[$d].setShadowSoftness(this.shadowSoftness),this[Zd]()),e.has("exposure")&&(this[$d].exposure=this.exposure,this[Zd]()),e.has("toneMapping")&&(this[$d].toneMapping="commerce"===this.toneMapping?5:"agx"===this.toneMapping?6:4,this[Zd]()),(e.has("environmentImage")||e.has("skyboxImage"))&&this[op]()&&this[ra](),e.has("skyboxHeight")&&(this[$d].setGroundedSkybox(),this[Zd]())}hasBakedShadow(){return this[$d].bakedShadows.size>0}async[(t=ia,r=na,s=sa,ra)](){const{skyboxImage:e,environmentImage:t}=this;null!=this[sa]&&(this[sa](),this[sa]=null);const{textureUtils:r}=this[np];if(null==r)return;const s=this[rp].beginActivity("environment-update");try{const{environmentMap:o,skybox:l}=await r.generateEnvironmentMapAndSkybox(deserializeUrl(e),t,(e=>s(utilities_clamp(e,0,1))));this[ia]!==o&&(this[ia]=o,this.dispatchEvent(new CustomEvent("environment-change"))),this[na]=null!=l?l.name===o.name?o:l:null,this[$d].setEnvironmentAndSkybox(this[ia],this[na])}catch(e){if(e instanceof Error)throw this[$d].setEnvironmentAndSkybox(null,null),e}finally{s(1)}}}return __decorate([n({type:String,attribute:"environment-image"})],EnvironmentModelViewerElement.prototype,"environmentImage",void 0),__decorate([n({type:String,attribute:"skybox-image"})],EnvironmentModelViewerElement.prototype,"skyboxImage",void 0),__decorate([n({type:Number,attribute:"shadow-intensity"})],EnvironmentModelViewerElement.prototype,"shadowIntensity",void 0),__decorate([n({type:Number,attribute:"shadow-softness"})],EnvironmentModelViewerElement.prototype,"shadowSoftness",void 0),__decorate([n({type:Number})],EnvironmentModelViewerElement.prototype,"exposure",void 0),__decorate([n({type:String,attribute:"tone-mapping"})],EnvironmentModelViewerElement.prototype,"toneMapping",void 0),__decorate([n({type:String,attribute:"skybox-height"})],EnvironmentModelViewerElement.prototype,"skyboxHeight",void 0),EnvironmentModelViewerElement})((e=>{var t,r,s,o,l,c,h,d,p,A,m,f,g,_,y,x,S;class ControlsModelViewerElement extends e{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=$l,this.cameraTarget="auto auto auto",this.fieldOfView="auto",this.minCameraOrbit="auto",this.maxCameraOrbit="auto",this.minFieldOfView="auto",this.maxFieldOfView="auto",this.interactionPromptThreshold=3e3,this.interactionPrompt=tc,this.interactionPromptStyle=nc,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.touchAction=rc,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=50,this[t]=this.shadowRoot.querySelector(".interaction-prompt"),this[r]=this.shadowRoot.querySelector("#prompt"),this[s]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[o]=this.shadowRoot.querySelector(".pan-target"),this[l]=0,this[c]=1/0,this[h]=!1,this[d]=!1,this[p]=Hc.AUTOMATIC,this[A]=new SmoothControls(this[$d].camera,this[Kd],this[$d]),this[m]=new Spherical,this[f]=!1,this[g]=!1,this[_]=!1,this[y]=()=>{const e=this[uc].changeSource;this[bc]=e,e===Hc.USER_INTERACTION&&(this[Sc]=!0,this[fc]())},this[x]=()=>{this[gc](),this[Zd]();const e=this[uc].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:e}}))},this[S]=e=>{this[Yd].classList.toggle("pointer-tumbling","pointer-change-start"===e.type)}}get inputSensitivity(){return this[uc].inputSensitivity}set inputSensitivity(e){this[uc].inputSensitivity=e}getCameraOrbit(){const{theta:e,phi:t,radius:r}=this[wc];return{theta:e,phi:t,radius:r,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return toVector3D(this[np].isPresenting?this[np].arRenderer.target:this[$d].getTarget())}getFieldOfView(){return this[uc].getFieldOfView()}getMinimumFieldOfView(){return this[uc].options.minimumFieldOfView}getMaximumFieldOfView(){return this[uc].options.maximumFieldOfView}getIdealAspect(){return this[$d].idealAspect}jumpCameraToGoal(){this[Ic]=!0,this.requestUpdate(Ic,!1)}resetInteractionPrompt(){this[Cc]=0,this[Mc]=1/0,this[Sc]=!1,this[xc]=this.interactionPrompt===tc&&this.cameraControls}zoom(e){const t=new WheelEvent("wheel",{deltaY:-30*e});this[Kd].dispatchEvent(t)}connectedCallback(){super.connectedCallback(),this[uc].addEventListener("user-interaction",this[vc]),this[uc].addEventListener("pointer-change-start",this[Ec]),this[uc].addEventListener("pointer-change-end",this[Ec])}disconnectedCallback(){super.disconnectedCallback(),this[uc].removeEventListener("user-interaction",this[vc]),this[uc].removeEventListener("pointer-change-start",this[Ec]),this[uc].removeEventListener("pointer-change-end",this[Ec])}updated(e){super.updated(e);const t=this[uc],r=this[$d];if(e.has("cameraControls")&&(this.cameraControls?(t.enableInteraction(),this.interactionPrompt===tc&&(this[xc]=!0)):(t.disableInteraction(),this[fc]()),this[Kd].setAttribute("aria-label",this[Vd])),e.has("disableZoom")&&(t.disableZoom=this.disableZoom),e.has("disablePan")&&(t.enablePan=!this.disablePan),e.has("disableTap")&&(t.enableTap=!this.disableTap),(e.has("interactionPrompt")||e.has("cameraControls")||e.has("src"))&&(this.interactionPrompt===tc&&this.cameraControls&&!this[Sc]?this[xc]=!0:this[fc]()),e.has("interactionPromptStyle")&&(this[Ac].style.opacity=this.interactionPromptStyle==ic?"1":"0"),e.has("touchAction")){const e=this.touchAction;t.applyOptions({touchAction:e}),t.updateTouchActionStyle()}e.has("orbitSensitivity")&&(t.orbitSensitivity=this.orbitSensitivity),e.has("zoomSensitivity")&&(t.zoomSensitivity=this.zoomSensitivity),e.has("panSensitivity")&&(t.panSensitivity=this.panSensitivity),e.has("interpolationDecay")&&(t.setDamperDecayTime(this.interpolationDecay),r.setTargetDamperDecayTime(this.interpolationDecay)),!0===this[Ic]&&Promise.resolve().then((()=>{t.jumpToGoal(),r.jumpToGoal(),this[yc](),this[Ic]=!1}))}async updateFraming(){const e=this[$d],t=e.adjustedFoV(e.framedFoVDeg);await e.updateFraming();const r=e.adjustedFoV(e.framedFoVDeg),s=this[uc].getFieldOfView()/t;this[uc].setFieldOfView(r*s),this[Bc]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(e,t,r){const s=this[Kd],o=this[mc];if("1"===o[0].style.opacity)return void Yl.warn("interact() failed because an existing interaction is running.");const l=new Array;l.push({x:timeline(t.x),y:timeline(t.y)});const c=[{x:l[0].x(0),y:l[0].y(0)}];null!=r&&(l.push({x:timeline(r.x),y:timeline(r.y)}),c.push({x:l[1].x(0),y:l[1].y(0)}));let h=performance.now();const{width:d,height:p}=this[$d],A=this.getBoundingClientRect(),dispatchTouches=e=>{for(const[t,r]of c.entries()){const{style:l}=o[t];l.transform=`translateX(${d*r.x}px) translateY(${p*r.y}px)`,"pointerdown"===e?l.opacity="1":"pointerup"===e&&(l.opacity="0");const c={pointerId:t-5678,pointerType:"touch",target:s,clientX:d*r.x+A.x,clientY:p*r.y+A.y,altKey:!0};s.dispatchEvent(new PointerEvent(e,c))}},moveTouches=()=>{const t=this[bc];if(t!==Hc.AUTOMATIC||!s.isConnected){for(const e of this[mc])e.style.opacity="0";return dispatchTouches("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:t}})),void document.removeEventListener("visibilitychange",onVisibilityChange)}const r=Math.min(1,(performance.now()-h)/e);for(const[e,t]of c.entries())t.x=l[e].x(r),t.y=l[e].y(r);dispatchTouches("pointermove"),r<1?requestAnimationFrame(moveTouches):(dispatchTouches("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:Hc.AUTOMATIC}})),document.removeEventListener("visibilitychange",onVisibilityChange))},onVisibilityChange=()=>{let e=0;"hidden"===document.visibilityState?e=performance.now()-h:h=performance.now()-e};document.addEventListener("visibilitychange",onVisibilityChange),dispatchTouches("pointerdown"),this[bc]=Hc.AUTOMATIC,requestAnimationFrame(moveTouches)}[(t=pc,r=Ac,s=mc,o=dc,l=Cc,c=Mc,h=Sc,d=xc,p=bc,A=uc,m=wc,f=Ic,g=Tc,_=Bc,Lc)](e){const t=this[uc],r=this[$d];r.framedFoVDeg=180*e[0]/Math.PI,t.changeSource=Hc.NONE,t.setFieldOfView(r.adjustedFoV(r.framedFoVDeg)),this[vc]()}[Rc](e){const t=this[uc];if(this[Bc]){const{theta:t,phi:r}=this.getCameraOrbit();e[0]=t,e[1]=r,this[Bc]=!1}t.changeSource=Hc.NONE,t.setOrbit(e[0],e[1],e[2]),this[vc]()}[Uc](e){this[uc].applyOptions({minimumAzimuthalAngle:e[0],minimumPolarAngle:e[1],minimumRadius:e[2]}),this.jumpCameraToGoal()}[Pc](e){this[uc].applyOptions({maximumAzimuthalAngle:e[0],maximumPolarAngle:e[1],maximumRadius:e[2]}),this[_c](e[2]),this.jumpCameraToGoal()}[Fc](e){this[uc].applyOptions({minimumFieldOfView:180*e[0]/Math.PI}),this.jumpCameraToGoal()}[Nc](e){const t=this[$d].adjustedFoV(180*e[0]/Math.PI);this[uc].applyOptions({maximumFieldOfView:t}),this.jumpCameraToGoal()}[Dc](e){const[t,r,s]=e;this[np].arRenderer.isPresenting||this[$d].setTarget(t,r,s),this[uc].changeSource=Hc.NONE,this[np].arRenderer.updateTarget(),this[vc]()}[ep](e,t){if(super[ep](e,t),this[np].isPresenting||!this[ap]())return;const r=this[uc],s=this[$d],o=performance.now();if(this[xc]&&this.loaded&&o>this[qd]+this.interactionPromptThreshold&&(this[xc]=!1,this[Mc]=o,this[pc].classList.add("visible")),isFinite(this[Mc])&&this.interactionPromptStyle===nc){const e=(o-this[Mc])/5e3%1,t=Kl(e),l=Jl(e);if(this[Ac].style.opacity=`${l}`,t!==this[Cc]){const e=t*s.width*.05,o=(t-this[Cc])*Math.PI/16;this[Ac].style.transform=`translateX(${e}px)`,r.changeSource=Hc.AUTOMATIC,r.adjustOrbit(o,0,0),this[Cc]=t}}const l=r.update(e,t),c=s.updateTarget(t);(l||c)&&this[yc]()}[fc](){this[xc]=!1,this[pc].classList.remove("visible"),this[Mc]=1/0}[_c](e){const t=Math.max(this[$d].farRadius(),e),r=Math.abs(2*t);this[uc].updateNearFar(0,r)}[gc](){const{theta:e,phi:t}=this[uc].getCameraSpherical(this[wc]),r=(4+Math.floor((e%hc+cc)/ac))%4,s=Math.floor(t/oc),o=Zl[r],l=ec[s];this[Wd](`View from stage ${l}${o}`)}get[Vd](){return super[Vd].replace(/\.$/,"")+(this.cameraControls?". Use mouse, touch or arrow keys to move.":"")}async[ip](e){const t=this[uc],r=this[$d],s=r.adjustedFoV(r.framedFoVDeg);super[ip](e);const o=r.adjustedFoV(r.framedFoVDeg)/s,l=t.getFieldOfView()*(isFinite(o)?o:1);t.updateAspect(this[$d].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[uc].setFieldOfView(l),this.jumpCameraToGoal()}[tp](){super[tp](),this[Tc]?this[Bc]=!0:this[Tc]=!0,this.requestUpdate("maxFieldOfView",this.maxFieldOfView),this.requestUpdate("fieldOfView",this.fieldOfView),this.requestUpdate("minCameraOrbit",this.minCameraOrbit),this.requestUpdate("maxCameraOrbit",this.maxCameraOrbit),this.requestUpdate("cameraOrbit",this.cameraOrbit),this.requestUpdate("cameraTarget",this.cameraTarget),this.jumpCameraToGoal()}}return y=vc,x=yc,S=Ec,controls_decorate([n({type:Boolean,attribute:"camera-controls"})],ControlsModelViewerElement.prototype,"cameraControls",void 0),controls_decorate([style({intrinsics:sc,observeEffects:!0,updateHandler:Rc}),n({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"cameraOrbit",void 0),controls_decorate([style({intrinsics:cameraTargetIntrinsics,observeEffects:!0,updateHandler:Dc}),n({type:String,attribute:"camera-target",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"cameraTarget",void 0),controls_decorate([style({intrinsics:fieldOfViewIntrinsics,observeEffects:!0,updateHandler:Lc}),n({type:String,attribute:"field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"fieldOfView",void 0),controls_decorate([style({intrinsics:minCameraOrbitIntrinsics,updateHandler:Uc}),n({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"minCameraOrbit",void 0),controls_decorate([style({intrinsics:maxCameraOrbitIntrinsics,updateHandler:Pc}),n({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"maxCameraOrbit",void 0),controls_decorate([style({intrinsics:minFieldOfViewIntrinsics,updateHandler:Fc}),n({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"minFieldOfView",void 0),controls_decorate([style({intrinsics:fieldOfViewIntrinsics,updateHandler:Nc}),n({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"maxFieldOfView",void 0),controls_decorate([n({type:Number,attribute:"interaction-prompt-threshold"})],ControlsModelViewerElement.prototype,"interactionPromptThreshold",void 0),controls_decorate([n({type:String,attribute:"interaction-prompt"})],ControlsModelViewerElement.prototype,"interactionPrompt",void 0),controls_decorate([n({type:String,attribute:"interaction-prompt-style"})],ControlsModelViewerElement.prototype,"interactionPromptStyle",void 0),controls_decorate([n({type:Number,attribute:"orbit-sensitivity"})],ControlsModelViewerElement.prototype,"orbitSensitivity",void 0),controls_decorate([n({type:Number,attribute:"zoom-sensitivity"})],ControlsModelViewerElement.prototype,"zoomSensitivity",void 0),controls_decorate([n({type:Number,attribute:"pan-sensitivity"})],ControlsModelViewerElement.prototype,"panSensitivity",void 0),controls_decorate([n({type:String,attribute:"touch-action"})],ControlsModelViewerElement.prototype,"touchAction",void 0),controls_decorate([n({type:Boolean,attribute:"disable-zoom"})],ControlsModelViewerElement.prototype,"disableZoom",void 0),controls_decorate([n({type:Boolean,attribute:"disable-pan"})],ControlsModelViewerElement.prototype,"disablePan",void 0),controls_decorate([n({type:Boolean,attribute:"disable-tap"})],ControlsModelViewerElement.prototype,"disableTap",void 0),controls_decorate([n({type:Number,attribute:"interpolation-decay"})],ControlsModelViewerElement.prototype,"interpolationDecay",void 0),ControlsModelViewerElement})((e=>{var t,r,s,o,l,c,h,d,p,A;class ARModelViewerElement extends e{constructor(){super(...arguments),this.ar=!1,this.arScale="auto",this.arPlacement="floor",this.arModes="webxr scene-viewer quick-look",this.iosSrc=null,this.xrEnvironment=!1,this[t]=!1,this[r]=this.shadowRoot.querySelector(".ar-button"),this[s]=document.createElement("a"),this[o]=new Set,this[l]=Jp,this[c]=!1,this[h]=e=>{e.preventDefault(),this.activateAR()},this[d]=({status:e})=>{e!==qc&&this[np].arRenderer.presentedScene!==this[$d]||(this.setAttribute("ar-status",e),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:e}})),e===qc?this.removeAttribute("ar-tracking"):e===jc&&this.setAttribute("ar-tracking",Kc))},this[p]=({status:e})=>{this.setAttribute("ar-tracking",e),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:e}}))},this[A]=e=>{"_apple_ar_quicklook_button_tapped"==e.data&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[nA]!==Jp}connectedCallback(){super.connectedCallback(),this[np].arRenderer.addEventListener("status",this[lA]),this.setAttribute("ar-status",qc),this[np].arRenderer.addEventListener("tracking",this[cA]),this[sA].addEventListener("message",this[hA])}disconnectedCallback(){super.disconnectedCallback(),this[np].arRenderer.removeEventListener("status",this[lA]),this[np].arRenderer.removeEventListener("tracking",this[cA]),this[sA].removeEventListener("message",this[hA])}update(e){super.update(e),e.has("arScale")&&(this[$d].canScale="fixed"!==this.arScale),e.has("arPlacement")&&(this[$d].updateShadow(),this[Zd]()),e.has("arModes")&&(this[rA]=qp(this.arModes)),(e.has("ar")||e.has("arModes")||e.has("src")||e.has("iosSrc"))&&this[uA]()}async activateAR(){switch(this[nA]){case Xp:await this[tA]();break;case Kp:await this[Zp]();break;case Yp:this[eA]();break;default:Vp.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities")}}async[(t=iA,r=$p,s=sA,o=rA,l=nA,c=aA,h=oA,d=lA,p=cA,A=hA,uA)](){let e=Jp;if(this.ar){if(null!=this.src)for(const t of this[rA]){if("webxr"===t&&Ws&&!Hp&&await this[np].arRenderer.supportsPresentation()){e=Kp;break}if("scene-viewer"===t&&Ks&&!zp){e=Yp;break}if("quick-look"===t&&$s){e=Xp;break}}e===Jp&&null!=this.iosSrc&&$s&&(e=Xp)}if(e!==Jp)this[$p].classList.add("enabled"),this[$p].addEventListener("click",this[oA]);else if(this[$p].classList.contains("enabled")){this[$p].removeEventListener("click",this[oA]),this[$p].classList.remove("enabled");const e=Yc;this.setAttribute("ar-status",e),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:e}}))}this[nA]=e}async[Zp](){Vp.log("Attempting to present in AR with WebXR..."),await this[dA]();try{this[$p].removeEventListener("click",this[oA]);const{arRenderer:e}=this[np];e.placeOnWall="wall"===this.arPlacement,await e.present(this[$d],this.xrEnvironment)}catch(e){Vp.warn("Error while trying to present in AR with WebXR"),Vp.error(e),await this[np].arRenderer.stopPresenting(),Hp=!0,Vp.warn("Falling back to next ar-mode"),await this[uA](),this.activateAR()}finally{this[uA]()}}async[dA](){this.loaded||(this[aA]=!0,this[jd](),await((e,t,r=null)=>new Promise((s=>{e.addEventListener(t,(function handler(o){r&&!r(o)||(s(o),e.removeEventListener(t,handler))}))})))(this,"load"),this[aA]=!1)}[op](){return super[op]()||this[aA]}[eA](){const e=self.location.toString(),t=new URL(e),r=new URL(this.src,e);r.hash&&(r.hash="");const s=new URLSearchParams(r.search);if(t.hash=Wp,s.set("mode","ar_preferred"),s.has("disable_occlusion")||s.set("disable_occlusion","true"),"fixed"===this.arScale&&s.set("resizable","false"),"wall"===this.arPlacement&&s.set("enable_vertical_placement","true"),s.has("sound")){const t=new URL(s.get("sound"),e);s.set("sound",t.toString())}if(s.has("link")){const t=new URL(s.get("link"),e);s.set("link",t.toString())}const o=`intent://arvr.google.com/scene-viewer/1.0?${s.toString()+"&file="+encodeURIComponent(r.toString())}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(t.toString())};end;`;self.addEventListener("hashchange",(()=>{self.location.hash===Wp&&(zp=!0,self.history.back(),Vp.warn("Error while trying to present in AR with Scene Viewer"),Vp.warn("Falling back to next ar-mode"),this[uA]())}),{once:!0}),this[sA].setAttribute("href",o),Vp.log("Attempting to present in AR with Scene Viewer..."),this[sA].click()}async[tA](){const e=!this.iosSrc;this[$p].classList.remove("enabled");const t=e?await this.prepareUSDZ():this.iosSrc,r=new URL(t,self.location.toString());if(e){const e=self.location.toString(),t=new URL(e),s=new URL(this.src,t);s.hash&&(r.hash=s.hash)}"fixed"===this.arScale&&(r.hash&&(r.hash+="&"),r.hash+="allowsContentScaling=0");const s=this[sA];s.setAttribute("rel","ar");const o=document.createElement("img");s.appendChild(o),s.setAttribute("href",r.toString()),e&&s.setAttribute("download","model.usdz"),s.style.display="none",s.isConnected||this.shadowRoot.appendChild(s),Vp.log("Attempting to present in AR with Quick Look..."),s.click(),s.removeChild(o),e&&URL.revokeObjectURL(t),this[$p].classList.add("enabled")}async prepareUSDZ(){const e=this[rp].beginActivity("usdz-conversion");await this[dA]();const{model:t,shadow:r}=this[$d];if(null==t)return"";let s=!1;null!=r&&(s=r.visible,r.visible=!1),e(.2);const o=new USDZExporter,l=await o.parse(t),c=new Blob([l],{type:"model/vnd.usdz+zip"}),h=URL.createObjectURL(c);return e(1),null!=r&&(r.visible=s),h}}return ar_decorate([n({type:Boolean,attribute:"ar"})],ARModelViewerElement.prototype,"ar",void 0),ar_decorate([n({type:String,attribute:"ar-scale"})],ARModelViewerElement.prototype,"arScale",void 0),ar_decorate([n({type:String,attribute:"ar-placement"})],ARModelViewerElement.prototype,"arPlacement",void 0),ar_decorate([n({type:String,attribute:"ar-modes"})],ARModelViewerElement.prototype,"arModes",void 0),ar_decorate([n({type:String,attribute:"ios-src"})],ARModelViewerElement.prototype,"iosSrc",void 0),ar_decorate([n({type:Boolean,attribute:"xr-environment"})],ARModelViewerElement.prototype,"xrEnvironment",void 0),ARModelViewerElement})((e=>{var t,r,s,o,l,c,h,d;class LoadingModelViewerElement extends e{constructor(...e){super(...e),this.poster=null,this.reveal=pA,this.loading=AA,this[t]=!1,this[r]=!1,this[s]=this.shadowRoot.querySelector(".slot.poster"),this[o]=this.shadowRoot.querySelector("#default-poster"),this[l]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[c]=this[_A].getAttribute("aria-label"),this[h]=((e,t)=>{let r=null;const throttled=(...s)=>{null==r&&(e(...s),r=self.setTimeout((()=>r=null),t))};return throttled.flush=()=>{null!=r&&(self.clearTimeout(r),r=null)},throttled})((e=>{const t=this[fA].parentNode;requestAnimationFrame((()=>{this[fA].style.transform=`scaleX(${e})`,0===e&&(t.removeChild(this[fA]),t.appendChild(this[fA])),this[fA].classList.toggle("hide",1===e)}))}),100),this[d]=e=>{const t=e.detail.totalProgress;1===t&&(this[xA].flush(),this.loaded&&(this[vA]||this.reveal===pA)&&this[yA]()),this[xA](t),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:t}}))};const p=self.ModelViewerElement||{},A=p.dracoDecoderLocation||"https://www.gstatic.com/draco/versioned/decoders/1.5.6/";CachingGLTFLoader.setDRACODecoderLocation(A);const m=p.ktx2TranscoderLocation||"https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";CachingGLTFLoader.setKTX2TranscoderLocation(m),p.meshoptDecoderLocation&&CachingGLTFLoader.setMeshoptDecoderLocation(p.meshoptDecoderLocation);const f=p.lottieLoaderLocation||"https://cdn.jsdelivr.net/npm/three@0.149.0/examples/jsm/loaders/LottieLoader.js";Renderer.singleton.textureUtils.lottieLoaderUrl=f}static set dracoDecoderLocation(e){CachingGLTFLoader.setDRACODecoderLocation(e)}static get dracoDecoderLocation(){return CachingGLTFLoader.getDRACODecoderLocation()}static set ktx2TranscoderLocation(e){CachingGLTFLoader.setKTX2TranscoderLocation(e)}static get ktx2TranscoderLocation(){return CachingGLTFLoader.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(e){CachingGLTFLoader.setMeshoptDecoderLocation(e)}static get meshoptDecoderLocation(){return CachingGLTFLoader.getMeshoptDecoderLocation()}static set lottieLoaderLocation(e){Renderer.singleton.textureUtils.lottieLoaderUrl=e}static get lottieLoaderLocation(){return Renderer.singleton.textureUtils.lottieLoaderUrl}static mapURLs(e){Renderer.singleton.loader[xo].manager.setURLModifier(e)}dismissPoster(){this.loaded?this[yA]():(this[vA]=!0,this[jd]())}showPoster(){const e=this[gA];if(e.classList.contains("show"))return;e.classList.add("show"),this[Kd].classList.remove("show");const t=this[_A];t.removeAttribute("tabindex"),t.removeAttribute("aria-hidden");const r=this.modelIsVisible;this[EA]=!1,this[Gd](r)}getDimensions(){return toVector3D(this[$d].size)}getBoundingBoxCenter(){return toVector3D(this[$d].boundingBox.getCenter(new three_module_Vector3))}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[rp].addEventListener("progress",this[MA])}disconnectedCallback(){super.disconnectedCallback(),this[rp].removeEventListener("progress",this[MA])}async updated(e){super.updated(e),e.has("poster")&&null!=this.poster&&(this[_A].style.backgroundImage=`url(${this.poster})`),e.has("alt")&&this[_A].setAttribute("aria-label",this[Hd]),(e.has("reveal")||e.has("loading"))&&this[jd]()}[(t=EA,r=vA,s=gA,o=_A,l=fA,c=SA,h=xA,d=MA,op)](){return!!this.src&&(this[vA]||this.loading===mA||this.reveal===pA&&this[kd])}[yA](){this[vA]=!1;const e=this[gA];if(!e.classList.contains("show"))return;e.classList.remove("show"),this[Kd].classList.add("show");const t=this.modelIsVisible;this[EA]=!0,this[Gd](t);const r=this.getRootNode();r&&r.activeElement===this&&this[Kd].focus();const s=this[_A];s.setAttribute("aria-hidden","true"),s.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[ap](){return super[ap]()&&this[EA]}}return loading_decorate([n({type:String})],LoadingModelViewerElement.prototype,"poster",void 0),loading_decorate([n({type:String})],LoadingModelViewerElement.prototype,"reveal",void 0),loading_decorate([n({type:String})],LoadingModelViewerElement.prototype,"loading",void 0),LoadingModelViewerElement})((e=>{var t;class AnimationModelViewerElement extends e{constructor(...e){super(e),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[t]=!0,this[$d].subscribeMixerEvent("loop",(e=>{const t=e.action._loopCount;this.dispatchEvent(new CustomEvent("loop",{detail:{count:t}}))})),this[$d].subscribeMixerEvent("finished",(()=>{this[cp]=!0,this.dispatchEvent(new CustomEvent("finished"))}))}get availableAnimations(){return this.loaded?this[$d].animationNames:[]}get duration(){return this[$d].duration}get paused(){return this[cp]}get currentTime(){return this[$d].animationTime}set currentTime(e){this[$d].animationTime=e,this[Zd]()}get timeScale(){return this[$d].animationTimeScale}set timeScale(e){this[$d].animationTimeScale=e}pause(){this[cp]||(this[cp]=!0,this.dispatchEvent(new CustomEvent("pause")))}play(e){this.availableAnimations.length>0&&(this[cp]=!1,this[lp](e),this.dispatchEvent(new CustomEvent("play")))}[(t=cp,tp)](){super[tp](),this[cp]=!0,null!=this.animationName&&this[lp](),this.autoplay&&this.play()}[ep](e,t){super[ep](e,t),this[cp]||!this[ap]()&&!this[np].isPresenting||(this[$d].updateAnimation(t/1e3),this[Zd]())}updated(e){super.updated(e),e.has("autoplay")&&this.autoplay&&this.play(),e.has("animationName")&&this[lp]()}[lp](e=hp){var t;const r=null!==(t=e.repetitions)&&void 0!==t?t:1/0,s=e.pingpong?Le:1===r?2200:Re;this[$d].playAnimation(this.animationName,this.animationCrossfadeDuration/1e3,s,r),this[cp]&&(this[$d].updateAnimation(0),this[Zd]())}}return animation_decorate([n({type:Boolean})],AnimationModelViewerElement.prototype,"autoplay",void 0),animation_decorate([n({type:String,attribute:"animation-name"})],AnimationModelViewerElement.prototype,"animationName",void 0),animation_decorate([n({type:Number,attribute:"animation-crossfade-duration"})],AnimationModelViewerElement.prototype,"animationCrossfadeDuration",void 0),AnimationModelViewerElement})(ModelViewerElementBase))))))));customElements.define("model-viewer",RA)}}]);