Viewing File: /home/maglabs/julia/wp-content/plugins/3d-viewer/public/js/o3dviewer.js

/*! For license information please see o3dviewer.js.LICENSE.txt */
(()=>{"use strict";var e={594:(e,t,n)=>{n.d(t,{Z:()=>X});var r=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),i=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VERSION=void 0,e.VERSION="9.0.1"})),o=r(((e,t)=>{var n=e&&e.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};function r(e){return e&&0===e.length}function i(e){return null==e?[]:Object.keys(e)}function o(e){for(var t=[],n=Object.keys(e),r=0;r<n.length;r++)t.push(e[n[r]]);return t}function s(e,t){for(var n=[],r=i(e),o=0;o<r.length;o++){var s=r[o];n.push(t.call(null,e[s],s))}return n}function a(e,t){for(var n=[],r=0;r<e.length;r++)n.push(t.call(null,e[r],r));return n}function l(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];Array.isArray(r)?t=t.concat(l(r)):t.push(r)}return t}function c(e){return r(e)?void 0:e[0]}function u(e){var t=e&&e.length;return t?e[t-1]:void 0}function h(e,t){if(Array.isArray(e))for(var n=0;n<e.length;n++)t.call(null,e[n],n);else{if(!L(e))throw Error("non exhaustive match");var r=i(e);for(n=0;n<r.length;n++){var o=r[n],s=e[o];t.call(null,s,o)}}}function d(e){return"string"==typeof e}function p(e){return void 0===e}function f(e){return e instanceof Function}function m(e,t){return void 0===t&&(t=1),e.slice(t,e.length)}function g(e,t){return void 0===t&&(t=1),e.slice(0,e.length-t)}function v(e,t){var n=[];if(Array.isArray(e))for(var r=0;r<e.length;r++){var i=e[r];t.call(null,i)&&n.push(i)}return n}function y(e,t){return v(e,(function(e){return!t(e)}))}function x(e,t){for(var n=Object.keys(e),r={},i=0;i<n.length;i++){var o=n[i],s=e[o];t(s)&&(r[o]=s)}return r}function _(e,t){return!!L(e)&&e.hasOwnProperty(t)}function T(e,t){return void 0!==b(e,(function(e){return e===t}))}function E(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n]);return t}function M(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}function b(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(t.call(null,r))return r}}function S(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r];t.call(null,i)&&n.push(i)}return n}function w(e,t,n){for(var r=Array.isArray(e),s=r?e:o(e),a=r?[]:i(e),l=n,c=0;c<s.length;c++)l=t.call(null,l,s[c],r?c:a[c]);return l}function A(e){return y(e,(function(e){return null==e}))}function C(e,t){void 0===t&&(t=function(e){return e});var n=[];return w(e,(function(e,r){var i=t(r);return T(n,i)?e:(n.push(i),e.concat(r))}),[])}function R(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=[null].concat(t);return Function.bind.apply(e,r)}function I(e){return Array.isArray(e)}function P(e){return e instanceof RegExp}function L(e){return e instanceof Object}function N(e,t){for(var n=0;n<e.length;n++)if(!t(e[n],n))return!1;return!0}function O(e,t){return y(e,(function(e){return T(t,e)}))}function U(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return!0;return!1}function D(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}function k(e,t){var n=E(e);return n.sort((function(e,n){return t(e)-t(n)})),n}function F(e,t){if(e.length!==t.length)throw Error("can't zipObject with different number of keys and values!");for(var n={},r=0;r<e.length;r++)n[e[r]]=t[r];return n}function G(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++)for(var o=t[r],s=i(o),a=0;a<s.length;a++){var l=s[a];e[l]=o[l]}return e}function B(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++)for(var o=t[r],s=i(o),a=0;a<s.length;a++){var l=s[a];_(e,l)||(e[l]=o[l])}return e}function V(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return B.apply(void 0,n([{}],e))}function z(e,t){var n={};return h(e,(function(e){var r=t(e),i=n[r];i?i.push(e):n[r]=[e]})),n}function H(e,t){for(var n=M(e),r=i(t),o=0;o<r.length;o++){var s=r[o],a=t[s];n[s]=a}return n}function W(){}function j(e){return e}function X(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(void 0!==r?r:void 0)}return t}function q(e){console&&console.error&&console.error("Error: "+e)}function Y(e){console&&console.warn&&console.warn("Warning: "+e)}function K(){return"function"==typeof Map}function Z(e){return e[e.length-1]}function J(e){var t=(new Date).getTime(),n=e();return{time:(new Date).getTime()-t,value:n}}function $(e){function t(){}t.prototype=e;var n=new t;function r(){return typeof n.bar}return r(),r(),e}Object.defineProperty(e,"__esModule",{value:!0}),e.toFastProperties=e.timer=e.peek=e.isES2015MapSupported=e.PRINT_WARNING=e.PRINT_ERROR=e.packArray=e.IDENTITY=e.NOOP=e.merge=e.groupBy=e.defaults=e.assignNoOverwrite=e.assign=e.zipObject=e.sortBy=e.indexOf=e.some=e.difference=e.every=e.isObject=e.isRegExp=e.isArray=e.partial=e.uniq=e.compact=e.reduce=e.findAll=e.find=e.cloneObj=e.cloneArr=e.contains=e.has=e.pick=e.reject=e.filter=e.dropRight=e.drop=e.isFunction=e.isUndefined=e.isString=e.forEach=e.last=e.first=e.flatten=e.map=e.mapValues=e.values=e.keys=e.isEmpty=void 0,e.isEmpty=r,e.keys=i,e.values=o,e.mapValues=s,e.map=a,e.flatten=l,e.first=c,e.last=u,e.forEach=h,e.isString=d,e.isUndefined=p,e.isFunction=f,e.drop=m,e.dropRight=g,e.filter=v,e.reject=y,e.pick=x,e.has=_,e.contains=T,e.cloneArr=E,e.cloneObj=M,e.find=b,e.findAll=S,e.reduce=w,e.compact=A,e.uniq=C,e.partial=R,e.isArray=I,e.isRegExp=P,e.isObject=L,e.every=N,e.difference=O,e.some=U,e.indexOf=D,e.sortBy=k,e.zipObject=F,e.assign=G,e.assignNoOverwrite=B,e.defaults=V,e.groupBy=z,e.merge=H,e.NOOP=W,e.IDENTITY=j,e.packArray=X,e.PRINT_ERROR=q,e.PRINT_WARNING=Y,e.isES2015MapSupported=K,e.peek=Z,e.timer=J,e.toFastProperties=$})),s=r(((e,t)=>{var n,r;n="undefined"!=typeof self?self:e,r=function(){function e(){}e.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},e.prototype.restoreState=function(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx},e.prototype.pattern=function(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");var t=this.disjunction();this.consumeChar("/");for(var n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":s(n,"global");break;case"i":s(n,"ignoreCase");break;case"m":s(n,"multiLine");break;case"u":s(n,"unicode");break;case"y":s(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:t,loc:this.loc(0)}},e.prototype.disjunction=function(){var e=[],t=this.idx;for(e.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}},e.prototype.alternative=function(){for(var e=[],t=this.idx;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}},e.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},e.prototype.assertion=function(){var e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":var t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead"}a(t);var n=this.disjunction();return this.consumeChar(")"),{type:t,value:n,loc:this.loc(e)}}!function(){throw Error("Internal Error - Should never get here!")}()},e.prototype.quantifier=function(e){var t,n=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":var r=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:r,atMost:r};break;case",":t=this.isDigit()?{atLeast:r,atMost:this.integerIncludingZero()}:{atLeast:r,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;a(t)}if(!0!==e||void 0!==t)return a(t),"?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(n),t},e.prototype.atom=function(){var e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group()}return void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),a(e),e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e},e.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[i("\n"),i("\r"),i("\u2028"),i("\u2029")]}},e.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},e.prototype.decimalEscapeAtom=function(){return{type:"GroupBackReference",value:this.positiveInteger()}},e.prototype.characterClassEscape=function(){var e,t=!1;switch(this.popChar()){case"d":e=c;break;case"D":e=c,t=!0;break;case"s":e=h;break;case"S":e=h,t=!0;break;case"w":e=u;break;case"W":e=u,t=!0}return a(e),{type:"Set",value:e,complement:t}},e.prototype.controlEscapeAtom=function(){var e;switch(this.popChar()){case"f":e=i("\f");break;case"n":e=i("\n");break;case"r":e=i("\r");break;case"t":e=i("\t");break;case"v":e=i("\v")}return a(e),{type:"Character",value:e}},e.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}},e.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:i("\0")}},e.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},e.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},e.prototype.identityEscapeAtom=function(){return{type:"Character",value:i(this.popChar())}},e.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:i(this.popChar())}}},e.prototype.characterClass=function(){var e=[],t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){var n=this.classAtom();if("Character"===n.type&&this.isRangeDash()){this.consumeChar("-");var r=this.classAtom();if("Character"===r.type){if(r.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:r.value})}else o(n.value,e),e.push(i("-")),o(r.value,e)}else o(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}},e.prototype.classAtom=function(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},e.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:i("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},e.prototype.group=function(){var e=!0;"?"===(this.consumeChar("("),this.peekChar(0))?(this.consumeChar("?"),this.consumeChar(":"),e=!1):this.groupIdx++;var t=this.disjunction();this.consumeChar(")");var n={type:"Group",capturing:e,value:t};return e&&(n.idx=this.groupIdx),n},e.prototype.positiveInteger=function(){var e=this.popChar();if(!1===r.test(e))throw Error("Expecting a positive integer");for(;n.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)},e.prototype.integerIncludingZero=function(){var e=this.popChar();if(!1===n.test(e))throw Error("Expecting an integer");for(;n.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)},e.prototype.patternCharacter=function(){var e=this.popChar();switch(e){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:i(e)}}},e.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},e.prototype.isRangeDash=function(){return"-"===this.peekChar()&&this.isClassAtom(1)},e.prototype.isDigit=function(){return n.test(this.peekChar(0))},e.prototype.isClassAtom=function(e){switch(void 0===e&&(e=0),this.peekChar(e)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},e.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},e.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},e.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2));default:return!1}},e.prototype.isQuantifier=function(){var e=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(e)}},e.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},e.prototype.parseHexDigits=function(e){for(var n="",r=0;r<e;r++){var i=this.popChar();if(!1===t.test(i))throw Error("Expecting a HexDecimal digits");n+=i}return{type:"Character",value:parseInt(n,16)}},e.prototype.peekChar=function(e){return void 0===e&&(e=0),this.input[this.idx+e]},e.prototype.popChar=function(){var e=this.peekChar(0);return this.consumeChar(),e},e.prototype.consumeChar=function(e){if(void 0!==e&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},e.prototype.loc=function(e){return{begin:e,end:this.idx}};var t=/[0-9a-fA-F]/,n=/[0-9]/,r=/[1-9]/;function i(e){return e.charCodeAt(0)}function o(e,t){void 0!==e.length?e.forEach((function(e){t.push(e)})):t.push(e)}function s(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t]=!0}function a(e){if(void 0===e)throw Error("Internal Error - Should never get here!")}var l,c=[];for(l=i("0");l<=i("9");l++)c.push(l);var u=[i("_")].concat(c);for(l=i("a");l<=i("z");l++)u.push(l);for(l=i("A");l<=i("Z");l++)u.push(l);var h=[i(" "),i("\f"),i("\n"),i("\r"),i("\t"),i("\v"),i("\t"),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i("\u2028"),i("\u2029"),i(" "),i(" "),i(" "),i("\ufeff")];function d(){}return d.prototype.visitChildren=function(e){for(var t in e){var n=e[t];e.hasOwnProperty(t)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach((function(e){this.visit(e)}),this))}},d.prototype.visit=function(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)},d.prototype.visitPattern=function(e){},d.prototype.visitFlags=function(e){},d.prototype.visitDisjunction=function(e){},d.prototype.visitAlternative=function(e){},d.prototype.visitStartAnchor=function(e){},d.prototype.visitEndAnchor=function(e){},d.prototype.visitWordBoundary=function(e){},d.prototype.visitNonWordBoundary=function(e){},d.prototype.visitLookahead=function(e){},d.prototype.visitNegativeLookahead=function(e){},d.prototype.visitCharacter=function(e){},d.prototype.visitSet=function(e){},d.prototype.visitGroup=function(e){},d.prototype.visitGroupBackReference=function(e){},d.prototype.visitQuantifier=function(e){},{RegExpParser:e,BaseRegExpVisitor:d,VERSION:"0.5.0"}},"function"==typeof define&&define.amd?define([],r):"object"==typeof t&&t.exports?t.exports=r():n.regexpToAst=r()})),a=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.clearRegExpParserCache=e.getRegExpAst=void 0;var t=s(),n={},r=new t.RegExpParser;e.getRegExpAst=function(e){var t=e.toString();if(n.hasOwnProperty(t))return n[t];var i=r.pattern(t);return n[t]=i,i},e.clearRegExpParserCache=function(){n={}}})),l=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.canMatchCharCode=e.firstCharOptimizedIndices=e.getOptimizedStartCodesIndices=e.failedOptimizationPrefixMsg=void 0;var r=s(),i=o(),l=a(),u=c(),h="Complement Sets are not supported for first char optimization";function d(e,t,n){switch(e.type){case"Disjunction":for(var r=0;r<e.value.length;r++)d(e.value[r],t,n);break;case"Alternative":var o=e.value;for(r=0;r<o.length;r++){var s=o[r];switch(s.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var a=s;switch(a.type){case"Character":p(a.value,t,n);break;case"Set":if(!0===a.complement)throw Error(h);i.forEach(a.value,(function(e){if("number"==typeof e)p(e,t,n);else{var r=e;if(!0===n)for(var i=r.from;i<=r.to;i++)p(i,t,n);else{for(i=r.from;i<=r.to&&i<u.minOptimizationVal;i++)p(i,t,n);if(r.to>=u.minOptimizationVal)for(var o=r.from>=u.minOptimizationVal?r.from:u.minOptimizationVal,s=r.to,a=u.charCodeToOptimizedIndex(o),l=u.charCodeToOptimizedIndex(s),c=a;c<=l;c++)t[c]=c}}}));break;case"Group":d(a.value,t,n);break;default:throw Error("Non Exhaustive Match")}var l=void 0!==a.quantifier&&0===a.quantifier.atLeast;if("Group"===a.type&&!1===m(a)||"Group"!==a.type&&!1===l)break}break;default:throw Error("non exhaustive match!")}return i.values(t)}function p(e,t,n){var r=u.charCodeToOptimizedIndex(e);t[r]=r,!0===n&&function(e,t){var n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){t[i=u.charCodeToOptimizedIndex(r.charCodeAt(0))]=i}else{var i,o=n.toLowerCase();if(o!==n)t[i=u.charCodeToOptimizedIndex(o.charCodeAt(0))]=i}}(e,t)}function f(e,t){return i.find(e.value,(function(e){if("number"==typeof e)return i.contains(t,e);var n=e;return void 0!==i.find(t,(function(e){return n.from<=e&&e<=n.to}))}))}function m(e){return!(!e.quantifier||0!==e.quantifier.atLeast)||!!e.value&&(i.isArray(e.value)?i.every(e.value,m):m(e.value))}e.failedOptimizationPrefixMsg='Unable to use "first char" lexer optimizations:\n',e.getOptimizedStartCodesIndices=function(t,n){void 0===n&&(n=!1);try{var o=l.getRegExpAst(t);return d(o.value,{},o.flags.ignoreCase)}catch(o){if(o.message===h)n&&i.PRINT_WARNING(e.failedOptimizationPrefixMsg+"\tUnable to optimize: < "+t.toString()+" >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.");else{var s="";n&&(s="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),i.PRINT_ERROR(e.failedOptimizationPrefixMsg+"\n\tFailed parsing: < "+t.toString()+" >\n\tUsing the regexp-to-ast library version: "+r.VERSION+"\n\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues"+s)}}return[]},e.firstCharOptimizedIndices=d;var g=function(e){function t(t){var n=e.call(this)||this;return n.targetCharCodes=t,n.found=!1,n}return n(t,e),t.prototype.visitChildren=function(t){if(!0!==this.found){switch(t.type){case"Lookahead":return void this.visitLookahead(t);case"NegativeLookahead":return void this.visitNegativeLookahead(t)}e.prototype.visitChildren.call(this,t)}},t.prototype.visitCharacter=function(e){i.contains(this.targetCharCodes,e.value)&&(this.found=!0)},t.prototype.visitSet=function(e){e.complement?void 0===f(e,this.targetCharCodes)&&(this.found=!0):void 0!==f(e,this.targetCharCodes)&&(this.found=!0)},t}(r.BaseRegExpVisitor);e.canMatchCharCode=function(e,t){if(t instanceof RegExp){var n=l.getRegExpAst(t),r=new g(e);return r.visit(n),r.found}return void 0!==i.find(t,(function(t){return i.contains(e,t.charCodeAt(0))}))}})),c=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.charCodeToOptimizedIndex=e.minOptimizationVal=e.buildLineBreakIssueMessage=e.LineTerminatorOptimizedTester=e.isShortPattern=e.isCustomPattern=e.cloneEmptyGroups=e.performWarningRuntimeChecks=e.performRuntimeChecks=e.addStickyFlag=e.addStartOfInput=e.findUnreachablePatterns=e.findModesThatDoNotExist=e.findInvalidGroupType=e.findDuplicatePatterns=e.findUnsupportedFlags=e.findStartOfInputAnchor=e.findEmptyMatchRegExps=e.findEndOfInputAnchor=e.findInvalidPatterns=e.findMissingPatterns=e.validatePatterns=e.analyzeTokenTypes=e.enableSticky=e.disableSticky=e.SUPPORT_STICKY=e.MODES=e.DEFAULT_MODE=void 0;var r=s(),i=d(),c=o(),u=l(),h=a(),p="PATTERN";function f(e){var t=c.filter(e,(function(e){return!c.has(e,p)}));return{errors:c.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:i.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[e]}})),valid:c.difference(e,t)}}function m(e){var t=c.filter(e,(function(e){var t=e[p];return!(c.isRegExp(t)||c.isFunction(t)||c.has(t,"exec")||c.isString(t))}));return{errors:c.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:i.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[e]}})),valid:c.difference(e,t)}}e.DEFAULT_MODE="defaultMode",e.MODES="modes",e.SUPPORT_STICKY="boolean"==typeof new RegExp("(?:)").sticky,e.disableSticky=function(){e.SUPPORT_STICKY=!1},e.enableSticky=function(){e.SUPPORT_STICKY=!0},e.analyzeTokenTypes=function(t,n){var r,o=(n=c.defaults(n,{useSticky:e.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:function(e,t){return t()}})).tracer;o("initCharCodeToOptimizedIndexMap",(function(){!function(){if(c.isEmpty(O)){O=new Array(65536);for(var e=0;e<65536;e++)O[e]=e>255?255+~~(e/255):e}}()})),o("Reject Lexer.NA",(function(){r=c.reject(t,(function(e){return e[p]===i.Lexer.NA}))}));var s,a,l,h,d,f,m,g,v,y,x,_=!1;o("Transform Patterns",(function(){_=!1,s=c.map(r,(function(e){var t=e[p];if(c.isRegExp(t)){var r=t.source;return 1!==r.length||"^"===r||"$"===r||"."===r||t.ignoreCase?2!==r.length||"\\"!==r[0]||c.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],r[1])?n.useSticky?A(t):w(t):r[1]:r}if(c.isFunction(t))return _=!0,{exec:t};if(c.has(t,"exec"))return _=!0,t;if("string"==typeof t){if(1===t.length)return t;var i=t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),o=new RegExp(i);return n.useSticky?A(o):w(o)}throw Error("non exhaustive match")}))})),o("misc mapping",(function(){a=c.map(r,(function(e){return e.tokenTypeIdx})),l=c.map(r,(function(e){var t=e.GROUP;if(t!==i.Lexer.SKIPPED){if(c.isString(t))return t;if(c.isUndefined(t))return!1;throw Error("non exhaustive match")}})),h=c.map(r,(function(e){var t=e.LONGER_ALT;if(t)return c.indexOf(r,t)})),d=c.map(r,(function(e){return e.PUSH_MODE})),f=c.map(r,(function(e){return c.has(e,"POP_MODE")}))})),o("Line Terminator Handling",(function(){var e=L(n.lineTerminatorCharacters);m=c.map(r,(function(e){return!1})),"onlyOffset"!==n.positionTracking&&(m=c.map(r,(function(t){return c.has(t,"LINE_BREAKS")?t.LINE_BREAKS:!1===I(t,e)?u.canMatchCharCode(e,t.PATTERN):void 0})))})),o("Misc Mapping #2",(function(){g=c.map(r,C),v=c.map(s,R),y=c.reduce(r,(function(e,t){var n=t.GROUP;return c.isString(n)&&n!==i.Lexer.SKIPPED&&(e[n]=[]),e}),{}),x=c.map(s,(function(e,t){return{pattern:s[t],longerAlt:h[t],canLineTerminator:m[t],isCustom:g[t],short:v[t],group:l[t],push:d[t],pop:f[t],tokenTypeIdx:a[t],tokenType:r[t]}}))}));var T=!0,E=[];return n.safeMode||o("First Char Optimization",(function(){E=c.reduce(r,(function(e,t,r){if("string"==typeof t.PATTERN){var i=U(t.PATTERN.charCodeAt(0));N(e,i,x[r])}else if(c.isArray(t.START_CHARS_HINT)){var o;c.forEach(t.START_CHARS_HINT,(function(t){var n=U("string"==typeof t?t.charCodeAt(0):t);o!==n&&(o=n,N(e,n,x[r]))}))}else if(c.isRegExp(t.PATTERN))if(t.PATTERN.unicode)T=!1,n.ensureOptimizations&&c.PRINT_ERROR(u.failedOptimizationPrefixMsg+"\tUnable to analyze < "+t.PATTERN.toString()+" > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE");else{var s=u.getOptimizedStartCodesIndices(t.PATTERN,n.ensureOptimizations);c.isEmpty(s)&&(T=!1),c.forEach(s,(function(t){N(e,t,x[r])}))}else n.ensureOptimizations&&c.PRINT_ERROR(u.failedOptimizationPrefixMsg+"\tTokenType: <"+t.name+"> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE"),T=!1;return e}),[])})),o("ArrayPacking",(function(){E=c.packArray(E)})),{emptyGroups:y,patternIdxToConfig:x,charCodeToPatternIdxToConfig:E,hasCustom:_,canBeOptimized:T}},e.validatePatterns=function(e,t){var n=[],r=f(e);n=n.concat(r.errors);var i=m(r.valid),o=i.valid;return n=(n=n.concat(i.errors)).concat(function(e){var t=[],n=c.filter(e,(function(e){return c.isRegExp(e[p])}));return t=t.concat(v(n)),t=t.concat(_(n)),t=t.concat(T(n)),t=t.concat(E(n)),t=t.concat(y(n)),t}(o)),n=(n=(n=n.concat(M(o))).concat(b(o,t))).concat(S(o))},e.findMissingPatterns=f,e.findInvalidPatterns=m;var g=/[^\\][\$]/;function v(e){var t=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.found=!1,t}return n(t,e),t.prototype.visitEndAnchor=function(e){this.found=!0},t}(r.BaseRegExpVisitor),o=c.filter(e,(function(e){var n=e[p];try{var r=h.getRegExpAst(n),i=new t;return i.visit(r),i.found}catch(e){return g.test(n.source)}}));return c.map(o,(function(e){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:i.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[e]}}))}function y(e){var t=c.filter(e,(function(e){return e[p].test("")}));return c.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:i.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[e]}}))}e.findEndOfInputAnchor=v,e.findEmptyMatchRegExps=y;var x=/[^\\[][\^]|^\^/;function _(e){var t=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.found=!1,t}return n(t,e),t.prototype.visitStartAnchor=function(e){this.found=!0},t}(r.BaseRegExpVisitor),o=c.filter(e,(function(e){var n=e[p];try{var r=h.getRegExpAst(n),i=new t;return i.visit(r),i.found}catch(e){return x.test(n.source)}}));return c.map(o,(function(e){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:i.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[e]}}))}function T(e){var t=c.filter(e,(function(e){var t=e[p];return t instanceof RegExp&&(t.multiline||t.global)}));return c.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:i.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}}))}function E(e){var t=[],n=c.map(e,(function(n){return c.reduce(e,(function(e,r){return n.PATTERN.source===r.PATTERN.source&&!c.contains(t,r)&&r.PATTERN!==i.Lexer.NA&&(t.push(r),e.push(r)),e}),[])}));n=c.compact(n);var r=c.filter(n,(function(e){return e.length>1}));return c.map(r,(function(e){var t=c.map(e,(function(e){return e.name}));return{message:"The same RegExp pattern ->"+c.first(e).PATTERN+"<-has been used in all of the following Token Types: "+t.join(", ")+" <-",type:i.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}}))}function M(e){var t=c.filter(e,(function(e){if(!c.has(e,"GROUP"))return!1;var t=e.GROUP;return t!==i.Lexer.SKIPPED&&t!==i.Lexer.NA&&!c.isString(t)}));return c.map(t,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:i.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}}))}function b(e,t){var n=c.filter(e,(function(e){return void 0!==e.PUSH_MODE&&!c.contains(t,e.PUSH_MODE)}));return c.map(n,(function(e){return{message:"Token Type: ->"+e.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+e.PUSH_MODE+"<-which does not exist",type:i.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}}))}function S(e){var t=[],n=c.reduce(e,(function(e,t,n){var r=t.PATTERN;return r===i.Lexer.NA||(c.isString(r)?e.push({str:r,idx:n,tokenType:t}):c.isRegExp(r)&&function(e){var t=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return void 0===c.find(t,(function(t){return-1!==e.source.indexOf(t)}))}(r)&&e.push({str:r.source,idx:n,tokenType:t})),e}),[]);return c.forEach(e,(function(e,r){c.forEach(n,(function(n){var o=n.str,s=n.idx,a=n.tokenType;if(r<s&&function(e,t){if(c.isRegExp(t)){var n=t.exec(e);return null!==n&&0===n.index}if(c.isFunction(t))return t(e,0,[],{});if(c.has(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(o,e.PATTERN)){var l="Token: ->"+a.name+"<- can never be matched.\nBecause it appears AFTER the Token Type ->"+e.name+"<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE";t.push({message:l,type:i.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}}))})),t}function w(e){var t=e.ignoreCase?"i":"";return new RegExp("^(?:"+e.source+")",t)}function A(e){var t=e.ignoreCase?"iy":"y";return new RegExp(""+e.source,t)}function C(e){var t=e.PATTERN;if(c.isRegExp(t))return!1;if(c.isFunction(t))return!0;if(c.has(t,"exec"))return!0;if(c.isString(t))return!1;throw Error("non exhaustive match")}function R(e){return!(!c.isString(e)||1!==e.length)&&e.charCodeAt(0)}function I(e,t){if(c.has(e,"LINE_BREAKS"))return!1;if(c.isRegExp(e.PATTERN)){try{u.canMatchCharCode(t,e.PATTERN)}catch(e){return{issue:i.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(c.isString(e.PATTERN))return!1;if(C(e))return{issue:i.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function P(e,t){if(t.issue===i.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return"Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <"+e.name+"> Token Type\n\t Root cause: "+t.errMsg+".\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(t.issue===i.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return"Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <"+e.name+"> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}function L(e){return c.map(e,(function(e){return c.isString(e)&&e.length>0?e.charCodeAt(0):e}))}function N(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}e.findStartOfInputAnchor=_,e.findUnsupportedFlags=T,e.findDuplicatePatterns=E,e.findInvalidGroupType=M,e.findModesThatDoNotExist=b,e.findUnreachablePatterns=S,e.addStartOfInput=w,e.addStickyFlag=A,e.performRuntimeChecks=function(t,n,r){var o=[];return c.has(t,e.DEFAULT_MODE)||o.push({message:"A MultiMode Lexer cannot be initialized without a <"+e.DEFAULT_MODE+"> property in its definition\n",type:i.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),c.has(t,e.MODES)||o.push({message:"A MultiMode Lexer cannot be initialized without a <"+e.MODES+"> property in its definition\n",type:i.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),c.has(t,e.MODES)&&c.has(t,e.DEFAULT_MODE)&&!c.has(t.modes,t.defaultMode)&&o.push({message:"A MultiMode Lexer cannot be initialized with a "+e.DEFAULT_MODE+": <"+t.defaultMode+">which does not exist\n",type:i.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),c.has(t,e.MODES)&&c.forEach(t.modes,(function(e,t){c.forEach(e,(function(e,n){c.isUndefined(e)&&o.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:<"+t+"> at index: <"+n+">\n",type:i.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})}))})),o},e.performWarningRuntimeChecks=function(e,t,n){var r=[],o=!1,s=c.compact(c.flatten(c.mapValues(e.modes,(function(e){return e})))),a=c.reject(s,(function(e){return e[p]===i.Lexer.NA})),l=L(n);return t&&c.forEach(a,(function(e){var t=I(e,l);if(!1!==t){var n={message:P(e,t),type:t.issue,tokenType:e};r.push(n)}else c.has(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(o=!0):u.canMatchCharCode(l,e.PATTERN)&&(o=!0)})),t&&!o&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS\n\tfor details.",type:i.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),r},e.cloneEmptyGroups=function(e){var t={},n=c.keys(e);return c.forEach(n,(function(n){var r=e[n];if(!c.isArray(r))throw Error("non exhaustive match");t[n]=[]})),t},e.isCustomPattern=C,e.isShortPattern=R,e.LineTerminatorOptimizedTester={test:function(e){for(var t=e.length,n=this.lastIndex;n<t;n++){var r=e.charCodeAt(n);if(10===r)return this.lastIndex=n+1,!0;if(13===r)return 10===e.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0},e.buildLineBreakIssueMessage=P,e.minOptimizationVal=256;var O=[];function U(t){return t<e.minOptimizationVal?t:O[t]}e.charCodeToOptimizedIndex=U})),u=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isTokenType=e.hasExtendingTokensTypesMapProperty=e.hasExtendingTokensTypesProperty=e.hasCategoriesProperty=e.hasShortKeyProperty=e.singleAssignCategoriesToksMap=e.assignCategoriesMapProp=e.assignCategoriesTokensProp=e.assignTokenDefaultProps=e.expandCategories=e.augmentTokenTypes=e.tokenIdxToClass=e.tokenShortNameIdx=e.tokenStructuredMatcherNoCategories=e.tokenStructuredMatcher=void 0;var t=o();function n(e){for(var n=t.cloneArr(e),r=e,i=!0;i;){r=t.compact(t.flatten(t.map(r,(function(e){return e.CATEGORIES}))));var o=t.difference(r,n);n=n.concat(o),t.isEmpty(o)?i=!1:r=o}return n}function r(n){t.forEach(n,(function(n){l(n)||(e.tokenIdxToClass[e.tokenShortNameIdx]=n,n.tokenTypeIdx=e.tokenShortNameIdx++),c(n)&&!t.isArray(n.CATEGORIES)&&(n.CATEGORIES=[n.CATEGORIES]),c(n)||(n.CATEGORIES=[]),u(n)||(n.categoryMatches=[]),h(n)||(n.categoryMatchesMap={})}))}function i(n){t.forEach(n,(function(n){n.categoryMatches=[],t.forEach(n.categoryMatchesMap,(function(t,r){n.categoryMatches.push(e.tokenIdxToClass[r].tokenTypeIdx)}))}))}function s(e){t.forEach(e,(function(e){a([],e)}))}function a(e,n){t.forEach(e,(function(e){n.categoryMatchesMap[e.tokenTypeIdx]=!0})),t.forEach(n.CATEGORIES,(function(r){var i=e.concat(n);t.contains(i,r)||a(i,r)}))}function l(e){return t.has(e,"tokenTypeIdx")}function c(e){return t.has(e,"CATEGORIES")}function u(e){return t.has(e,"categoryMatches")}function h(e){return t.has(e,"categoryMatchesMap")}e.tokenStructuredMatcher=function(e,t){var n=e.tokenTypeIdx;return n===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[n]},e.tokenStructuredMatcherNoCategories=function(e,t){return e.tokenTypeIdx===t.tokenTypeIdx},e.tokenShortNameIdx=1,e.tokenIdxToClass={},e.augmentTokenTypes=function(e){var o=n(e);r(o),s(o),i(o),t.forEach(o,(function(e){e.isParent=e.categoryMatches.length>0}))},e.expandCategories=n,e.assignTokenDefaultProps=r,e.assignCategoriesTokensProp=i,e.assignCategoriesMapProp=s,e.singleAssignCategoriesToksMap=a,e.hasShortKeyProperty=l,e.hasCategoriesProperty=c,e.hasExtendingTokensTypesProperty=u,e.hasExtendingTokensTypesMapProperty=h,e.isTokenType=function(e){return t.has(e,"tokenTypeIdx")}})),h=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultLexerErrorProvider=void 0,e.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,n,r,i){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+", skipped "+n+" characters."}}})),d=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Lexer=e.LexerDefinitionErrorType=void 0;var t,n=c(),r=o(),i=u(),s=h(),l=a();(t=e.LexerDefinitionErrorType||(e.LexerDefinitionErrorType={}))[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK";var d={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:s.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(d);var p=function(){function e(e,t){var o=this;if(void 0===t&&(t=d),this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=r.merge(d,t);var s=this.config.traceInitPerf;!0===s?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof s&&(this.traceInitMaxIdent=s,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",(function(){var s,a=!0;o.TRACE_INIT("Lexer Config handling",(function(){if(o.config.lineTerminatorsPattern===d.lineTerminatorsPattern)o.config.lineTerminatorsPattern=n.LineTerminatorOptimizedTester;else if(o.config.lineTerminatorCharacters===d.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');o.trackStartLines=/full|onlyStart/i.test(o.config.positionTracking),o.trackEndLines=/full/i.test(o.config.positionTracking),r.isArray(e)?((s={modes:{}}).modes[n.DEFAULT_MODE]=r.cloneArr(e),s[n.DEFAULT_MODE]=n.DEFAULT_MODE):(a=!1,s=r.cloneObj(e))})),!1===o.config.skipValidations&&(o.TRACE_INIT("performRuntimeChecks",(function(){o.lexerDefinitionErrors=o.lexerDefinitionErrors.concat(n.performRuntimeChecks(s,o.trackStartLines,o.config.lineTerminatorCharacters))})),o.TRACE_INIT("performWarningRuntimeChecks",(function(){o.lexerDefinitionWarning=o.lexerDefinitionWarning.concat(n.performWarningRuntimeChecks(s,o.trackStartLines,o.config.lineTerminatorCharacters))}))),s.modes=s.modes?s.modes:{},r.forEach(s.modes,(function(e,t){s.modes[t]=r.reject(e,(function(e){return r.isUndefined(e)}))}));var c=r.keys(s.modes);if(r.forEach(s.modes,(function(e,s){o.TRACE_INIT("Mode: <"+s+"> processing",(function(){var a;(o.modes.push(s),!1===o.config.skipValidations&&o.TRACE_INIT("validatePatterns",(function(){o.lexerDefinitionErrors=o.lexerDefinitionErrors.concat(n.validatePatterns(e,c))})),r.isEmpty(o.lexerDefinitionErrors))&&(i.augmentTokenTypes(e),o.TRACE_INIT("analyzeTokenTypes",(function(){a=n.analyzeTokenTypes(e,{lineTerminatorCharacters:o.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:o.TRACE_INIT.bind(o)})})),o.patternIdxToConfig[s]=a.patternIdxToConfig,o.charCodeToPatternIdxToConfig[s]=a.charCodeToPatternIdxToConfig,o.emptyGroups=r.merge(o.emptyGroups,a.emptyGroups),o.hasCustom=a.hasCustom||o.hasCustom,o.canModeBeOptimized[s]=a.canBeOptimized)}))})),o.defaultMode=s.defaultMode,!r.isEmpty(o.lexerDefinitionErrors)&&!o.config.deferDefinitionErrorsHandling){var u=r.map(o.lexerDefinitionErrors,(function(e){return e.message})).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+u)}r.forEach(o.lexerDefinitionWarning,(function(e){r.PRINT_WARNING(e.message)})),o.TRACE_INIT("Choosing sub-methods implementations",(function(){if(n.SUPPORT_STICKY?(o.chopInput=r.IDENTITY,o.match=o.matchWithTest):(o.updateLastIndex=r.NOOP,o.match=o.matchWithExec),a&&(o.handleModes=r.NOOP),!1===o.trackStartLines&&(o.computeNewColumn=r.IDENTITY),!1===o.trackEndLines&&(o.updateTokenEndLineColumnLocation=r.NOOP),/full/i.test(o.config.positionTracking))o.createTokenInstance=o.createFullToken;else if(/onlyStart/i.test(o.config.positionTracking))o.createTokenInstance=o.createStartOnlyToken;else{if(!/onlyOffset/i.test(o.config.positionTracking))throw Error('Invalid <positionTracking> config option: "'+o.config.positionTracking+'"');o.createTokenInstance=o.createOffsetOnlyToken}o.hasCustom?(o.addToken=o.addTokenUsingPush,o.handlePayload=o.handlePayloadWithCustom):(o.addToken=o.addTokenUsingMemberAccess,o.handlePayload=o.handlePayloadNoCustom)})),o.TRACE_INIT("Failed Optimization Warnings",(function(){var e=r.reduce(o.canModeBeOptimized,(function(e,t,n){return!1===t&&e.push(n),e}),[]);if(t.ensureOptimizations&&!r.isEmpty(e))throw Error("Lexer Modes: < "+e.join(", ")+' > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.')})),o.TRACE_INIT("clearRegExpParserCache",(function(){l.clearRegExpParserCache()})),o.TRACE_INIT("toFastProperties",(function(){r.toFastProperties(o)}))}))}return e.prototype.tokenize=function(e,t){if(void 0===t&&(t=this.defaultMode),!r.isEmpty(this.lexerDefinitionErrors)){var n=r.map(this.lexerDefinitionErrors,(function(e){return e.message})).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+n)}return this.tokenizeInternal(e,t)},e.prototype.tokenizeInternal=function(e,t){var i,o,s,a,l,c,u,h,d,p,f,m,g,v,y=this,x=e,_=x.length,T=0,E=0,M=this.hasCustom?0:Math.floor(e.length/10),b=new Array(M),S=[],w=this.trackStartLines?1:void 0,A=this.trackStartLines?1:void 0,C=n.cloneEmptyGroups(this.emptyGroups),R=this.trackStartLines,I=this.config.lineTerminatorsPattern,P=0,L=[],N=[],O=[],U=[];Object.freeze(U);var D=void 0;function k(){return L}function F(e){var t=n.charCodeToOptimizedIndex(e),r=N[t];return void 0===r?U:r}var G,B=function(e){if(1===O.length&&void 0===e.tokenType.PUSH_MODE){var t=y.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);S.push({offset:e.startOffset,line:void 0!==e.startLine?e.startLine:void 0,column:void 0!==e.startColumn?e.startColumn:void 0,length:e.image.length,message:t})}else{O.pop();var n=r.last(O);L=y.patternIdxToConfig[n],N=y.charCodeToPatternIdxToConfig[n],P=L.length;var i=y.canModeBeOptimized[n]&&!1===y.config.safeMode;D=N&&i?F:k}};function V(e){O.push(e),N=this.charCodeToPatternIdxToConfig[e],L=this.patternIdxToConfig[e],P=L.length,P=L.length;var t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;D=N&&t?F:k}for(V.call(this,t);T<_;){l=null;var z=x.charCodeAt(T),H=D(z),W=H.length;for(i=0;i<W;i++){var j=(G=H[i]).pattern;if(c=null,!1!==(te=G.short)?z===te&&(l=j):!0===G.isCustom?null!==(v=j.exec(x,T,b,C))?(l=v[0],void 0!==v.payload&&(c=v.payload)):l=null:(this.updateLastIndex(j,T),l=this.match(j,e,T)),null!==l){if(void 0!==(a=G.longerAlt)){var X=L[a],q=X.pattern;u=null,!0===X.isCustom?null!==(v=q.exec(x,T,b,C))?(s=v[0],void 0!==v.payload&&(u=v.payload)):s=null:(this.updateLastIndex(q,T),s=this.match(q,e,T)),s&&s.length>l.length&&(l=s,c=u,G=X)}break}}if(null!==l){if(h=l.length,void 0!==(d=G.group)&&(p=G.tokenTypeIdx,f=this.createTokenInstance(l,T,p,G.tokenType,w,A,h),this.handlePayload(f,c),!1===d?E=this.addToken(b,E,f):C[d].push(f)),e=this.chopInput(e,h),T+=h,A=this.computeNewColumn(A,h),!0===R&&!0===G.canLineTerminator){var Y=0,K=void 0,Z=void 0;I.lastIndex=0;do{!0===(K=I.test(l))&&(Z=I.lastIndex-1,Y++)}while(!0===K);0!==Y&&(w+=Y,A=h-Z,this.updateTokenEndLineColumnLocation(f,d,Z,Y,w,A,h))}this.handleModes(G,B,V,f)}else{for(var J=T,$=w,Q=A,ee=!1;!ee&&T<_;)for(x.charCodeAt(T),e=this.chopInput(e,1),T++,o=0;o<P;o++){var te,ne=L[o];j=ne.pattern;if(!1!==(te=ne.short)?x.charCodeAt(T)===te&&(ee=!0):!0===ne.isCustom?ee=null!==j.exec(x,T,b,C):(this.updateLastIndex(j,T),ee=null!==j.exec(e)),!0===ee)break}m=T-J,g=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(x,J,m,$,Q),S.push({offset:J,line:$,column:Q,length:m,message:g})}}return this.hasCustom||(b.length=E),{tokens:b,groups:C,errors:S}},e.prototype.handleModes=function(e,t,n,r){if(!0===e.pop){var i=e.push;t(r),void 0!==i&&n.call(this,i)}else void 0!==e.push&&n.call(this,e.push)},e.prototype.chopInput=function(e,t){return e.substring(t)},e.prototype.updateLastIndex=function(e,t){e.lastIndex=t},e.prototype.updateTokenEndLineColumnLocation=function(e,t,n,r,i,o,s){var a,l;void 0!==t&&(l=(a=n===s-1)?-1:0,1===r&&!0===a||(e.endLine=i+l,e.endColumn=o-1-l))},e.prototype.computeNewColumn=function(e,t){return e+t},e.prototype.createTokenInstance=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null},e.prototype.createOffsetOnlyToken=function(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}},e.prototype.createStartOnlyToken=function(e,t,n,r,i,o){return{image:e,startOffset:t,startLine:i,startColumn:o,tokenTypeIdx:n,tokenType:r}},e.prototype.createFullToken=function(e,t,n,r,i,o,s){return{image:e,startOffset:t,endOffset:t+s-1,startLine:i,endLine:i,startColumn:o,endColumn:o+s-1,tokenTypeIdx:n,tokenType:r}},e.prototype.addToken=function(e,t,n){return 666},e.prototype.addTokenUsingPush=function(e,t,n){return e.push(n),t},e.prototype.addTokenUsingMemberAccess=function(e,t,n){return e[t]=n,++t},e.prototype.handlePayload=function(e,t){},e.prototype.handlePayloadNoCustom=function(e,t){},e.prototype.handlePayloadWithCustom=function(e,t){null!==t&&(e.payload=t)},e.prototype.match=function(e,t,n){return null},e.prototype.matchWithTest=function(e,t,n){return!0===e.test(t)?t.substring(n,e.lastIndex):null},e.prototype.matchWithExec=function(e,t){var n=e.exec(t);return null!==n?n[0]:n},e.prototype.TRACE_INIT=function(e,t){if(!0===this.traceInitPerf){this.traceInitIndent++;var n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(n+"--\x3e <"+e+">");var i=r.timer(t),o=i.time,s=i.value,a=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(n+"<-- <"+e+"> time: "+o+"ms"),this.traceInitIndent--,s}return t()},e.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",e.NA=/NOT_APPLICABLE/,e}();e.Lexer=p})),p=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tokenMatcher=e.createTokenInstance=e.EOF=e.createToken=e.hasTokenLabel=e.tokenName=e.tokenLabel=void 0;var t=o(),n=d(),r=u();function i(e){return t.isString(e.LABEL)&&""!==e.LABEL}e.tokenLabel=function(e){return i(e)?e.LABEL:e.name},e.tokenName=function(e){return e.name},e.hasTokenLabel=i;var s="parent",a="categories",l="label",c="group",h="push_mode",p="pop_mode",f="longer_alt",m="line_breaks",g="start_chars_hint";function v(e){return function(e){var n=e.pattern,i={};if(i.name=e.name,t.isUndefined(n)||(i.PATTERN=n),t.has(e,s))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";return t.has(e,a)&&(i.CATEGORIES=e[a]),r.augmentTokenTypes([i]),t.has(e,l)&&(i.LABEL=e[l]),t.has(e,c)&&(i.GROUP=e[c]),t.has(e,p)&&(i.POP_MODE=e[p]),t.has(e,h)&&(i.PUSH_MODE=e[h]),t.has(e,f)&&(i.LONGER_ALT=e[f]),t.has(e,m)&&(i.LINE_BREAKS=e[m]),t.has(e,g)&&(i.START_CHARS_HINT=e[g]),i}(e)}e.createToken=v,e.EOF=v({name:"EOF",pattern:n.Lexer.NA}),r.augmentTokenTypes([e.EOF]),e.createTokenInstance=function(e,t,n,r,i,o,s,a){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:o,startColumn:s,endColumn:a,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}},e.tokenMatcher=function(e,t){return r.tokenStructuredMatcher(e,t)}})),f=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.serializeProduction=e.serializeGrammar=e.Terminal=e.Alternation=e.RepetitionWithSeparator=e.Repetition=e.RepetitionMandatoryWithSeparator=e.RepetitionMandatory=e.Option=e.Alternative=e.Rule=e.NonTerminal=e.AbstractProduction=void 0;var r=o(),i=p(),s=function(){function e(e){this._definition=e}return Object.defineProperty(e.prototype,"definition",{get:function(){return this._definition},set:function(e){this._definition=e},enumerable:!1,configurable:!0}),e.prototype.accept=function(e){e.visit(this),r.forEach(this.definition,(function(t){t.accept(e)}))},e}();e.AbstractProduction=s;var a=function(e){function t(t){var n=e.call(this,[])||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),Object.defineProperty(t.prototype,"definition",{get:function(){return void 0!==this.referencedRule?this.referencedRule.definition:[]},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.accept=function(e){e.visit(this)},t}(s);e.NonTerminal=a;var l=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.orgText="",r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(s);e.Rule=l;var c=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.ignoreAmbiguities=!1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(s);e.Alternative=c;var u=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(s);e.Option=u;var h=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(s);e.RepetitionMandatory=h;var d=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(s);e.RepetitionMandatoryWithSeparator=d;var f=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(s);e.Repetition=f;var m=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),t}(s);e.RepetitionWithSeparator=m;var g=function(e){function t(t){var n=e.call(this,t.definition)||this;return n.idx=1,n.ignoreAmbiguities=!1,n.hasPredicates=!1,r.assign(n,r.pick(t,(function(e){return void 0!==e}))),n}return n(t,e),Object.defineProperty(t.prototype,"definition",{get:function(){return this._definition},set:function(e){this._definition=e},enumerable:!1,configurable:!0}),t}(s);e.Alternation=g;var v=function(){function e(e){this.idx=1,r.assign(this,r.pick(e,(function(e){return void 0!==e})))}return e.prototype.accept=function(e){e.visit(this)},e}();function y(e){function t(e){return r.map(e,y)}if(e instanceof a)return{type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};if(e instanceof c)return{type:"Alternative",definition:t(e.definition)};if(e instanceof u)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof h)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof d)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:y(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof m)return{type:"RepetitionWithSeparator",idx:e.idx,separator:y(new v({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof f)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof g)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof v){var n={type:"Terminal",name:e.terminalType.name,label:i.tokenLabel(e.terminalType),idx:e.idx},o=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(n.pattern=r.isRegExp(o)?o.source:o),n}if(e instanceof l)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}e.Terminal=v,e.serializeGrammar=function(e){return r.map(e,y)},e.serializeProduction=y})),m=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RestWalker=void 0;var t=o(),n=f(),r=function(){function e(){}return e.prototype.walk=function(e,r){var i=this;void 0===r&&(r=[]),t.forEach(e.definition,(function(o,s){var a=t.drop(e.definition,s+1);if(o instanceof n.NonTerminal)i.walkProdRef(o,a,r);else if(o instanceof n.Terminal)i.walkTerminal(o,a,r);else if(o instanceof n.Alternative)i.walkFlat(o,a,r);else if(o instanceof n.Option)i.walkOption(o,a,r);else if(o instanceof n.RepetitionMandatory)i.walkAtLeastOne(o,a,r);else if(o instanceof n.RepetitionMandatoryWithSeparator)i.walkAtLeastOneSep(o,a,r);else if(o instanceof n.RepetitionWithSeparator)i.walkManySep(o,a,r);else if(o instanceof n.Repetition)i.walkMany(o,a,r);else{if(!(o instanceof n.Alternation))throw Error("non exhaustive match");i.walkOr(o,a,r)}}))},e.prototype.walkTerminal=function(e,t,n){},e.prototype.walkProdRef=function(e,t,n){},e.prototype.walkFlat=function(e,t,n){var r=t.concat(n);this.walk(e,r)},e.prototype.walkOption=function(e,t,n){var r=t.concat(n);this.walk(e,r)},e.prototype.walkAtLeastOne=function(e,t,r){var i=[new n.Option({definition:e.definition})].concat(t,r);this.walk(e,i)},e.prototype.walkAtLeastOneSep=function(e,t,n){var r=i(e,t,n);this.walk(e,r)},e.prototype.walkMany=function(e,t,r){var i=[new n.Option({definition:e.definition})].concat(t,r);this.walk(e,i)},e.prototype.walkManySep=function(e,t,n){var r=i(e,t,n);this.walk(e,r)},e.prototype.walkOr=function(e,r,i){var o=this,s=r.concat(i);t.forEach(e.definition,(function(e){var t=new n.Alternative({definition:[e]});o.walk(t,s)}))},e}();function i(e,t,r){return[new n.Option({definition:[new n.Terminal({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}e.RestWalker=r})),g=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GAstVisitor=void 0;var t=f(),n=function(){function e(){}return e.prototype.visit=function(e){var n=e;switch(n.constructor){case t.NonTerminal:return this.visitNonTerminal(n);case t.Alternative:return this.visitAlternative(n);case t.Option:return this.visitOption(n);case t.RepetitionMandatory:return this.visitRepetitionMandatory(n);case t.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(n);case t.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(n);case t.Repetition:return this.visitRepetition(n);case t.Alternation:return this.visitAlternation(n);case t.Terminal:return this.visitTerminal(n);case t.Rule:return this.visitRule(n);default:throw Error("non exhaustive match")}},e.prototype.visitNonTerminal=function(e){},e.prototype.visitAlternative=function(e){},e.prototype.visitOption=function(e){},e.prototype.visitRepetition=function(e){},e.prototype.visitRepetitionMandatory=function(e){},e.prototype.visitRepetitionMandatoryWithSeparator=function(e){},e.prototype.visitRepetitionWithSeparator=function(e){},e.prototype.visitAlternation=function(e){},e.prototype.visitTerminal=function(e){},e.prototype.visitRule=function(e){},e}();e.GAstVisitor=n})),v=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.collectMethods=e.DslMethodsCollectorVisitor=e.getProductionDslName=e.isBranchingProd=e.isOptionalProd=e.isSequenceProd=void 0;var r=o(),i=f(),s=g();e.isSequenceProd=function(e){return e instanceof i.Alternative||e instanceof i.Option||e instanceof i.Repetition||e instanceof i.RepetitionMandatory||e instanceof i.RepetitionMandatoryWithSeparator||e instanceof i.RepetitionWithSeparator||e instanceof i.Terminal||e instanceof i.Rule},e.isOptionalProd=function e(t,n){return void 0===n&&(n=[]),!!(t instanceof i.Option||t instanceof i.Repetition||t instanceof i.RepetitionWithSeparator)||(t instanceof i.Alternation?r.some(t.definition,(function(t){return e(t,n)})):!(t instanceof i.NonTerminal&&r.contains(n,t))&&(t instanceof i.AbstractProduction&&(t instanceof i.NonTerminal&&n.push(t),r.every(t.definition,(function(t){return e(t,n)})))))},e.isBranchingProd=function(e){return e instanceof i.Alternation},e.getProductionDslName=function(e){if(e instanceof i.NonTerminal)return"SUBRULE";if(e instanceof i.Option)return"OPTION";if(e instanceof i.Alternation)return"OR";if(e instanceof i.RepetitionMandatory)return"AT_LEAST_ONE";if(e instanceof i.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(e instanceof i.RepetitionWithSeparator)return"MANY_SEP";if(e instanceof i.Repetition)return"MANY";if(e instanceof i.Terminal)return"CONSUME";throw Error("non exhaustive match")};var a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.separator="-",t.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},t}return n(t,e),t.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},t.prototype.visitTerminal=function(e){var t=e.terminalType.name+this.separator+"Terminal";r.has(this.dslMethods,t)||(this.dslMethods[t]=[]),this.dslMethods[t].push(e)},t.prototype.visitNonTerminal=function(e){var t=e.nonTerminalName+this.separator+"Terminal";r.has(this.dslMethods,t)||(this.dslMethods[t]=[]),this.dslMethods[t].push(e)},t.prototype.visitOption=function(e){this.dslMethods.option.push(e)},t.prototype.visitRepetitionWithSeparator=function(e){this.dslMethods.repetitionWithSeparator.push(e)},t.prototype.visitRepetitionMandatory=function(e){this.dslMethods.repetitionMandatory.push(e)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)},t.prototype.visitRepetition=function(e){this.dslMethods.repetition.push(e)},t.prototype.visitAlternation=function(e){this.dslMethods.alternation.push(e)},t}(s.GAstVisitor);e.DslMethodsCollectorVisitor=a;var l=new a;e.collectMethods=function(e){l.reset(),e.accept(l);var t=l.dslMethods;return l.reset(),t}})),y=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.firstForTerminal=e.firstForBranching=e.firstForSequence=e.first=void 0;var t=o(),n=f(),r=v();function i(e){if(e instanceof n.NonTerminal)return i(e.referencedRule);if(e instanceof n.Terminal)return l(e);if(r.isSequenceProd(e))return s(e);if(r.isBranchingProd(e))return a(e);throw Error("non exhaustive match")}function s(e){for(var n,o=[],s=e.definition,a=0,l=s.length>a,c=!0;l&&c;)n=s[a],c=r.isOptionalProd(n),o=o.concat(i(n)),a+=1,l=s.length>a;return t.uniq(o)}function a(e){var n=t.map(e.definition,(function(e){return i(e)}));return t.uniq(t.flatten(n))}function l(e){return[e.terminalType]}e.first=i,e.firstForSequence=s,e.firstForBranching=a,e.firstForTerminal=l})),x=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IN=void 0,e.IN="_~IN~_"})),_=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.buildInProdFollowPrefix=e.buildBetweenProdsFollowPrefix=e.computeAllProdsFollows=e.ResyncFollowsWalker=void 0;var r=m(),i=y(),s=o(),a=x(),l=f(),c=function(e){function t(t){var n=e.call(this)||this;return n.topProd=t,n.follows={},n}return n(t,e),t.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},t.prototype.walkTerminal=function(e,t,n){},t.prototype.walkProdRef=function(e,t,n){var r=u(e.referencedRule,e.idx)+this.topProd.name,o=t.concat(n),s=new l.Alternative({definition:o}),a=i.first(s);this.follows[r]=a},t}(r.RestWalker);function u(e,t){return e.name+t+a.IN}e.ResyncFollowsWalker=c,e.computeAllProdsFollows=function(e){var t={};return s.forEach(e,(function(e){var n=new c(e).startWalking();s.assign(t,n)})),t},e.buildBetweenProdsFollowPrefix=u,e.buildInProdFollowPrefix=function(e){return e.terminalType.name+e.idx+a.IN}})),T=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultGrammarValidatorErrorProvider=e.defaultGrammarResolverErrorProvider=e.defaultParserErrorProvider=void 0;var t=p(),n=o(),r=o(),i=f(),s=v();e.defaultParserErrorProvider={buildMismatchTokenMessage:function(e){var n=e.expected,r=e.actual;e.previous,e.ruleName;return"Expecting "+(t.hasTokenLabel(n)?"--\x3e "+t.tokenLabel(n)+" <--":"token of type --\x3e "+n.name+" <--")+" but found --\x3e '"+r.image+"' <--"},buildNotAllInputParsedMessage:function(e){var t=e.firstRedundant;e.ruleName;return"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage:function(e){var n=e.expectedPathsPerAlt,i=e.actual,o=(e.previous,e.customUserDescription),s=(e.ruleName,"Expecting: "),a="\nbut found: '"+r.first(i).image+"'";if(o)return s+o+a;var l=r.reduce(n,(function(e,t){return e.concat(t)}),[]),c=r.map(l,(function(e){return"["+r.map(e,(function(e){return t.tokenLabel(e)})).join(", ")+"]"}));return s+("one of these possible Token sequences:\n"+r.map(c,(function(e,t){return"  "+(t+1)+". "+e})).join("\n"))+a},buildEarlyExitMessage:function(e){var n=e.expectedIterationPaths,i=e.actual,o=e.customUserDescription,s=(e.ruleName,"Expecting: "),a="\nbut found: '"+r.first(i).image+"'";return o?s+o+a:s+("expecting at least one iteration which starts with one of these possible Token sequences::\n  <"+r.map(n,(function(e){return"["+r.map(e,(function(e){return t.tokenLabel(e)})).join(",")+"]"})).join(" ,")+">")+a}},Object.freeze(e.defaultParserErrorProvider),e.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"}},e.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(e,t){var n,o=e.name,a=r.first(t),l=a.idx,c=s.getProductionDslName(a),u=(n=a)instanceof i.Terminal?n.terminalType.name:n instanceof i.NonTerminal?n.nonTerminalName:"",h="->"+c+(l>0?l:"")+"<- "+(u?"with argument: ->"+u+"<-":"")+"\n                  appears more than once ("+t.length+" times) in the top level rule: ->"+o+"<-.\n                  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES\n                  ";return h=(h=h.replace(/[ \t]+/g," ")).replace(/\s\s+/g,"\n")},buildNamespaceConflictError:function(e){return"Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+e.name+">.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter."},buildAlternationPrefixAmbiguityError:function(e){var n=r.map(e.prefixPath,(function(e){return t.tokenLabel(e)})).join(", "),i=0===e.alternation.idx?"":e.alternation.idx;return"Ambiguous alternatives: <"+e.ambiguityIndices.join(" ,")+"> due to common lookahead prefix\nin <OR"+i+"> inside <"+e.topLevelRule.name+"> Rule,\n<"+n+"> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details."},buildAlternationAmbiguityError:function(e){var n=r.map(e.prefixPath,(function(e){return t.tokenLabel(e)})).join(", "),i=0===e.alternation.idx?"":e.alternation.idx,o="Ambiguous Alternatives Detected: <"+e.ambiguityIndices.join(" ,")+"> in <OR"+i+"> inside <"+e.topLevelRule.name+"> Rule,\n<"+n+"> may appears as a prefix path in all these alternatives.\n";return o+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details."},buildEmptyRepetitionError:function(e){var t=s.getProductionDslName(e.repetition);return 0!==e.repetition.idx&&(t+=e.repetition.idx),"The repetition <"+t+"> within Rule <"+e.topLevelRule.name+"> can never consume any tokens.\nThis could lead to an infinite loop."},buildTokenNameError:function(e){return"deprecated"},buildEmptyAlternationError:function(e){return"Ambiguous empty alternative: <"+(e.emptyChoiceIdx+1)+"> in <OR"+e.alternation.idx+"> inside <"+e.topLevelRule.name+"> Rule.\nOnly the last alternative may be an empty alternative."},buildTooManyAlternativesError:function(e){return"An Alternation cannot have more than 256 alternatives:\n<OR"+e.alternation.idx+"> inside <"+e.topLevelRule.name+"> Rule.\n has "+(e.alternation.definition.length+1)+" alternatives."},buildLeftRecursionError:function(e){var t=e.topLevelRule.name;return"Left Recursion found in grammar.\nrule: <"+t+"> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is:\n "+(t+" --\x3e "+n.map(e.leftRecursionPath,(function(e){return e.name})).concat([t]).join(" --\x3e "))+"\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring."},buildInvalidRuleNameError:function(e){return"deprecated"},buildDuplicateRuleNameError:function(e){return"Duplicate definition, rule: ->"+(e.topLevelRule instanceof i.Rule?e.topLevelRule.name:e.topLevelRule)+"<- is already defined in the grammar: ->"+e.grammarName+"<-"}}})),E=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.GastRefResolverVisitor=e.resolveGrammar=void 0;var r=H(),i=o(),s=g();e.resolveGrammar=function(e,t){var n=new a(e,t);return n.resolveRefs(),n.errors};var a=function(e){function t(t,n){var r=e.call(this)||this;return r.nameToTopRule=t,r.errMsgProvider=n,r.errors=[],r}return n(t,e),t.prototype.resolveRefs=function(){var e=this;i.forEach(i.values(this.nameToTopRule),(function(t){e.currTopLevel=t,t.accept(e)}))},t.prototype.visitNonTerminal=function(e){var t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{var n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:r.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}},t}(s.GAstVisitor);e.GastRefResolverVisitor=a})),M=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.nextPossibleTokensAfter=e.possiblePathsFrom=e.NextTerminalAfterAtLeastOneSepWalker=e.NextTerminalAfterAtLeastOneWalker=e.NextTerminalAfterManySepWalker=e.NextTerminalAfterManyWalker=e.AbstractNextTerminalAfterProductionWalker=e.NextAfterTokenWalker=e.AbstractNextPossibleTokensWalker=void 0;var r=m(),i=o(),s=y(),a=f(),l=function(e){function t(t,n){var r=e.call(this)||this;return r.topProd=t,r.path=n,r.possibleTokTypes=[],r.nextProductionName="",r.nextProductionOccurrence=0,r.found=!1,r.isAtEndOfPath=!1,r}return n(t,e),t.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=i.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=i.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},t.prototype.walk=function(t,n){void 0===n&&(n=[]),this.found||e.prototype.walk.call(this,t,n)},t.prototype.walkProdRef=function(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){var r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}},t.prototype.updateExpectedNext=function(){i.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},t}(r.RestWalker);e.AbstractNextPossibleTokensWalker=l;var c=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.path=n,r.nextTerminalName="",r.nextTerminalOccurrence=0,r.nextTerminalName=r.path.lastTok.name,r.nextTerminalOccurrence=r.path.lastTokOccurrence,r}return n(t,e),t.prototype.walkTerminal=function(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){var r=t.concat(n),i=new a.Alternative({definition:r});this.possibleTokTypes=s.first(i),this.found=!0}},t}(l);e.NextAfterTokenWalker=c;var u=function(e){function t(t,n){var r=e.call(this)||this;return r.topRule=t,r.occurrence=n,r.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},r}return n(t,e),t.prototype.startWalking=function(){return this.walk(this.topRule),this.result},t}(r.RestWalker);e.AbstractNextTerminalAfterProductionWalker=u;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkMany=function(t,n,r){if(t.idx===this.occurrence){var o=i.first(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof a.Terminal&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else e.prototype.walkMany.call(this,t,n,r)},t}(u);e.NextTerminalAfterManyWalker=h;var d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkManySep=function(t,n,r){if(t.idx===this.occurrence){var o=i.first(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof a.Terminal&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else e.prototype.walkManySep.call(this,t,n,r)},t}(u);e.NextTerminalAfterManySepWalker=d;var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkAtLeastOne=function(t,n,r){if(t.idx===this.occurrence){var o=i.first(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof a.Terminal&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else e.prototype.walkAtLeastOne.call(this,t,n,r)},t}(u);e.NextTerminalAfterAtLeastOneWalker=p;var g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.walkAtLeastOneSep=function(t,n,r){if(t.idx===this.occurrence){var o=i.first(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof a.Terminal&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else e.prototype.walkAtLeastOneSep.call(this,t,n,r)},t}(u);function v(e,t,n,r){var o=i.cloneArr(n);o.push(e.name);var s=i.cloneArr(r);return s.push(1),{idx:t,def:e.definition,ruleStack:o,occurrenceStack:s}}e.NextTerminalAfterAtLeastOneSepWalker=g,e.possiblePathsFrom=function e(t,n,r){void 0===r&&(r=[]),r=i.cloneArr(r);var o=[],s=0;function l(a){var l=e(function(e){return e.concat(i.drop(t,s+1))}(a),n,r);return o.concat(l)}for(;r.length<n&&s<t.length;){var c=t[s];if(c instanceof a.Alternative)return l(c.definition);if(c instanceof a.NonTerminal)return l(c.definition);if(c instanceof a.Option)o=l(c.definition);else{if(c instanceof a.RepetitionMandatory)return l(u=c.definition.concat([new a.Repetition({definition:c.definition})]));if(c instanceof a.RepetitionMandatoryWithSeparator)return l(u=[new a.Alternative({definition:c.definition}),new a.Repetition({definition:[new a.Terminal({terminalType:c.separator})].concat(c.definition)})]);if(c instanceof a.RepetitionWithSeparator){var u=c.definition.concat([new a.Repetition({definition:[new a.Terminal({terminalType:c.separator})].concat(c.definition)})]);o=l(u)}else if(c instanceof a.Repetition){u=c.definition.concat([new a.Repetition({definition:c.definition})]);o=l(u)}else{if(c instanceof a.Alternation)return i.forEach(c.definition,(function(e){!1===i.isEmpty(e.definition)&&(o=l(e.definition))})),o;if(!(c instanceof a.Terminal))throw Error("non exhaustive match");r.push(c.terminalType)}}s++}return o.push({partialPath:r,suffixDef:i.drop(t,s)}),o},e.nextPossibleTokensAfter=function(e,t,n,r){var o="EXIT_NONE_TERMINAL",s=[o],l="EXIT_ALTERNATIVE",c=!1,u=t.length,h=u-r-1,d=[],p=[];for(p.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!i.isEmpty(p);){var f=p.pop();if(f!==l){var m=f.def,g=f.idx,y=f.ruleStack,x=f.occurrenceStack;if(!i.isEmpty(m)){var _=m[0];if(_===o){var T={idx:g,def:i.drop(m),ruleStack:i.dropRight(y),occurrenceStack:i.dropRight(x)};p.push(T)}else if(_ instanceof a.Terminal)if(g<u-1){var E=g+1;if(n(t[E],_.terminalType)){T={idx:E,def:i.drop(m),ruleStack:y,occurrenceStack:x};p.push(T)}}else{if(g!==u-1)throw Error("non exhaustive match");d.push({nextTokenType:_.terminalType,nextTokenOccurrence:_.idx,ruleStack:y,occurrenceStack:x}),c=!0}else if(_ instanceof a.NonTerminal){var M=i.cloneArr(y);M.push(_.nonTerminalName);var b=i.cloneArr(x);b.push(_.idx);T={idx:g,def:_.definition.concat(s,i.drop(m)),ruleStack:M,occurrenceStack:b};p.push(T)}else if(_ instanceof a.Option){var S={idx:g,def:i.drop(m),ruleStack:y,occurrenceStack:x};p.push(S),p.push(l);var w={idx:g,def:_.definition.concat(i.drop(m)),ruleStack:y,occurrenceStack:x};p.push(w)}else if(_ instanceof a.RepetitionMandatory){var A=new a.Repetition({definition:_.definition,idx:_.idx});T={idx:g,def:_.definition.concat([A],i.drop(m)),ruleStack:y,occurrenceStack:x};p.push(T)}else if(_ instanceof a.RepetitionMandatoryWithSeparator){var C=new a.Terminal({terminalType:_.separator});A=new a.Repetition({definition:[C].concat(_.definition),idx:_.idx}),T={idx:g,def:_.definition.concat([A],i.drop(m)),ruleStack:y,occurrenceStack:x};p.push(T)}else if(_ instanceof a.RepetitionWithSeparator){S={idx:g,def:i.drop(m),ruleStack:y,occurrenceStack:x};p.push(S),p.push(l);C=new a.Terminal({terminalType:_.separator});var R=new a.Repetition({definition:[C].concat(_.definition),idx:_.idx});w={idx:g,def:_.definition.concat([R],i.drop(m)),ruleStack:y,occurrenceStack:x};p.push(w)}else if(_ instanceof a.Repetition){S={idx:g,def:i.drop(m),ruleStack:y,occurrenceStack:x};p.push(S),p.push(l);R=new a.Repetition({definition:_.definition,idx:_.idx}),w={idx:g,def:_.definition.concat([R],i.drop(m)),ruleStack:y,occurrenceStack:x};p.push(w)}else if(_ instanceof a.Alternation)for(var I=_.definition.length-1;I>=0;I--){var P={idx:g,def:_.definition[I].definition.concat(i.drop(m)),ruleStack:y,occurrenceStack:x};p.push(P),p.push(l)}else if(_ instanceof a.Alternative)p.push({idx:g,def:_.definition.concat(i.drop(m)),ruleStack:y,occurrenceStack:x});else{if(!(_ instanceof a.Rule))throw Error("non exhaustive match");p.push(v(_,g,y,x))}}}else c&&i.last(p).idx<=h&&p.pop()}return d}})),b=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.areTokenCategoriesNotUsed=e.isStrictPrefixOfPath=e.containsPath=e.getLookaheadPathsForOptionalProd=e.getLookaheadPathsForOr=e.lookAheadSequenceFromAlternatives=e.buildSingleAlternativeLookaheadFunction=e.buildAlternativesLookAheadFunc=e.buildLookaheadFuncForOptionalProd=e.buildLookaheadFuncForOr=e.getProdType=e.PROD_TYPE=void 0;var r,i=o(),s=M(),a=m(),l=u(),c=f(),h=g();!function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"}(r=e.PROD_TYPE||(e.PROD_TYPE={})),e.getProdType=function(e){if(e instanceof c.Option)return r.OPTION;if(e instanceof c.Repetition)return r.REPETITION;if(e instanceof c.RepetitionMandatory)return r.REPETITION_MANDATORY;if(e instanceof c.RepetitionMandatoryWithSeparator)return r.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof c.RepetitionWithSeparator)return r.REPETITION_WITH_SEPARATOR;if(e instanceof c.Alternation)return r.ALTERNATION;throw Error("non exhaustive match")},e.buildLookaheadFuncForOr=function(e,t,n,r,i,o){var s=T(e,t,n);return o(s,r,S(s)?l.tokenStructuredMatcherNoCategories:l.tokenStructuredMatcher,i)},e.buildLookaheadFuncForOptionalProd=function(e,t,n,r,i,o){var s=E(e,t,i,n),a=S(s)?l.tokenStructuredMatcherNoCategories:l.tokenStructuredMatcher;return o(s[0],a,r)},e.buildAlternativesLookAheadFunc=function(e,t,n,r){var o=e.length,s=i.every(e,(function(e){return i.every(e,(function(e){return 1===e.length}))}));if(t)return function(t){for(var r=i.map(t,(function(e){return e.GATE})),s=0;s<o;s++){var a=e[s],l=a.length,c=r[s];if(void 0===c||!1!==c.call(this))e:for(var u=0;u<l;u++){for(var h=a[u],d=h.length,p=0;p<d;p++){var f=this.LA(p+1);if(!1===n(f,h[p]))continue e}return s}}};if(s&&!r){var a=i.map(e,(function(e){return i.flatten(e)})),l=i.reduce(a,(function(e,t,n){return i.forEach(t,(function(t){i.has(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),i.forEach(t.categoryMatches,(function(t){i.has(e,t)||(e[t]=n)}))})),e}),[]);return function(){var e=this.LA(1);return l[e.tokenTypeIdx]}}return function(){for(var t=0;t<o;t++){var r=e[t],i=r.length;e:for(var s=0;s<i;s++){for(var a=r[s],l=a.length,c=0;c<l;c++){var u=this.LA(c+1);if(!1===n(u,a[c]))continue e}return t}}}},e.buildSingleAlternativeLookaheadFunction=function(e,t,n){var r=i.every(e,(function(e){return 1===e.length})),o=e.length;if(r&&!n){var s=i.flatten(e);if(1===s.length&&i.isEmpty(s[0].categoryMatches)){var a=s[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===a}}var l=i.reduce(s,(function(e,t,n){return e[t.tokenTypeIdx]=!0,i.forEach(t.categoryMatches,(function(t){e[t]=!0})),e}),[]);return function(){var e=this.LA(1);return!0===l[e.tokenTypeIdx]}}return function(){e:for(var n=0;n<o;n++){for(var r=e[n],i=r.length,s=0;s<i;s++){var a=this.LA(s+1);if(!1===t(a,r[s]))continue e}return!0}return!1}};var d=function(e){function t(t,n,r){var i=e.call(this)||this;return i.topProd=t,i.targetOccurrence=n,i.targetProdType=r,i}return n(t,e),t.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},t.prototype.checkIsTarget=function(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=n.concat(r),!0)},t.prototype.walkOption=function(t,n,i){this.checkIsTarget(t,r.OPTION,n,i)||e.prototype.walkOption.call(this,t,n,i)},t.prototype.walkAtLeastOne=function(t,n,i){this.checkIsTarget(t,r.REPETITION_MANDATORY,n,i)||e.prototype.walkOption.call(this,t,n,i)},t.prototype.walkAtLeastOneSep=function(t,n,i){this.checkIsTarget(t,r.REPETITION_MANDATORY_WITH_SEPARATOR,n,i)||e.prototype.walkOption.call(this,t,n,i)},t.prototype.walkMany=function(t,n,i){this.checkIsTarget(t,r.REPETITION,n,i)||e.prototype.walkOption.call(this,t,n,i)},t.prototype.walkManySep=function(t,n,i){this.checkIsTarget(t,r.REPETITION_WITH_SEPARATOR,n,i)||e.prototype.walkOption.call(this,t,n,i)},t}(a.RestWalker),p=function(e){function t(t,n,r){var i=e.call(this)||this;return i.targetOccurrence=t,i.targetProdType=n,i.targetRef=r,i.result=[],i}return n(t,e),t.prototype.checkIsTarget=function(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(void 0===this.targetRef||e===this.targetRef)&&(this.result=e.definition)},t.prototype.visitOption=function(e){this.checkIsTarget(e,r.OPTION)},t.prototype.visitRepetition=function(e){this.checkIsTarget(e,r.REPETITION)},t.prototype.visitRepetitionMandatory=function(e){this.checkIsTarget(e,r.REPETITION_MANDATORY)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.checkIsTarget(e,r.REPETITION_MANDATORY_WITH_SEPARATOR)},t.prototype.visitRepetitionWithSeparator=function(e){this.checkIsTarget(e,r.REPETITION_WITH_SEPARATOR)},t.prototype.visitAlternation=function(e){this.checkIsTarget(e,r.ALTERNATION)},t}(h.GAstVisitor);function v(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=[];return t}function y(e){for(var t=[""],n=0;n<e.length;n++){for(var r=e[n],i=[],o=0;o<t.length;o++){var s=t[o];i.push(s+"_"+r.tokenTypeIdx);for(var a=0;a<r.categoryMatches.length;a++){var l="_"+r.categoryMatches[a];i.push(s+l)}}t=i}return t}function x(e,t,n){for(var r=0;r<e.length;r++)if(r!==n)for(var i=e[r],o=0;o<t.length;o++){if(!0===i[t[o]])return!1}return!0}function _(e,t){for(var n=i.map(e,(function(e){return s.possiblePathsFrom([e],1)})),r=v(n.length),o=i.map(n,(function(e){var t={};return i.forEach(e,(function(e){var n=y(e.partialPath);i.forEach(n,(function(e){t[e]=!0}))})),t})),a=n,l=1;l<=t;l++){var c=a;a=v(c.length);for(var u=function(e){for(var n=c[e],u=0;u<n.length;u++){var h=n[u].partialPath,d=n[u].suffixDef,p=y(h);if(x(o,p,e)||i.isEmpty(d)||h.length===t){var f=r[e];if(!1===b(f,h)){f.push(h);for(var m=0;m<p.length;m++){var g=p[m];o[e][g]=!0}}}else{var v=s.possiblePathsFrom(d,l+1,h);a[e]=a[e].concat(v),i.forEach(v,(function(t){var n=y(t.partialPath);i.forEach(n,(function(t){o[e][t]=!0}))}))}}},h=0;h<c.length;h++)u(h)}return r}function T(e,t,n,i){var o=new p(e,r.ALTERNATION,i);return t.accept(o),_(o.result,n)}function E(e,t,n,r){var i=new p(e,n);t.accept(i);var o=i.result,s=new d(t,e,n).startWalking();return _([new c.Alternative({definition:o}),new c.Alternative({definition:s})],r)}function b(e,t){e:for(var n=0;n<e.length;n++){var r=e[n];if(r.length===t.length){for(var i=0;i<r.length;i++){var o=t[i],s=r[i];if(!1===(o===s||void 0!==s.categoryMatchesMap[o.tokenTypeIdx]))continue e}return!0}}return!1}function S(e){return i.every(e,(function(e){return i.every(e,(function(e){return i.every(e,(function(e){return i.isEmpty(e.categoryMatches)}))}))}))}e.lookAheadSequenceFromAlternatives=_,e.getLookaheadPathsForOr=T,e.getLookaheadPathsForOptionalProd=E,e.containsPath=b,e.isStrictPrefixOfPath=function(e,t){return e.length<t.length&&i.every(e,(function(e,n){var r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]}))},e.areTokenCategoriesNotUsed=S})),S=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.checkPrefixAlternativesAmbiguities=e.validateSomeNonEmptyLookaheadPath=e.validateTooManyAlts=e.RepetionCollector=e.validateAmbiguousAlternationAlternatives=e.validateEmptyOrAlternative=e.getFirstNoneTerminal=e.validateNoLeftRecursion=e.validateRuleIsOverridden=e.validateRuleDoesNotAlreadyExist=e.OccurrenceValidationCollector=e.identifyProductionForDuplicates=e.validateGrammar=void 0;var r=o(),i=o(),s=H(),a=v(),l=b(),c=M(),u=f(),h=g();function d(e){return a.getProductionDslName(e)+"_#_"+e.idx+"_#_"+p(e)}function p(e){return e instanceof u.Terminal?e.terminalType.name:e instanceof u.NonTerminal?e.nonTerminalName:""}e.validateGrammar=function(e,t,n,o,l){var c=r.map(e,(function(e){return function(e,t){var n=new m;e.accept(n);var i=n.allProductions,o=r.groupBy(i,d),l=r.pick(o,(function(e){return e.length>1})),c=r.map(r.values(l),(function(n){var i=r.first(n),o=t.buildDuplicateFoundError(e,n),l=a.getProductionDslName(i),c={message:o,type:s.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:l,occurrence:i.idx},u=p(i);return u&&(c.parameter=u),c}));return c}(e,o)})),u=r.map(e,(function(e){return x(e,e,o)})),h=[],f=[],g=[];i.every(u,i.isEmpty)&&(h=i.map(e,(function(e){return E(e,o)})),f=i.map(e,(function(e){return S(e,t,o)})),g=C(e,t,o));var v=function(e,t,n){var r=[],o=i.map(t,(function(e){return e.name}));return i.forEach(e,(function(e){var t=e.name;if(i.contains(o,t)){var a=n.buildNamespaceConflictError(e);r.push({message:a,type:s.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}})),r}(e,n,o),_=i.map(e,(function(e){return A(e,o)})),T=i.map(e,(function(t){return y(t,e,l,o)}));return r.flatten(c.concat(g,u,h,f,v,_,T))},e.identifyProductionForDuplicates=d;var m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.allProductions=[],t}return n(t,e),t.prototype.visitNonTerminal=function(e){this.allProductions.push(e)},t.prototype.visitOption=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatory=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetition=function(e){this.allProductions.push(e)},t.prototype.visitAlternation=function(e){this.allProductions.push(e)},t.prototype.visitTerminal=function(e){this.allProductions.push(e)},t}(h.GAstVisitor);function y(e,t,n,r){var o=[];if(i.reduce(t,(function(t,n){return n.name===e.name?t+1:t}),0)>1){var a=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});o.push({message:a,type:s.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e.name})}return o}function x(e,t,n,i){void 0===i&&(i=[]);var o=[],a=_(t.definition);if(r.isEmpty(a))return[];var l=e.name;r.contains(a,e)&&o.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:i}),type:s.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:l});var c=r.difference(a,i.concat([e])),u=r.map(c,(function(t){var o=r.cloneArr(i);return o.push(t),x(e,t,n,o)}));return o.concat(r.flatten(u))}function _(e){var t=[];if(r.isEmpty(e))return t;var n=r.first(e);if(n instanceof u.NonTerminal)t.push(n.referencedRule);else if(n instanceof u.Alternative||n instanceof u.Option||n instanceof u.RepetitionMandatory||n instanceof u.RepetitionMandatoryWithSeparator||n instanceof u.RepetitionWithSeparator||n instanceof u.Repetition)t=t.concat(_(n.definition));else if(n instanceof u.Alternation)t=r.flatten(r.map(n.definition,(function(e){return _(e.definition)})));else if(!(n instanceof u.Terminal))throw Error("non exhaustive match");var i=a.isOptionalProd(n),o=e.length>1;if(i&&o){var s=r.drop(e);return t.concat(_(s))}return t}e.OccurrenceValidationCollector=m,e.validateRuleDoesNotAlreadyExist=y,e.validateRuleIsOverridden=function(e,t,n){var i,o=[];return r.contains(t,e)||(i="Invalid rule override, rule: ->"+e+"<- cannot be overridden in the grammar: ->"+n+"<-as it is not defined in any of the super grammars ",o.push({message:i,type:s.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:e})),o},e.validateNoLeftRecursion=x,e.getFirstNoneTerminal=_;var T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.alternations=[],t}return n(t,e),t.prototype.visitAlternation=function(e){this.alternations.push(e)},t}(h.GAstVisitor);function E(e,t){var n=new T;e.accept(n);var i=n.alternations;return r.reduce(i,(function(n,i){var o=r.dropRight(i.definition),a=r.map(o,(function(n,o){var a=c.nextPossibleTokensAfter([n],[],null,1);return r.isEmpty(a)?{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:i,emptyChoiceIdx:o}),type:s.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:i.idx,alternative:o+1}:null}));return n.concat(r.compact(a))}),[])}function S(e,t,n){var o=new T;e.accept(o);var a=o.alternations;a=i.reject(a,(function(e){return!0===e.ignoreAmbiguities}));var c=r.reduce(a,(function(o,a){var c=a.idx,u=a.maxLookahead||t,h=l.getLookaheadPathsForOr(c,e,u,a),d=function(e,t,n,o){var a=[],c=i.reduce(e,(function(n,r,o){return!0===t.definition[o].ignoreAmbiguities||i.forEach(r,(function(r){var s=[o];i.forEach(e,(function(e,n){o!==n&&l.containsPath(e,r)&&!0!==t.definition[n].ignoreAmbiguities&&s.push(n)})),s.length>1&&!l.containsPath(a,r)&&(a.push(r),n.push({alts:s,path:r}))})),n}),[]),u=r.map(c,(function(e){var r=i.map(e.alts,(function(e){return e+1}));return{message:o.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:r,prefixPath:e.path}),type:s.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:[e.alts]}}));return u}(h,a,e,n),p=R(h,a,e,n);return o.concat(d,p)}),[]);return c}e.validateEmptyOrAlternative=E,e.validateAmbiguousAlternationAlternatives=S;var w=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.allProductions=[],t}return n(t,e),t.prototype.visitRepetitionWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatory=function(e){this.allProductions.push(e)},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){this.allProductions.push(e)},t.prototype.visitRepetition=function(e){this.allProductions.push(e)},t}(h.GAstVisitor);function A(e,t){var n=new T;e.accept(n);var i=n.alternations;return r.reduce(i,(function(n,r){return r.definition.length>255&&n.push({message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:r}),type:s.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:e.name,occurrence:r.idx}),n}),[])}function C(e,t,n){var r=[];return i.forEach(e,(function(e){var o=new w;e.accept(o);var a=o.allProductions;i.forEach(a,(function(o){var a=l.getProdType(o),c=o.maxLookahead||t,u=o.idx,h=l.getLookaheadPathsForOptionalProd(u,e,a,c)[0];if(i.isEmpty(i.flatten(h))){var d=n.buildEmptyRepetitionError({topLevelRule:e,repetition:o});r.push({message:d,type:s.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}}))})),r}function R(e,t,n,r){var o=[],a=i.reduce(e,(function(e,t,n){var r=i.map(t,(function(e){return{idx:n,path:e}}));return e.concat(r)}),[]);return i.forEach(a,(function(e){if(!0!==t.definition[e.idx].ignoreAmbiguities){var c=e.idx,u=e.path,h=i.findAll(a,(function(e){return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<c&&l.isStrictPrefixOfPath(e.path,u)})),d=i.map(h,(function(e){var i=[e.idx+1,c+1],o=0===t.idx?"":t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:s.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}}));o=o.concat(d)}})),o}e.RepetionCollector=w,e.validateTooManyAlts=A,e.validateSomeNonEmptyLookaheadPath=C,e.checkPrefixAlternativesAmbiguities=R})),w=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateGrammar=e.resolveGrammar=void 0;var t=o(),n=E(),r=S(),i=T();e.resolveGrammar=function(e){e=t.defaults(e,{errMsgProvider:i.defaultGrammarResolverErrorProvider});var r={};return t.forEach(e.rules,(function(e){r[e.name]=e})),n.resolveGrammar(r,e.errMsgProvider)},e.validateGrammar=function(e){return e=t.defaults(e,{errMsgProvider:i.defaultGrammarValidatorErrorProvider}),r.validateGrammar(e.rules,e.maxLookahead,e.tokenTypes,e.errMsgProvider,e.grammarName)}})),A=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.EarlyExitException=e.NotAllInputParsedException=e.NoViableAltException=e.MismatchedTokenException=e.isRecognitionException=void 0;var r=o(),i="MismatchedTokenException",s="NoViableAltException",a="EarlyExitException",l="NotAllInputParsedException",c=[i,s,a,l];Object.freeze(c),e.isRecognitionException=function(e){return r.contains(c,e.name)};var u=function(e){function t(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.token=n,i.resyncedTokens=[],Object.setPrototypeOf(i,r.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,i.constructor),i}return n(t,e),t}(Error),h=function(e){function t(t,n,r){var o=e.call(this,t,n)||this;return o.previousToken=r,o.name=i,o}return n(t,e),t}(u);e.MismatchedTokenException=h;var d=function(e){function t(t,n,r){var i=e.call(this,t,n)||this;return i.previousToken=r,i.name=s,i}return n(t,e),t}(u);e.NoViableAltException=d;var p=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=l,r}return n(t,e),t}(u);e.NotAllInputParsedException=p;var f=function(e){function t(t,n,r){var i=e.call(this,t,n)||this;return i.previousToken=r,i.name=a,i}return n(t,e),t}(u);e.EarlyExitException=f})),C=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.attemptInRepetitionRecovery=e.Recoverable=e.InRuleRecoveryException=e.IN_RULE_RECOVERY_EXCEPTION=e.EOF_FOLLOW_KEY=void 0;var t=p(),n=o(),r=A(),i=x(),s=H();function a(t){this.name=e.IN_RULE_RECOVERY_EXCEPTION,this.message=t}e.EOF_FOLLOW_KEY={},e.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException",e.InRuleRecoveryException=a,a.prototype=Error.prototype;var l=function(){function o(){}return o.prototype.initRecoverable=function(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=n.has(e,"recoveryEnabled")?e.recoveryEnabled:s.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=c)},o.prototype.getTokenToInsert=function(e){var n=t.createTokenInstance(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return n.isInsertedInRecovery=!0,n},o.prototype.canTokenTypeBeInsertedInRecovery=function(e){return!0},o.prototype.tryInRepetitionRecovery=function(e,t,i,o){for(var s=this,a=this.findReSyncTokenType(),l=this.exportLexerState(),c=[],u=!1,h=this.LA(1),d=this.LA(1),p=function(){var e=s.LA(0),t=s.errorMessageProvider.buildMismatchTokenMessage({expected:o,actual:h,previous:e,ruleName:s.getCurrRuleFullName()}),i=new r.MismatchedTokenException(t,h,s.LA(0));i.resyncedTokens=n.dropRight(c),s.SAVE_ERROR(i)};!u;){if(this.tokenMatcher(d,o))return void p();if(i.call(this))return p(),void e.apply(this,t);this.tokenMatcher(d,a)?u=!0:(d=this.SKIP_TOKEN(),this.addToResyncTokens(d,c))}this.importLexerState(l)},o.prototype.shouldInRepetitionRecoveryBeTried=function(e,t,n){return!(!1===n||void 0===e||void 0===t||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))},o.prototype.getFollowsForInRuleRecovery=function(e,t){var n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)},o.prototype.tryInRuleRecovery=function(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){var n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new a("sad sad panda")},o.prototype.canPerformInRuleRecovery=function(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)},o.prototype.canRecoverWithSingleTokenInsertion=function(e,t){var r=this;if(!this.canTokenTypeBeInsertedInRecovery(e)||n.isEmpty(t))return!1;var i=this.LA(1);return void 0!==n.find(t,(function(e){return r.tokenMatcher(i,e)}))},o.prototype.canRecoverWithSingleTokenDeletion=function(e){return this.tokenMatcher(this.LA(2),e)},o.prototype.isInCurrentRuleReSyncSet=function(e){var t=this.getCurrFollowKey(),r=this.getFollowSetFromFollowKey(t);return n.contains(r,e)},o.prototype.findReSyncTokenType=function(){for(var e=this.flattenFollowSet(),t=this.LA(1),r=2;;){var i=t.tokenType;if(n.contains(e,i))return i;t=this.LA(r),r++}},o.prototype.getCurrFollowKey=function(){if(1===this.RULE_STACK.length)return e.EOF_FOLLOW_KEY;var t=this.getLastExplicitRuleShortName(),n=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:n,inRule:this.shortRuleNameToFullName(r)}},o.prototype.buildFullFollowKeyStack=function(){var t=this,r=this.RULE_STACK,i=this.RULE_OCCURRENCE_STACK;return n.map(r,(function(n,o){return 0===o?e.EOF_FOLLOW_KEY:{ruleName:t.shortRuleNameToFullName(n),idxInCallingRule:i[o],inRule:t.shortRuleNameToFullName(r[o-1])}}))},o.prototype.flattenFollowSet=function(){var e=this,t=n.map(this.buildFullFollowKeyStack(),(function(t){return e.getFollowSetFromFollowKey(t)}));return n.flatten(t)},o.prototype.getFollowSetFromFollowKey=function(n){if(n===e.EOF_FOLLOW_KEY)return[t.EOF];var r=n.ruleName+n.idxInCallingRule+i.IN+n.inRule;return this.resyncFollows[r]},o.prototype.addToResyncTokens=function(e,n){return this.tokenMatcher(e,t.EOF)||n.push(e),n},o.prototype.reSyncTo=function(e){for(var t=[],r=this.LA(1);!1===this.tokenMatcher(r,e);)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return n.dropRight(t)},o.prototype.attemptInRepetitionRecovery=function(e,t,n,r,i,o,s){},o.prototype.getCurrentGrammarPath=function(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:n.cloneArr(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}},o.prototype.getHumanReadableRuleStack=function(){var e=this;return n.map(this.RULE_STACK,(function(t){return e.shortRuleNameToFullName(t)}))},o}();function c(e,n,r,i,o,s,a){var l=this.getKeyForAutomaticLookahead(i,o),c=this.firstAfterRepMap[l];if(void 0===c){var u=this.getCurrRuleFullName();c=new s(this.getGAstProductions()[u],o).startWalking(),this.firstAfterRepMap[l]=c}var h=c.token,d=c.occurrence,p=c.isEndOfRule;1===this.RULE_STACK.length&&p&&void 0===h&&(h=t.EOF,d=1),this.shouldInRepetitionRecoveryBeTried(h,d,a)&&this.tryInRepetitionRecovery(e,n,r,h)}e.Recoverable=l,e.attemptInRepetitionRecovery=c})),R=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getKeyForAutomaticLookahead=e.AT_LEAST_ONE_SEP_IDX=e.MANY_SEP_IDX=e.AT_LEAST_ONE_IDX=e.MANY_IDX=e.OPTION_IDX=e.OR_IDX=e.BITS_FOR_ALT_IDX=e.BITS_FOR_RULE_IDX=e.BITS_FOR_OCCURRENCE_IDX=e.BITS_FOR_METHOD_TYPE=void 0,e.BITS_FOR_METHOD_TYPE=4,e.BITS_FOR_OCCURRENCE_IDX=8,e.BITS_FOR_RULE_IDX=12,e.BITS_FOR_ALT_IDX=8,e.OR_IDX=1<<e.BITS_FOR_OCCURRENCE_IDX,e.OPTION_IDX=2<<e.BITS_FOR_OCCURRENCE_IDX,e.MANY_IDX=3<<e.BITS_FOR_OCCURRENCE_IDX,e.AT_LEAST_ONE_IDX=4<<e.BITS_FOR_OCCURRENCE_IDX,e.MANY_SEP_IDX=5<<e.BITS_FOR_OCCURRENCE_IDX,e.AT_LEAST_ONE_SEP_IDX=6<<e.BITS_FOR_OCCURRENCE_IDX,e.getKeyForAutomaticLookahead=function(e,t,n){return n|t|e};e.BITS_FOR_ALT_IDX})),I=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LooksAhead=void 0;var t=b(),n=o(),r=H(),i=R(),s=v(),a=function(){function e(){}return e.prototype.initLooksAhead=function(e){this.dynamicTokensEnabled=n.has(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:r.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=n.has(e,"maxLookahead")?e.maxLookahead:r.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=n.isES2015MapSupported()?new Map:[],n.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},e.prototype.preComputeLookaheadFunctions=function(e){var r=this;n.forEach(e,(function(e){r.TRACE_INIT(e.name+" Rule Lookahead",(function(){var o=s.collectMethods(e),a=o.alternation,l=o.repetition,c=o.option,u=o.repetitionMandatory,h=o.repetitionMandatoryWithSeparator,d=o.repetitionWithSeparator;n.forEach(a,(function(n){var o=0===n.idx?"":n.idx;r.TRACE_INIT(""+s.getProductionDslName(n)+o,(function(){var o=t.buildLookaheadFuncForOr(n.idx,e,n.maxLookahead||r.maxLookahead,n.hasPredicates,r.dynamicTokensEnabled,r.lookAheadBuilderForAlternatives),s=i.getKeyForAutomaticLookahead(r.fullRuleNameToShort[e.name],i.OR_IDX,n.idx);r.setLaFuncCache(s,o)}))})),n.forEach(l,(function(n){r.computeLookaheadFunc(e,n.idx,i.MANY_IDX,t.PROD_TYPE.REPETITION,n.maxLookahead,s.getProductionDslName(n))})),n.forEach(c,(function(n){r.computeLookaheadFunc(e,n.idx,i.OPTION_IDX,t.PROD_TYPE.OPTION,n.maxLookahead,s.getProductionDslName(n))})),n.forEach(u,(function(n){r.computeLookaheadFunc(e,n.idx,i.AT_LEAST_ONE_IDX,t.PROD_TYPE.REPETITION_MANDATORY,n.maxLookahead,s.getProductionDslName(n))})),n.forEach(h,(function(n){r.computeLookaheadFunc(e,n.idx,i.AT_LEAST_ONE_SEP_IDX,t.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,n.maxLookahead,s.getProductionDslName(n))})),n.forEach(d,(function(n){r.computeLookaheadFunc(e,n.idx,i.MANY_SEP_IDX,t.PROD_TYPE.REPETITION_WITH_SEPARATOR,n.maxLookahead,s.getProductionDslName(n))}))}))}))},e.prototype.computeLookaheadFunc=function(e,n,r,o,s,a){var l=this;this.TRACE_INIT(""+a+(0===n?"":n),(function(){var a=t.buildLookaheadFuncForOptionalProd(n,e,s||l.maxLookahead,l.dynamicTokensEnabled,o,l.lookAheadBuilderForOptional),c=i.getKeyForAutomaticLookahead(l.fullRuleNameToShort[e.name],r,n);l.setLaFuncCache(c,a)}))},e.prototype.lookAheadBuilderForOptional=function(e,n,r){return t.buildSingleAlternativeLookaheadFunction(e,n,r)},e.prototype.lookAheadBuilderForAlternatives=function(e,n,r,i){return t.buildAlternativesLookAheadFunc(e,n,r,i)},e.prototype.getKeyForAutomaticLookahead=function(e,t){var n=this.getLastExplicitRuleShortName();return i.getKeyForAutomaticLookahead(n,e,t)},e.prototype.getLaFuncFromCache=function(e){},e.prototype.getLaFuncFromMap=function(e){return this.lookAheadFuncsCache.get(e)},e.prototype.getLaFuncFromObj=function(e){return this.lookAheadFuncsCache[e]},e.prototype.setLaFuncCache=function(e,t){},e.prototype.setLaFuncCacheUsingMap=function(e,t){this.lookAheadFuncsCache.set(e,t)},e.prototype.setLaFuncUsingObj=function(e,t){this.lookAheadFuncsCache[e]=t},e}();e.LooksAhead=a})),P=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.addNoneTerminalToCst=e.addTerminalToCst=e.setNodeLocationFull=e.setNodeLocationOnlyOffset=void 0,e.setNodeLocationOnlyOffset=function(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)},e.setNodeLocationFull=function(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)},e.addTerminalToCst=function(e,t,n){void 0===e.children[n]?e.children[n]=[t]:e.children[n].push(t)},e.addNoneTerminalToCst=function(e,t,n){void 0===e.children[t]?e.children[t]=[n]:e.children[t].push(n)}})),L=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defineNameProp=e.functionName=e.classNameFromInstance=void 0;var t=o();e.classNameFromInstance=function(e){return r(e.constructor)};var n="name";function r(e){return e.name||"anonymous"}e.functionName=r,e.defineNameProp=function(e,r){var i=Object.getOwnPropertyDescriptor(e,n);return!(!t.isUndefined(i)&&!i.configurable)&&(Object.defineProperty(e,n,{enumerable:!1,configurable:!0,writable:!1,value:r}),!0)}})),N=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateRedundantMethods=e.validateMissingCstMethods=e.validateVisitor=e.CstVisitorDefinitionError=e.createBaseVisitorConstructorWithDefaults=e.createBaseSemanticVisitorConstructor=e.defaultVisit=void 0;var t,n,r=o(),i=L();function s(e,t){for(var n=r.keys(e),i=n.length,o=0;o<i;o++)for(var s=e[n[o]],a=s.length,l=0;l<a;l++){var c=s[l];void 0===c.tokenTypeIdx&&this[c.name](c.children,t)}}function a(e,t){var n=l(e,t),r=u(e,t);return n.concat(r)}function l(e,n){var o=r.map(n,(function(n){if(!r.isFunction(e[n]))return{msg:"Missing visitor method: <"+n+"> on "+i.functionName(e.constructor)+" CST Visitor.",type:t.MISSING_METHOD,methodName:n}}));return r.compact(o)}e.defaultVisit=s,e.createBaseSemanticVisitorConstructor=function(e,t){var n=function(){};return i.defineNameProp(n,e+"BaseSemantics"),(n.prototype={visit:function(e,t){if(r.isArray(e)&&(e=e[0]),!r.isUndefined(e))return this[e.name](e.children,t)},validateVisitor:function(){var e=a(this,t);if(!r.isEmpty(e)){var n=r.map(e,(function(e){return e.msg}));throw Error("Errors Detected in CST Visitor <"+i.functionName(this.constructor)+">:\n\t"+n.join("\n\n").replace(/\n/g,"\n\t"))}}}).constructor=n,n._RULE_NAMES=t,n},e.createBaseVisitorConstructorWithDefaults=function(e,t,n){var o=function(){};i.defineNameProp(o,e+"BaseSemanticsWithDefaults");var a=Object.create(n.prototype);return r.forEach(t,(function(e){a[e]=s})),(o.prototype=a).constructor=o,o},(n=t=e.CstVisitorDefinitionError||(e.CstVisitorDefinitionError={}))[n.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",n[n.MISSING_METHOD=1]="MISSING_METHOD",e.validateVisitor=a,e.validateMissingCstMethods=l;var c=["constructor","visit","validateVisitor"];function u(e,n){var o=[];for(var s in e)r.isFunction(e[s])&&!r.contains(c,s)&&!r.contains(n,s)&&o.push({msg:"Redundant visitor method: <"+s+"> on "+i.functionName(e.constructor)+" CST Visitor\nThere is no Grammar Rule corresponding to this method's name.\n",type:t.REDUNDANT_METHOD,methodName:s});return o}e.validateRedundantMethods=u})),O=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TreeBuilder=void 0;var t=P(),n=o(),r=N(),i=H(),s=function(){function e(){}return e.prototype.initTreeBuilder=function(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=n.has(e,"nodeLocationTracking")?e.nodeLocationTracking:i.DEFAULT_PARSER_CONFIG.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=t.setNodeLocationFull,this.setNodeLocationFromNode=t.setNodeLocationFull,this.cstPostRule=n.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=n.NOOP,this.setNodeLocationFromNode=n.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=t.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=t.setNodeLocationOnlyOffset,this.cstPostRule=n.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=n.NOOP,this.setNodeLocationFromNode=n.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error('Invalid <nodeLocationTracking> config option: "'+e.nodeLocationTracking+'"');this.setNodeLocationFromToken=n.NOOP,this.setNodeLocationFromNode=n.NOOP,this.cstPostRule=n.NOOP,this.setInitialNodeLocation=n.NOOP}else this.cstInvocationStateUpdate=n.NOOP,this.cstFinallyStateUpdate=n.NOOP,this.cstPostTerminal=n.NOOP,this.cstPostNonTerminal=n.NOOP,this.cstPostRule=n.NOOP},e.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(e){e.location={startOffset:NaN,endOffset:NaN}},e.prototype.setInitialNodeLocationOnlyOffsetRegular=function(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},e.prototype.setInitialNodeLocationFullRecovery=function(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},e.prototype.setInitialNodeLocationFullRegular=function(e){var t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},e.prototype.cstInvocationStateUpdate=function(e,t){var n={name:e,children:{}};this.setInitialNodeLocation(n),this.CST_STACK.push(n)},e.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},e.prototype.cstPostRuleFull=function(e){var t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)},e.prototype.cstPostRuleOnlyOffset=function(e){var t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN},e.prototype.cstPostTerminal=function(e,n){var r=this.CST_STACK[this.CST_STACK.length-1];t.addTerminalToCst(r,n,e),this.setNodeLocationFromToken(r.location,n)},e.prototype.cstPostNonTerminal=function(e,n){var r=this.CST_STACK[this.CST_STACK.length-1];t.addNoneTerminalToCst(r,n,e),this.setNodeLocationFromNode(r.location,e.location)},e.prototype.getBaseCstVisitorConstructor=function(){if(n.isUndefined(this.baseCstVisitorConstructor)){var e=r.createBaseSemanticVisitorConstructor(this.className,n.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor},e.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(n.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var e=r.createBaseVisitorConstructorWithDefaults(this.className,n.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor},e.prototype.getLastExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-1]},e.prototype.getPreviousExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-2]},e.prototype.getLastExplicitRuleOccurrenceIndex=function(){var e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]},e}();e.TreeBuilder=s})),U=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LexerAdapter=void 0;var t=H(),n=function(){function e(){}return e.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(e.prototype,"input",{get:function(){return this.tokVector},set:function(e){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length},enumerable:!1,configurable:!0}),e.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):t.END_OF_FILE},e.prototype.LA=function(e){var n=this.currIdx+e;return n<0||this.tokVectorLength<=n?t.END_OF_FILE:this.tokVector[n]},e.prototype.consumeToken=function(){this.currIdx++},e.prototype.exportLexerState=function(){return this.currIdx},e.prototype.importLexerState=function(e){this.currIdx=e},e.prototype.resetLexerState=function(){this.currIdx=-1},e.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},e.prototype.getLexerPosition=function(){return this.exportLexerState()},e}();e.LexerAdapter=n})),D=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecognizerApi=void 0;var t=o(),n=A(),r=H(),i=T(),s=S(),a=f(),l=function(){function e(){}return e.prototype.ACTION=function(e){return e.call(this)},e.prototype.consume=function(e,t,n){return this.consumeInternal(t,e,n)},e.prototype.subrule=function(e,t,n){return this.subruleInternal(t,e,n)},e.prototype.option=function(e,t){return this.optionInternal(t,e)},e.prototype.or=function(e,t){return this.orInternal(t,e)},e.prototype.many=function(e,t){return this.manyInternal(e,t)},e.prototype.atLeastOne=function(e,t){return this.atLeastOneInternal(e,t)},e.prototype.CONSUME=function(e,t){return this.consumeInternal(e,0,t)},e.prototype.CONSUME1=function(e,t){return this.consumeInternal(e,1,t)},e.prototype.CONSUME2=function(e,t){return this.consumeInternal(e,2,t)},e.prototype.CONSUME3=function(e,t){return this.consumeInternal(e,3,t)},e.prototype.CONSUME4=function(e,t){return this.consumeInternal(e,4,t)},e.prototype.CONSUME5=function(e,t){return this.consumeInternal(e,5,t)},e.prototype.CONSUME6=function(e,t){return this.consumeInternal(e,6,t)},e.prototype.CONSUME7=function(e,t){return this.consumeInternal(e,7,t)},e.prototype.CONSUME8=function(e,t){return this.consumeInternal(e,8,t)},e.prototype.CONSUME9=function(e,t){return this.consumeInternal(e,9,t)},e.prototype.SUBRULE=function(e,t){return this.subruleInternal(e,0,t)},e.prototype.SUBRULE1=function(e,t){return this.subruleInternal(e,1,t)},e.prototype.SUBRULE2=function(e,t){return this.subruleInternal(e,2,t)},e.prototype.SUBRULE3=function(e,t){return this.subruleInternal(e,3,t)},e.prototype.SUBRULE4=function(e,t){return this.subruleInternal(e,4,t)},e.prototype.SUBRULE5=function(e,t){return this.subruleInternal(e,5,t)},e.prototype.SUBRULE6=function(e,t){return this.subruleInternal(e,6,t)},e.prototype.SUBRULE7=function(e,t){return this.subruleInternal(e,7,t)},e.prototype.SUBRULE8=function(e,t){return this.subruleInternal(e,8,t)},e.prototype.SUBRULE9=function(e,t){return this.subruleInternal(e,9,t)},e.prototype.OPTION=function(e){return this.optionInternal(e,0)},e.prototype.OPTION1=function(e){return this.optionInternal(e,1)},e.prototype.OPTION2=function(e){return this.optionInternal(e,2)},e.prototype.OPTION3=function(e){return this.optionInternal(e,3)},e.prototype.OPTION4=function(e){return this.optionInternal(e,4)},e.prototype.OPTION5=function(e){return this.optionInternal(e,5)},e.prototype.OPTION6=function(e){return this.optionInternal(e,6)},e.prototype.OPTION7=function(e){return this.optionInternal(e,7)},e.prototype.OPTION8=function(e){return this.optionInternal(e,8)},e.prototype.OPTION9=function(e){return this.optionInternal(e,9)},e.prototype.OR=function(e){return this.orInternal(e,0)},e.prototype.OR1=function(e){return this.orInternal(e,1)},e.prototype.OR2=function(e){return this.orInternal(e,2)},e.prototype.OR3=function(e){return this.orInternal(e,3)},e.prototype.OR4=function(e){return this.orInternal(e,4)},e.prototype.OR5=function(e){return this.orInternal(e,5)},e.prototype.OR6=function(e){return this.orInternal(e,6)},e.prototype.OR7=function(e){return this.orInternal(e,7)},e.prototype.OR8=function(e){return this.orInternal(e,8)},e.prototype.OR9=function(e){return this.orInternal(e,9)},e.prototype.MANY=function(e){this.manyInternal(0,e)},e.prototype.MANY1=function(e){this.manyInternal(1,e)},e.prototype.MANY2=function(e){this.manyInternal(2,e)},e.prototype.MANY3=function(e){this.manyInternal(3,e)},e.prototype.MANY4=function(e){this.manyInternal(4,e)},e.prototype.MANY5=function(e){this.manyInternal(5,e)},e.prototype.MANY6=function(e){this.manyInternal(6,e)},e.prototype.MANY7=function(e){this.manyInternal(7,e)},e.prototype.MANY8=function(e){this.manyInternal(8,e)},e.prototype.MANY9=function(e){this.manyInternal(9,e)},e.prototype.MANY_SEP=function(e){this.manySepFirstInternal(0,e)},e.prototype.MANY_SEP1=function(e){this.manySepFirstInternal(1,e)},e.prototype.MANY_SEP2=function(e){this.manySepFirstInternal(2,e)},e.prototype.MANY_SEP3=function(e){this.manySepFirstInternal(3,e)},e.prototype.MANY_SEP4=function(e){this.manySepFirstInternal(4,e)},e.prototype.MANY_SEP5=function(e){this.manySepFirstInternal(5,e)},e.prototype.MANY_SEP6=function(e){this.manySepFirstInternal(6,e)},e.prototype.MANY_SEP7=function(e){this.manySepFirstInternal(7,e)},e.prototype.MANY_SEP8=function(e){this.manySepFirstInternal(8,e)},e.prototype.MANY_SEP9=function(e){this.manySepFirstInternal(9,e)},e.prototype.AT_LEAST_ONE=function(e){this.atLeastOneInternal(0,e)},e.prototype.AT_LEAST_ONE1=function(e){return this.atLeastOneInternal(1,e)},e.prototype.AT_LEAST_ONE2=function(e){this.atLeastOneInternal(2,e)},e.prototype.AT_LEAST_ONE3=function(e){this.atLeastOneInternal(3,e)},e.prototype.AT_LEAST_ONE4=function(e){this.atLeastOneInternal(4,e)},e.prototype.AT_LEAST_ONE5=function(e){this.atLeastOneInternal(5,e)},e.prototype.AT_LEAST_ONE6=function(e){this.atLeastOneInternal(6,e)},e.prototype.AT_LEAST_ONE7=function(e){this.atLeastOneInternal(7,e)},e.prototype.AT_LEAST_ONE8=function(e){this.atLeastOneInternal(8,e)},e.prototype.AT_LEAST_ONE9=function(e){this.atLeastOneInternal(9,e)},e.prototype.AT_LEAST_ONE_SEP=function(e){this.atLeastOneSepFirstInternal(0,e)},e.prototype.AT_LEAST_ONE_SEP1=function(e){this.atLeastOneSepFirstInternal(1,e)},e.prototype.AT_LEAST_ONE_SEP2=function(e){this.atLeastOneSepFirstInternal(2,e)},e.prototype.AT_LEAST_ONE_SEP3=function(e){this.atLeastOneSepFirstInternal(3,e)},e.prototype.AT_LEAST_ONE_SEP4=function(e){this.atLeastOneSepFirstInternal(4,e)},e.prototype.AT_LEAST_ONE_SEP5=function(e){this.atLeastOneSepFirstInternal(5,e)},e.prototype.AT_LEAST_ONE_SEP6=function(e){this.atLeastOneSepFirstInternal(6,e)},e.prototype.AT_LEAST_ONE_SEP7=function(e){this.atLeastOneSepFirstInternal(7,e)},e.prototype.AT_LEAST_ONE_SEP8=function(e){this.atLeastOneSepFirstInternal(8,e)},e.prototype.AT_LEAST_ONE_SEP9=function(e){this.atLeastOneSepFirstInternal(9,e)},e.prototype.RULE=function(e,n,o){if(void 0===o&&(o=r.DEFAULT_RULE_CONFIG),t.contains(this.definedRulesNames,e)){var s={message:i.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(s)}this.definedRulesNames.push(e);var a=this.defineRule(e,n,o);return this[e]=a,a},e.prototype.OVERRIDE_RULE=function(e,t,n){void 0===n&&(n=r.DEFAULT_RULE_CONFIG);var i=[];i=i.concat(s.validateRuleIsOverridden(e,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(i);var o=this.defineRule(e,t,n);return this[e]=o,o},e.prototype.BACKTRACK=function(e,t){return function(){this.isBackTrackingStack.push(1);var r=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(n.isRecognitionException(e))return!1;throw e}finally{this.reloadRecogState(r),this.isBackTrackingStack.pop()}}},e.prototype.getGAstProductions=function(){return this.gastProductionsCache},e.prototype.getSerializedGastProductions=function(){return a.serializeGrammar(t.values(this.gastProductionsCache))},e}();e.RecognizerApi=l})),k=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecognizerEngine=void 0;var t=o(),n=R(),r=A(),i=b(),s=M(),a=H(),l=C(),c=p(),h=u(),d=L(),f=function(){function e(){}return e.prototype.initRecognizerEngine=function(e,n){if(this.className=d.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=h.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},t.has(n,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(t.isArray(e)){if(t.isEmpty(e))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(t.isArray(e))this.tokensMap=t.reduce(e,(function(e,t){return e[t.name]=t,e}),{});else if(t.has(e,"modes")&&t.every(t.flatten(t.values(e.modes)),h.isTokenType)){var r=t.flatten(t.values(e.modes)),i=t.uniq(r);this.tokensMap=t.reduce(i,(function(e,t){return e[t.name]=t,e}),{})}else{if(!t.isObject(e))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=t.cloneObj(e)}this.tokensMap.EOF=c.EOF;var o=t.every(t.values(e),(function(e){return t.isEmpty(e.categoryMatches)}));this.tokenMatcher=o?h.tokenStructuredMatcherNoCategories:h.tokenStructuredMatcher,h.augmentTokenTypes(t.values(this.tokensMap))},e.prototype.defineRule=function(e,r,i){if(this.selfAnalysisDone)throw Error("Grammar rule <"+e+"> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.");var o=t.has(i,"resyncEnabled")?i.resyncEnabled:a.DEFAULT_RULE_CONFIG.resyncEnabled,s=t.has(i,"recoveryValueFunc")?i.recoveryValueFunc:a.DEFAULT_RULE_CONFIG.recoveryValueFunc,l=this.ruleShortNameIdx<<n.BITS_FOR_METHOD_TYPE+n.BITS_FOR_OCCURRENCE_IDX;function c(e){try{if(!0===this.outputCst){r.apply(this,e);var t=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(t),t}return r.apply(this,e)}catch(e){return this.invokeRuleCatch(e,o,s)}finally{this.ruleFinallyStateUpdate()}}this.ruleShortNameIdx++,this.shortRuleNameToFull[l]=e,this.fullRuleNameToShort[e]=l;var u=function(t,n){return void 0===t&&(t=0),this.ruleInvocationStateUpdate(l,e,t),c.call(this,n)};return u.ruleName=e,u.originalGrammarAction=r,u},e.prototype.invokeRuleCatch=function(e,t,n){var i=1===this.RULE_STACK.length,o=t&&!this.isBackTracking()&&this.recoveryEnabled;if(r.isRecognitionException(e)){var s=e;if(o){var a,l=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(l))return s.resyncedTokens=this.reSyncTo(l),this.outputCst?((a=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,a):n();throw this.outputCst&&((a=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,s.partialCstResult=a),s}if(i)return this.moveToTerminatedState(),n();throw s}throw e},e.prototype.optionInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.OPTION_IDX,t);return this.optionInternalLogic(e,t,r)},e.prototype.optionInternalLogic=function(e,t,n){var r,i,o=this,s=this.getLaFuncFromCache(n);if(void 0!==e.DEF){if(r=e.DEF,void 0!==(i=e.GATE)){var a=s;s=function(){return i.call(o)&&a.call(o)}}}else r=e;if(!0===s.call(this))return r.call(this)},e.prototype.atLeastOneInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.AT_LEAST_ONE_IDX,e);return this.atLeastOneInternalLogic(e,t,r)},e.prototype.atLeastOneInternalLogic=function(e,t,r){var o,a,l=this,c=this.getLaFuncFromCache(r);if(void 0!==t.DEF){if(o=t.DEF,void 0!==(a=t.GATE)){var u=c;c=function(){return a.call(l)&&u.call(l)}}}else o=t;if(!0!==c.call(this))throw this.raiseEarlyExitException(e,i.PROD_TYPE.REPETITION_MANDATORY,t.ERR_MSG);for(var h=this.doSingleRepetition(o);!0===c.call(this)&&!0===h;)h=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],c,n.AT_LEAST_ONE_IDX,e,s.NextTerminalAfterAtLeastOneWalker)},e.prototype.atLeastOneSepFirstInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.AT_LEAST_ONE_SEP_IDX,e);this.atLeastOneSepFirstInternalLogic(e,t,r)},e.prototype.atLeastOneSepFirstInternalLogic=function(e,t,r){var o=this,a=t.DEF,l=t.SEP;if(!0!==this.getLaFuncFromCache(r).call(this))throw this.raiseEarlyExitException(e,i.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG);a.call(this);for(var c=function(){return o.tokenMatcher(o.LA(1),l)};!0===this.tokenMatcher(this.LA(1),l);)this.CONSUME(l),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,l,c,a,s.NextTerminalAfterAtLeastOneSepWalker],c,n.AT_LEAST_ONE_SEP_IDX,e,s.NextTerminalAfterAtLeastOneSepWalker)},e.prototype.manyInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.MANY_IDX,e);return this.manyInternalLogic(e,t,r)},e.prototype.manyInternalLogic=function(e,t,r){var i,o,a=this,l=this.getLaFuncFromCache(r);if(void 0!==t.DEF){if(i=t.DEF,void 0!==(o=t.GATE)){var c=l;l=function(){return o.call(a)&&c.call(a)}}}else i=t;for(var u=!0;!0===l.call(this)&&!0===u;)u=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],l,n.MANY_IDX,e,s.NextTerminalAfterManyWalker,u)},e.prototype.manySepFirstInternal=function(e,t){var r=this.getKeyForAutomaticLookahead(n.MANY_SEP_IDX,e);this.manySepFirstInternalLogic(e,t,r)},e.prototype.manySepFirstInternalLogic=function(e,t,r){var i=this,o=t.DEF,a=t.SEP;if(!0===this.getLaFuncFromCache(r).call(this)){o.call(this);for(var l=function(){return i.tokenMatcher(i.LA(1),a)};!0===this.tokenMatcher(this.LA(1),a);)this.CONSUME(a),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,a,l,o,s.NextTerminalAfterManySepWalker],l,n.MANY_SEP_IDX,e,s.NextTerminalAfterManySepWalker)}},e.prototype.repetitionSepSecondInternal=function(e,t,r,i,o){for(;r();)this.CONSUME(t),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,i,o],r,n.AT_LEAST_ONE_SEP_IDX,e,o)},e.prototype.doSingleRepetition=function(e){var t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t},e.prototype.orInternal=function(e,r){var i=this.getKeyForAutomaticLookahead(n.OR_IDX,r),o=t.isArray(e)?e:e.DEF,s=this.getLaFuncFromCache(i).call(this,o);if(void 0!==s)return o[s].ALT.call(this);this.raiseNoAltException(r,e.ERR_MSG)},e.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){var e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new r.NotAllInputParsedException(t,e))}},e.prototype.subruleInternal=function(e,t,n){var r;try{var i=void 0!==n?n.ARGS:void 0;return r=e.call(this,t,i),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:e.ruleName),r}catch(t){this.subruleInternalError(t,n,e.ruleName)}},e.prototype.subruleInternalError=function(e,t,n){throw r.isRecognitionException(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:n),delete e.partialCstResult),e},e.prototype.consumeInternal=function(e,t,n){var r;try{var i=this.LA(1);!0===this.tokenMatcher(i,e)?(this.consumeToken(),r=i):this.consumeInternalError(e,i,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:e.name,r),r},e.prototype.consumeInternalError=function(e,t,n){var i,o=this.LA(0);throw i=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:o,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new r.MismatchedTokenException(i,t,o))},e.prototype.consumeInternalRecovery=function(e,t,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;var r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===l.IN_RULE_RECOVERY_EXCEPTION?n:e}},e.prototype.saveRecogState=function(){var e=this.errors,n=t.cloneArr(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:n,CST_STACK:this.CST_STACK}},e.prototype.reloadRecogState=function(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK},e.prototype.ruleInvocationStateUpdate=function(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t,e)},e.prototype.isBackTracking=function(){return 0!==this.isBackTrackingStack.length},e.prototype.getCurrRuleFullName=function(){var e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]},e.prototype.shortRuleNameToFullName=function(e){return this.shortRuleNameToFull[e]},e.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),c.EOF)},e.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},e}();e.RecognizerEngine=f})),F=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorHandler=void 0;var t=A(),n=o(),r=b(),i=H(),s=function(){function e(){}return e.prototype.initErrorHandler=function(e){this._errors=[],this.errorMessageProvider=n.has(e,"errorMessageProvider")?e.errorMessageProvider:i.DEFAULT_PARSER_CONFIG.errorMessageProvider},e.prototype.SAVE_ERROR=function(e){if(t.isRecognitionException(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:n.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(e.prototype,"errors",{get:function(){return n.cloneArr(this._errors)},set:function(e){this._errors=e},enumerable:!1,configurable:!0}),e.prototype.raiseEarlyExitException=function(e,n,i){for(var o=this.getCurrRuleFullName(),s=this.getGAstProductions()[o],a=r.getLookaheadPathsForOptionalProd(e,s,n,this.maxLookahead)[0],l=[],c=1;c<=this.maxLookahead;c++)l.push(this.LA(c));var u=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:l,previous:this.LA(0),customUserDescription:i,ruleName:o});throw this.SAVE_ERROR(new t.EarlyExitException(u,this.LA(1),this.LA(0)))},e.prototype.raiseNoAltException=function(e,n){for(var i=this.getCurrRuleFullName(),o=this.getGAstProductions()[i],s=r.getLookaheadPathsForOr(e,o,this.maxLookahead),a=[],l=1;l<=this.maxLookahead;l++)a.push(this.LA(l));var c=this.LA(0),u=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:s,actual:a,previous:c,customUserDescription:n,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new t.NoViableAltException(u,this.LA(1),c))},e}();e.ErrorHandler=s})),G=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentAssist=void 0;var t=M(),n=o(),r=function(){function e(){}return e.prototype.initContentAssist=function(){},e.prototype.computeContentAssist=function(e,r){var i=this.gastProductionsCache[e];if(n.isUndefined(i))throw Error("Rule ->"+e+"<- does not exist in this grammar.");return t.nextPossibleTokensAfter([i],r,this.tokenMatcher,this.maxLookahead)},e.prototype.getNextPossibleTokenTypes=function(e){var r=n.first(e.ruleStack),i=this.getGAstProductions()[r];return new t.NextAfterTokenWalker(i,e).startWalking()},e}();e.ContentAssist=r})),B=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GastRecorder=void 0;var t=o(),n=f(),r=d(),i=u(),s=p(),a=H(),l=R(),c={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(c);var h=Math.pow(2,l.BITS_FOR_OCCURRENCE_IDX)-1,m=s.createToken({name:"RECORDING_PHASE_TOKEN",pattern:r.Lexer.NA});i.augmentTokenTypes([m]);var g=s.createTokenInstance(m,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(g);var v={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}},y=function(){function e(){}return e.prototype.initGastRecorder=function(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1},e.prototype.enableRecording=function(){var e=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",(function(){for(var t=function(t){var n=t>0?t:"";e["CONSUME"+n]=function(e,n){return this.consumeInternalRecord(e,t,n)},e["SUBRULE"+n]=function(e,n){return this.subruleInternalRecord(e,t,n)},e["OPTION"+n]=function(e){return this.optionInternalRecord(e,t)},e["OR"+n]=function(e){return this.orInternalRecord(e,t)},e["MANY"+n]=function(e){this.manyInternalRecord(t,e)},e["MANY_SEP"+n]=function(e){this.manySepFirstInternalRecord(t,e)},e["AT_LEAST_ONE"+n]=function(e){this.atLeastOneInternalRecord(t,e)},e["AT_LEAST_ONE_SEP"+n]=function(e){this.atLeastOneSepFirstInternalRecord(t,e)}},n=0;n<10;n++)t(n);e.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},e.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},e.option=function(e,t){return this.optionInternalRecord(t,e)},e.or=function(e,t){return this.orInternalRecord(t,e)},e.many=function(e,t){this.manyInternalRecord(e,t)},e.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},e.ACTION=e.ACTION_RECORD,e.BACKTRACK=e.BACKTRACK_RECORD,e.LA=e.LA_RECORD}))},e.prototype.disableRecording=function(){var e=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",(function(){for(var t=0;t<10;t++){var n=t>0?t:"";delete e["CONSUME"+n],delete e["SUBRULE"+n],delete e["OPTION"+n],delete e["OR"+n],delete e["MANY"+n],delete e["MANY_SEP"+n],delete e["AT_LEAST_ONE"+n],delete e["AT_LEAST_ONE_SEP"+n]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA}))},e.prototype.ACTION_RECORD=function(e){},e.prototype.BACKTRACK_RECORD=function(e,t){return function(){return!0}},e.prototype.LA_RECORD=function(e){return a.END_OF_FILE},e.prototype.topLevelRuleRecord=function(e,t){try{var r=new n.Rule({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(e){if(!0!==e.KNOWN_RECORDER_ERROR)try{e.message=e.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(t){throw e}throw e}},e.prototype.optionInternalRecord=function(e,t){return x.call(this,n.Option,e,t)},e.prototype.atLeastOneInternalRecord=function(e,t){x.call(this,n.RepetitionMandatory,t,e)},e.prototype.atLeastOneSepFirstInternalRecord=function(e,t){x.call(this,n.RepetitionMandatoryWithSeparator,t,e,true)},e.prototype.manyInternalRecord=function(e,t){x.call(this,n.Repetition,t,e)},e.prototype.manySepFirstInternalRecord=function(e,t){x.call(this,n.RepetitionWithSeparator,t,e,true)},e.prototype.orInternalRecord=function(e,t){return _.call(this,e,t)},e.prototype.subruleInternalRecord=function(e,r,i){if(E(r),!e||!1===t.has(e,"ruleName")){var o=new Error("<SUBRULE"+T(r)+"> argument is invalid expecting a Parser method reference but got: <"+JSON.stringify(e)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw o.KNOWN_RECORDER_ERROR=!0,o}var s=t.peek(this.recordingProdStack),a=e.ruleName,l=new n.NonTerminal({idx:r,nonTerminalName:a,referencedRule:void 0});return s.definition.push(l),this.outputCst?v:c},e.prototype.consumeInternalRecord=function(e,r,o){if(E(r),!i.hasShortKeyProperty(e)){var s=new Error("<CONSUME"+T(r)+"> argument is invalid expecting a TokenType reference but got: <"+JSON.stringify(e)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw s.KNOWN_RECORDER_ERROR=!0,s}var a=t.peek(this.recordingProdStack),l=new n.Terminal({idx:r,terminalType:e});return a.definition.push(l),g},e}();function x(e,n,r,i){void 0===i&&(i=!1),E(r);var o=t.peek(this.recordingProdStack),s=t.isFunction(n)?n:n.DEF,a=new e({definition:[],idx:r});return i&&(a.separator=n.SEP),t.has(n,"MAX_LOOKAHEAD")&&(a.maxLookahead=n.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),o.definition.push(a),this.recordingProdStack.pop(),c}function _(e,r){var i=this;E(r);var o=t.peek(this.recordingProdStack),s=!1===t.isArray(e),a=!1===s?e:e.DEF,l=new n.Alternation({definition:[],idx:r,ignoreAmbiguities:s&&!0===e.IGNORE_AMBIGUITIES});t.has(e,"MAX_LOOKAHEAD")&&(l.maxLookahead=e.MAX_LOOKAHEAD);var u=t.some(a,(function(e){return t.isFunction(e.GATE)}));return l.hasPredicates=u,o.definition.push(l),t.forEach(a,(function(e){var r=new n.Alternative({definition:[]});l.definition.push(r),t.has(e,"IGNORE_AMBIGUITIES")?r.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:t.has(e,"GATE")&&(r.ignoreAmbiguities=!0),i.recordingProdStack.push(r),e.ALT.call(i),i.recordingProdStack.pop()})),c}function T(e){return 0===e?"":""+e}function E(e){if(e<0||e>h){var t=new Error("Invalid DSL Method idx value: <"+e+">\n\tIdx value must be a none negative value smaller than "+(h+1));throw t.KNOWN_RECORDER_ERROR=!0,t}}e.GastRecorder=y})),V=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PerformanceTracer=void 0;var t=o(),n=H(),r=function(){function e(){}return e.prototype.initPerformanceTracer=function(e){if(t.has(e,"traceInitPerf")){var r=e.traceInitPerf,i="number"==typeof r;this.traceInitMaxIdent=i?r:1/0,this.traceInitPerf=i?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=n.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},e.prototype.TRACE_INIT=function(e,n){if(!0===this.traceInitPerf){this.traceInitIndent++;var r=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(r+"--\x3e <"+e+">");var i=t.timer(n),o=i.time,s=i.value,a=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(r+"<-- <"+e+"> time: "+o+"ms"),this.traceInitIndent--,s}return n()},e}();e.PerformanceTracer=r})),z=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.applyMixins=void 0,e.applyMixins=function(e,t){t.forEach((function(t){var n=t.prototype;Object.getOwnPropertyNames(n).forEach((function(r){if("constructor"!==r){var i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]}}))}))}})),H=r((e=>{var t,n=e&&e.__extends||(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)},function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.EmbeddedActionsParser=e.CstParser=e.Parser=e.EMPTY_ALT=e.ParserDefinitionErrorType=e.DEFAULT_RULE_CONFIG=e.DEFAULT_PARSER_CONFIG=e.END_OF_FILE=void 0;var r=o(),i=_(),s=p(),a=T(),l=w(),c=C(),u=I(),h=O(),d=U(),f=D(),m=k(),g=F(),v=G(),y=B(),x=V(),E=z();e.END_OF_FILE=s.createTokenInstance(s.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(e.END_OF_FILE),e.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:a.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),e.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0}),function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"}(e.ParserDefinitionErrorType||(e.ParserDefinitionErrorType={})),e.EMPTY_ALT=function(e){return void 0===e&&(e=void 0),function(){return e}};var M=function(){function t(t,n){this.definitionErrors=[],this.selfAnalysisDone=!1;var i=this;if(i.initErrorHandler(n),i.initLexerAdapter(),i.initLooksAhead(n),i.initRecognizerEngine(t,n),i.initRecoverable(n),i.initTreeBuilder(n),i.initContentAssist(),i.initGastRecorder(n),i.initPerformanceTracer(n),r.has(n,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=r.has(n,"skipValidations")?n.skipValidations:e.DEFAULT_PARSER_CONFIG.skipValidations}return t.performSelfAnalysis=function(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")},t.prototype.performSelfAnalysis=function(){var e=this;this.TRACE_INIT("performSelfAnalysis",(function(){var n;e.selfAnalysisDone=!0;var o=e.className;e.TRACE_INIT("toFastProps",(function(){r.toFastProperties(e)})),e.TRACE_INIT("Grammar Recording",(function(){try{e.enableRecording(),r.forEach(e.definedRulesNames,(function(t){var n=e[t].originalGrammarAction,r=void 0;e.TRACE_INIT(t+" Rule",(function(){r=e.topLevelRuleRecord(t,n)})),e.gastProductionsCache[t]=r}))}finally{e.disableRecording()}}));var s=[];if(e.TRACE_INIT("Grammar Resolving",(function(){s=l.resolveGrammar({rules:r.values(e.gastProductionsCache)}),e.definitionErrors=e.definitionErrors.concat(s)})),e.TRACE_INIT("Grammar Validations",(function(){if(r.isEmpty(s)&&!1===e.skipValidations){var t=l.validateGrammar({rules:r.values(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:r.values(e.tokensMap),errMsgProvider:a.defaultGrammarValidatorErrorProvider,grammarName:o});e.definitionErrors=e.definitionErrors.concat(t)}})),r.isEmpty(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",(function(){var t=i.computeAllProdsFollows(r.values(e.gastProductionsCache));e.resyncFollows=t})),e.TRACE_INIT("ComputeLookaheadFunctions",(function(){e.preComputeLookaheadFunctions(r.values(e.gastProductionsCache))}))),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!r.isEmpty(e.definitionErrors))throw n=r.map(e.definitionErrors,(function(e){return e.message})),new Error("Parser Definition Errors detected:\n "+n.join("\n-------------------------------\n"))}))},t.DEFER_DEFINITION_ERRORS_HANDLING=!1,t}();e.Parser=M,E.applyMixins(M,[c.Recoverable,u.LooksAhead,h.TreeBuilder,d.LexerAdapter,m.RecognizerEngine,f.RecognizerApi,g.ErrorHandler,v.ContentAssist,y.GastRecorder,x.PerformanceTracer]);var b=function(t){function i(n,i){void 0===i&&(i=e.DEFAULT_PARSER_CONFIG);var o=r.cloneObj(i);return o.outputCst=!0,t.call(this,n,o)||this}return n(i,t),i}(M);e.CstParser=b;var S=function(t){function i(n,i){void 0===i&&(i=e.DEFAULT_PARSER_CONFIG);var o=r.cloneObj(i);return o.outputCst=!1,t.call(this,n,o)||this}return n(i,t),i}(M);e.EmbeddedActionsParser=S})),W=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createSyntaxDiagramsCode=void 0;var t=i();e.createSyntaxDiagramsCode=function(e,n){var r=void 0===n?{}:n,i=r.resourceBase,o=void 0===i?"https://unpkg.com/chevrotain@"+t.VERSION+"/diagrams/":i,s=r.css;return'\n\x3c!-- This is a generated file --\x3e\n<!DOCTYPE html>\n<meta charset="utf-8">\n<style>\n  body {\n    background-color: hsl(30, 20%, 95%)\n  }\n</style>\n\n'+("\n<link rel='stylesheet' href='"+(void 0===s?"https://unpkg.com/chevrotain@"+t.VERSION+"/diagrams/diagrams.css":s)+"'>\n")+("\n<script src='"+o+"vendor/railroad-diagrams.js'><\/script>\n<script src='"+o+"src/diagrams_builder.js'><\/script>\n<script src='"+o+"src/diagrams_behavior.js'><\/script>\n<script src='"+o+"src/main.js'><\/script>\n")+'\n<div id="diagrams" align="center"></div>\n'+("\n<script>\n    window.serializedGrammar = "+JSON.stringify(e,null,"  ")+";\n<\/script>\n")+'\n<script>\n    var diagramsDiv = document.getElementById("diagrams");\n    main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);\n<\/script>\n'}})),j=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Parser=e.createSyntaxDiagramsCode=e.clearCache=e.GAstVisitor=e.serializeProduction=e.serializeGrammar=e.Terminal=e.Rule=e.RepetitionWithSeparator=e.RepetitionMandatoryWithSeparator=e.RepetitionMandatory=e.Repetition=e.Option=e.NonTerminal=e.Alternative=e.Alternation=e.defaultLexerErrorProvider=e.NoViableAltException=e.NotAllInputParsedException=e.MismatchedTokenException=e.isRecognitionException=e.EarlyExitException=e.defaultParserErrorProvider=e.tokenName=e.tokenMatcher=e.tokenLabel=e.EOF=e.createTokenInstance=e.createToken=e.LexerDefinitionErrorType=e.Lexer=e.EMPTY_ALT=e.ParserDefinitionErrorType=e.EmbeddedActionsParser=e.CstParser=e.VERSION=void 0;var t=i();Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return t.VERSION}});var n=H();Object.defineProperty(e,"CstParser",{enumerable:!0,get:function(){return n.CstParser}}),Object.defineProperty(e,"EmbeddedActionsParser",{enumerable:!0,get:function(){return n.EmbeddedActionsParser}}),Object.defineProperty(e,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return n.ParserDefinitionErrorType}}),Object.defineProperty(e,"EMPTY_ALT",{enumerable:!0,get:function(){return n.EMPTY_ALT}});var r=d();Object.defineProperty(e,"Lexer",{enumerable:!0,get:function(){return r.Lexer}}),Object.defineProperty(e,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return r.LexerDefinitionErrorType}});var o=p();Object.defineProperty(e,"createToken",{enumerable:!0,get:function(){return o.createToken}}),Object.defineProperty(e,"createTokenInstance",{enumerable:!0,get:function(){return o.createTokenInstance}}),Object.defineProperty(e,"EOF",{enumerable:!0,get:function(){return o.EOF}}),Object.defineProperty(e,"tokenLabel",{enumerable:!0,get:function(){return o.tokenLabel}}),Object.defineProperty(e,"tokenMatcher",{enumerable:!0,get:function(){return o.tokenMatcher}}),Object.defineProperty(e,"tokenName",{enumerable:!0,get:function(){return o.tokenName}});var s=T();Object.defineProperty(e,"defaultParserErrorProvider",{enumerable:!0,get:function(){return s.defaultParserErrorProvider}});var a=A();Object.defineProperty(e,"EarlyExitException",{enumerable:!0,get:function(){return a.EarlyExitException}}),Object.defineProperty(e,"isRecognitionException",{enumerable:!0,get:function(){return a.isRecognitionException}}),Object.defineProperty(e,"MismatchedTokenException",{enumerable:!0,get:function(){return a.MismatchedTokenException}}),Object.defineProperty(e,"NotAllInputParsedException",{enumerable:!0,get:function(){return a.NotAllInputParsedException}}),Object.defineProperty(e,"NoViableAltException",{enumerable:!0,get:function(){return a.NoViableAltException}});var l=h();Object.defineProperty(e,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return l.defaultLexerErrorProvider}});var c=f();Object.defineProperty(e,"Alternation",{enumerable:!0,get:function(){return c.Alternation}}),Object.defineProperty(e,"Alternative",{enumerable:!0,get:function(){return c.Alternative}}),Object.defineProperty(e,"NonTerminal",{enumerable:!0,get:function(){return c.NonTerminal}}),Object.defineProperty(e,"Option",{enumerable:!0,get:function(){return c.Option}}),Object.defineProperty(e,"Repetition",{enumerable:!0,get:function(){return c.Repetition}}),Object.defineProperty(e,"RepetitionMandatory",{enumerable:!0,get:function(){return c.RepetitionMandatory}}),Object.defineProperty(e,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return c.RepetitionMandatoryWithSeparator}}),Object.defineProperty(e,"RepetitionWithSeparator",{enumerable:!0,get:function(){return c.RepetitionWithSeparator}}),Object.defineProperty(e,"Rule",{enumerable:!0,get:function(){return c.Rule}}),Object.defineProperty(e,"Terminal",{enumerable:!0,get:function(){return c.Terminal}});var u=f();Object.defineProperty(e,"serializeGrammar",{enumerable:!0,get:function(){return u.serializeGrammar}}),Object.defineProperty(e,"serializeProduction",{enumerable:!0,get:function(){return u.serializeProduction}});var m=g();Object.defineProperty(e,"GAstVisitor",{enumerable:!0,get:function(){return m.GAstVisitor}}),e.clearCache=function(){console.warn("The clearCache function was 'soft' removed from the Chevrotain API.\n\t It performs no action other than printing this message.\n\t Please avoid using it as it will be completely removed in the future")};var v=W();Object.defineProperty(e,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return v.createSyntaxDiagramsCode}});var y=function(){throw new Error("The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.\nSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0")};e.Parser=y}));const X=j()}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{var e={};n.r(e),n.d(e,{AddCoord2D:()=>jh,AddCoord3D:()=>yd,AddDiv:()=>ev,AddDomElement:()=>Qg,ArrayBufferToAsciiString:()=>Id,ArrayBufferToUtf8String:()=>Rd,ArrayToCoord3D:()=>Sd,ArrayToQuaternion:()=>Zd,ArrayToRGBColor:()=>sd,AsciiStringToArrayBuffer:()=>Pd,Base64DataURIToArrayBuffer:()=>Nd,BezierTweenFunction:()=>Rp,BigEps:()=>Ih,BinaryReader:()=>Mf,BinaryWriter:()=>Xd,BoundingBoxCalculator3D:()=>wp,Box3D:()=>Sp,CalculateSurfaceArea:()=>Ag,CalculateTriangleNormal:()=>op,CalculateVolume:()=>wg,Camera:()=>Rg,CameraIsEqual3D:()=>Ig,CameraMode:()=>Cg,CameraValidator:()=>Mv,CheckModel:()=>pf,ClearDomElement:()=>tv,ClickDetector:()=>mv,ColorComponentFromFloat:()=>Zh,ColorComponentToFloat:()=>Jh,ColorToMaterialConverter:()=>Tf,ConvertColorToThreeColor:()=>lf,ConvertMeshToMeshBuffer:()=>Cd,ConvertModelToThreeObject:()=>jg,ConvertThreeColorToColor:()=>af,ConvertThreeGeometryToMesh:()=>cf,Coord2D:()=>Hh,Coord3D:()=>gd,Coord4D:()=>qd,CoordDistance2D:()=>qh,CoordDistance3D:()=>_d,CoordIsEqual2D:()=>Wh,CoordIsEqual3D:()=>vd,CopyObjectAttributes:()=>ah,CreateDiv:()=>dv,CreateDomElement:()=>$g,CreateModelUrlParameters:()=>Bg,CreateObjectUrl:()=>Ud,CreateObjectUrlWithMimeType:()=>Dd,CreateUrlBuilder:()=>Fg,CreateUrlParser:()=>Gg,CrossVector3D:()=>Md,DegRad:()=>Lh,Direction:()=>zh,DisposeThreeObjects:()=>uf,DotVector3D:()=>Td,EdgeSettings:()=>Ng,EmbeddedViewer:()=>wv,EnvironmentSettings:()=>yv,Eps:()=>Rh,EscapeHtmlChars:()=>ch,EventNotifier:()=>uh,ExportedFile:()=>Fd,Exporter:()=>bp,Exporter3dm:()=>Bd,ExporterBase:()=>Gd,ExporterBim:()=>jd,ExporterGltf:()=>gp,ExporterModel:()=>yp,ExporterObj:()=>_p,ExporterOff:()=>Tp,ExporterPly:()=>Ep,ExporterSettings:()=>vp,ExporterStl:()=>Mp,FaceMaterial:()=>dd,FileFormat:()=>Eh,FileSource:()=>Th,FinalizeModel:()=>df,FlipMeshTrianglesOrientation:()=>ap,GenerateCone:()=>_g,GenerateCuboid:()=>xg,GenerateCylinder:()=>Tg,GeneratePlatonicSolid:()=>Mg,GenerateSphere:()=>Eg,Generator:()=>gg,GeneratorHelper:()=>vg,GeneratorParams:()=>mg,GetBoundingBox:()=>qp,GetDefaultCamera:()=>_v,GetDomElementClientCoordinates:()=>Jg,GetDomElementExternalHeight:()=>Kg,GetDomElementExternalWidth:()=>Yg,GetDomElementInnerDimensions:()=>Zg,GetDomElementOuterHeight:()=>cv,GetDomElementOuterWidth:()=>lv,GetExternalLibPath:()=>xh,GetFileExtension:()=>bh,GetFileExtensionFromMimeType:()=>Od,GetFileName:()=>Mh,GetIntegerFromStyle:()=>qg,GetMeshType:()=>ip,GetShadingType:()=>nf,GetShadingTypeOfObject:()=>Ev,GetTetrahedronSignedVolume:()=>Sg,GetTopology:()=>Yp,GetTriangleArea:()=>bg,HasDefaultMaterial:()=>Zp,HasHighpDriverIssue:()=>ef,HexStringToRGBAColor:()=>od,HexStringToRGBColor:()=>id,ImportError:()=>ug,ImportErrorCode:()=>cg,ImportResult:()=>hg,ImportSettings:()=>lg,Importer:()=>pg,Importer3dm:()=>Ef,Importer3ds:()=>dm,ImporterBase:()=>ff,ImporterBim:()=>Zm,ImporterFcstd:()=>ag,ImporterFile:()=>Dp,ImporterFileAccessor:()=>dg,ImporterFileList:()=>kp,ImporterGltf:()=>Um,ImporterIfc:()=>Dm,ImporterObj:()=>Gm,ImporterOcct:()=>Ym,ImporterOff:()=>Bm,ImporterPly:()=>qm,ImporterStl:()=>Km,ImporterThree3mf:()=>tg,ImporterThreeAmf:()=>ng,ImporterThreeBase:()=>Jm,ImporterThreeDae:()=>Qm,ImporterThreeFbx:()=>$m,ImporterThreeSvg:()=>fg,ImporterThreeWrl:()=>eg,Init3DViewerElements:()=>Rv,Init3DViewerFromFileList:()=>Cv,Init3DViewerFromUrlList:()=>Av,InputFile:()=>Np,InputFilesFromFileObjects:()=>Up,InputFilesFromUrls:()=>Op,InsertDomElementAfter:()=>rv,InsertDomElementBefore:()=>nv,IntegerToHexString:()=>td,IsDefined:()=>oh,IsDomElementVisible:()=>ov,IsEqual:()=>Fh,IsEqualEps:()=>Gh,IsGreater:()=>Uh,IsGreaterOrEqual:()=>kh,IsLower:()=>Oh,IsLowerOrEqual:()=>Dh,IsModelEmpty:()=>Xp,IsNegative:()=>Vh,IsObjectEmpty:()=>lh,IsPositive:()=>Bh,IsPowerOfTwo:()=>yf,IsTwoManifold:()=>Kp,IsUrl:()=>Ch,IsZero:()=>Nh,LinearToSRGB:()=>ed,LinearTweenFunction:()=>Ip,LoadExternalLibrary:()=>_h,MaterialBase:()=>hd,MaterialType:()=>ud,Matrix:()=>Qd,MatrixIsEqual:()=>ep,Mesh:()=>$p,MeshBuffer:()=>Ad,MeshInstance:()=>hp,MeshInstanceId:()=>up,MeshPrimitiveBuffer:()=>wd,MeshType:()=>rp,Model:()=>Bp,ModelObject3D:()=>cp,ModelToThreeConversionOutput:()=>zg,ModelToThreeConversionParams:()=>Vg,MouseInteraction:()=>pv,NameFromLine:()=>mf,Navigation:()=>vv,NavigationType:()=>gv,NextPowerOfTwo:()=>xf,Node:()=>Gp,Object3D:()=>lp,Octree:()=>Cp,OctreeNode:()=>Ap,ParabolicTweenFunction:()=>Pp,ParameterConverter:()=>Ug,ParameterListBuilder:()=>Dg,ParameterListParser:()=>kg,ParametersFromLine:()=>gf,PhongMaterial:()=>pd,PhysicalMaterial:()=>fd,Property:()=>zd,PropertyGroup:()=>Hd,PropertyToString:()=>Wd,PropertyType:()=>Vd,Quaternion:()=>Yd,QuaternionFromAxisAngle:()=>Jd,QuaternionFromXYZ:()=>$d,QuaternionIsEqual:()=>Kd,RGBAColor:()=>Kh,RGBAColorToHexString:()=>rd,RGBColor:()=>Yh,RGBColorFromFloatComponents:()=>$h,RGBColorIsEqual:()=>ad,RGBColorToHexString:()=>nd,RadDeg:()=>Ph,ReadFile:()=>wh,ReadLines:()=>vf,ReplaceDefaultMaterialColor:()=>Jp,RequestUrl:()=>Sh,RevokeObjectUrl:()=>kd,RunTaskAsync:()=>dh,RunTasks:()=>ph,RunTasksBatch:()=>fh,SRGBToLinear:()=>Qh,SetDomElementHeight:()=>av,SetDomElementOuterHeight:()=>hv,SetDomElementOuterWidth:()=>uv,SetDomElementWidth:()=>sv,SetExternalLibLocation:()=>yh,SetThreeMeshPolygonOffset:()=>Pg,ShadingModel:()=>xv,ShadingType:()=>tf,ShowDomElement:()=>iv,SubCoord2D:()=>Xh,SubCoord3D:()=>xd,TaskRunner:()=>hh,TextWriter:()=>xp,TextureIsEqual:()=>md,TextureMap:()=>ld,TextureMapIsEqual:()=>cd,ThreeColorConverter:()=>rf,ThreeConversionStateHandler:()=>Hg,ThreeLinearToSRGBColorConverter:()=>of,ThreeModelLoader:()=>Xg,ThreeNodeTree:()=>Wg,ThreeSRGBToLinearColorConverter:()=>sf,Topology:()=>jp,TopologyEdge:()=>zp,TopologyTriangle:()=>Wp,TopologyTriangleEdge:()=>Hp,TopologyVertex:()=>Vp,TouchInteraction:()=>fv,TransformFileHostUrls:()=>Ah,TransformMesh:()=>sp,Transformation:()=>tp,TransformationIsEqual:()=>np,TraverseThreeObject:()=>Tv,Triangle:()=>Qp,TweenCoord3D:()=>Lp,UpVector:()=>bv,UpdateMaterialTransparency:()=>_f,Utf8StringToArrayBuffer:()=>Ld,ValueOrDefault:()=>sh,VectorAngle3D:()=>Ed,VectorLength3D:()=>bd,Viewer:()=>Sv,ViewerMainModel:()=>Og,ViewerModel:()=>Lg,WaitWhile:()=>mh});const t="153",r=1,i=2,o=3,s=0,a=1,l=2,c=100,u=0,h=1,d=2,p=0,f=1,m=2,g=3,v=4,y=5,x=301,_=302,T=303,E=304,M=306,b=1e3,S=1001,w=1002,A=1003,C=1004,R=1005,I=1006,P=1008,L=1009,N=1012,O=1013,U=1014,D=1015,k=1016,F=1020,G=1023,B=1026,V=1027,z=33776,H=33777,W=33778,j=33779,X=36492,q=2300,Y=2301,K=2302,Z=2400,J=2401,$=2402,Q=3001,ee="",te="srgb",ne="srgb-linear",re="display-p3",ie=7680,oe=35044,se="300 es",ae=1035,le=2e3,ce=2001;class ue{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}}const he=["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 de=1234567;const pe=Math.PI/180,fe=180/Math.PI;function me(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(he[255&e]+he[e>>8&255]+he[e>>16&255]+he[e>>24&255]+"-"+he[255&t]+he[t>>8&255]+"-"+he[t>>16&15|64]+he[t>>24&255]+"-"+he[63&n|128]+he[n>>8&255]+"-"+he[n>>16&255]+he[n>>24&255]+he[255&r]+he[r>>8&255]+he[r>>16&255]+he[r>>24&255]).toLowerCase()}function ge(e,t,n){return Math.max(t,Math.min(n,e))}function ve(e,t){return(e%t+t)%t}function ye(e,t,n){return(1-n)*e+n*t}function xe(e){return 0==(e&e-1)&&0!==e}function _e(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Te(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ee(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 Me(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 be={DEG2RAD:pe,RAD2DEG:fe,generateUUID:me,clamp:ge,euclideanModulo:ve,mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:ye,damp:function(e,t,n,r){return ye(e,t,1-Math.exp(-n*r))},pingpong:function(e,t=1){return t-Math.abs(ve(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(de=e);let t=de+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*pe},radToDeg:function(e){return e*fe},isPowerOfTwo:xe,ceilPowerOfTwo:_e,floorPowerOfTwo:Te,setQuaternionFromProperEuler:function(e,t,n,r,i){const o=Math.cos,s=Math.sin,a=o(n/2),l=s(n/2),c=o((t+r)/2),u=s((t+r)/2),h=o((t-r)/2),d=s((t-r)/2),p=o((r-t)/2),f=s((r-t)/2);switch(i){case"XYX":e.set(a*u,l*h,l*d,a*c);break;case"YZY":e.set(l*d,a*u,l*h,a*c);break;case"ZXZ":e.set(l*h,l*d,a*u,a*c);break;case"XZX":e.set(a*u,l*f,l*p,a*c);break;case"YXY":e.set(l*p,a*u,l*f,a*c);break;case"ZYZ":e.set(l*f,l*p,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:Me,denormalize:Ee};class Se{constructor(e=0,t=0){Se.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*n-o*r+e.x,this.y=i*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class we{constructor(e,t,n,r,i,o,s,a,l){we.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,r,i,o,s,a,l)}set(e,t,n,r,i,o,s,a,l){const c=this.elements;return c[0]=e,c[1]=r,c[2]=s,c[3]=t,c[4]=i,c[5]=a,c[6]=n,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,o=n[0],s=n[3],a=n[6],l=n[1],c=n[4],u=n[7],h=n[2],d=n[5],p=n[8],f=r[0],m=r[3],g=r[6],v=r[1],y=r[4],x=r[7],_=r[2],T=r[5],E=r[8];return i[0]=o*f+s*v+a*_,i[3]=o*m+s*y+a*T,i[6]=o*g+s*x+a*E,i[1]=l*f+c*v+u*_,i[4]=l*m+c*y+u*T,i[7]=l*g+c*x+u*E,i[2]=h*f+d*v+p*_,i[5]=h*m+d*y+p*T,i[8]=h*g+d*x+p*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8];return t*o*c-t*s*l-n*i*c+n*s*a+r*i*l-r*o*a}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=c*o-s*l,h=s*a-c*i,d=l*i-o*a,p=t*u+n*h+r*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=u*f,e[1]=(r*l-c*n)*f,e[2]=(s*n-r*o)*f,e[3]=h*f,e[4]=(c*t-r*a)*f,e[5]=(r*i-s*t)*f,e[6]=d*f,e[7]=(n*a-l*t)*f,e[8]=(o*t-n*i)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,o,s){const a=Math.cos(i),l=Math.sin(i);return this.set(n*a,n*l,-n*(a*o+l*s)+o+e,-r*l,r*a,-r*(-l*o+a*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(Ae.makeScale(e,t)),this}rotate(e){return this.premultiply(Ae.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ae.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Ae=new we;function Ce(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 Re(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const Ie={};function Pe(e){e in Ie||(Ie[e]=!0,console.warn(e))}function Le(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Ne(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const Oe=(new we).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),Ue=(new we).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);const De={[ne]:e=>e,[te]:e=>e.convertSRGBToLinear(),[re]:function(e){return e.convertSRGBToLinear().applyMatrix3(Ue)}},ke={[ne]:e=>e,[te]:e=>e.convertLinearToSRGB(),[re]:function(e){return e.applyMatrix3(Oe).convertLinearToSRGB()}},Fe={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return ne},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const r=De[t],i=ke[n];if(void 0===r||void 0===i)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return i(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let Ge;class Be{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===Ge&&(Ge=Re("canvas")),Ge.width=e.width,Ge.height=e.height;const n=Ge.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ge}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=Re("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=255*Le(i[e]/255);return n.putImageData(r,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*Le(t[e]/255)):t[e]=Le(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Ve=0;class ze{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ve++}),this.uuid=me(),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 n={uuid:this.uuid,url:""},r=this.data;if(null!==r){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(He(r[t].image)):e.push(He(r[t]))}else e=He(r);n.url=e}return t||(e.images[this.uuid]=n),n}}function He(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Be.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let We=0;class je extends ue{constructor(e=je.DEFAULT_IMAGE,t=je.DEFAULT_MAPPING,n=1001,r=1001,i=1006,o=1008,s=1023,a=1009,l=je.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:We++}),this.uuid=me(),this.name="",this.source=new ze(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new Se(0,0),this.repeat=new Se(1,1),this.center=new Se(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new we,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof c?this.colorSpace=c:(Pe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=c===Q?te:ee),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 n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case b:e.x=e.x-Math.floor(e.x);break;case S:e.x=e.x<0?0:1;break;case w: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 b:e.y=e.y-Math.floor(e.y);break;case S:e.y=e.y<0?0:1;break;case w: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 Pe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===te?Q:3e3}set encoding(e){Pe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Q?te:ee}}je.DEFAULT_IMAGE=null,je.DEFAULT_MAPPING=300,je.DEFAULT_ANISOTROPY=1;class Xe{constructor(e=0,t=0,n=0,r=1){Xe.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i;const o=.01,s=.1,a=e.elements,l=a[0],c=a[4],u=a[8],h=a[1],d=a[5],p=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(c-h)<o&&Math.abs(u-f)<o&&Math.abs(p-m)<o){if(Math.abs(c+h)<s&&Math.abs(u+f)<s&&Math.abs(p+m)<s&&Math.abs(l+d+g-3)<s)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,a=(d+1)/2,v=(g+1)/2,y=(c+h)/4,x=(u+f)/4,_=(p+m)/4;return e>a&&e>v?e<o?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=y/n,i=x/n):a>v?a<o?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(a),n=y/r,i=_/r):v<o?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(v),n=x/i,r=_/i),this.set(n,r,i,t),this}let v=Math.sqrt((m-p)*(m-p)+(u-f)*(u-f)+(h-c)*(h-c));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(u-f)/v,this.z=(h-c)/v,this.w=Math.acos((l+d+g-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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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 qe extends ue{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Xe(0,0,e,t),this.scissorTest=!1,this.viewport=new Xe(0,0,e,t);const r={width:e,height:t,depth:1};void 0!==n.encoding&&(Pe("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Q?te:ee),this.texture=new je(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:I,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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 ze(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 Ye extends je{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=A,this.minFilter=A,this.wrapR=S,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ke extends je{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=A,this.minFilter=A,this.wrapR=S,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ze{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,o,s){let a=n[r+0],l=n[r+1],c=n[r+2],u=n[r+3];const h=i[o+0],d=i[o+1],p=i[o+2],f=i[o+3];if(0===s)return e[t+0]=a,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===s)return e[t+0]=h,e[t+1]=d,e[t+2]=p,void(e[t+3]=f);if(u!==f||a!==h||l!==d||c!==p){let e=1-s;const t=a*h+l*d+c*p+u*f,n=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const i=Math.sqrt(r),o=Math.atan2(i,t*n);e=Math.sin(e*o)/i,s=Math.sin(s*o)/i}const i=s*n;if(a=a*e+h*i,l=l*e+d*i,c=c*e+p*i,u=u*e+f*i,e===1-s){const e=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=e,l*=e,c*=e,u*=e}}e[t]=a,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,o){const s=n[r],a=n[r+1],l=n[r+2],c=n[r+3],u=i[o],h=i[o+1],d=i[o+2],p=i[o+3];return e[t]=s*p+c*u+a*d-l*h,e[t+1]=a*p+c*h+l*u-s*d,e[t+2]=l*p+c*d+s*h-a*u,e[t+3]=c*p-s*u-a*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,r=e._y,i=e._z,o=e._order,s=Math.cos,a=Math.sin,l=s(n/2),c=s(r/2),u=s(i/2),h=a(n/2),d=a(r/2),p=a(i/2);switch(o){case"XYZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"YXZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"ZXY":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"ZYX":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"YZX":this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p;break;case"XZY":this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],o=t[1],s=t[5],a=t[9],l=t[2],c=t[6],u=t[10],h=n+s+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(c-a)*e,this._y=(i-l)*e,this._z=(o-r)*e}else if(n>s&&n>u){const e=2*Math.sqrt(1+n-s-u);this._w=(c-a)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(i+l)/e}else if(s>u){const e=2*Math.sqrt(1+s-n-u);this._w=(i-l)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(a+c)/e}else{const e=2*Math.sqrt(1+u-n-s);this._w=(o-r)/e,this._x=(i+l)/e,this._y=(a+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ge(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,i=e._z,o=e._w,s=t._x,a=t._y,l=t._z,c=t._w;return this._x=n*c+o*s+r*l-i*a,this._y=r*c+o*a+i*s-n*l,this._z=i*c+o*l+n*a-r*s,this._w=o*c-n*s-r*a-i*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,i=this._z,o=this._w;let s=o*e._w+n*e._x+r*e._y+i*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;const a=1-s*s;if(a<=Number.EPSILON){const e=1-t;return this._w=e*o+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(a),c=Math.atan2(l,s),u=Math.sin((1-t)*c)/l,h=Math.sin(t*c)/l;return this._w=o*u+this._w*h,this._x=n*u+this._x*h,this._y=r*u+this._y*h,this._z=i*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}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 Je{constructor(e=0,t=0,n=0){Je.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Qe.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Qe.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,o=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,o=e.y,s=e.z,a=e.w,l=a*t+o*r-s*n,c=a*n+s*t-i*r,u=a*r+i*n-o*t,h=-i*t-o*n-s*r;return this.x=l*a+h*-i+c*-s-u*-o,this.y=c*a+h*-o+u*-i-l*-s,this.z=u*a+h*-s+l*-o-c*-i,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,o=t.x,s=t.y,a=t.z;return this.x=r*a-i*s,this.y=i*o-n*a,this.z=n*s-r*o,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return $e.copy(this).projectOnVector(e),this.sub($e)}reflect(e){return this.sub($e.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const $e=new Je,Qe=new Ze;class et{constructor(e=new Je(1/0,1/0,1/0),t=new Je(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(nt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(nt.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=nt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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){if(e.updateWorldMatrix(!1,!1),void 0!==e.boundingBox)null===e.boundingBox&&e.computeBoundingBox(),rt.copy(e.boundingBox),rt.applyMatrix4(e.matrixWorld),this.union(rt);else{const n=e.geometry;if(void 0!==n)if(t&&void 0!==n.attributes&&void 0!==n.attributes.position){const t=n.attributes.position;for(let n=0,r=t.count;n<r;n++)nt.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(nt)}else null===n.boundingBox&&n.computeBoundingBox(),rt.copy(n.boundingBox),rt.applyMatrix4(e.matrixWorld),this.union(rt)}const n=e.children;for(let e=0,r=n.length;e<r;e++)this.expandByObject(n[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,nt),nt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ut),ht.subVectors(this.max,ut),it.subVectors(e.a,ut),ot.subVectors(e.b,ut),st.subVectors(e.c,ut),at.subVectors(ot,it),lt.subVectors(st,ot),ct.subVectors(it,st);let t=[0,-at.z,at.y,0,-lt.z,lt.y,0,-ct.z,ct.y,at.z,0,-at.x,lt.z,0,-lt.x,ct.z,0,-ct.x,-at.y,at.x,0,-lt.y,lt.x,0,-ct.y,ct.x,0];return!!ft(t,it,ot,st,ht)&&(t=[1,0,0,0,1,0,0,0,1],!!ft(t,it,ot,st,ht)&&(dt.crossVectors(at,lt),t=[dt.x,dt.y,dt.z],ft(t,it,ot,st,ht)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,nt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(nt).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()||(tt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),tt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),tt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),tt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),tt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),tt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),tt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),tt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(tt)),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 tt=[new Je,new Je,new Je,new Je,new Je,new Je,new Je,new Je],nt=new Je,rt=new et,it=new Je,ot=new Je,st=new Je,at=new Je,lt=new Je,ct=new Je,ut=new Je,ht=new Je,dt=new Je,pt=new Je;function ft(e,t,n,r,i){for(let o=0,s=e.length-3;o<=s;o+=3){pt.fromArray(e,o);const s=i.x*Math.abs(pt.x)+i.y*Math.abs(pt.y)+i.z*Math.abs(pt.z),a=t.dot(pt),l=n.dot(pt),c=r.dot(pt);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>s)return!1}return!0}const mt=new et,gt=new Je,vt=new Je;class yt{constructor(e=new Je,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):mt.setFromPoints(e).getCenter(n);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),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 n=this.center.distanceToSquared(e);return t.copy(e),n>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),n=.5*(e-this.radius);this.center.addScaledVector(gt,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(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 xt=new Je,_t=new Je,Tt=new Je,Et=new Je,Mt=new Je,bt=new Je,St=new Je;class wt{constructor(e=new Je,t=new Je(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,xt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=xt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(xt.copy(this.origin).addScaledVector(this.direction,t),xt.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){_t.copy(e).add(t).multiplyScalar(.5),Tt.copy(t).sub(e).normalize(),Et.copy(this.origin).sub(_t);const i=.5*e.distanceTo(t),o=-this.direction.dot(Tt),s=Et.dot(this.direction),a=-Et.dot(Tt),l=Et.lengthSq(),c=Math.abs(1-o*o);let u,h,d,p;if(c>0)if(u=o*a-s,h=o*s-a,p=i*c,u>=0)if(h>=-p)if(h<=p){const e=1/c;u*=e,h*=e,d=u*(u+o*h+2*s)+h*(o*u+h+2*a)+l}else h=i,u=Math.max(0,-(o*h+s)),d=-u*u+h*(h+2*a)+l;else h=-i,u=Math.max(0,-(o*h+s)),d=-u*u+h*(h+2*a)+l;else h<=-p?(u=Math.max(0,-(-o*i+s)),h=u>0?-i:Math.min(Math.max(-i,-a),i),d=-u*u+h*(h+2*a)+l):h<=p?(u=0,h=Math.min(Math.max(-i,-a),i),d=h*(h+2*a)+l):(u=Math.max(0,-(o*i+s)),h=u>0?i:Math.min(Math.max(-i,-a),i),d=-u*u+h*(h+2*a)+l);else h=o>0?-i:i,u=Math.max(0,-(o*h+s)),d=-u*u+h*(h+2*a)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(_t).addScaledVector(Tt,h),d}intersectSphere(e,t){xt.subVectors(e.center,this.origin);const n=xt.dot(this.direction),r=xt.dot(xt)-n*n,i=e.radius*e.radius;if(r>i)return null;const o=Math.sqrt(i-r),s=n-o,a=n+o;return a<0?null:s<0?this.at(a,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,o,s,a;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),c>=0?(i=(e.min.y-h.y)*c,o=(e.max.y-h.y)*c):(i=(e.max.y-h.y)*c,o=(e.min.y-h.y)*c),n>o||i>r?null:((i>n||isNaN(n))&&(n=i),(o<r||isNaN(r))&&(r=o),u>=0?(s=(e.min.z-h.z)*u,a=(e.max.z-h.z)*u):(s=(e.max.z-h.z)*u,a=(e.min.z-h.z)*u),n>a||s>r?null:((s>n||n!=n)&&(n=s),(a<r||r!=r)&&(r=a),r<0?null:this.at(n>=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,xt)}intersectTriangle(e,t,n,r,i){Mt.subVectors(t,e),bt.subVectors(n,e),St.crossVectors(Mt,bt);let o,s=this.direction.dot(St);if(s>0){if(r)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}Et.subVectors(this.origin,e);const a=o*this.direction.dot(bt.crossVectors(Et,bt));if(a<0)return null;const l=o*this.direction.dot(Mt.cross(Et));if(l<0)return null;if(a+l>s)return null;const c=-o*Et.dot(St);return c<0?null:this.at(c/s,i)}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 At{constructor(e,t,n,r,i,o,s,a,l,c,u,h,d,p,f,m){At.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,r,i,o,s,a,l,c,u,h,d,p,f,m)}set(e,t,n,r,i,o,s,a,l,c,u,h,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=s,g[13]=a,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new At).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/Ct.setFromMatrixColumn(e,0).length(),i=1/Ct.setFromMatrixColumn(e,1).length(),o=1/Ct.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,o=Math.cos(n),s=Math.sin(n),a=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i);if("XYZ"===e.order){const e=o*c,n=o*u,r=s*c,i=s*u;t[0]=a*c,t[4]=-a*u,t[8]=l,t[1]=n+r*l,t[5]=e-i*l,t[9]=-s*a,t[2]=i-e*l,t[6]=r+n*l,t[10]=o*a}else if("YXZ"===e.order){const e=a*c,n=a*u,r=l*c,i=l*u;t[0]=e+i*s,t[4]=r*s-n,t[8]=o*l,t[1]=o*u,t[5]=o*c,t[9]=-s,t[2]=n*s-r,t[6]=i+e*s,t[10]=o*a}else if("ZXY"===e.order){const e=a*c,n=a*u,r=l*c,i=l*u;t[0]=e-i*s,t[4]=-o*u,t[8]=r+n*s,t[1]=n+r*s,t[5]=o*c,t[9]=i-e*s,t[2]=-o*l,t[6]=s,t[10]=o*a}else if("ZYX"===e.order){const e=o*c,n=o*u,r=s*c,i=s*u;t[0]=a*c,t[4]=r*l-n,t[8]=e*l+i,t[1]=a*u,t[5]=i*l+e,t[9]=n*l-r,t[2]=-l,t[6]=s*a,t[10]=o*a}else if("YZX"===e.order){const e=o*a,n=o*l,r=s*a,i=s*l;t[0]=a*c,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=o*c,t[9]=-s*c,t[2]=-l*c,t[6]=n*u+r,t[10]=e-i*u}else if("XZY"===e.order){const e=o*a,n=o*l,r=s*a,i=s*l;t[0]=a*c,t[4]=-u,t[8]=l*c,t[1]=e*u+i,t[5]=o*c,t[9]=n*u-r,t[2]=r*u-n,t[6]=s*c,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(It,e,Pt)}lookAt(e,t,n){const r=this.elements;return Ot.subVectors(e,t),0===Ot.lengthSq()&&(Ot.z=1),Ot.normalize(),Lt.crossVectors(n,Ot),0===Lt.lengthSq()&&(1===Math.abs(n.z)?Ot.x+=1e-4:Ot.z+=1e-4,Ot.normalize(),Lt.crossVectors(n,Ot)),Lt.normalize(),Nt.crossVectors(Ot,Lt),r[0]=Lt.x,r[4]=Nt.x,r[8]=Ot.x,r[1]=Lt.y,r[5]=Nt.y,r[9]=Ot.y,r[2]=Lt.z,r[6]=Nt.z,r[10]=Ot.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,o=n[0],s=n[4],a=n[8],l=n[12],c=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],_=n[15],T=r[0],E=r[4],M=r[8],b=r[12],S=r[1],w=r[5],A=r[9],C=r[13],R=r[2],I=r[6],P=r[10],L=r[14],N=r[3],O=r[7],U=r[11],D=r[15];return i[0]=o*T+s*S+a*R+l*N,i[4]=o*E+s*w+a*I+l*O,i[8]=o*M+s*A+a*P+l*U,i[12]=o*b+s*C+a*L+l*D,i[1]=c*T+u*S+h*R+d*N,i[5]=c*E+u*w+h*I+d*O,i[9]=c*M+u*A+h*P+d*U,i[13]=c*b+u*C+h*L+d*D,i[2]=p*T+f*S+m*R+g*N,i[6]=p*E+f*w+m*I+g*O,i[10]=p*M+f*A+m*P+g*U,i[14]=p*b+f*C+m*L+g*D,i[3]=v*T+y*S+x*R+_*N,i[7]=v*E+y*w+x*I+_*O,i[11]=v*M+y*A+x*P+_*U,i[15]=v*b+y*C+x*L+_*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],o=e[1],s=e[5],a=e[9],l=e[13],c=e[2],u=e[6],h=e[10],d=e[14];return e[3]*(+i*a*u-r*l*u-i*s*h+n*l*h+r*s*d-n*a*d)+e[7]*(+t*a*d-t*l*h+i*o*h-r*o*d+r*l*c-i*a*c)+e[11]*(+t*l*u-t*s*d-i*o*u+n*o*d+i*s*c-n*l*c)+e[15]*(-r*s*c-t*a*u+t*s*h+r*o*u-n*o*h+n*a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=u*m*l-f*h*l+f*a*d-s*m*d-u*a*g+s*h*g,y=p*h*l-c*m*l-p*a*d+o*m*d+c*a*g-o*h*g,x=c*f*l-p*u*l+p*s*d-o*f*d-c*s*g+o*u*g,_=p*u*a-c*f*a-p*s*h+o*f*h+c*s*m-o*u*m,T=t*v+n*y+r*x+i*_;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/T;return e[0]=v*E,e[1]=(f*h*i-u*m*i-f*r*d+n*m*d+u*r*g-n*h*g)*E,e[2]=(s*m*i-f*a*i+f*r*l-n*m*l-s*r*g+n*a*g)*E,e[3]=(u*a*i-s*h*i-u*r*l+n*h*l+s*r*d-n*a*d)*E,e[4]=y*E,e[5]=(c*m*i-p*h*i+p*r*d-t*m*d-c*r*g+t*h*g)*E,e[6]=(p*a*i-o*m*i-p*r*l+t*m*l+o*r*g-t*a*g)*E,e[7]=(o*h*i-c*a*i+c*r*l-t*h*l-o*r*d+t*a*d)*E,e[8]=x*E,e[9]=(p*u*i-c*f*i-p*n*d+t*f*d+c*n*g-t*u*g)*E,e[10]=(o*f*i-p*s*i+p*n*l-t*f*l-o*n*g+t*s*g)*E,e[11]=(c*s*i-o*u*i-c*n*l+t*u*l+o*n*d-t*s*d)*E,e[12]=_*E,e[13]=(c*f*r-p*u*r+p*n*h-t*f*h-c*n*m+t*u*m)*E,e[14]=(p*s*r-o*f*r-p*n*a+t*f*a+o*n*m-t*s*m)*E,e[15]=(o*u*r-c*s*r+c*n*a-t*u*a-o*n*h+t*s*h)*E,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),i=1-n,o=e.x,s=e.y,a=e.z,l=i*o,c=i*s;return this.set(l*o+n,l*s-r*a,l*a+r*s,0,l*s+r*a,c*s+n,c*a-r*o,0,l*a-r*s,c*a+r*o,i*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,o){return this.set(1,n,i,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,o=t._y,s=t._z,a=t._w,l=i+i,c=o+o,u=s+s,h=i*l,d=i*c,p=i*u,f=o*c,m=o*u,g=s*u,v=a*l,y=a*c,x=a*u,_=n.x,T=n.y,E=n.z;return r[0]=(1-(f+g))*_,r[1]=(d+x)*_,r[2]=(p-y)*_,r[3]=0,r[4]=(d-x)*T,r[5]=(1-(h+g))*T,r[6]=(m+v)*T,r[7]=0,r[8]=(p+y)*E,r[9]=(m-v)*E,r[10]=(1-(h+f))*E,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=Ct.set(r[0],r[1],r[2]).length();const o=Ct.set(r[4],r[5],r[6]).length(),s=Ct.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],Rt.copy(this);const a=1/i,l=1/o,c=1/s;return Rt.elements[0]*=a,Rt.elements[1]*=a,Rt.elements[2]*=a,Rt.elements[4]*=l,Rt.elements[5]*=l,Rt.elements[6]*=l,Rt.elements[8]*=c,Rt.elements[9]*=c,Rt.elements[10]*=c,t.setFromRotationMatrix(Rt),n.x=i,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,o,s=2e3){const a=this.elements,l=2*i/(t-e),c=2*i/(n-r),u=(t+e)/(t-e),h=(n+r)/(n-r);let d,p;if(s===le)d=-(o+i)/(o-i),p=-2*o*i/(o-i);else{if(s!==ce)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);d=-o/(o-i),p=-o*i/(o-i)}return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,r,i,o,s=2e3){const a=this.elements,l=1/(t-e),c=1/(n-r),u=1/(o-i),h=(t+e)*l,d=(n+r)*c;let p,f;if(s===le)p=(o+i)*u,f=-2*u;else{if(s!==ce)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=i*u,f=-1*u}return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=f,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ct=new Je,Rt=new At,It=new Je(0,0,0),Pt=new Je(1,1,1),Lt=new Je,Nt=new Je,Ot=new Je,Ut=new At,Dt=new Ze;class kt{constructor(e=0,t=0,n=0,r=kt.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,i=r[0],o=r[4],s=r[8],a=r[1],l=r[5],c=r[9],u=r[2],h=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(ge(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ge(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(ge(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-ge(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(ge(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-ge(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ut.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ut,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Dt.setFromEuler(this),this.setFromQuaternion(Dt,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}}kt.DEFAULT_ORDER="XYZ";class Ft{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}isEnabled(e){return 0!=(this.mask&(1<<e|0))}}let Gt=0;const Bt=new Je,Vt=new Ze,zt=new At,Ht=new Je,Wt=new Je,jt=new Je,Xt=new Ze,qt=new Je(1,0,0),Yt=new Je(0,1,0),Kt=new Je(0,0,1),Zt={type:"added"},Jt={type:"removed"};class $t extends ue{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gt++}),this.uuid=me(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=$t.DEFAULT_UP.clone();const e=new Je,t=new kt,n=new Ze,r=new Je(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,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:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new At},normalMatrix:{value:new we}}),this.matrix=new At,this.matrixWorld=new At,this.matrixAutoUpdate=$t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=$t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Ft,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 Vt.setFromAxisAngle(e,t),this.quaternion.multiply(Vt),this}rotateOnWorldAxis(e,t){return Vt.setFromAxisAngle(e,t),this.quaternion.premultiply(Vt),this}rotateX(e){return this.rotateOnAxis(qt,e)}rotateY(e){return this.rotateOnAxis(Yt,e)}rotateZ(e){return this.rotateOnAxis(Kt,e)}translateOnAxis(e,t){return Bt.copy(e).applyQuaternion(this.quaternion),this.position.add(Bt.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(qt,e)}translateY(e){return this.translateOnAxis(Yt,e)}translateZ(e){return this.translateOnAxis(Kt,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(zt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ht.copy(e):Ht.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Wt.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?zt.lookAt(Wt,Ht,this.up):zt.lookAt(Ht,Wt,this.up),this.quaternion.setFromRotationMatrix(zt),r&&(zt.extractRotation(r.matrixWorld),Vt.setFromRotationMatrix(zt),this.quaternion.premultiply(Vt.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.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(Zt)):console.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(Jt)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(Jt)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),zt.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),zt.multiply(e.parent.matrixWorld)),e.applyMatrix4(zt),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 n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let r=0,i=this.children.length;r<i;r++){const i=this.children[r].getObjectsByProperty(e,t);i.length>0&&(n=n.concat(i))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wt,e,jt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wt,Xt,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].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 n=0,r=t.length;n<r;n++){const r=t[n];!0!==r.matrixWorldAutoUpdate&&!0!==e||r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.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,n=e.length;t<n;t++){const n=e[t];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};function i(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){const r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){const t=o(e.geometries),r=o(e.materials),i=o(e.textures),s=o(e.images),a=o(e.shapes),l=o(e.skeletons),c=o(e.animations),u=o(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),s.length>0&&(n.images=s),a.length>0&&(n.shapes=a),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=r,n;function o(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}$t.DEFAULT_UP=new Je(0,1,0),$t.DEFAULT_MATRIX_AUTO_UPDATE=!0,$t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Qt=new Je,en=new Je,tn=new Je,nn=new Je,rn=new Je,on=new Je,sn=new Je,an=new Je,ln=new Je,cn=new Je;let un=!1;class hn{constructor(e=new Je,t=new Je,n=new Je){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Qt.subVectors(e,t),r.cross(Qt);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Qt.subVectors(r,t),en.subVectors(n,t),tn.subVectors(e,t);const o=Qt.dot(Qt),s=Qt.dot(en),a=Qt.dot(tn),l=en.dot(en),c=en.dot(tn),u=o*l-s*s;if(0===u)return i.set(-2,-1,-1);const h=1/u,d=(l*a-s*c)*h,p=(o*c-s*a)*h;return i.set(1-d-p,p,d)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,nn),nn.x>=0&&nn.y>=0&&nn.x+nn.y<=1}static getUV(e,t,n,r,i,o,s,a){return!1===un&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),un=!0),this.getInterpolation(e,t,n,r,i,o,s,a)}static getInterpolation(e,t,n,r,i,o,s,a){return this.getBarycoord(e,t,n,r,nn),a.setScalar(0),a.addScaledVector(i,nn.x),a.addScaledVector(o,nn.y),a.addScaledVector(s,nn.z),a}static isFrontFacing(e,t,n,r){return Qt.subVectors(n,t),en.subVectors(e,t),Qt.cross(en).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Qt.subVectors(this.c,this.b),en.subVectors(this.a,this.b),.5*Qt.cross(en).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return hn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return hn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,i){return!1===un&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),un=!0),hn.getInterpolation(e,this.a,this.b,this.c,t,n,r,i)}getInterpolation(e,t,n,r,i){return hn.getInterpolation(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return hn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return hn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,i=this.c;let o,s;rn.subVectors(r,n),on.subVectors(i,n),an.subVectors(e,n);const a=rn.dot(an),l=on.dot(an);if(a<=0&&l<=0)return t.copy(n);ln.subVectors(e,r);const c=rn.dot(ln),u=on.dot(ln);if(c>=0&&u<=c)return t.copy(r);const h=a*u-c*l;if(h<=0&&a>=0&&c<=0)return o=a/(a-c),t.copy(n).addScaledVector(rn,o);cn.subVectors(e,i);const d=rn.dot(cn),p=on.dot(cn);if(p>=0&&d<=p)return t.copy(i);const f=d*l-a*p;if(f<=0&&l>=0&&p<=0)return s=l/(l-p),t.copy(n).addScaledVector(on,s);const m=c*p-d*u;if(m<=0&&u-c>=0&&d-p>=0)return sn.subVectors(i,r),s=(u-c)/(u-c+(d-p)),t.copy(r).addScaledVector(sn,s);const g=1/(m+f+h);return o=f*g,s=h*g,t.copy(n).addScaledVector(rn,o).addScaledVector(on,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let dn=0;class pn extends ue{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:dn++}),this.uuid=me(),this.name="",this.type="Material",this.blending=1,this.side=s,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=c,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ie,this.stencilZFail=ie,this.stencilZPass=ie,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==s&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const fn={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},mn={h:0,s:0,l:0},gn={h:0,s:0,l:0};function vn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class yn{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=te){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Fe.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Fe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Fe.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Fe.workingColorSpace){if(e=ve(e,1),t=ge(t,0,1),n=ge(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=vn(i,r,e+1/3),this.g=vn(i,r,e),this.b=vn(i,r,e-1/3)}return Fe.toWorkingColorSpace(this,r),this}setStyle(e,t=te){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const o=r[1],s=r[2];switch(o){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=r[1],i=n.length;if(3===i)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===i)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=te){const n=fn[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Le(e.r),this.g=Le(e.g),this.b=Le(e.b),this}copyLinearToSRGB(e){return this.r=Ne(e.r),this.g=Ne(e.g),this.b=Ne(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=te){return Fe.fromWorkingColorSpace(xn.copy(this),e),65536*Math.round(ge(255*xn.r,0,255))+256*Math.round(ge(255*xn.g,0,255))+Math.round(ge(255*xn.b,0,255))}getHexString(e=te){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Fe.workingColorSpace){Fe.fromWorkingColorSpace(xn.copy(this),t);const n=xn.r,r=xn.g,i=xn.b,o=Math.max(n,r,i),s=Math.min(n,r,i);let a,l;const c=(s+o)/2;if(s===o)a=0,l=0;else{const e=o-s;switch(l=c<=.5?e/(o+s):e/(2-o-s),o){case n:a=(r-i)/e+(r<i?6:0);break;case r:a=(i-n)/e+2;break;case i:a=(n-r)/e+4}a/=6}return e.h=a,e.s=l,e.l=c,e}getRGB(e,t=Fe.workingColorSpace){return Fe.fromWorkingColorSpace(xn.copy(this),t),e.r=xn.r,e.g=xn.g,e.b=xn.b,e}getStyle(e=te){Fe.fromWorkingColorSpace(xn.copy(this),e);const t=xn.r,n=xn.g,r=xn.b;return e!==te?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*n)},${Math.round(255*r)})`}offsetHSL(e,t,n){return this.getHSL(mn),mn.h+=e,mn.s+=t,mn.l+=n,this.setHSL(mn.h,mn.s,mn.l),this}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(mn),e.getHSL(gn);const n=ye(mn.h,gn.h,t),r=ye(mn.s,gn.s,t),i=ye(mn.l,gn.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,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 xn=new yn;yn.NAMES=fn;class _n extends pn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yn(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=u,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 Tn=new Je,En=new Se;class Mn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=oe,this.updateRange={offset:0,count:-1},this.gpuType=D,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)En.fromBufferAttribute(this,t),En.applyMatrix3(e),this.setXY(t,En.x,En.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)Tn.fromBufferAttribute(this,t),Tn.applyMatrix3(e),this.setXYZ(t,Tn.x,Tn.y,Tn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Tn.fromBufferAttribute(this,t),Tn.applyMatrix4(e),this.setXYZ(t,Tn.x,Tn.y,Tn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Tn.fromBufferAttribute(this,t),Tn.applyNormalMatrix(e),this.setXYZ(t,Tn.x,Tn.y,Tn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Tn.fromBufferAttribute(this,t),Tn.transformDirection(e),this.setXYZ(t,Tn.x,Tn.y,Tn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ee(t,this.array)),t}setX(e,t){return this.normalized&&(t=Me(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ee(t,this.array)),t}setY(e,t){return this.normalized&&(t=Me(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=Ee(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Me(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=Ee(t,this.array)),t}setW(e,t){return this.normalized&&(t=Me(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Me(t,this.array),n=Me(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Me(t,this.array),n=Me(n,this.array),r=Me(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Me(t,this.array),n=Me(n,this.array),r=Me(r,this.array),i=Me(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,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!==oe&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class bn extends Mn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Sn extends Mn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class wn extends Mn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let An=0;const Cn=new At,Rn=new $t,In=new Je,Pn=new et,Ln=new et,Nn=new Je;class On extends ue{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:An++}),this.uuid=me(),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(Ce(e)?Sn:bn)(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,n=0){this.groups.push({start:e,count:t,materialIndex:n})}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 n=this.attributes.normal;if(void 0!==n){const t=(new we).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Cn.makeRotationFromQuaternion(e),this.applyMatrix4(Cn),this}rotateX(e){return Cn.makeRotationX(e),this.applyMatrix4(Cn),this}rotateY(e){return Cn.makeRotationY(e),this.applyMatrix4(Cn),this}rotateZ(e){return Cn.makeRotationZ(e),this.applyMatrix4(Cn),this}translate(e,t,n){return Cn.makeTranslation(e,t,n),this.applyMatrix4(Cn),this}scale(e,t,n){return Cn.makeScale(e,t,n),this.applyMatrix4(Cn),this}lookAt(e){return Rn.lookAt(e),Rn.updateMatrix(),this.applyMatrix4(Rn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(In).negate(),this.translate(In.x,In.y,In.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new wn(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new et);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Je(-1/0,-1/0,-1/0),new Je(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Pn.setFromBufferAttribute(n),this.morphTargetsRelative?(Nn.addVectors(this.boundingBox.min,Pn.min),this.boundingBox.expandByPoint(Nn),Nn.addVectors(this.boundingBox.max,Pn.max),this.boundingBox.expandByPoint(Nn)):(this.boundingBox.expandByPoint(Pn.min),this.boundingBox.expandByPoint(Pn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new yt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Je,1/0);if(e){const n=this.boundingSphere.center;if(Pn.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Ln.setFromBufferAttribute(n),this.morphTargetsRelative?(Nn.addVectors(Pn.min,Ln.min),Pn.expandByPoint(Nn),Nn.addVectors(Pn.max,Ln.max),Pn.expandByPoint(Nn)):(Pn.expandByPoint(Ln.min),Pn.expandByPoint(Ln.max))}Pn.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Nn.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Nn));if(t)for(let i=0,o=t.length;i<o;i++){const o=t[i],s=this.morphTargetsRelative;for(let t=0,i=o.count;t<i;t++)Nn.fromBufferAttribute(o,t),s&&(In.fromBufferAttribute(e,t),Nn.add(In)),r=Math.max(r,n.distanceToSquared(Nn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}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 console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,r=t.position.array,i=t.normal.array,o=t.uv.array,s=r.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Mn(new Float32Array(4*s),4));const a=this.getAttribute("tangent").array,l=[],c=[];for(let e=0;e<s;e++)l[e]=new Je,c[e]=new Je;const u=new Je,h=new Je,d=new Je,p=new Se,f=new Se,m=new Se,g=new Je,v=new Je;function y(e,t,n){u.fromArray(r,3*e),h.fromArray(r,3*t),d.fromArray(r,3*n),p.fromArray(o,2*e),f.fromArray(o,2*t),m.fromArray(o,2*n),h.sub(u),d.sub(u),f.sub(p),m.sub(p);const i=1/(f.x*m.y-m.x*f.y);isFinite(i)&&(g.copy(h).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(i),v.copy(d).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(i),l[e].add(g),l[t].add(g),l[n].add(g),c[e].add(v),c[t].add(v),c[n].add(v))}let x=this.groups;0===x.length&&(x=[{start:0,count:n.length}]);for(let e=0,t=x.length;e<t;++e){const t=x[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)y(n[e+0],n[e+1],n[e+2])}const _=new Je,T=new Je,E=new Je,M=new Je;function b(e){E.fromArray(i,3*e),M.copy(E);const t=l[e];_.copy(t),_.sub(E.multiplyScalar(E.dot(t))).normalize(),T.crossVectors(M,t);const n=T.dot(c[e])<0?-1:1;a[4*e]=_.x,a[4*e+1]=_.y,a[4*e+2]=_.z,a[4*e+3]=n}for(let e=0,t=x.length;e<t;++e){const t=x[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)b(n[e+0]),b(n[e+1]),b(n[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new Mn(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const r=new Je,i=new Je,o=new Je,s=new Je,a=new Je,l=new Je,c=new Je,u=new Je;if(e)for(let h=0,d=e.count;h<d;h+=3){const d=e.getX(h+0),p=e.getX(h+1),f=e.getX(h+2);r.fromBufferAttribute(t,d),i.fromBufferAttribute(t,p),o.fromBufferAttribute(t,f),c.subVectors(o,i),u.subVectors(r,i),c.cross(u),s.fromBufferAttribute(n,d),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),s.add(c),a.add(c),l.add(c),n.setXYZ(d,s.x,s.y,s.z),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,s=t.count;e<s;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),o.fromBufferAttribute(t,e+2),c.subVectors(o,i),u.subVectors(r,i),c.cross(u),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Nn.fromBufferAttribute(e,t),Nn.normalize(),e.setXYZ(t,Nn.x,Nn.y,Nn.z)}toNonIndexed(){function e(e,t){const n=e.array,r=e.itemSize,i=e.normalized,o=new n.constructor(t.length*r);let s=0,a=0;for(let i=0,l=t.length;i<l;i++){s=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)o[a++]=n[s++]}return new Mn(o,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new On,n=this.index.array,r=this.attributes;for(const i in r){const o=e(r[i],n);t.setAttribute(i,o)}const i=this.morphAttributes;for(const r in i){const o=[],s=i[r];for(let t=0,r=s.length;t<r;t++){const r=e(s[t],n);o.push(r)}t.morphAttributes[r]=o}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let e=0,n=o.length;e<n;e++){const n=o[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}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 n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const r=n[t];e.data.attributes[t]=r.toJSON(e.data)}const r={};let i=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],o=[];for(let t=0,r=n.length;t<r;t++){const r=n[t];o.push(r.toJSON(e.data))}o.length>0&&(r[t]=o,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const r=e.attributes;for(const e in r){const n=r[e];this.setAttribute(e,n.clone(t))}const i=e.morphAttributes;for(const e in i){const n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let e=0,t=o.length;e<t;e++){const t=o[e];this.addGroup(t.start,t.count,t.materialIndex)}const s=e.boundingBox;null!==s&&(this.boundingBox=s.clone());const a=e.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Un=new At,Dn=new wt,kn=new yt,Fn=new Je,Gn=new Je,Bn=new Je,Vn=new Je,zn=new Je,Hn=new Je,Wn=new Se,jn=new Se,Xn=new Se,qn=new Je,Yn=new Je,Kn=new Je,Zn=new Je,Jn=new Je;class $n extends $t{constructor(e=new On,t=new _n){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=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const s=this.morphTargetInfluences;if(i&&s){Hn.set(0,0,0);for(let n=0,r=i.length;n<r;n++){const r=s[n],a=i[n];0!==r&&(zn.fromBufferAttribute(a,e),o?Hn.addScaledVector(zn,r):Hn.addScaledVector(zn.sub(t),r))}t.add(Hn)}return t}raycast(e,t){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0!==r){if(null===n.boundingSphere&&n.computeBoundingSphere(),kn.copy(n.boundingSphere),kn.applyMatrix4(i),Dn.copy(e.ray).recast(e.near),!1===kn.containsPoint(Dn.origin)){if(null===Dn.intersectSphere(kn,Fn))return;if(Dn.origin.distanceToSquared(Fn)>(e.far-e.near)**2)return}Un.copy(i).invert(),Dn.copy(e.ray).applyMatrix4(Un),null!==n.boundingBox&&!1===Dn.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,Dn)}}_computeIntersections(e,t,n){let r;const i=this.geometry,o=this.material,s=i.index,a=i.attributes.position,l=i.attributes.uv,c=i.attributes.uv1,u=i.attributes.normal,h=i.groups,d=i.drawRange;if(null!==s)if(Array.isArray(o))for(let i=0,a=h.length;i<a;i++){const a=h[i],p=o[a.materialIndex];for(let i=Math.max(a.start,d.start),o=Math.min(s.count,Math.min(a.start+a.count,d.start+d.count));i<o;i+=3){r=Qn(this,p,e,n,l,c,u,s.getX(i),s.getX(i+1),s.getX(i+2)),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=a.materialIndex,t.push(r))}}else{for(let i=Math.max(0,d.start),a=Math.min(s.count,d.start+d.count);i<a;i+=3){r=Qn(this,o,e,n,l,c,u,s.getX(i),s.getX(i+1),s.getX(i+2)),r&&(r.faceIndex=Math.floor(i/3),t.push(r))}}else if(void 0!==a)if(Array.isArray(o))for(let i=0,s=h.length;i<s;i++){const s=h[i],p=o[s.materialIndex];for(let i=Math.max(s.start,d.start),o=Math.min(a.count,Math.min(s.start+s.count,d.start+d.count));i<o;i+=3){r=Qn(this,p,e,n,l,c,u,i,i+1,i+2),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{for(let i=Math.max(0,d.start),s=Math.min(a.count,d.start+d.count);i<s;i+=3){r=Qn(this,o,e,n,l,c,u,i,i+1,i+2),r&&(r.faceIndex=Math.floor(i/3),t.push(r))}}}}function Qn(e,t,n,r,i,o,l,c,u,h){e.getVertexPosition(c,Gn),e.getVertexPosition(u,Bn),e.getVertexPosition(h,Vn);const d=function(e,t,n,r,i,o,l,c){let u;if(u=t.side===a?r.intersectTriangle(l,o,i,!0,c):r.intersectTriangle(i,o,l,t.side===s,c),null===u)return null;Jn.copy(c),Jn.applyMatrix4(e.matrixWorld);const h=n.ray.origin.distanceTo(Jn);return h<n.near||h>n.far?null:{distance:h,point:Jn.clone(),object:e}}(e,t,n,r,Gn,Bn,Vn,Zn);if(d){i&&(Wn.fromBufferAttribute(i,c),jn.fromBufferAttribute(i,u),Xn.fromBufferAttribute(i,h),d.uv=hn.getInterpolation(Zn,Gn,Bn,Vn,Wn,jn,Xn,new Se)),o&&(Wn.fromBufferAttribute(o,c),jn.fromBufferAttribute(o,u),Xn.fromBufferAttribute(o,h),d.uv1=hn.getInterpolation(Zn,Gn,Bn,Vn,Wn,jn,Xn,new Se),d.uv2=d.uv1),l&&(qn.fromBufferAttribute(l,c),Yn.fromBufferAttribute(l,u),Kn.fromBufferAttribute(l,h),d.normal=hn.getInterpolation(Zn,Gn,Bn,Vn,qn,Yn,Kn,new Je),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const e={a:c,b:u,c:h,normal:new Je,materialIndex:0};hn.getNormal(Gn,Bn,Vn,e.normal),d.face=e}return d}class er extends On{constructor(e=1,t=1,n=1,r=1,i=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:o};const s=this;r=Math.floor(r),i=Math.floor(i),o=Math.floor(o);const a=[],l=[],c=[],u=[];let h=0,d=0;function p(e,t,n,r,i,o,p,f,m,g,v){const y=o/m,x=p/g,_=o/2,T=p/2,E=f/2,M=m+1,b=g+1;let S=0,w=0;const A=new Je;for(let o=0;o<b;o++){const s=o*x-T;for(let a=0;a<M;a++){const h=a*y-_;A[e]=h*r,A[t]=s*i,A[n]=E,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[n]=f>0?1:-1,c.push(A.x,A.y,A.z),u.push(a/m),u.push(1-o/g),S+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const n=h+t+M*e,r=h+t+M*(e+1),i=h+(t+1)+M*(e+1),o=h+(t+1)+M*e;a.push(n,r,o),a.push(r,i,o),w+=6}s.addGroup(d,w,v),d+=w,h+=S}p("z","y","x",-1,-1,n,t,e,o,i,0),p("z","y","x",1,-1,n,t,-e,o,i,1),p("x","z","y",1,1,e,n,t,r,o,2),p("x","z","y",1,-1,e,n,-t,r,o,3),p("x","y","z",1,-1,e,t,n,r,i,4),p("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(a),this.setAttribute("position",new wn(l,3)),this.setAttribute("normal",new wn(c,3)),this.setAttribute("uv",new wn(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new er(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function tr(e){const t={};for(const n in e){t[n]={};for(const r in e[n]){const i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function nr(e){const t={};for(let n=0;n<e.length;n++){const r=tr(e[n]);for(const e in r)t[e]=r[e]}return t}function rr(e){return null===e.getRenderTarget()?e.outputColorSpace:ne}const ir={clone:tr,merge:nr};class or extends pn{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},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=tr(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].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 n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}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 n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class sr extends $t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new At,this.projectionMatrix=new At,this.projectionMatrixInverse=new At,this.coordinateSystem=le}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class ar extends sr{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=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*fe*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*pe*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*fe*Math.atan(Math.tan(.5*pe*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,o){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*pe*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;const o=this.view;if(null!==this.view&&this.view.enabled){const e=o.fullWidth,s=o.fullHeight;i+=o.offsetX*r/e,t-=o.offsetY*n/s,r*=o.width/e,n*=o.height/s}const s=this.filmOffset;0!==s&&(i+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const lr=-90;class cr extends $t{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const r=new ar(lr,1,e,t);r.layers=this.layers,this.add(r);const i=new ar(lr,1,e,t);i.layers=this.layers,this.add(i);const o=new ar(lr,1,e,t);o.layers=this.layers,this.add(o);const s=new ar(lr,1,e,t);s.layers=this.layers,this.add(s);const a=new ar(lr,1,e,t);a.layers=this.layers,this.add(a);const l=new ar(lr,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,i,o,s,a]=t;for(const e of t)this.remove(e);if(e===le)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else{if(e!==ce)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,i,o,s,a,l]=this.children,c=e.getRenderTarget(),u=e.toneMapping,h=e.xr.enabled;e.toneMapping=p,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,i),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,s),e.setRenderTarget(n,4),e.render(t,a),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=u,e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}}class ur extends je{constructor(e,t,n,r,i,o,s,a,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:x,n,r,i,o,s,a,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hr extends qe{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];void 0!==t.encoding&&(Pe("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Q?te:ee),this.texture=new ur(r,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:I}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={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"},r=new er(5,5,5),i=new or({name:"CubemapFromEquirect",uniforms:tr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:a,blending:0});i.uniforms.tEquirect.value=t;const o=new $n(r,i),s=t.minFilter;t.minFilter===P&&(t.minFilter=I);return new cr(1,10,this).update(e,o),t.minFilter=s,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,r){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}}const dr=new Je,pr=new Je,fr=new we;class mr{constructor(e=new Je(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=dr.subVectors(n,t).cross(pr.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(dr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||fr.getNormalMatrix(e),r=this.coplanarPoint(dr).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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 gr=new yt,vr=new Je;class yr{constructor(e=new mr,t=new mr,n=new mr,r=new mr,i=new mr,o=new mr){this.planes=[e,t,n,r,i,o]}set(e,t,n,r,i,o){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(r),s[4].copy(i),s[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,r=e.elements,i=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],u=r[6],h=r[7],d=r[8],p=r[9],f=r[10],m=r[11],g=r[12],v=r[13],y=r[14],x=r[15];if(n[0].setComponents(a-i,h-l,m-d,x-g).normalize(),n[1].setComponents(a+i,h+l,m+d,x+g).normalize(),n[2].setComponents(a+o,h+c,m+p,x+v).normalize(),n[3].setComponents(a-o,h-c,m-p,x-v).normalize(),n[4].setComponents(a-s,h-u,m-f,x-y).normalize(),t===le)n[5].setComponents(a+s,h+u,m+f,x+y).normalize();else{if(t!==ce)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,u,f,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),gr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),gr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gr)}intersectsSprite(e){return gr.center.set(0,0,0),gr.radius=.7071067811865476,gr.applyMatrix4(e.matrixWorld),this.intersectsSphere(gr)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<r)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(vr.x=r.normal.x>0?e.max.x:e.min.x,vr.y=r.normal.y>0?e.max.y:e.min.y,vr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(vr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function xr(){let e=null,t=!1,n=null,r=null;function i(t,o){n(t,o),r=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function _r(e,t){const n=t.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))},update:function(t,i){if(t.isGLBufferAttribute){const e=r.get(t);return void((!e||e.version<t.version)&&r.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const o=r.get(t);void 0===o?r.set(t,function(t,r){const i=t.array,o=t.usage,s=e.createBuffer();let a;if(e.bindBuffer(r,s),e.bufferData(r,i,o),t.onUploadCallback(),i instanceof Float32Array)a=e.FLOAT;else if(i instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");a=e.HALF_FLOAT}else a=e.UNSIGNED_SHORT;else if(i instanceof Int16Array)a=e.SHORT;else if(i instanceof Uint32Array)a=e.UNSIGNED_INT;else if(i instanceof Int32Array)a=e.INT;else if(i instanceof Int8Array)a=e.BYTE;else if(i instanceof Uint8Array)a=e.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);a=e.UNSIGNED_BYTE}return{buffer:s,type:a,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(t,i)):o.version<t.version&&(!function(t,r,i){const o=r.array,s=r.updateRange;e.bindBuffer(i,t),-1===s.count?e.bufferSubData(i,0,o):(n?e.bufferSubData(i,s.offset*o.BYTES_PER_ELEMENT,o,s.offset,s.count):e.bufferSubData(i,s.offset*o.BYTES_PER_ELEMENT,o.subarray(s.offset,s.offset+s.count)),s.count=-1),r.onUploadCallback()}(o.buffer,t,i),o.version=t.version)}}}class Tr extends On{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const i=e/2,o=t/2,s=Math.floor(n),a=Math.floor(r),l=s+1,c=a+1,u=e/s,h=t/a,d=[],p=[],f=[],m=[];for(let e=0;e<c;e++){const t=e*h-o;for(let n=0;n<l;n++){const r=n*u-i;p.push(r,-t,0),f.push(0,0,1),m.push(n/s),m.push(1-e/a)}}for(let e=0;e<a;e++)for(let t=0;t<s;t++){const n=t+l*e,r=t+l*(e+1),i=t+1+l*(e+1),o=t+1+l*e;d.push(n,r,o),d.push(r,i,o)}this.setIndex(d),this.setAttribute("position",new wn(p,3)),this.setAttribute("normal",new wn(f,3)),this.setAttribute("uv",new wn(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Tr(e.width,e.height,e.widthSegments,e.heightSegments)}}const Er={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_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\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",begin_vertex:"vec3 transformed = vec3( position );",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\t return 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 R21 = R12;\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 = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = 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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n    float x2 = x * x;\n    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\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, vNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(  1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,  1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,  1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#ifdef USE_UV\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:"#ifdef USE_UV\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:"#ifdef USE_UV\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <encodings_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 <encodings_fragment>\n}",depth_vert:"#include <common>\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 <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 <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 <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 <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 <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 <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\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 <encodings_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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\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#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 <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <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 <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <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 <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <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 <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 <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 <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <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 <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 <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 + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <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 <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\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 <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 <encodings_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 <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\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},Mr={common:{diffuse:{value:new yn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new we},alphaMap:{value:null},alphaMapTransform:{value:new we},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new we}},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 we}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new we}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new we},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new we},normalScale:{value:new Se(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new we},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new we}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new we}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new we}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new yn(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 yn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new we},alphaTest:{value:0},uvTransform:{value:new we}},sprite:{diffuse:{value:new yn(16777215)},opacity:{value:1},center:{value:new Se(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new we},alphaMap:{value:null},alphaMapTransform:{value:new we},alphaTest:{value:0}}},br={basic:{uniforms:nr([Mr.common,Mr.specularmap,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.fog]),vertexShader:Er.meshbasic_vert,fragmentShader:Er.meshbasic_frag},lambert:{uniforms:nr([Mr.common,Mr.specularmap,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.fog,Mr.lights,{emissive:{value:new yn(0)}}]),vertexShader:Er.meshlambert_vert,fragmentShader:Er.meshlambert_frag},phong:{uniforms:nr([Mr.common,Mr.specularmap,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.fog,Mr.lights,{emissive:{value:new yn(0)},specular:{value:new yn(1118481)},shininess:{value:30}}]),vertexShader:Er.meshphong_vert,fragmentShader:Er.meshphong_frag},standard:{uniforms:nr([Mr.common,Mr.envmap,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.roughnessmap,Mr.metalnessmap,Mr.fog,Mr.lights,{emissive:{value:new yn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Er.meshphysical_vert,fragmentShader:Er.meshphysical_frag},toon:{uniforms:nr([Mr.common,Mr.aomap,Mr.lightmap,Mr.emissivemap,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.gradientmap,Mr.fog,Mr.lights,{emissive:{value:new yn(0)}}]),vertexShader:Er.meshtoon_vert,fragmentShader:Er.meshtoon_frag},matcap:{uniforms:nr([Mr.common,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,Mr.fog,{matcap:{value:null}}]),vertexShader:Er.meshmatcap_vert,fragmentShader:Er.meshmatcap_frag},points:{uniforms:nr([Mr.points,Mr.fog]),vertexShader:Er.points_vert,fragmentShader:Er.points_frag},dashed:{uniforms:nr([Mr.common,Mr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Er.linedashed_vert,fragmentShader:Er.linedashed_frag},depth:{uniforms:nr([Mr.common,Mr.displacementmap]),vertexShader:Er.depth_vert,fragmentShader:Er.depth_frag},normal:{uniforms:nr([Mr.common,Mr.bumpmap,Mr.normalmap,Mr.displacementmap,{opacity:{value:1}}]),vertexShader:Er.meshnormal_vert,fragmentShader:Er.meshnormal_frag},sprite:{uniforms:nr([Mr.sprite,Mr.fog]),vertexShader:Er.sprite_vert,fragmentShader:Er.sprite_frag},background:{uniforms:{uvTransform:{value:new we},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Er.background_vert,fragmentShader:Er.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Er.backgroundCube_vert,fragmentShader:Er.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Er.cube_vert,fragmentShader:Er.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Er.equirect_vert,fragmentShader:Er.equirect_frag},distanceRGBA:{uniforms:nr([Mr.common,Mr.displacementmap,{referencePosition:{value:new Je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Er.distanceRGBA_vert,fragmentShader:Er.distanceRGBA_frag},shadow:{uniforms:nr([Mr.lights,Mr.fog,{color:{value:new yn(0)},opacity:{value:1}}]),vertexShader:Er.shadow_vert,fragmentShader:Er.shadow_frag}};br.physical={uniforms:nr([br.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new we},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new we},clearcoatNormalScale:{value:new Se(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new we},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new we},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new we},sheen:{value:0},sheenColor:{value:new yn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new we},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new we},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new we},transmissionSamplerSize:{value:new Se},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new we},attenuationDistance:{value:0},attenuationColor:{value:new yn(0)},specularColor:{value:new yn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new we},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new we},anisotropyVector:{value:new Se},anisotropyMap:{value:null},anisotropyMapTransform:{value:new we}}]),vertexShader:Er.meshphysical_vert,fragmentShader:Er.meshphysical_frag};const Sr={r:0,b:0,g:0};function wr(e,t,n,r,i,o,l){const c=new yn(0);let u,h,d=!0===o?0:1,p=null,f=0,m=null;function g(t,n){t.getRGB(Sr,rr(e)),r.buffers.color.setClear(Sr.r,Sr.g,Sr.b,n,l)}return{getClearColor:function(){return c},setClearColor:function(e,t=1){c.set(e),d=t,g(c,d)},getClearAlpha:function(){return d},setClearAlpha:function(e){d=e,g(c,d)},render:function(o,v){let y=!1,x=!0===v.isScene?v.background:null;if(x&&x.isTexture){x=(v.backgroundBlurriness>0?n:t).get(x)}switch(null===x?g(c,d):x&&x.isColor&&(g(x,1),y=!0),e.xr.getEnvironmentBlendMode()){case"opaque":y=!0;break;case"additive":r.buffers.color.setClear(0,0,0,1,l),y=!0;break;case"alpha-blend":r.buffers.color.setClear(0,0,0,0,l),y=!0}(e.autoClear||y)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),x&&(x.isCubeTexture||x.mapping===M)?(void 0===h&&(h=new $n(new er(1,1,1),new or({name:"BackgroundCubeMaterial",uniforms:tr(br.backgroundCube.uniforms),vertexShader:br.backgroundCube.vertexShader,fragmentShader:br.backgroundCube.fragmentShader,side:a,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&!1===x.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.toneMapped=x.colorSpace!==te,p===x&&f===x.version&&m===e.toneMapping||(h.material.needsUpdate=!0,p=x,f=x.version,m=e.toneMapping),h.layers.enableAll(),o.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(void 0===u&&(u=new $n(new Tr(2,2),new or({name:"BackgroundMaterial",uniforms:tr(br.background.uniforms),vertexShader:br.background.vertexShader,fragmentShader:br.background.fragmentShader,side:s,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=x,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=x.colorSpace!==te,!0===x.matrixAutoUpdate&&x.updateMatrix(),u.material.uniforms.uvTransform.value.copy(x.matrix),p===x&&f===x.version&&m===e.toneMapping||(u.material.needsUpdate=!0,p=x,f=x.version,m=e.toneMapping),u.layers.enableAll(),o.unshift(u,u.geometry,u.material,0,0,null))}}}function Ar(e,t,n,r){const i=e.getParameter(e.MAX_VERTEX_ATTRIBS),o=r.isWebGL2?null:t.get("OES_vertex_array_object"),s=r.isWebGL2||null!==o,a={},l=p(null);let c=l,u=!1;function h(t){return r.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function d(t){return r.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function f(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function m(e){g(e,0)}function g(n,i){const o=c.newAttributes,s=c.enabledAttributes,a=c.attributeDivisors;if(o[n]=1,0===s[n]&&(e.enableVertexAttribArray(n),s[n]=1),a[n]!==i){(r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),a[n]=i}}function v(){const t=c.newAttributes,n=c.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function y(t,n,r,i,o,s,a){!0===a?e.vertexAttribIPointer(t,n,r,o,s):e.vertexAttribPointer(t,n,r,i,o,s)}function x(){_(),u=!0,c!==l&&(c=l,h(c.object))}function _(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(i,l,d,x,_){let T=!1;if(s){const t=function(t,n,i){const s=!0===i.wireframe;let l=a[t.id];void 0===l&&(l={},a[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let u=c[s];void 0===u&&(u=p(r.isWebGL2?e.createVertexArray():o.createVertexArrayOES()),c[s]=u);return u}(x,d,l);c!==t&&(c=t,h(c.object)),T=function(e,t,n,r){const i=c.attributes,o=t.attributes;let s=0;const a=n.getAttributes();for(const t in a){if(a[t].location>=0){const n=i[t];let r=o[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===n)return!0;if(n.attribute!==r)return!0;if(r&&n.data!==r.data)return!0;s++}}return c.attributesNum!==s||c.index!==r}(i,x,d,_),T&&function(e,t,n,r){const i={},o=t.attributes;let s=0;const a=n.getAttributes();for(const t in a){if(a[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}}c.attributes=i,c.attributesNum=s,c.index=r}(i,x,d,_)}else{const e=!0===l.wireframe;c.geometry===x.id&&c.program===d.id&&c.wireframe===e||(c.geometry=x.id,c.program=d.id,c.wireframe=e,T=!0)}null!==_&&n.update(_,e.ELEMENT_ARRAY_BUFFER),(T||u)&&(u=!1,function(i,o,s,a){if(!1===r.isWebGL2&&(i.isInstancedMesh||a.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();const l=a.attributes,c=s.getAttributes(),u=o.defaultAttributeValues;for(const t in c){const o=c[t];if(o.location>=0){let s=l[t];if(void 0===s&&("instanceMatrix"===t&&i.instanceMatrix&&(s=i.instanceMatrix),"instanceColor"===t&&i.instanceColor&&(s=i.instanceColor)),void 0!==s){const t=s.normalized,l=s.itemSize,c=n.get(s);if(void 0===c)continue;const u=c.buffer,h=c.type,d=c.bytesPerElement,p=!0===r.isWebGL2&&(h===e.INT||h===e.UNSIGNED_INT||s.gpuType===O);if(s.isInterleavedBufferAttribute){const n=s.data,r=n.stride,c=s.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<o.locationSize;e++)g(o.location+e,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<o.locationSize;e++)m(o.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<o.locationSize;e++)y(o.location+e,l/o.locationSize,h,t,r*d,(c+l/o.locationSize*e)*d,p)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<o.locationSize;e++)g(o.location+e,s.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<o.locationSize;e++)m(o.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<o.locationSize;e++)y(o.location+e,l/o.locationSize,h,t,l*d,l/o.locationSize*e*d,p)}}else if(void 0!==u){const n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(o.location,n);break;case 3:e.vertexAttrib3fv(o.location,n);break;case 4:e.vertexAttrib4fv(o.location,n);break;default:e.vertexAttrib1fv(o.location,n)}}}}v()}(i,l,d,x),null!==_&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(_).buffer))},reset:x,resetDefaultState:_,dispose:function(){x();for(const e in a){const t=a[e];for(const e in t){const n=t[e];for(const e in n)d(n[e].object),delete n[e];delete t[e]}delete a[e]}},releaseStatesOfGeometry:function(e){if(void 0===a[e.id])return;const t=a[e.id];for(const e in t){const n=t[e];for(const e in n)d(n[e].object),delete n[e];delete t[e]}delete a[e.id]},releaseStatesOfProgram:function(e){for(const t in a){const n=a[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)d(r[e].object),delete r[e];delete n[e.id]}},initAttributes:f,enableAttribute:m,disableUnusedAttributes:v}}function Cr(e,t,n,r){const i=r.isWebGL2;let o;this.setMode=function(e){o=e},this.render=function(t,r){e.drawArrays(o,t,r),n.update(r,o,1)},this.renderInstances=function(r,s,a){if(0===a)return;let l,c;if(i)l=e,c="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](o,r,s,a),n.update(s,o,a)}}function Rr(e,t,n){let r;function i(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 o="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let s=void 0!==n.precision?n.precision:"highp";const a=i(s);a!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",a,"instead."),s=a);const l=o||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=h>0,x=o||t.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:s,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:o?e.getParameter(e.MAX_SAMPLES):0}}function Ir(e){const t=this;let n=null,r=0,i=!1,o=!1;const s=new mr,a=new we,l={value:null,needsUpdate:!1};function c(e,n,r,i){const o=null!==e?e.length:0;let c=null;if(0!==o){if(c=l.value,!0!==i||null===c){const t=r+4*o,i=n.matrixWorldInverse;a.getNormalMatrix(i),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=r;t!==o;++t,n+=4)s.copy(e[t]).applyMatrix4(i,a),s.normal.toArray(c,n),c[n+3]=s.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=o,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==r||i;return i=t,r=e.length,n},this.beginShadows=function(){o=!0,c(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(s,a,u){const h=s.clippingPlanes,d=s.clipIntersection,p=s.clipShadows,f=e.get(s);if(!i||null===h||0===h.length||o&&!p)o?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=r>0);t.numPlanes=r,t.numIntersection=0}();else{const e=o?0:r,t=4*e;let i=f.clippingState||null;l.value=i,i=c(h,a,t,u);for(let e=0;e!==t;++e)i[e]=n[e];f.clippingState=i,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Pr(e){let t=new WeakMap;function n(e,t){return t===T?e.mapping=x:t===E&&(e.mapping=_),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const o=i.mapping;if(o===T||o===E){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const o=i.image;if(o&&o.height>0){const s=new hr(o.height/2);return s.fromEquirectangularTexture(e,i),t.set(i,s),i.addEventListener("dispose",r),n(s.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}class Lr extends sr{constructor(e=-1,t=1,n=1,r=-1,i=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-e,o=n+e,s=r+t,a=r-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;i+=e*this.view.offsetX,o=i+e*this.view.width,s-=t*this.view.offsetY,a=s-t*this.view.height}this.projectionMatrix.makeOrthographic(i,o,s,a,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 Nr=[.125,.215,.35,.446,.526,.582],Or=20,Ur=new Lr,Dr=new yn;let kr=null;const Fr=(1+Math.sqrt(5))/2,Gr=1/Fr,Br=[new Je(1,1,1),new Je(-1,1,1),new Je(1,1,-1),new Je(-1,1,-1),new Je(0,Fr,Gr),new Je(0,Fr,-Gr),new Je(Gr,0,Fr),new Je(-Gr,0,Fr),new Je(Fr,Gr,0),new Je(-Fr,Gr,0)];class Vr{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){kr=this._renderer.getRenderTarget(),this._setSize(256);const i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=jr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Wr(),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(kr),e.scissorTest=!1,Hr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===x||e.mapping===_?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),kr=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:I,minFilter:I,generateMipmaps:!1,type:k,format:G,colorSpace:ne,depthBuffer:!1},r=zr(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=zr(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],r=[];let i=e;const o=e-4+1+Nr.length;for(let s=0;s<o;s++){const o=Math.pow(2,i);n.push(o);let a=1/o;s>e-4?a=Nr[s-e+4-1]:0===s&&(a=0),r.push(a);const l=1/(o-2),c=-l,u=1+l,h=[c,c,u,c,u,u,c,c,u,u,c,u],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),y=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let e=0;e<d;e++){const t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(r,f*p*e),y.set(h,m*p*e);const i=[e,e,e,e,e,e];x.set(i,g*p*e)}const _=new On;_.setAttribute("position",new Mn(v,f)),_.setAttribute("uv",new Mn(y,m)),_.setAttribute("faceIndex",new Mn(x,g)),t.push(_),i>4&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(Or),i=new Je(0,1,0),o=new or({name:"SphericalGaussianBlur",defines:{n:Or,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Xr(),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 o}(r,e,t)}return r}_compileMaterial(e){const t=new $n(this._lodPlanes[0],e);this._renderer.compile(t,Ur)}_sceneToCubeUV(e,t,n,r){const i=new ar(90,1,t,n),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,u=l.toneMapping;l.getClearColor(Dr),l.toneMapping=p,l.autoClear=!1;const h=new _n({name:"PMREM.Background",side:a,depthWrite:!1,depthTest:!1}),d=new $n(new er,h);let f=!1;const m=e.background;m?m.isColor&&(h.color.copy(m),e.background=null,f=!0):(h.color.copy(Dr),f=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,o[t],0),i.lookAt(s[t],0,0)):1===n?(i.up.set(0,0,o[t]),i.lookAt(0,s[t],0)):(i.up.set(0,o[t],0),i.lookAt(0,0,s[t]));const a=this._cubeSize;Hr(r,n*a,t>2?a:0,a,a),l.setRenderTarget(r),f&&l.render(d,i),l.render(e,i)}d.geometry.dispose(),d.material.dispose(),l.toneMapping=u,l.autoClear=c,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===x||e.mapping===_;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=jr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Wr());const i=r?this._cubemapMaterial:this._equirectMaterial,o=new $n(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const s=this._cubeSize;Hr(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(o,Ur)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),r=Br[(t-1)%Br.length];this._blur(e,t-1,t,n,r)}t.autoClear=n}_blur(e,t,n,r,i){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",i),this._halfBlur(o,e,n,n,r,"longitudinal",i)}_halfBlur(e,t,n,r,i,o,s){const a=this._renderer,l=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new $n(this._lodPlanes[r],l),u=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(i)?Math.PI/(2*h):2*Math.PI/39,p=i/d,f=isFinite(i)?1+Math.floor(3*p):Or;f>Or&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<Or;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<f&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===o,s&&(u.poleAxis.value=s);const{_lodMax:v}=this;u.dTheta.value=d,u.mipInt.value=v-n;const y=this._sizeLods[r];Hr(t,3*y*(r>v-4?r-v+4:0),4*(this._cubeSize-y),3*y,2*y),a.setRenderTarget(t),a.render(c,Ur)}}function zr(e,t,n){const r=new qe(e,t,n);return r.texture.mapping=M,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Hr(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Wr(){return new or({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Xr(),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 jr(){return new or({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Xr(),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 Xr(){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 qr(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const o=i.mapping,s=o===T||o===E,a=o===x||o===_;if(s||a){if(i.isRenderTargetTexture&&!0===i.needsPMREMUpdate){i.needsPMREMUpdate=!1;let r=t.get(i);return null===n&&(n=new Vr(e)),r=s?n.fromEquirectangular(i,r):n.fromCubemap(i,r),t.set(i,r),r.texture}if(t.has(i))return t.get(i).texture;{const o=i.image;if(s&&o&&o.height>0||a&&o&&function(e){let t=0;const n=6;for(let r=0;r<n;r++)void 0!==e[r]&&t++;return t===n}(o)){null===n&&(n=new Vr(e));const o=s?n.fromEquirectangular(i):n.fromCubemap(i);return t.set(i,o),i.addEventListener("dispose",r),o.texture}return null}}}return i},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Yr(e){const t={};function n(n){if(void 0!==t[n])return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=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":r=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":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Kr(e,t,n,r){const i={},o=new WeakMap;function s(e){const a=e.target;null!==a.index&&t.remove(a.index);for(const e in a.attributes)t.remove(a.attributes[e]);for(const e in a.morphAttributes){const n=a.morphAttributes[e];for(let e=0,r=n.length;e<r;e++)t.remove(n[e])}a.removeEventListener("dispose",s),delete i[a.id];const l=o.get(a);l&&(t.remove(l),o.delete(a)),r.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,n.memory.geometries--}function a(e){const n=[],r=e.index,i=e.attributes.position;let s=0;if(null!==r){const e=r.array;s=r.version;for(let t=0,r=e.length;t<r;t+=3){const r=e[t+0],i=e[t+1],o=e[t+2];n.push(r,i,i,o,o,r)}}else{const e=i.array;s=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){const e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}const a=new(Ce(n)?Sn:bn)(n,1);a.version=s;const l=o.get(e);l&&t.remove(l),o.set(e,a)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener("dispose",s),i[t.id]=!0,n.memory.geometries++),t},update:function(n){const r=n.attributes;for(const n in r)t.update(r[n],e.ARRAY_BUFFER);const i=n.morphAttributes;for(const n in i){const r=i[n];for(let n=0,i=r.length;n<i;n++)t.update(r[n],e.ARRAY_BUFFER)}},getWireframeAttribute:function(e){const t=o.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&a(e)}else a(e);return o.get(e)}}}function Zr(e,t,n,r){const i=r.isWebGL2;let o,s,a;this.setMode=function(e){o=e},this.setIndex=function(e){s=e.type,a=e.bytesPerElement},this.render=function(t,r){e.drawElements(o,r,s,t*a),n.update(r,o,1)},this.renderInstances=function(r,l,c){if(0===c)return;let u,h;if(i)u=e,h="drawElementsInstanced";else if(u=t.get("ANGLE_instanced_arrays"),h="drawElementsInstancedANGLE",null===u)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[h](o,l,s,r*a,c),n.update(l,o,c)}}function Jr(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(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,r,i){switch(t.calls++,r){case e.TRIANGLES:t.triangles+=i*(n/3);break;case e.LINES:t.lines+=i*(n/2);break;case e.LINE_STRIP:t.lines+=i*(n-1);break;case e.LINE_LOOP:t.lines+=i*n;break;case e.POINTS:t.points+=i*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r)}}}}function $r(e,t){return e[0]-t[0]}function Qr(e,t){return Math.abs(t[1])-Math.abs(e[1])}function ei(e,t,n){const r={},i=new Float32Array(8),o=new WeakMap,s=new Xe,a=[];for(let e=0;e<8;e++)a[e]=[e,0];return{update:function(l,c,u){const h=l.morphTargetInfluences;if(!0===t.isWebGL2){const d=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,p=void 0!==d?d.length:0;let f=o.get(c);if(void 0===f||f.count!==p){void 0!==f&&f.texture.dispose();const v=void 0!==c.morphAttributes.position,y=void 0!==c.morphAttributes.normal,x=void 0!==c.morphAttributes.color,_=c.morphAttributes.position||[],T=c.morphAttributes.normal||[],E=c.morphAttributes.color||[];let M=0;!0===v&&(M=1),!0===y&&(M=2),!0===x&&(M=3);let b=c.attributes.position.count*M,S=1;b>t.maxTextureSize&&(S=Math.ceil(b/t.maxTextureSize),b=t.maxTextureSize);const w=new Float32Array(b*S*4*p),A=new Ye(w,b,S,p);A.type=D,A.needsUpdate=!0;const C=4*M;for(let I=0;I<p;I++){const P=_[I],L=T[I],N=E[I],O=b*S*4*I;for(let U=0;U<P.count;U++){const k=U*C;!0===v&&(s.fromBufferAttribute(P,U),w[O+k+0]=s.x,w[O+k+1]=s.y,w[O+k+2]=s.z,w[O+k+3]=0),!0===y&&(s.fromBufferAttribute(L,U),w[O+k+4]=s.x,w[O+k+5]=s.y,w[O+k+6]=s.z,w[O+k+7]=0),!0===x&&(s.fromBufferAttribute(N,U),w[O+k+8]=s.x,w[O+k+9]=s.y,w[O+k+10]=s.z,w[O+k+11]=4===N.itemSize?s.w:1)}}function R(){A.dispose(),o.delete(c),c.removeEventListener("dispose",R)}f={count:p,texture:A,size:new Se(b,S)},o.set(c,f),c.addEventListener("dispose",R)}let m=0;for(let F=0;F<h.length;F++)m+=h[F];const g=c.morphTargetsRelative?1:1-m;u.getUniforms().setValue(e,"morphTargetBaseInfluence",g),u.getUniforms().setValue(e,"morphTargetInfluences",h),u.getUniforms().setValue(e,"morphTargetsTexture",f.texture,n),u.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}else{const G=void 0===h?0:h.length;let B=r[c.id];if(void 0===B||B.length!==G){B=[];for(let j=0;j<G;j++)B[j]=[j,0];r[c.id]=B}for(let X=0;X<G;X++){const q=B[X];q[0]=X,q[1]=h[X]}B.sort(Qr);for(let Y=0;Y<8;Y++)Y<G&&B[Y][1]?(a[Y][0]=B[Y][0],a[Y][1]=B[Y][1]):(a[Y][0]=Number.MAX_SAFE_INTEGER,a[Y][1]=0);a.sort($r);const V=c.morphAttributes.position,z=c.morphAttributes.normal;let H=0;for(let K=0;K<8;K++){const Z=a[K],J=Z[0],$=Z[1];J!==Number.MAX_SAFE_INTEGER&&$?(V&&c.getAttribute("morphTarget"+K)!==V[J]&&c.setAttribute("morphTarget"+K,V[J]),z&&c.getAttribute("morphNormal"+K)!==z[J]&&c.setAttribute("morphNormal"+K,z[J]),i[K]=$,H+=$):(V&&!0===c.hasAttribute("morphTarget"+K)&&c.deleteAttribute("morphTarget"+K),z&&!0===c.hasAttribute("morphNormal"+K)&&c.deleteAttribute("morphNormal"+K),i[K]=0)}const W=c.morphTargetsRelative?1:1-H;u.getUniforms().setValue(e,"morphTargetBaseInfluence",W),u.getUniforms().setValue(e,"morphTargetInfluences",i)}}}}function ti(e,t,n,r){let i=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(s){const a=r.render.frame,l=s.geometry,c=t.get(s,l);return i.get(c)!==a&&(t.update(c),i.set(c,a)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",o)&&s.addEventListener("dispose",o),n.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,e.ARRAY_BUFFER)),c},dispose:function(){i=new WeakMap}}}const ni=new je,ri=new Ye,ii=new Ke,oi=new ur,si=[],ai=[],li=new Float32Array(16),ci=new Float32Array(9),ui=new Float32Array(4);function hi(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let o=si[i];if(void 0===o&&(o=new Float32Array(i),si[i]=o),0!==t){r.toArray(o,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(o,i)}return o}function di(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function pi(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function fi(e,t){let n=ai[t];void 0===n&&(n=new Int32Array(t),ai[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function mi(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function gi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(di(n,t))return;e.uniform2fv(this.addr,t),pi(n,t)}}function vi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(di(n,t))return;e.uniform3fv(this.addr,t),pi(n,t)}}function yi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(di(n,t))return;e.uniform4fv(this.addr,t),pi(n,t)}}function xi(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(di(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),pi(n,t)}else{if(di(n,r))return;ui.set(r),e.uniformMatrix2fv(this.addr,!1,ui),pi(n,r)}}function _i(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(di(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),pi(n,t)}else{if(di(n,r))return;ci.set(r),e.uniformMatrix3fv(this.addr,!1,ci),pi(n,r)}}function Ti(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(di(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),pi(n,t)}else{if(di(n,r))return;li.set(r),e.uniformMatrix4fv(this.addr,!1,li),pi(n,r)}}function Ei(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Mi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(di(n,t))return;e.uniform2iv(this.addr,t),pi(n,t)}}function bi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(di(n,t))return;e.uniform3iv(this.addr,t),pi(n,t)}}function Si(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(di(n,t))return;e.uniform4iv(this.addr,t),pi(n,t)}}function wi(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Ai(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(di(n,t))return;e.uniform2uiv(this.addr,t),pi(n,t)}}function Ci(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(di(n,t))return;e.uniform3uiv(this.addr,t),pi(n,t)}}function Ri(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(di(n,t))return;e.uniform4uiv(this.addr,t),pi(n,t)}}function Ii(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2D(t||ni,i)}function Pi(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||ii,i)}function Li(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||oi,i)}function Ni(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||ri,i)}function Oi(e,t){e.uniform1fv(this.addr,t)}function Ui(e,t){const n=hi(t,this.size,2);e.uniform2fv(this.addr,n)}function Di(e,t){const n=hi(t,this.size,3);e.uniform3fv(this.addr,n)}function ki(e,t){const n=hi(t,this.size,4);e.uniform4fv(this.addr,n)}function Fi(e,t){const n=hi(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Gi(e,t){const n=hi(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Bi(e,t){const n=hi(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Vi(e,t){e.uniform1iv(this.addr,t)}function zi(e,t){e.uniform2iv(this.addr,t)}function Hi(e,t){e.uniform3iv(this.addr,t)}function Wi(e,t){e.uniform4iv(this.addr,t)}function ji(e,t){e.uniform1uiv(this.addr,t)}function Xi(e,t){e.uniform2uiv(this.addr,t)}function qi(e,t){e.uniform3uiv(this.addr,t)}function Yi(e,t){e.uniform4uiv(this.addr,t)}function Ki(e,t,n){const r=this.cache,i=t.length,o=fi(n,i);di(r,o)||(e.uniform1iv(this.addr,o),pi(r,o));for(let e=0;e!==i;++e)n.setTexture2D(t[e]||ni,o[e])}function Zi(e,t,n){const r=this.cache,i=t.length,o=fi(n,i);di(r,o)||(e.uniform1iv(this.addr,o),pi(r,o));for(let e=0;e!==i;++e)n.setTexture3D(t[e]||ii,o[e])}function Ji(e,t,n){const r=this.cache,i=t.length,o=fi(n,i);di(r,o)||(e.uniform1iv(this.addr,o),pi(r,o));for(let e=0;e!==i;++e)n.setTextureCube(t[e]||oi,o[e])}function $i(e,t,n){const r=this.cache,i=t.length,o=fi(n,i);di(r,o)||(e.uniform1iv(this.addr,o),pi(r,o));for(let e=0;e!==i;++e)n.setTexture2DArray(t[e]||ri,o[e])}class Qi{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return mi;case 35664:return gi;case 35665:return vi;case 35666:return yi;case 35674:return xi;case 35675:return _i;case 35676:return Ti;case 5124:case 35670:return Ei;case 35667:case 35671:return Mi;case 35668:case 35672:return bi;case 35669:case 35673:return Si;case 5125:return wi;case 36294:return Ai;case 36295:return Ci;case 36296:return Ri;case 35678:case 36198:case 36298:case 36306:case 35682:return Ii;case 35679:case 36299:case 36307:return Pi;case 35680:case 36300:case 36308:case 36293:return Li;case 36289:case 36303:case 36311:case 36292:return Ni}}(t.type)}}class eo{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Oi;case 35664:return Ui;case 35665:return Di;case 35666:return ki;case 35674:return Fi;case 35675:return Gi;case 35676:return Bi;case 5124:case 35670:return Vi;case 35667:case 35671:return zi;case 35668:case 35672:return Hi;case 35669:case 35673:return Wi;case 5125:return ji;case 36294:return Xi;case 36295:return qi;case 36296:return Yi;case 35678:case 36198:case 36298:case 36306:case 35682:return Ki;case 35679:case 36299:case 36307:return Zi;case 35680:case 36300:case 36308:case 36293:return Ji;case 36289:case 36303:case 36311:case 36292:return $i}}(t.type)}}class to{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let i=0,o=r.length;i!==o;++i){const o=r[i];o.setValue(e,t[o.id],n)}}}const no=/(\w+)(\])?(\[|\.)?/g;function ro(e,t){e.seq.push(t),e.map[t.id]=t}function io(e,t,n){const r=e.name,i=r.length;for(no.lastIndex=0;;){const o=no.exec(r),s=no.lastIndex;let a=o[1];const l="]"===o[2],c=o[3];if(l&&(a|=0),void 0===c||"["===c&&s+2===i){ro(n,void 0===c?new Qi(a,e,t):new eo(a,e,t));break}{let e=n.map[a];void 0===e&&(e=new to(a),ro(n,e)),n=e}}}class oo{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const n=e.getActiveUniform(t,r);io(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];void 0!==r&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,o=t.length;i!==o;++i){const o=t[i],s=n[o.id];!1!==s.needsUpdate&&o.setValue(e,s.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,i=e.length;r!==i;++r){const i=e[r];i.id in t&&n.push(i)}return n}}function so(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}let ao=0;function lo(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&""===i)return"";const o=/ERROR: 0:(\d+)/.exec(i);if(o){const r=parseInt(o[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+function(e,t){const n=e.split("\n"),r=[],i=Math.max(t-6,0),o=Math.min(t+6,n.length);for(let e=i;e<o;e++){const i=e+1;r.push(`${i===t?">":" "} ${i}: ${n[e]}`)}return r.join("\n")}(e.getShaderSource(t),r)}return i}function co(e,t){const n=function(e){switch(e){case ne:return["Linear","( value )"];case te:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function uo(e,t){let n;switch(t){case f:n="Linear";break;case m:n="Reinhard";break;case g:n="OptimizedCineon";break;case v:n="ACESFilmic";break;case y:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function ho(e){return""!==e}function po(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function fo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const mo=/^[ \t]*#include +<([\w\d./]+)>/gm;function go(e){return e.replace(mo,vo)}function vo(e,t){const n=Er[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return go(n)}const yo=/#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 xo(e){return e.replace(yo,_o)}function _o(e,t,n,r){let i="";for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return i}function To(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 Eo(e,t,n,s){const a=e.getContext(),l=n.defines;let c=n.vertexShader,f=n.fragmentShader;const m=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===r?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===i?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===o&&(t="SHADOWMAP_TYPE_VSM"),t}(n),g=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case x:case _:t="ENVMAP_TYPE_CUBE";break;case M:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),v=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===_&&(t="ENVMAP_MODE_REFRACTION");return t}(n),y=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case u:t="ENVMAP_BLENDING_MULTIPLY";break;case h:t="ENVMAP_BLENDING_MIX";break;case d:t="ENVMAP_BLENDING_ADD"}return t}(n),T=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}(n),E=n.isWebGL2?"":function(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(ho).join("\n")}(n),b=function(e){const t=[];for(const n in e){const r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(l),S=a.createProgram();let w,A,C=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(w=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ho).join("\n"),w.length>0&&(w+="\n"),A=[E,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ho).join("\n"),A.length>0&&(A+="\n")):(w=[To(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+v:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ho).join("\n"),A=[E,To(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+g:"",n.envMap?"#define "+v:"",n.envMap?"#define "+y:"",T?"#define CUBEUV_TEXEL_WIDTH "+T.texelWidth:"",T?"#define CUBEUV_TEXEL_HEIGHT "+T.texelHeight:"",T?"#define CUBEUV_MAX_MIP "+T.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==p?"#define TONE_MAPPING":"",n.toneMapping!==p?Er.tonemapping_pars_fragment:"",n.toneMapping!==p?uo("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Er.encodings_pars_fragment,co("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ho).join("\n")),c=go(c),c=po(c,n),c=fo(c,n),f=go(f),f=po(f,n),f=fo(f,n),c=xo(c),f=xo(f),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(C="#version 300 es\n",w=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+w,A=["#define varying in",n.glslVersion===se?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===se?"":"#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"+A);const R=C+w+c,I=C+A+f,P=so(a,a.VERTEX_SHADER,R),L=so(a,a.FRAGMENT_SHADER,I);if(a.attachShader(S,P),a.attachShader(S,L),void 0!==n.index0AttributeName?a.bindAttribLocation(S,0,n.index0AttributeName):!0===n.morphTargets&&a.bindAttribLocation(S,0,"position"),a.linkProgram(S),e.debug.checkShaderErrors){const t=a.getProgramInfoLog(S).trim(),n=a.getShaderInfoLog(P).trim(),r=a.getShaderInfoLog(L).trim();let i=!0,o=!0;if(!1===a.getProgramParameter(S,a.LINK_STATUS))if(i=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(a,S,P,L);else{const e=lo(a,P,"vertex"),n=lo(a,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(S,a.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==n&&""!==r||(o=!1);o&&(this.diagnostics={runnable:i,programLog:t,vertexShader:{log:n,prefix:w},fragmentShader:{log:r,prefix:A}})}let N,O;return a.deleteShader(P),a.deleteShader(L),this.getUniforms=function(){return void 0===N&&(N=new oo(a,S)),N},this.getAttributes=function(){return void 0===O&&(O=function(e,t){const n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i),o=r.name;let s=1;r.type===e.FLOAT_MAT2&&(s=2),r.type===e.FLOAT_MAT3&&(s=3),r.type===e.FLOAT_MAT4&&(s=4),n[o]={type:r.type,location:e.getAttribLocation(t,o),locationSize:s}}return n}(a,S)),O},this.destroy=function(){s.releaseStatesOfProgram(this),a.deleteProgram(S),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ao++,this.cacheKey=t,this.usedTimes=1,this.program=S,this.vertexShader=P,this.fragmentShader=L,this}let Mo=0;class bo{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return!1===o.has(r)&&(o.add(r),r.usedTimes++),!1===o.has(i)&&(o.add(i),i.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 n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new So(e),t.set(e,n)),n}}class So{constructor(e){this.id=Mo++,this.code=e,this.usedTimes=0}}function wo(e,t,n,r,i,o,s){const c=new Ft,u=new bo,h=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let g=i.precision;const v={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 y(e){return 0===e?"uv":`uv${e}`}return{getParameters:function(o,c,h,x,_){const T=x.fog,E=_.geometry,b=o.isMeshStandardMaterial?x.environment:null,S=(o.isMeshStandardMaterial?n:t).get(o.envMap||b),w=S&&S.mapping===M?S.image.height:null,A=v[o.type];null!==o.precision&&(g=i.getMaxPrecision(o.precision),g!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",g,"instead."));const C=E.morphAttributes.position||E.morphAttributes.normal||E.morphAttributes.color,R=void 0!==C?C.length:0;let I,P,L,N,O=0;if(void 0!==E.morphAttributes.position&&(O=1),void 0!==E.morphAttributes.normal&&(O=2),void 0!==E.morphAttributes.color&&(O=3),A){const e=br[A];I=e.vertexShader,P=e.fragmentShader}else I=o.vertexShader,P=o.fragmentShader,u.update(o),L=u.getVertexShaderID(o),N=u.getFragmentShaderID(o);const U=e.getRenderTarget(),D=!0===_.isInstancedMesh,k=!!o.map,F=!!o.matcap,G=!!S,B=!!o.aoMap,V=!!o.lightMap,z=!!o.bumpMap,H=!!o.normalMap,W=!!o.displacementMap,j=!!o.emissiveMap,X=!!o.metalnessMap,q=!!o.roughnessMap,Y=o.anisotropy>0,K=o.clearcoat>0,Z=o.iridescence>0,J=o.sheen>0,$=o.transmission>0,Q=Y&&!!o.anisotropyMap,ee=K&&!!o.clearcoatMap,te=K&&!!o.clearcoatNormalMap,re=K&&!!o.clearcoatRoughnessMap,ie=Z&&!!o.iridescenceMap,oe=Z&&!!o.iridescenceThicknessMap,se=J&&!!o.sheenColorMap,ae=J&&!!o.sheenRoughnessMap,le=!!o.specularMap,ce=!!o.specularColorMap,ue=!!o.specularIntensityMap,he=$&&!!o.transmissionMap,de=$&&!!o.thicknessMap,pe=!!o.gradientMap,fe=!!o.alphaMap,me=o.alphaTest>0,ge=!!o.extensions,ve=!!E.attributes.uv1,ye=!!E.attributes.uv2,xe=!!E.attributes.uv3;return{isWebGL2:d,shaderID:A,shaderType:o.type,shaderName:o.name,vertexShader:I,fragmentShader:P,defines:o.defines,customVertexShaderID:L,customFragmentShaderID:N,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:g,instancing:D,instancingColor:D&&null!==_.instanceColor,supportsVertexTextures:m,outputColorSpace:null===U?e.outputColorSpace:!0===U.isXRRenderTarget?U.texture.colorSpace:ne,map:k,matcap:F,envMap:G,envMapMode:G&&S.mapping,envMapCubeUVHeight:w,aoMap:B,lightMap:V,bumpMap:z,normalMap:H,displacementMap:m&&W,emissiveMap:j,normalMapObjectSpace:H&&1===o.normalMapType,normalMapTangentSpace:H&&0===o.normalMapType,metalnessMap:X,roughnessMap:q,anisotropy:Y,anisotropyMap:Q,clearcoat:K,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:re,iridescence:Z,iridescenceMap:ie,iridescenceThicknessMap:oe,sheen:J,sheenColorMap:se,sheenRoughnessMap:ae,specularMap:le,specularColorMap:ce,specularIntensityMap:ue,transmission:$,transmissionMap:he,thicknessMap:de,gradientMap:pe,opaque:!1===o.transparent&&1===o.blending,alphaMap:fe,alphaTest:me,combine:o.combine,mapUv:k&&y(o.map.channel),aoMapUv:B&&y(o.aoMap.channel),lightMapUv:V&&y(o.lightMap.channel),bumpMapUv:z&&y(o.bumpMap.channel),normalMapUv:H&&y(o.normalMap.channel),displacementMapUv:W&&y(o.displacementMap.channel),emissiveMapUv:j&&y(o.emissiveMap.channel),metalnessMapUv:X&&y(o.metalnessMap.channel),roughnessMapUv:q&&y(o.roughnessMap.channel),anisotropyMapUv:Q&&y(o.anisotropyMap.channel),clearcoatMapUv:ee&&y(o.clearcoatMap.channel),clearcoatNormalMapUv:te&&y(o.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&y(o.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&y(o.iridescenceMap.channel),iridescenceThicknessMapUv:oe&&y(o.iridescenceThicknessMap.channel),sheenColorMapUv:se&&y(o.sheenColorMap.channel),sheenRoughnessMapUv:ae&&y(o.sheenRoughnessMap.channel),specularMapUv:le&&y(o.specularMap.channel),specularColorMapUv:ce&&y(o.specularColorMap.channel),specularIntensityMapUv:ue&&y(o.specularIntensityMap.channel),transmissionMapUv:he&&y(o.transmissionMap.channel),thicknessMapUv:de&&y(o.thicknessMap.channel),alphaMapUv:fe&&y(o.alphaMap.channel),vertexTangents:!!E.attributes.tangent&&(H||Y),vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!E.attributes.color&&4===E.attributes.color.itemSize,vertexUv1s:ve,vertexUv2s:ye,vertexUv3s:xe,pointsUvs:!0===_.isPoints&&!!E.attributes.uv&&(k||fe),fog:!!T,useFog:!0===o.fog,fogExp2:T&&T.isFogExp2,flatShading:!0===o.flatShading,sizeAttenuation:!0===o.sizeAttenuation,logarithmicDepthBuffer:f,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==E.morphAttributes.position,morphNormals:void 0!==E.morphAttributes.normal,morphColors:void 0!==E.morphAttributes.color,morphTargetsCount:R,morphTextureStride:O,numDirLights:c.directional.length,numPointLights:c.point.length,numSpotLights:c.spot.length,numSpotLightMaps:c.spotLightMap.length,numRectAreaLights:c.rectArea.length,numHemiLights:c.hemi.length,numDirLightShadows:c.directionalShadowMap.length,numPointLightShadows:c.pointShadowMap.length,numSpotLightShadows:c.spotShadowMap.length,numSpotLightShadowsWithMaps:c.numSpotLightShadowsWithMaps,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:o.toneMapped?e.toneMapping:p,useLegacyLights:e.useLegacyLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:o.side===l,flipSided:o.side===a,useDepthPacking:o.depthPacking>=0,depthPacking:o.depthPacking||0,index0AttributeName:o.index0AttributeName,extensionDerivatives:ge&&!0===o.extensions.derivatives,extensionFragDepth:ge&&!0===o.extensions.fragDepth,extensionDrawBuffers:ge&&!0===o.extensions.drawBuffers,extensionShaderTextureLOD:ge&&!0===o.extensions.shaderTextureLOD,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){c.disableAll(),t.isWebGL2&&c.enable(0);t.supportsVertexTextures&&c.enable(1);t.instancing&&c.enable(2);t.instancingColor&&c.enable(3);t.matcap&&c.enable(4);t.envMap&&c.enable(5);t.normalMapObjectSpace&&c.enable(6);t.normalMapTangentSpace&&c.enable(7);t.clearcoat&&c.enable(8);t.iridescence&&c.enable(9);t.alphaTest&&c.enable(10);t.vertexColors&&c.enable(11);t.vertexAlphas&&c.enable(12);t.vertexUv1s&&c.enable(13);t.vertexUv2s&&c.enable(14);t.vertexUv3s&&c.enable(15);t.vertexTangents&&c.enable(16);t.anisotropy&&c.enable(17);e.push(c.mask),c.disableAll(),t.fog&&c.enable(0);t.useFog&&c.enable(1);t.flatShading&&c.enable(2);t.logarithmicDepthBuffer&&c.enable(3);t.skinning&&c.enable(4);t.morphTargets&&c.enable(5);t.morphNormals&&c.enable(6);t.morphColors&&c.enable(7);t.premultipliedAlpha&&c.enable(8);t.shadowMapEnabled&&c.enable(9);t.useLegacyLights&&c.enable(10);t.doubleSided&&c.enable(11);t.flipSided&&c.enable(12);t.useDepthPacking&&c.enable(13);t.dithering&&c.enable(14);t.transmission&&c.enable(15);t.sheen&&c.enable(16);t.opaque&&c.enable(17);t.pointsUvs&&c.enable(18);e.push(c.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=v[e.type];let n;if(t){const e=br[t];n=ir.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,t=h.length;e<t;e++){const t=h[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return void 0===r&&(r=new Eo(e,n,t,o),h.push(r)),r},releaseProgram:function(e){if(0==--e.usedTimes){const t=h.indexOf(e);h[t]=h[h.length-1],h.pop(),e.destroy()}},releaseShaderCache:function(e){u.remove(e)},programs:h,dispose:function(){u.dispose()}}}function Ao(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,r){e.get(t)[n]=r},dispose:function(){e=new WeakMap}}}function Co(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 Ro(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 Io(){const e=[];let t=0;const n=[],r=[],i=[];function o(n,r,i,o,s,a){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:r,material:i,groupOrder:o,renderOrder:n.renderOrder,z:s,group:a},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=s,l.group=a),t++,l}return{opaque:n,transmissive:r,transparent:i,init:function(){t=0,n.length=0,r.length=0,i.length=0},push:function(e,t,s,a,l,c){const u=o(e,t,s,a,l,c);s.transmission>0?r.push(u):!0===s.transparent?i.push(u):n.push(u)},unshift:function(e,t,s,a,l,c){const u=o(e,t,s,a,l,c);s.transmission>0?r.unshift(u):!0===s.transparent?i.unshift(u):n.unshift(u)},finish:function(){for(let n=t,r=e.length;n<r;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Co),r.length>1&&r.sort(t||Ro),i.length>1&&i.sort(t||Ro)}}}function Po(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new Io,e.set(t,[i])):n>=r.length?(i=new Io,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Lo(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Je,color:new yn};break;case"SpotLight":n={position:new Je,direction:new Je,color:new yn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Je,color:new yn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Je,skyColor:new yn,groundColor:new yn};break;case"RectAreaLight":n={color:new yn,position:new Je,halfWidth:new Je,halfHeight:new Je}}return e[t.id]=n,n}}}let No=0;function Oo(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Uo(e,t){const n=new Lo,r=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Se};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Se,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)i.probe.push(new Je);const o=new Je,s=new At,a=new At;return{setup:function(o,s){let a=0,l=0,c=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let u=0,h=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0,x=0;o.sort(Oo);const _=!0===s?Math.PI:1;for(let e=0,t=o.length;e<t;e++){const t=o[e],s=t.color,T=t.intensity,E=t.distance,M=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)a+=s.r*T*_,l+=s.g*T*_,c+=s.b*T*_;else if(t.isLightProbe)for(let e=0;e<9;e++)i.probe[e].addScaledVector(t.sh.coefficients[e],T);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*_),t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.directionalShadow[u]=n,i.directionalShadowMap[u]=M,i.directionalShadowMatrix[u]=t.shadow.matrix,m++}i.directional[u]=e,u++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(s).multiplyScalar(T*_),e.distance=E,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,i.spot[d]=e;const o=t.shadow;if(t.map&&(i.spotLightMap[y]=t.map,y++,o.updateMatrices(t),t.castShadow&&x++),i.spotLightMatrix[d]=o.matrix,t.castShadow){const e=r.get(t);e.shadowBias=o.bias,e.shadowNormalBias=o.normalBias,e.shadowRadius=o.radius,e.shadowMapSize=o.mapSize,i.spotShadow[d]=e,i.spotShadowMap[d]=M,v++}d++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(s).multiplyScalar(T),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),i.rectArea[p]=e,p++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*_),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,i.pointShadow[h]=n,i.pointShadowMap[h]=M,i.pointShadowMatrix[h]=t.shadow.matrix,g++}i.point[h]=e,h++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(T*_),e.groundColor.copy(t.groundColor).multiplyScalar(T*_),i.hemi[f]=e,f++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=Mr.LTC_FLOAT_1,i.rectAreaLTC2=Mr.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=Mr.LTC_HALF_1,i.rectAreaLTC2=Mr.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=a,i.ambient[1]=l,i.ambient[2]=c;const T=i.hash;T.directionalLength===u&&T.pointLength===h&&T.spotLength===d&&T.rectAreaLength===p&&T.hemiLength===f&&T.numDirectionalShadows===m&&T.numPointShadows===g&&T.numSpotShadows===v&&T.numSpotMaps===y||(i.directional.length=u,i.spot.length=d,i.rectArea.length=p,i.point.length=h,i.hemi.length=f,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=v,i.spotShadowMap.length=v,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotLightMatrix.length=v+y-x,i.spotLightMap.length=y,i.numSpotLightShadowsWithMaps=x,T.directionalLength=u,T.pointLength=h,T.spotLength=d,T.rectAreaLength=p,T.hemiLength=f,T.numDirectionalShadows=m,T.numPointShadows=g,T.numSpotShadows=v,T.numSpotMaps=y,i.version=No++)},setupView:function(e,t){let n=0,r=0,l=0,c=0,u=0;const h=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(d.matrixWorld),o.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(h),n++}else if(d.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),e.direction.setFromMatrixPosition(d.matrixWorld),o.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(h),l++}else if(d.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),a.identity(),s.copy(d.matrixWorld),s.premultiply(h),a.extractRotation(s),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(a),e.halfHeight.applyMatrix4(a),c++}else if(d.isPointLight){const e=i.point[r];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(h),r++}else if(d.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(h),u++}}},state:i}}function Do(e,t){const n=new Uo(e,t),r=[],i=[];return{init:function(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function(e){n.setup(r,e)},setupLightsView:function(e){n.setupView(r,e)},pushLight:function(e){r.push(e)},pushShadow:function(e){i.push(e)}}}function ko(e,t){let n=new WeakMap;return{get:function(r,i=0){const o=n.get(r);let s;return void 0===o?(s=new Do(e,t),n.set(r,[s])):i>=o.length?(s=new Do(e,t),o.push(s)):s=o[i],s},dispose:function(){n=new WeakMap}}}class Fo extends pn{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 Go extends pn{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 Bo(e,t,n){let i=new yr;const c=new Se,u=new Se,h=new Xe,d=new Fo({depthPacking:3201}),p=new Go,f={},m=n.maxTextureSize,g={[s]:a,[a]:s,[l]:l},v=new or({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Se},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}"}),y=v.clone();y.defines.HORIZONTAL_PASS=1;const x=new On;x.setAttribute("position",new Mn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new $n(x,v),T=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=r;let E=this.type;function M(n,r){const i=t.update(_);v.defines.VSM_SAMPLES!==n.blurSamples&&(v.defines.VSM_SAMPLES=n.blurSamples,y.defines.VSM_SAMPLES=n.blurSamples,v.needsUpdate=!0,y.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new qe(c.x,c.y)),v.uniforms.shadow_pass.value=n.map.texture,v.uniforms.resolution.value=n.mapSize,v.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,i,v,_,null),y.uniforms.shadow_pass.value=n.mapPass.texture,y.uniforms.resolution.value=n.mapSize,y.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,i,y,_,null)}function b(t,n,r,i){let s=null;const a=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===r.isPointLight?p:d,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let r=f[e];void 0===r&&(r={},f[e]=r);let i=r[t];void 0===i&&(i=s.clone(),r[t]=i),s=i}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=i===o?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:g[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===r.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=r}return s}function S(n,r,s,a,l){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&l===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const r=t.update(n),i=n.material;if(Array.isArray(i)){const t=r.groups;for(let o=0,c=t.length;o<c;o++){const c=t[o],u=i[c.materialIndex];if(u&&u.visible){const t=b(n,u,a,l);e.renderBufferDirect(s,null,r,t,n,c)}}}else if(i.visible){const t=b(n,i,a,l);e.renderBufferDirect(s,null,r,t,n,null)}}const c=n.children;for(let e=0,t=c.length;e<t;e++)S(c[e],r,s,a,l)}this.render=function(t,n,r){if(!1===T.enabled)return;if(!1===T.autoUpdate&&!1===T.needsUpdate)return;if(0===t.length)return;const s=e.getRenderTarget(),a=e.getActiveCubeFace(),l=e.getActiveMipmapLevel(),d=e.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=E!==o&&this.type===o,f=E===o&&this.type!==o;for(let s=0,a=t.length;s<a;s++){const a=t[s],l=a.shadow;if(void 0===l){console.warn("THREE.WebGLShadowMap:",a,"has no shadow.");continue}if(!1===l.autoUpdate&&!1===l.needsUpdate)continue;c.copy(l.mapSize);const g=l.getFrameExtents();if(c.multiply(g),u.copy(l.mapSize),(c.x>m||c.y>m)&&(c.x>m&&(u.x=Math.floor(m/g.x),c.x=u.x*g.x,l.mapSize.x=u.x),c.y>m&&(u.y=Math.floor(m/g.y),c.y=u.y*g.y,l.mapSize.y=u.y)),null===l.map||!0===p||!0===f){const e=this.type!==o?{minFilter:A,magFilter:A}:{};null!==l.map&&l.map.dispose(),l.map=new qe(c.x,c.y,e),l.map.texture.name=a.name+".shadowMap",l.camera.updateProjectionMatrix()}e.setRenderTarget(l.map),e.clear();const v=l.getViewportCount();for(let e=0;e<v;e++){const t=l.getViewport(e);h.set(u.x*t.x,u.y*t.y,u.x*t.z,u.y*t.w),d.viewport(h),l.updateMatrices(a,e),i=l.getFrustum(),S(n,r,l.camera,a,this.type)}!0!==l.isPointLightShadow&&this.type===o&&M(l,r),l.needsUpdate=!1}E=this.type,T.needsUpdate=!1,e.setRenderTarget(s,a,l)}}function Vo(e,t,n){const r=n.isWebGL2;const i=new function(){let t=!1;const n=new Xe;let r=null;const i=new Xe(0,0,0,0);return{setMask:function(n){r===n||t||(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,o,s,a){!0===a&&(t*=s,r*=s,o*=s),n.set(t,r,o,s),!1===i.equals(n)&&(e.clearColor(t,r,o,s),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}},o=new function(){let t=!1,n=null,r=null,i=null;return{setTest:function(t){t?H(e.DEPTH_TEST):W(e.DEPTH_TEST)},setMask:function(r){n===r||t||(e.depthMask(r),n=r)},setFunc:function(t){if(r!==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)}r=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,n=null,r=null,i=null}}},s=new function(){let t=!1,n=null,r=null,i=null,o=null,s=null,a=null,l=null,c=null;return{setTest:function(n){t||(n?H(e.STENCIL_TEST):W(e.STENCIL_TEST))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,s){r===t&&i===n&&o===s||(e.stencilFunc(t,n,s),r=t,i=n,o=s)},setOp:function(t,n,r){s===t&&a===n&&l===r||(e.stencilOp(t,n,r),s=t,a=n,l=r)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,r=null,i=null,o=null,s=null,a=null,l=null,c=null}}},u=new WeakMap,h=new WeakMap;let d={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,_=null,T=null,E=null,M=null,b=null,S=!1,w=null,A=null,C=null,R=null,I=null;const P=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let L=!1,N=0;const O=e.getParameter(e.VERSION);-1!==O.indexOf("WebGL")?(N=parseFloat(/^WebGL (\d)/.exec(O)[1]),L=N>=1):-1!==O.indexOf("OpenGL ES")&&(N=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),L=N>=2);let U=null,D={};const k=e.getParameter(e.SCISSOR_BOX),F=e.getParameter(e.VIEWPORT),G=(new Xe).fromArray(k),B=(new Xe).fromArray(F);function V(t,n,i,o){const s=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let a=0;a<i;a++)!r||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(n+a,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage3D(n,0,e.RGBA,1,1,o,0,e.RGBA,e.UNSIGNED_BYTE,s);return a}const z={};function H(t){!0!==d[t]&&(e.enable(t),d[t]=!0)}function W(t){!1!==d[t]&&(e.disable(t),d[t]=!1)}z[e.TEXTURE_2D]=V(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=V(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(z[e.TEXTURE_2D_ARRAY]=V(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=V(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),i.setClear(0,0,0,1),o.setClear(1),s.setClear(0),H(e.DEPTH_TEST),o.setFunc(3),Y(!1),K(1),H(e.CULL_FACE),q(0);const j={[c]:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT};if(r)j[103]=e.MIN,j[104]=e.MAX;else{const e=t.get("EXT_blend_minmax");null!==e&&(j[103]=e.MIN_EXT,j[104]=e.MAX_EXT)}const X={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA};function q(t,n,r,i,o,s,a,l){if(0!==t){if(!1===v&&(H(e.BLEND),v=!0),5===t)o=o||n,s=s||r,a=a||i,n===x&&o===E||(e.blendEquationSeparate(j[n],j[o]),x=n,E=o),r===_&&i===T&&s===M&&a===b||(e.blendFuncSeparate(X[r],X[i],X[s],X[a]),_=r,T=i,M=s,b=a),y=t,S=!1;else if(t!==y||l!==S){if(x===c&&E===c||(e.blendEquation(e.FUNC_ADD),x=c,E=c),l)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:console.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:console.error("THREE.WebGLState: Invalid blending: ",t)}_=null,T=null,M=null,b=null,y=t,S=l}}else!0===v&&(W(e.BLEND),v=!1)}function Y(t){w!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),w=t)}function K(t){0!==t?(H(e.CULL_FACE),t!==A&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):W(e.CULL_FACE),A=t}function Z(t,n,r){t?(H(e.POLYGON_OFFSET_FILL),R===n&&I===r||(e.polygonOffset(n,r),R=n,I=r)):W(e.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:o,stencil:s},enable:H,disable:W,bindFramebuffer:function(t,n){return p[t]!==n&&(e.bindFramebuffer(t,n),p[t]=n,r&&(t===e.DRAW_FRAMEBUFFER&&(p[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(p[e.DRAW_FRAMEBUFFER]=n)),!0)},drawBuffers:function(r,i){let o=m,s=!1;if(r)if(o=f.get(i),void 0===o&&(o=[],f.set(i,o)),r.isWebGLMultipleRenderTargets){const t=r.texture;if(o.length!==t.length||o[0]!==e.COLOR_ATTACHMENT0){for(let n=0,r=t.length;n<r;n++)o[n]=e.COLOR_ATTACHMENT0+n;o.length=t.length,s=!0}}else o[0]!==e.COLOR_ATTACHMENT0&&(o[0]=e.COLOR_ATTACHMENT0,s=!0);else o[0]!==e.BACK&&(o[0]=e.BACK,s=!0);s&&(n.isWebGL2?e.drawBuffers(o):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(o))},useProgram:function(t){return g!==t&&(e.useProgram(t),g=t,!0)},setBlending:q,setMaterial:function(t,n){t.side===l?W(e.CULL_FACE):H(e.CULL_FACE);let r=t.side===a;n&&(r=!r),Y(r),1===t.blending&&!1===t.transparent?q(0):q(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),i.setMask(t.colorWrite);const c=t.stencilWrite;s.setTest(c),c&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),Z(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?H(e.SAMPLE_ALPHA_TO_COVERAGE):W(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:Y,setCullFace:K,setLineWidth:function(t){t!==C&&(L&&e.lineWidth(t),C=t)},setPolygonOffset:Z,setScissorTest:function(t){t?H(e.SCISSOR_TEST):W(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+P-1),U!==t&&(e.activeTexture(t),U=t)},bindTexture:function(t,n,r){void 0===r&&(r=null===U?e.TEXTURE0+P-1:U);let i=D[r];void 0===i&&(i={type:void 0,texture:void 0},D[r]=i),i.type===t&&i.texture===n||(U!==r&&(e.activeTexture(r),U=r),e.bindTexture(t,n||z[t]),i.type=t,i.texture=n)},unbindTexture:function(){const t=D[U];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let r=h.get(n);void 0===r&&(r=new WeakMap,h.set(n,r));let i=r.get(t);void 0===i&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))},uniformBlockBinding:function(t,n){const r=h.get(n).get(t);u.get(n)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),u.set(n,r))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===G.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),G.copy(t))},viewport:function(t){!1===B.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),B.copy(t))},reset:function(){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.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===r&&(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),d={},U=null,D={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,_=null,T=null,E=null,M=null,b=null,S=!1,w=null,A=null,C=null,R=null,I=null,G.set(0,0,e.canvas.width,e.canvas.height),B.set(0,0,e.canvas.width,e.canvas.height),i.reset(),o.reset(),s.reset()}}}function zo(e,t,n,r,i,o,s){const a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap;let m;const g=new WeakMap;let v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function y(e,t){return v?new OffscreenCanvas(e,t):Re("canvas")}function x(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t?Te:Math.floor,o=r(i*e.width),s=r(i*e.height);void 0===m&&(m=y(o,s));const a=n?y(o,s):m;a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),a}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function _(e){return xe(e.width)&&xe(e.height)}function T(e,t){return e.generateMipmaps&&t&&e.minFilter!==A&&e.minFilter!==I}function E(t){e.generateMipmap(t)}function M(n,r,i,o,s=!1){if(!1===a)return r;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=r;return r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8)),r===e.RGBA&&(i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=o===te&&!1===s?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)),l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function O(e,t,n){return!0===T(e,n)||e.isFramebufferTexture&&e.minFilter!==A&&e.minFilter!==I?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 z(t){return t===A||t===C||t===R?e.NEAREST:e.LINEAR}function H(e){const t=e.target;t.removeEventListener("dispose",H),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=g.get(n);if(i){const r=i[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&j(e),0===Object.keys(i).length&&g.delete(n)}r.remove(e)}(t),t.isVideoTexture&&f.delete(t)}function W(t){const n=t.target;n.removeEventListener("dispose",W),function(t){const n=t.texture,i=r.get(t),o=r.get(n);void 0!==o.__webglTexture&&(e.deleteTexture(o.__webglTexture),s.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(i.__webglFramebuffer[t]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let t=0;t<i.__webglColorRenderbuffer.length;t++)i.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(i.__webglColorRenderbuffer[t]);i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);i.__webglTexture&&(e.deleteTexture(i.__webglTexture),s.memory.textures--),r.remove(n[t])}r.remove(n),r.remove(t)}(n)}function j(t){const n=r.get(t);e.deleteTexture(n.__webglTexture);const i=t.source;delete g.get(i)[n.__cacheKey],s.memory.textures--}let X=0;function q(t,i){const o=r.get(t);if(t.isVideoTexture&&function(e){const t=s.render.frame;f.get(e)!==t&&(f.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&o.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void Q(o,t,i);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,o.__webglTexture,e.TEXTURE0+i)}const Y={[b]:e.REPEAT,[S]:e.CLAMP_TO_EDGE,[w]:e.MIRRORED_REPEAT},K={[A]:e.NEAREST,[C]:e.NEAREST_MIPMAP_NEAREST,[R]:e.NEAREST_MIPMAP_LINEAR,[I]:e.LINEAR,1007:e.LINEAR_MIPMAP_NEAREST,[P]:e.LINEAR_MIPMAP_LINEAR},Z={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function J(n,o,s){if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,Y[o.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,Y[o.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,Y[o.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,K[o.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,K[o.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),o.wrapS===S&&o.wrapT===S||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,z(o.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,z(o.minFilter)),o.minFilter!==A&&o.minFilter!==I&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),o.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,Z[o.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const s=t.get("EXT_texture_filter_anisotropic");if(o.magFilter===A)return;if(o.minFilter!==R&&o.minFilter!==P)return;if(o.type===D&&!1===t.has("OES_texture_float_linear"))return;if(!1===a&&o.type===k&&!1===t.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||r.get(o).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function $(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",H));const i=n.source;let o=g.get(i);void 0===o&&(o={},g.set(i,o));const a=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(a!==t.__cacheKey){void 0===o[a]&&(o[a]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,r=!0),o[a].usedTimes++;const i=o[t.__cacheKey];void 0!==i&&(o[t.__cacheKey].usedTimes--,0===i.usedTimes&&j(n)),t.__cacheKey=a,t.__webglTexture=o[a].texture}return r}function Q(t,i,s){let l=e.TEXTURE_2D;(i.isDataArrayTexture||i.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),i.isData3DTexture&&(l=e.TEXTURE_3D);const c=$(t,i),h=i.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+s);const d=r.get(h);if(h.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=function(e){return!a&&(e.wrapS!==S||e.wrapT!==S||e.minFilter!==A&&e.minFilter!==I)}(i)&&!1===_(i.image);let r=x(i.image,t,!1,u);r=ce(i,r);const p=_(r)||a,f=o.convert(i.format,i.colorSpace);let m,g=o.convert(i.type),v=M(i.internalFormat,f,g,i.colorSpace);J(l,i,p);const y=i.mipmaps,b=a&&!0!==i.isVideoTexture,w=void 0===d.__version||!0===c,C=O(i,r,p);if(i.isDepthTexture)v=e.DEPTH_COMPONENT,a?v=i.type===D?e.DEPTH_COMPONENT32F:i.type===U?e.DEPTH_COMPONENT24:i.type===F?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:i.type===D&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===B&&v===e.DEPTH_COMPONENT&&i.type!==N&&i.type!==U&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=U,g=o.convert(i.type)),i.format===V&&v===e.DEPTH_COMPONENT&&(v=e.DEPTH_STENCIL,i.type!==F&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=F,g=o.convert(i.type))),w&&(b?n.texStorage2D(e.TEXTURE_2D,1,v,r.width,r.height):n.texImage2D(e.TEXTURE_2D,0,v,r.width,r.height,0,f,g,null));else if(i.isDataTexture)if(y.length>0&&p){b&&w&&n.texStorage2D(e.TEXTURE_2D,C,v,y[0].width,y[0].height);for(let t=0,r=y.length;t<r;t++)m=y[t],b?n.texSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,f,g,m.data):n.texImage2D(e.TEXTURE_2D,t,v,m.width,m.height,0,f,g,m.data);i.generateMipmaps=!1}else b?(w&&n.texStorage2D(e.TEXTURE_2D,C,v,r.width,r.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,f,g,r.data)):n.texImage2D(e.TEXTURE_2D,0,v,r.width,r.height,0,f,g,r.data);else if(i.isCompressedTexture)if(i.isCompressedArrayTexture){b&&w&&n.texStorage3D(e.TEXTURE_2D_ARRAY,C,v,y[0].width,y[0].height,r.depth);for(let t=0,o=y.length;t<o;t++)m=y[t],i.format!==G?null!==f?b?n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,m.width,m.height,r.depth,f,m.data,0,0):n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,v,m.width,m.height,r.depth,0,m.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):b?n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,m.width,m.height,r.depth,f,g,m.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,v,m.width,m.height,r.depth,0,f,g,m.data)}else{b&&w&&n.texStorage2D(e.TEXTURE_2D,C,v,y[0].width,y[0].height);for(let t=0,r=y.length;t<r;t++)m=y[t],i.format!==G?null!==f?b?n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,f,m.data):n.compressedTexImage2D(e.TEXTURE_2D,t,v,m.width,m.height,0,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):b?n.texSubImage2D(e.TEXTURE_2D,t,0,0,m.width,m.height,f,g,m.data):n.texImage2D(e.TEXTURE_2D,t,v,m.width,m.height,0,f,g,m.data)}else if(i.isDataArrayTexture)b?(w&&n.texStorage3D(e.TEXTURE_2D_ARRAY,C,v,r.width,r.height,r.depth),n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,r.width,r.height,r.depth,f,g,r.data)):n.texImage3D(e.TEXTURE_2D_ARRAY,0,v,r.width,r.height,r.depth,0,f,g,r.data);else if(i.isData3DTexture)b?(w&&n.texStorage3D(e.TEXTURE_3D,C,v,r.width,r.height,r.depth),n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,r.width,r.height,r.depth,f,g,r.data)):n.texImage3D(e.TEXTURE_3D,0,v,r.width,r.height,r.depth,0,f,g,r.data);else if(i.isFramebufferTexture){if(w)if(b)n.texStorage2D(e.TEXTURE_2D,C,v,r.width,r.height);else{let t=r.width,i=r.height;for(let r=0;r<C;r++)n.texImage2D(e.TEXTURE_2D,r,v,t,i,0,f,g,null),t>>=1,i>>=1}}else if(y.length>0&&p){b&&w&&n.texStorage2D(e.TEXTURE_2D,C,v,y[0].width,y[0].height);for(let t=0,r=y.length;t<r;t++)m=y[t],b?n.texSubImage2D(e.TEXTURE_2D,t,0,0,f,g,m):n.texImage2D(e.TEXTURE_2D,t,v,f,g,m);i.generateMipmaps=!1}else b?(w&&n.texStorage2D(e.TEXTURE_2D,C,v,r.width,r.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,f,g,r)):n.texImage2D(e.TEXTURE_2D,0,v,f,g,r);T(i,p)&&E(l),d.__version=h.version,i.onUpdate&&i.onUpdate(i)}t.__version=i.version}function re(t,i,s,a,l){const c=o.convert(s.format,s.colorSpace),u=o.convert(s.type),h=M(s.internalFormat,c,u,s.colorSpace);r.get(i).__hasExternalTextures||(l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,0,h,i.width,i.height,i.depth,0,c,u,null):n.texImage2D(l,0,h,i.width,i.height,0,c,u,null)),n.bindFramebuffer(e.FRAMEBUFFER,t),le(i)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,a,l,r.get(s).__webglTexture,0,se(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,a,l,r.get(s).__webglTexture,0),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ie(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let i=e.DEPTH_COMPONENT16;if(r||le(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===D?i=e.DEPTH_COMPONENT32F:t.type===U&&(i=e.DEPTH_COMPONENT24));const r=se(n);le(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,i,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,r,i,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,i,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const i=se(n);r&&!1===le(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):le(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let i=0;i<t.length;i++){const s=t[i],a=o.convert(s.format,s.colorSpace),l=o.convert(s.type),c=M(s.internalFormat,a,l,s.colorSpace),u=se(n);r&&!1===le(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,u,c,n.width,n.height):le(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,u,c,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,c,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function oe(t){const i=r.get(t),o=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),q(i.depthTexture,0);const o=r.get(i.depthTexture).__webglTexture,s=se(i);if(i.depthTexture.format===B)le(i)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o,0);else{if(i.depthTexture.format!==V)throw new Error("Unknown depthTexture format");le(i)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,o,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,o,0)}}(i.__webglFramebuffer,t)}else if(o){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=e.createRenderbuffer(),ie(i.__webglDepthbuffer[r],t,!1)}else n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),ie(i.__webglDepthbuffer,t,!1);n.bindFramebuffer(e.FRAMEBUFFER,null)}function se(e){return Math.min(h,e.samples)}function le(e){const n=r.get(e);return a&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function ce(e,n){const r=e.colorSpace,i=e.format,o=e.type;return!0===e.isCompressedTexture||e.format===ae||r!==ne&&r!==ee&&(r===te?!1===a?!0===t.has("EXT_sRGB")&&i===G?(e.format=ae,e.minFilter=I,e.generateMipmaps=!1):n=Be.sRGBToLinear(n):i===G&&o===L||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",r)),n}this.allocateTextureUnit=function(){const e=X;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),X+=1,e},this.resetTextureUnits=function(){X=0},this.setTexture2D=q,this.setTexture2DArray=function(t,i){const o=r.get(t);t.version>0&&o.__version!==t.version?Q(o,t,i):n.bindTexture(e.TEXTURE_2D_ARRAY,o.__webglTexture,e.TEXTURE0+i)},this.setTexture3D=function(t,i){const o=r.get(t);t.version>0&&o.__version!==t.version?Q(o,t,i):n.bindTexture(e.TEXTURE_3D,o.__webglTexture,e.TEXTURE0+i)},this.setTextureCube=function(t,i){const s=r.get(t);t.version>0&&s.__version!==t.version?function(t,i,s){if(6!==i.image.length)return;const l=$(t,i),u=i.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);const h=r.get(u);if(u.version!==h.__version||!0===l){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=i.isCompressedTexture||i.image[0].isCompressedTexture,r=i.image[0]&&i.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||r?r?i.image[e].image:i.image[e]:x(i.image[e],!1,!0,c),d[e]=ce(i,d[e]);const p=d[0],f=_(p)||a,m=o.convert(i.format,i.colorSpace),g=o.convert(i.type),v=M(i.internalFormat,m,g,i.colorSpace),y=a&&!0!==i.isVideoTexture,b=void 0===h.__version||!0===l;let S,w=O(i,p,f);if(J(e.TEXTURE_CUBE_MAP,i,f),t){y&&b&&n.texStorage2D(e.TEXTURE_CUBE_MAP,w,v,p.width,p.height);for(let t=0;t<6;t++){S=d[t].mipmaps;for(let r=0;r<S.length;r++){const o=S[r];i.format!==G?null!==m?y?n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,o.width,o.height,m,o.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,v,o.width,o.height,0,o.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):y?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,o.width,o.height,m,g,o.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,v,o.width,o.height,0,m,g,o.data)}}}else{S=i.mipmaps,y&&b&&(S.length>0&&w++,n.texStorage2D(e.TEXTURE_CUBE_MAP,w,v,d[0].width,d[0].height));for(let t=0;t<6;t++)if(r){y?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,m,g,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,v,d[t].width,d[t].height,0,m,g,d[t].data);for(let r=0;r<S.length;r++){const i=S[r].image[t].image;y?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,i.width,i.height,m,g,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,v,i.width,i.height,0,m,g,i.data)}}else{y?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m,g,d[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,v,m,g,d[t]);for(let r=0;r<S.length;r++){const i=S[r];y?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,m,g,i.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,v,m,g,i.image[t])}}}T(i,f)&&E(e.TEXTURE_CUBE_MAP),h.__version=u.version,i.onUpdate&&i.onUpdate(i)}t.__version=i.version}(s,t,i):n.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+i)},this.rebindTextures=function(t,n,i){const o=r.get(t);void 0!==n&&re(o.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),void 0!==i&&oe(t)},this.setupRenderTarget=function(t){const l=t.texture,c=r.get(t),u=r.get(l);t.addEventListener("dispose",W),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=l.version,s.memory.textures++);const h=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=_(t)||a;if(h){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else{if(c.__webglFramebuffer=e.createFramebuffer(),d)if(i.drawBuffers){const n=t.texture;for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);void 0===i.__webglTexture&&(i.__webglTexture=e.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&t.samples>0&&!1===le(t)){const r=d?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n<r.length;n++){const i=r[n];c.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,c.__webglColorRenderbuffer[n]);const s=o.convert(i.format,i.colorSpace),a=o.convert(i.type),l=M(i.internalFormat,s,a,i.colorSpace,!0===t.isXRRenderTarget),u=se(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,c.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),ie(c.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(h){n.bindTexture(e.TEXTURE_CUBE_MAP,u.__webglTexture),J(e.TEXTURE_CUBE_MAP,l,p);for(let n=0;n<6;n++)re(c.__webglFramebuffer[n],t,l,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n);T(l,p)&&E(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){const i=t.texture;for(let o=0,s=i.length;o<s;o++){const s=i[o],a=r.get(s);n.bindTexture(e.TEXTURE_2D,a.__webglTexture),J(e.TEXTURE_2D,s,p),re(c.__webglFramebuffer,t,s,e.COLOR_ATTACHMENT0+o,e.TEXTURE_2D),T(s,p)&&E(e.TEXTURE_2D)}n.unbindTexture()}else{let r=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(a?r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(r,u.__webglTexture),J(r,l,p),re(c.__webglFramebuffer,t,l,e.COLOR_ATTACHMENT0,r),T(l,p)&&E(r),n.unbindTexture()}t.depthBuffer&&oe(t)},this.updateRenderTargetMipmap=function(t){const i=_(t)||a,o=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let s=0,a=o.length;s<a;s++){const a=o[s];if(T(a,i)){const i=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,o=r.get(a).__webglTexture;n.bindTexture(i,o),E(i),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(a&&t.samples>0&&!1===le(t)){const i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],o=t.width,s=t.height;let a=e.COLOR_BUFFER_BIT;const l=[],c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),h=!0===t.isWebGLMultipleRenderTargets;if(h)for(let t=0;t<i.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<i.length;n++){l.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&l.push(c);const d=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===d&&(t.depthBuffer&&(a|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(a|=e.STENCIL_BUFFER_BIT)),h&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]),!0===d&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[c]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[c])),h){const t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,o,s,0,0,o,s,a,e.NEAREST),p&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,l)}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),h)for(let t=0;t<i.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);const o=r.get(i[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,o,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=re,this.useMultisampledRTT=le}function Ho(e,t,n){const r=n.isWebGL2;return{convert:function(n,i=""){let o;if(n===L)return e.UNSIGNED_BYTE;if(1017===n)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===n)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===n)return e.BYTE;if(1011===n)return e.SHORT;if(n===N)return e.UNSIGNED_SHORT;if(n===O)return e.INT;if(n===U)return e.UNSIGNED_INT;if(n===D)return e.FLOAT;if(n===k)return r?e.HALF_FLOAT:(o=t.get("OES_texture_half_float"),null!==o?o.HALF_FLOAT_OES:null);if(1021===n)return e.ALPHA;if(n===G)return e.RGBA;if(1024===n)return e.LUMINANCE;if(1025===n)return e.LUMINANCE_ALPHA;if(n===B)return e.DEPTH_COMPONENT;if(n===V)return e.DEPTH_STENCIL;if(n===ae)return o=t.get("EXT_sRGB"),null!==o?o.SRGB_ALPHA_EXT:null;if(1028===n)return e.RED;if(1029===n)return e.RED_INTEGER;if(1030===n)return e.RG;if(1031===n)return e.RG_INTEGER;if(1033===n)return e.RGBA_INTEGER;if(n===z||n===H||n===W||n===j)if(i===te){if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===o)return null;if(n===z)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===H)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===W)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===j)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(o=t.get("WEBGL_compressed_texture_s3tc"),null===o)return null;if(n===z)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===H)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===W)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===j)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===n||35841===n||35842===n||35843===n){if(o=t.get("WEBGL_compressed_texture_pvrtc"),null===o)return null;if(35840===n)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===n)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===n)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===n)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===n)return o=t.get("WEBGL_compressed_texture_etc1"),null!==o?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===n||37496===n){if(o=t.get("WEBGL_compressed_texture_etc"),null===o)return null;if(37492===n)return i===te?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(37496===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}if(37808===n||37809===n||37810===n||37811===n||37812===n||37813===n||37814===n||37815===n||37816===n||37817===n||37818===n||37819===n||37820===n||37821===n){if(o=t.get("WEBGL_compressed_texture_astc"),null===o)return null;if(37808===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===n)return i===te?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===X){if(o=t.get("EXT_texture_compression_bptc"),null===o)return null;if(n===X)return i===te?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(36283===n||36284===n||36285===n||36286===n){if(o=t.get("EXT_texture_compression_rgtc"),null===o)return null;if(n===X)return o.COMPRESSED_RED_RGTC1_EXT;if(36284===n)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===n)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===n)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===F?r?e.UNSIGNED_INT_24_8:(o=t.get("WEBGL_depth_texture"),null!==o?o.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}class Wo extends ar{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class jo extends $t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Xo={type:"move"};class qo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new jo,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 jo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Je,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Je),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new jo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Je,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Je),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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let r=null,i=null,o=null;const s=this._targetRay,a=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){o=!0;for(const r of e.hand.values()){const e=t.getJointPose(r,n),i=this._getHandJoint(l,r);null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=null!==e}const r=l.joints["index-finger-tip"],i=l.joints["thumb-tip"],s=r.position.distanceTo(i.position),a=.02,c=.005;l.inputState.pinching&&s>a+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=a-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==a&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1));null!==s&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==i&&(r=i),null!==r&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(Xo)))}return null!==s&&(s.visible=null!==r),null!==a&&(a.visible=null!==i),null!==l&&(l.visible=null!==o),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new jo;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Yo extends je{constructor(e,t,n,r,i,o,s,a,l,c){if((c=void 0!==c?c:B)!==B&&c!==V)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===B&&(n=U),void 0===n&&c===V&&(n=F),super(null,r,i,o,s,a,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:A,this.minFilter=void 0!==a?a:A,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class Ko extends ue{constructor(e,t){super();const n=this;let r=null,i=1,o=null,s="local-floor",a=1,l=null,c=null,u=null,h=null,d=null,p=null;const f=t.getContextAttributes();let m=null,g=null;const v=[],y=[];let x=null;const _=new ar;_.layers.enable(1),_.viewport=new Xe;const T=new ar;T.layers.enable(2),T.viewport=new Xe;const E=[_,T],M=new Wo;M.layers.enable(1),M.layers.enable(2);let b=null,S=null;function w(e){const t=y.indexOf(e.inputSource);if(-1===t)return;const n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||o),n.dispatchEvent({type:e.type,data:e.inputSource}))}function A(){r.removeEventListener("select",w),r.removeEventListener("selectstart",w),r.removeEventListener("selectend",w),r.removeEventListener("squeeze",w),r.removeEventListener("squeezestart",w),r.removeEventListener("squeezeend",w),r.removeEventListener("end",A),r.removeEventListener("inputsourceschange",C);for(let e=0;e<v.length;e++){const t=y[e];null!==t&&(y[e]=null,v[e].disconnect(t))}b=null,S=null,e.setRenderTarget(m),d=null,h=null,u=null,r=null,g=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function C(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],r=y.indexOf(n);r>=0&&(y[r]=null,v[r].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let r=y.indexOf(n);if(-1===r){for(let e=0;e<v.length;e++){if(e>=y.length){y.push(n),r=e;break}if(null===y[e]){y[e]=n,r=e;break}}if(-1===r)break}const i=v[r];i&&i.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getCamera=function(){},this.setUserCamera=function(e){x=e},this.getController=function(e){let t=v[e];return void 0===t&&(t=new qo,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new qo,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new qo,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(c){if(r=c,null!==r){if(m=e.getRenderTarget(),r.addEventListener("select",w),r.addEventListener("selectstart",w),r.addEventListener("selectend",w),r.addEventListener("squeeze",w),r.addEventListener("squeezestart",w),r.addEventListener("squeezeend",w),r.addEventListener("end",A),r.addEventListener("inputsourceschange",C),!0!==f.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==r.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:i};d=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:d}),g=new qe(d.framebufferWidth,d.framebufferHeight,{format:G,type:L,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,o=null,s=null;f.depth&&(s=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?V:B,o=f.stencil?F:U);const a={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:i};u=new XRWebGLBinding(r,t),h=u.createProjectionLayer(a),r.updateRenderState({layers:[h]}),g=new qe(h.textureWidth,h.textureHeight,{format:G,type:L,depthTexture:new Yo(h.textureWidth,h.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0});e.properties.get(g).__ignoreDepthValues=h.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(a),l=null,o=await r.requestReferenceSpace(s),O.setContext(r),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode};const R=new Je,I=new Je;function P(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCameraXR=function(e){if(null===r)return e;x&&(e=x),M.near=T.near=_.near=e.near,M.far=T.far=_.far=e.far,b===M.near&&S===M.far||(r.updateRenderState({depthNear:M.near,depthFar:M.far}),b=M.near,S=M.far);const t=e.parent,n=M.cameras;P(M,t);for(let e=0;e<n.length;e++)P(n[e],t);return 2===n.length?function(e,t,n){R.setFromMatrixPosition(t.matrixWorld),I.setFromMatrixPosition(n.matrixWorld);const r=R.distanceTo(I),i=t.projectionMatrix.elements,o=n.projectionMatrix.elements,s=i[14]/(i[10]-1),a=i[14]/(i[10]+1),l=(i[9]+1)/i[5],c=(i[9]-1)/i[5],u=(i[8]-1)/i[0],h=(o[8]+1)/o[0],d=s*u,p=s*h,f=r/(-u+h),m=f*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=s+f,v=a+f,y=d-m,x=p+(r-m),_=l*a/v*g,T=c*a/v*g;e.projectionMatrix.makePerspective(y,x,_,T,g,v),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(M,_,T):M.projectionMatrix.copy(_.projectionMatrix),x&&function(e,t){const n=x;null===t?n.matrix.copy(e.matrixWorld):(n.matrix.copy(t.matrixWorld),n.matrix.invert(),n.matrix.multiply(e.matrixWorld));n.matrix.decompose(n.position,n.quaternion,n.scale),n.updateMatrixWorld(!0);const r=n.children;for(let e=0,t=r.length;e<t;e++)r[e].updateMatrixWorld(!0);n.projectionMatrix.copy(e.projectionMatrix),n.projectionMatrixInverse.copy(e.projectionMatrixInverse),n.isPerspectiveCamera&&(n.fov=2*fe*Math.atan(1/n.projectionMatrix.elements[5]),n.zoom=1)}(M,t),M},this.getFoveation=function(){if(null!==h||null!==d)return a},this.setFoveation=function(e){a=e,null!==h&&(h.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let N=null;const O=new xr;O.setAnimationLoop((function(t,r){if(c=r.getViewerPose(l||o),p=r,null!==c){const t=c.views;null!==d&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let n=!1;t.length!==M.cameras.length&&(M.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){const i=t[r];let o=null;if(null!==d)o=d.getViewport(i);else{const t=u.getViewSubImage(h,i);o=t.viewport,0===r&&(e.setRenderTargetTextures(g,t.colorTexture,h.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(g))}let s=E[r];void 0===s&&(s=new ar,s.layers.enable(r),s.viewport=new Xe,E[r]=s),s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(i.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(o.x,o.y,o.width,o.height),0===r&&(M.matrix.copy(s.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),!0===n&&M.cameras.push(s)}}for(let e=0;e<v.length;e++){const t=y[e],n=v[e];null!==t&&void 0!==n&&n.update(t,r,l||o)}N&&N(t,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(e){N=e},this.dispose=function(){}}}function Zo(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function r(r,i){r.opacity.value=i.opacity,i.color&&r.diffuse.value.copy(i.color),i.emissive&&r.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(r.map.value=i.map,n(i.map,r.mapTransform)),i.alphaMap&&(r.alphaMap.value=i.alphaMap,n(i.alphaMap,r.alphaMapTransform)),i.bumpMap&&(r.bumpMap.value=i.bumpMap,n(i.bumpMap,r.bumpMapTransform),r.bumpScale.value=i.bumpScale,i.side===a&&(r.bumpScale.value*=-1)),i.normalMap&&(r.normalMap.value=i.normalMap,n(i.normalMap,r.normalMapTransform),r.normalScale.value.copy(i.normalScale),i.side===a&&r.normalScale.value.negate()),i.displacementMap&&(r.displacementMap.value=i.displacementMap,n(i.displacementMap,r.displacementMapTransform),r.displacementScale.value=i.displacementScale,r.displacementBias.value=i.displacementBias),i.emissiveMap&&(r.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,r.emissiveMapTransform)),i.specularMap&&(r.specularMap.value=i.specularMap,n(i.specularMap,r.specularMapTransform)),i.alphaTest>0&&(r.alphaTest.value=i.alphaTest);const o=t.get(i).envMap;if(o&&(r.envMap.value=o,r.flipEnvMap.value=o.isCubeTexture&&!1===o.isRenderTargetTexture?-1:1,r.reflectivity.value=i.reflectivity,r.ior.value=i.ior,r.refractionRatio.value=i.refractionRatio),i.lightMap){r.lightMap.value=i.lightMap;const t=!0===e.useLegacyLights?Math.PI:1;r.lightMapIntensity.value=i.lightMapIntensity*t,n(i.lightMap,r.lightMapTransform)}i.aoMap&&(r.aoMap.value=i.aoMap,r.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,rr(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,i,o,s,l){i.isMeshBasicMaterial||i.isMeshLambertMaterial?r(e,i):i.isMeshToonMaterial?(r(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(r(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(r(e,i),function(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,n(r.metalnessMap,e.metalnessMapTransform));e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,n(r.roughnessMap,e.roughnessMapTransform));const i=t.get(r).envMap;i&&(e.envMapIntensity.value=r.envMapIntensity)}(e,i),i.isMeshPhysicalMaterial&&function(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,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===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,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,i,l)):i.isMeshMatcapMaterial?(r(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?r(e,i):i.isMeshDistanceMaterial?(r(e,i),function(e,n){const r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,i)):i.isMeshNormalMaterial?r(e,i):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*i,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i,o,s):i.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function Jo(e,t,n,r){let i={},o={},s=[];const a=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){const r=e.value;if(void 0===n[t]){if("number"==typeof r)n[t]=r;else{const e=Array.isArray(r)?r:[r],i=[];for(let t=0;t<e.length;t++)i.push(e[t].clone());n[t]=i}return!0}if("number"==typeof r){if(n[t]!==r)return n[t]=r,!0}else{const e=Array.isArray(n[t])?n[t]:[n[t]],i=Array.isArray(r)?r:[r];for(let t=0;t<e.length;t++){const n=e[t];if(!1===n.equals(i[t]))return n.copy(i[t]),!0}}return!1}function c(e){const t={boundary:0,storage:0};return"number"==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?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){const n=t.target;n.removeEventListener("dispose",u);const r=s.indexOf(n.__bindingPointIndex);s.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete o[n.id]}return{bind:function(e,t){const n=t.program;r.uniformBlockBinding(e,n)},update:function(n,h){let d=i[n.id];void 0===d&&(!function(e){const t=e.uniforms;let n=0;const r=16;let i=0;for(let e=0,o=t.length;e<o;e++){const o=t[e],s={boundary:0,storage:0},a=Array.isArray(o.value)?o.value:[o.value];for(let e=0,t=a.length;e<t;e++){const t=c(a[e]);s.boundary+=t.boundary,s.storage+=t.storage}if(o.__data=new Float32Array(s.storage/Float32Array.BYTES_PER_ELEMENT),o.__offset=n,e>0){i=n%r;0!==i&&r-i-s.boundary<0&&(n+=r-i,o.__offset=n)}n+=s.storage}i=n%r,i>0&&(n+=r-i);e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e<a;e++)if(-1===s.indexOf(e))return s.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const r=e.createBuffer(),i=t.__size,o=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,o),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}(n),i[n.id]=d,n.addEventListener("dispose",u));const p=h.program;r.updateUBOMapping(n,p);const f=t.render.frame;o[n.id]!==f&&(!function(t){const n=i[t.id],r=t.uniforms,o=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){const n=r[t];if(!0===l(n,t,o)){const t=n.__offset,r=Array.isArray(n.value)?n.value:[n.value];let i=0;for(let o=0;o<r.length;o++){const s=r[o],a=c(s);"number"==typeof s?(n.__data[0]=s,e.bufferSubData(e.UNIFORM_BUFFER,t+i,n.__data)):s.isMatrix3?(n.__data[0]=s.elements[0],n.__data[1]=s.elements[1],n.__data[2]=s.elements[2],n.__data[3]=s.elements[0],n.__data[4]=s.elements[3],n.__data[5]=s.elements[4],n.__data[6]=s.elements[5],n.__data[7]=s.elements[0],n.__data[8]=s.elements[6],n.__data[9]=s.elements[7],n.__data[10]=s.elements[8],n.__data[11]=s.elements[0]):(s.toArray(n.__data,i),i+=a.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,n.__data)}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),o[n.id]=f)},dispose:function(){for(const t in i)e.deleteBuffer(i[t]);s=[],i={},o={}}}}function $o(){const e=Re("canvas");return e.style.display="block",e}class Qo{constructor(e={}){const{canvas:n=$o(),context:r=null,depth:i=!0,stencil:o=!0,alpha:c=!1,antialias:u=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:d=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:m=!1}=e;let g;this.isWebGLRenderer=!0,g=null!==r?r.getContextAttributes().alpha:c;const v=new Uint32Array(4),y=new Int32Array(4);let x=null,_=null;const T=[],E=[];this.domElement=n,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=te,this.useLegacyLights=!0,this.toneMapping=p,this.toneMappingExposure=1;const M=this;let b=!1,S=0,w=0,A=null,C=-1,R=null;const I=new Xe,O=new Xe;let B=null;const V=new yn(0);let z=0,H=n.width,W=n.height,j=1,X=null,q=null;const Y=new Xe(0,0,H,W),K=new Xe(0,0,H,W);let Z=!1;const J=new yr;let $=!1,Q=!1,ee=null;const re=new At,ie=new Se,oe=new Je,se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ae(){return null===A?j:1}let le,ce,ue,he,de,pe,fe,me,ge,ve,ye,xe,_e,Ee,Me,be,we,Ae,Ce,Re,Ie,Pe,Le,Ne,Oe=r;function Ue(e,t){for(let r=0;r<e.length;r++){const i=e[r],o=n.getContext(i,t);if(null!==o)return o}return null}try{const e={alpha:!0,depth:i,stencil:o,antialias:u,premultipliedAlpha:h,preserveDrawingBuffer:d,powerPreference:f,failIfMajorPerformanceCaveat:m};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${t}`),n.addEventListener("webglcontextlost",Fe,!1),n.addEventListener("webglcontextrestored",Ge,!1),n.addEventListener("webglcontextcreationerror",Be,!1),null===Oe){const t=["webgl2","webgl","experimental-webgl"];if(!0===M.isWebGL1Renderer&&t.shift(),Oe=Ue(t,e),null===Oe)throw Ue(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}Oe instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===Oe.getShaderPrecisionFormat&&(Oe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function De(){le=new Yr(Oe),ce=new Rr(Oe,le,e),le.init(ce),Pe=new Ho(Oe,le,ce),ue=new Vo(Oe,le,ce),he=new Jr(Oe),de=new Ao,pe=new zo(Oe,le,ue,de,ce,Pe,he),fe=new Pr(M),me=new qr(M),ge=new _r(Oe,ce),Le=new Ar(Oe,le,ge,ce),ve=new Kr(Oe,ge,he,Le),ye=new ti(Oe,ve,ge,he),Ce=new ei(Oe,ce,pe),be=new Ir(de),xe=new wo(M,fe,me,le,ce,Le,be),_e=new Zo(M,de),Ee=new Po,Me=new ko(le,ce),Ae=new wr(M,fe,me,ue,ye,g,h),we=new Bo(M,ye,ce),Ne=new Jo(Oe,he,ce,ue),Re=new Cr(Oe,le,he,ce),Ie=new Zr(Oe,le,he,ce),he.programs=xe.programs,M.capabilities=ce,M.extensions=le,M.properties=de,M.renderLists=Ee,M.shadowMap=we,M.state=ue,M.info=he}De();const ke=new Ko(M,Oe);function Fe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Ge(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const e=he.autoReset,t=we.enabled,n=we.autoUpdate,r=we.needsUpdate,i=we.type;De(),he.autoReset=e,we.enabled=t,we.autoUpdate=n,we.needsUpdate=r,we.type=i}function Be(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Ve(e){const t=e.target;t.removeEventListener("dispose",Ve),function(e){(function(e){const t=de.get(e).programs;void 0!==t&&(t.forEach((function(e){xe.releaseProgram(e)})),e.isShaderMaterial&&xe.releaseShaderCache(e))})(e),de.remove(e)}(t)}this.xr=ke,this.getContext=function(){return Oe},this.getContextAttributes=function(){return Oe.getContextAttributes()},this.forceContextLoss=function(){const e=le.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=le.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(e){void 0!==e&&(j=e,this.setSize(H,W,!1))},this.getSize=function(e){return e.set(H,W)},this.setSize=function(e,t,r=!0){ke.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(H=e,W=t,n.width=Math.floor(e*j),n.height=Math.floor(t*j),!0===r&&(n.style.width=e+"px",n.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(H*j,W*j).floor()},this.setDrawingBufferSize=function(e,t,r){H=e,W=t,j=r,n.width=Math.floor(e*r),n.height=Math.floor(t*r),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(I)},this.getViewport=function(e){return e.copy(Y)},this.setViewport=function(e,t,n,r){e.isVector4?Y.set(e.x,e.y,e.z,e.w):Y.set(e,t,n,r),ue.viewport(I.copy(Y).multiplyScalar(j).floor())},this.getScissor=function(e){return e.copy(K)},this.setScissor=function(e,t,n,r){e.isVector4?K.set(e.x,e.y,e.z,e.w):K.set(e,t,n,r),ue.scissor(O.copy(K).multiplyScalar(j).floor())},this.getScissorTest=function(){return Z},this.setScissorTest=function(e){ue.setScissorTest(Z=e)},this.setOpaqueSort=function(e){X=e},this.setTransparentSort=function(e){q=e},this.getClearColor=function(e){return e.copy(Ae.getClearColor())},this.setClearColor=function(){Ae.setClearColor.apply(Ae,arguments)},this.getClearAlpha=function(){return Ae.getClearAlpha()},this.setClearAlpha=function(){Ae.setClearAlpha.apply(Ae,arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(null!==A){const t=A.texture.format;e=1033===t||1031===t||1029===t}if(e){const e=A.texture.type,t=e===L||e===U||e===N||e===F||1017===e||1018===e,n=Ae.getClearColor(),r=Ae.getClearAlpha(),i=n.r,o=n.g,s=n.b,a=de.get(A).__webglFramebuffer;t?(v[0]=i,v[1]=o,v[2]=s,v[3]=r,Oe.clearBufferuiv(Oe.COLOR,a,v)):(y[0]=i,y[1]=o,y[2]=s,y[3]=r,Oe.clearBufferiv(Oe.COLOR,a,y))}else r|=Oe.COLOR_BUFFER_BIT}t&&(r|=Oe.DEPTH_BUFFER_BIT),n&&(r|=Oe.STENCIL_BUFFER_BIT),Oe.clear(r)},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(){n.removeEventListener("webglcontextlost",Fe,!1),n.removeEventListener("webglcontextrestored",Ge,!1),n.removeEventListener("webglcontextcreationerror",Be,!1),Ee.dispose(),Me.dispose(),de.dispose(),fe.dispose(),me.dispose(),ye.dispose(),Le.dispose(),Ne.dispose(),xe.dispose(),ke.dispose(),ke.removeEventListener("sessionstart",He),ke.removeEventListener("sessionend",We),ee&&(ee.dispose(),ee=null),je.stop()},this.renderBufferDirect=function(e,t,n,r,i,o){null===t&&(t=se);const s=i.isMesh&&i.matrixWorld.determinant()<0,a=function(e,t,n,r,i){!0!==t.isScene&&(t=se);pe.resetTextureUnits();const o=t.fog,s=r.isMeshStandardMaterial?t.environment:null,a=null===A?M.outputColorSpace:!0===A.isXRRenderTarget?A.texture.colorSpace:ne,l=(r.isMeshStandardMaterial?me:fe).get(r.envMap||s),c=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),h=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,f=!!n.morphAttributes.color,m=r.toneMapped?M.toneMapping:p,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,y=de.get(r),x=_.state.lights;if(!0===$&&(!0===Q||e!==R)){const t=e===R&&r.id===C;be.setState(r,e,t)}let T=!1;r.version===y.__version?y.needsLights&&y.lightsStateVersion!==x.state.version||y.outputColorSpace!==a||i.isInstancedMesh&&!1===y.instancing?T=!0:i.isInstancedMesh||!0!==y.instancing?i.isSkinnedMesh&&!1===y.skinning?T=!0:i.isSkinnedMesh||!0!==y.skinning?y.envMap!==l||!0===r.fog&&y.fog!==o?T=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===be.numPlanes&&y.numIntersection===be.numIntersection?(y.vertexAlphas!==c||y.vertexTangents!==u||y.morphTargets!==h||y.morphNormals!==d||y.morphColors!==f||y.toneMapping!==m||!0===ce.isWebGL2&&y.morphTargetsCount!==v)&&(T=!0):T=!0:T=!0:T=!0:(T=!0,y.__version=r.version);let E=y.currentProgram;!0===T&&(E=Qe(r,t,i));let b=!1,S=!1,w=!1;const I=E.getUniforms(),P=y.uniforms;ue.useProgram(E.program)&&(b=!0,S=!0,w=!0);r.id!==C&&(C=r.id,S=!0);if(b||R!==e){if(I.setValue(Oe,"projectionMatrix",e.projectionMatrix),ce.logarithmicDepthBuffer&&I.setValue(Oe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),R!==e&&(R=e,S=!0,w=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){const t=I.map.cameraPosition;void 0!==t&&t.setValue(Oe,oe.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&I.setValue(Oe,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&I.setValue(Oe,"viewMatrix",e.matrixWorldInverse)}if(i.isSkinnedMesh){I.setOptional(Oe,i,"bindMatrix"),I.setOptional(Oe,i,"bindMatrixInverse");const e=i.skeleton;e&&(ce.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),I.setValue(Oe,"boneTexture",e.boneTexture,pe),I.setValue(Oe,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const L=n.morphAttributes;(void 0!==L.position||void 0!==L.normal||void 0!==L.color&&!0===ce.isWebGL2)&&Ce.update(i,n,E);(S||y.receiveShadow!==i.receiveShadow)&&(y.receiveShadow=i.receiveShadow,I.setValue(Oe,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);S&&(I.setValue(Oe,"toneMappingExposure",M.toneMappingExposure),y.needsLights&&(O=w,(N=P).ambientLightColor.needsUpdate=O,N.lightProbe.needsUpdate=O,N.directionalLights.needsUpdate=O,N.directionalLightShadows.needsUpdate=O,N.pointLights.needsUpdate=O,N.pointLightShadows.needsUpdate=O,N.spotLights.needsUpdate=O,N.spotLightShadows.needsUpdate=O,N.rectAreaLights.needsUpdate=O,N.hemisphereLights.needsUpdate=O),o&&!0===r.fog&&_e.refreshFogUniforms(P,o),_e.refreshMaterialUniforms(P,r,j,W,ee),oo.upload(Oe,y.uniformsList,P,pe));var N,O;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(oo.upload(Oe,y.uniformsList,P,pe),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&I.setValue(Oe,"center",i.center);if(I.setValue(Oe,"modelViewMatrix",i.modelViewMatrix),I.setValue(Oe,"normalMatrix",i.normalMatrix),I.setValue(Oe,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if(ce.isWebGL2){const n=e[t];Ne.update(n,E),Ne.bind(n,E)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return E}(e,t,n,r,i);ue.setMaterial(r,s);let l=n.index,c=1;!0===r.wireframe&&(l=ve.getWireframeAttribute(n),c=2);const u=n.drawRange,h=n.attributes.position;let d=u.start*c,f=(u.start+u.count)*c;null!==o&&(d=Math.max(d,o.start*c),f=Math.min(f,(o.start+o.count)*c)),null!==l?(d=Math.max(d,0),f=Math.min(f,l.count)):null!=h&&(d=Math.max(d,0),f=Math.min(f,h.count));const m=f-d;if(m<0||m===1/0)return;let g;Le.setup(i,r,a,n,l);let v=Re;if(null!==l&&(g=ge.get(l),v=Ie,v.setIndex(g)),i.isMesh)!0===r.wireframe?(ue.setLineWidth(r.wireframeLinewidth*ae()),v.setMode(Oe.LINES)):v.setMode(Oe.TRIANGLES);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),ue.setLineWidth(e*ae()),i.isLineSegments?v.setMode(Oe.LINES):i.isLineLoop?v.setMode(Oe.LINE_LOOP):v.setMode(Oe.LINE_STRIP)}else i.isPoints?v.setMode(Oe.POINTS):i.isSprite&&v.setMode(Oe.TRIANGLES);if(i.isInstancedMesh)v.renderInstances(d,m,i.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);v.renderInstances(d,m,t)}else v.render(d,m)},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===l&&!1===e.forceSinglePass?(e.side=a,e.needsUpdate=!0,Qe(e,t,n),e.side=s,e.needsUpdate=!0,Qe(e,t,n),e.side=l):Qe(e,t,n)}_=Me.get(e),_.init(),E.push(_),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(_.pushLight(e),e.castShadow&&_.pushShadow(e))})),_.setupLights(M.useLegacyLights),e.traverse((function(t){const r=t.material;if(r)if(Array.isArray(r))for(let i=0;i<r.length;i++){n(r[i],e,t)}else n(r,e,t)})),E.pop(),_=null};let ze=null;function He(){je.stop()}function We(){je.start()}const je=new xr;function Ye(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)_.pushLight(e),e.castShadow&&_.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||J.intersectsSprite(e)){r&&oe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(re);const t=ye.update(e),i=e.material;i.visible&&x.push(e,t,i,n,oe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||J.intersectsObject(e))){e.isSkinnedMesh&&e.skeleton.frame!==he.render.frame&&(e.skeleton.update(),e.skeleton.frame=he.render.frame);const t=ye.update(e),i=e.material;if(r&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),oe.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),oe.copy(t.boundingSphere.center)),oe.applyMatrix4(e.matrixWorld).applyMatrix4(re)),Array.isArray(i)){const r=t.groups;for(let o=0,s=r.length;o<s;o++){const s=r[o],a=i[s.materialIndex];a&&a.visible&&x.push(e,t,a,n,oe.z,s)}}else i.visible&&x.push(e,t,i,n,oe.z,null)}const i=e.children;for(let e=0,o=i.length;e<o;e++)Ye(i[e],t,n,r)}function Ke(e,t,n,r){const i=e.opaque,o=e.transmissive,s=e.transparent;_.setupLightsView(n),!0===$&&be.setGlobalState(M.clippingPlanes,n),o.length>0&&function(e,t,n,r){const i=ce.isWebGL2;null===ee&&(ee=new qe(1,1,{generateMipmaps:!0,type:le.has("EXT_color_buffer_half_float")?k:L,minFilter:P,samples:i&&!0===u?4:0}));M.getDrawingBufferSize(ie),i?ee.setSize(ie.x,ie.y):ee.setSize(Te(ie.x),Te(ie.y));const o=M.getRenderTarget();M.setRenderTarget(ee),M.getClearColor(V),z=M.getClearAlpha(),z<1&&M.setClearColor(16777215,.5);M.clear();const s=M.toneMapping;M.toneMapping=p,Ze(e,n,r),pe.updateMultisampleRenderTarget(ee),pe.updateRenderTargetMipmap(ee);let c=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e],o=i.object,s=i.geometry,u=i.material,h=i.group;if(u.side===l&&o.layers.test(r.layers)){const e=u.side;u.side=a,u.needsUpdate=!0,$e(o,n,r,s,u,h),u.side=e,u.needsUpdate=!0,c=!0}}!0===c&&(pe.updateMultisampleRenderTarget(ee),pe.updateRenderTargetMipmap(ee));M.setRenderTarget(o),M.setClearColor(V,z),M.toneMapping=s}(i,o,t,n),r&&ue.viewport(I.copy(r)),i.length>0&&Ze(i,t,n),o.length>0&&Ze(o,t,n),s.length>0&&Ze(s,t,n),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function Ze(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let i=0,o=e.length;i<o;i++){const o=e[i],s=o.object,a=o.geometry,l=null===r?o.material:r,c=o.group;s.layers.test(n.layers)&&$e(s,t,n,a,l,c)}}function $e(e,t,n,r,i,o){e.onBeforeRender(M,t,n,r,i,o),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(M,t,n,r,e,o),!0===i.transparent&&i.side===l&&!1===i.forceSinglePass?(i.side=a,i.needsUpdate=!0,M.renderBufferDirect(n,t,r,i,e,o),i.side=s,i.needsUpdate=!0,M.renderBufferDirect(n,t,r,i,e,o),i.side=l):M.renderBufferDirect(n,t,r,i,e,o),e.onAfterRender(M,t,n,r,i,o)}function Qe(e,t,n){!0!==t.isScene&&(t=se);const r=de.get(e),i=_.state.lights,o=_.state.shadowsArray,s=i.state.version,a=xe.getParameters(e,i.state,o,t,n),l=xe.getProgramCacheKey(a);let c=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?me:fe).get(e.envMap||r.environment),void 0===c&&(e.addEventListener("dispose",Ve),c=new Map,r.programs=c);let u=c.get(l);if(void 0!==u){if(r.currentProgram===u&&r.lightsStateVersion===s)return et(e,a),u}else a.uniforms=xe.getUniforms(e),e.onBuild(n,a,M),e.onBeforeCompile(a,M),u=xe.acquireProgram(a,l),c.set(l,u),r.uniforms=a.uniforms;const h=r.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(h.clippingPlanes=be.uniform),et(e,a),r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=s,r.needsLights&&(h.ambientLightColor.value=i.state.ambient,h.lightProbe.value=i.state.probe,h.directionalLights.value=i.state.directional,h.directionalLightShadows.value=i.state.directionalShadow,h.spotLights.value=i.state.spot,h.spotLightShadows.value=i.state.spotShadow,h.rectAreaLights.value=i.state.rectArea,h.ltc_1.value=i.state.rectAreaLTC1,h.ltc_2.value=i.state.rectAreaLTC2,h.pointLights.value=i.state.point,h.pointLightShadows.value=i.state.pointShadow,h.hemisphereLights.value=i.state.hemi,h.directionalShadowMap.value=i.state.directionalShadowMap,h.directionalShadowMatrix.value=i.state.directionalShadowMatrix,h.spotShadowMap.value=i.state.spotShadowMap,h.spotLightMatrix.value=i.state.spotLightMatrix,h.spotLightMap.value=i.state.spotLightMap,h.pointShadowMap.value=i.state.pointShadowMap,h.pointShadowMatrix.value=i.state.pointShadowMatrix);const d=u.getUniforms(),p=oo.seqWithValue(d.seq,h);return r.currentProgram=u,r.uniformsList=p,u}function et(e,t){const n=de.get(e);n.outputColorSpace=t.outputColorSpace,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}je.setAnimationLoop((function(e){ze&&ze(e)})),"undefined"!=typeof self&&je.setContext(self),this.setAnimationLoop=function(e){ze=e,ke.setAnimationLoop(e),null===e?je.stop():je.start()},ke.addEventListener("sessionstart",He),ke.addEventListener("sessionend",We),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===b)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===ke.enabled&&!0===ke.isPresenting&&(t=ke.updateCameraXR(t)),!0===e.isScene&&e.onBeforeRender(M,e,t,A),_=Me.get(e,E.length),_.init(),E.push(_),re.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),J.setFromProjectionMatrix(re),Q=this.localClippingEnabled,$=be.init(this.clippingPlanes,Q),x=Ee.get(e,T.length),x.init(),T.push(x),Ye(e,t,0,M.sortObjects),x.finish(),!0===M.sortObjects&&x.sort(X,q),!0===$&&be.beginShadows();const n=_.state.shadowsArray;if(we.render(n,e,t),!0===$&&be.endShadows(),!0===this.info.autoReset&&this.info.reset(),this.info.render.frame++,Ae.render(x,e),_.setupLights(M.useLegacyLights),t.isArrayCamera){const n=t.cameras;for(let t=0,r=n.length;t<r;t++){const r=n[t];Ke(x,e,r,r.viewport)}}else Ke(x,e,t);null!==A&&(pe.updateMultisampleRenderTarget(A),pe.updateRenderTargetMipmap(A)),!0===e.isScene&&e.onAfterRender(M,e,t),Le.resetDefaultState(),C=-1,R=null,E.pop(),_=E.length>0?E[E.length-1]:null,T.pop(),x=T.length>0?T[T.length-1]:null},this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(e,t,n){de.get(e.texture).__webglTexture=t,de.get(e.depthTexture).__webglTexture=n;const r=de.get(e);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===le.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=de.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){A=e,S=t,w=n;let r=!0,i=null,o=!1,s=!1;if(e){const n=de.get(e);void 0!==n.__useDefaultFramebuffer?(ue.bindFramebuffer(Oe.FRAMEBUFFER,null),r=!1):void 0===n.__webglFramebuffer?pe.setupRenderTarget(e):n.__hasExternalTextures&&pe.rebindTextures(e,de.get(e.texture).__webglTexture,de.get(e.depthTexture).__webglTexture);const a=e.texture;(a.isData3DTexture||a.isDataArrayTexture||a.isCompressedArrayTexture)&&(s=!0);const l=de.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=l[t],o=!0):i=ce.isWebGL2&&e.samples>0&&!1===pe.useMultisampledRTT(e)?de.get(e).__webglMultisampledFramebuffer:l,I.copy(e.viewport),O.copy(e.scissor),B=e.scissorTest}else I.copy(Y).multiplyScalar(j).floor(),O.copy(K).multiplyScalar(j).floor(),B=Z;if(ue.bindFramebuffer(Oe.FRAMEBUFFER,i)&&ce.drawBuffers&&r&&ue.drawBuffers(e,i),ue.viewport(I),ue.scissor(O),ue.setScissorTest(B),o){const r=de.get(e.texture);Oe.framebufferTexture2D(Oe.FRAMEBUFFER,Oe.COLOR_ATTACHMENT0,Oe.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(s){const r=de.get(e.texture),i=t||0;Oe.framebufferTextureLayer(Oe.FRAMEBUFFER,Oe.COLOR_ATTACHMENT0,r.__webglTexture,n||0,i)}C=-1},this.readRenderTargetPixels=function(e,t,n,r,i,o,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=de.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(a=a[s]),a){ue.bindFramebuffer(Oe.FRAMEBUFFER,a);try{const s=e.texture,a=s.format,l=s.type;if(a!==G&&Pe.convert(a)!==Oe.getParameter(Oe.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===k&&(le.has("EXT_color_buffer_half_float")||ce.isWebGL2&&le.has("EXT_color_buffer_float"));if(!(l===L||Pe.convert(l)===Oe.getParameter(Oe.IMPLEMENTATION_COLOR_READ_TYPE)||l===D&&(ce.isWebGL2||le.has("OES_texture_float")||le.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&Oe.readPixels(t,n,r,i,Pe.convert(a),Pe.convert(l),o)}finally{const e=null!==A?de.get(A).__webglFramebuffer:null;ue.bindFramebuffer(Oe.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const r=Math.pow(2,-n),i=Math.floor(t.image.width*r),o=Math.floor(t.image.height*r);pe.setTexture2D(t,0),Oe.copyTexSubImage2D(Oe.TEXTURE_2D,n,0,0,e.x,e.y,i,o),ue.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){const i=t.image.width,o=t.image.height,s=Pe.convert(n.format),a=Pe.convert(n.type);pe.setTexture2D(n,0),Oe.pixelStorei(Oe.UNPACK_FLIP_Y_WEBGL,n.flipY),Oe.pixelStorei(Oe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Oe.pixelStorei(Oe.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?Oe.texSubImage2D(Oe.TEXTURE_2D,r,e.x,e.y,i,o,s,a,t.image.data):t.isCompressedTexture?Oe.compressedTexSubImage2D(Oe.TEXTURE_2D,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):Oe.texSubImage2D(Oe.TEXTURE_2D,r,e.x,e.y,s,a,t.image),0===r&&n.generateMipmaps&&Oe.generateMipmap(Oe.TEXTURE_2D),ue.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(M.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,a=e.max.z-e.min.z+1,l=Pe.convert(r.format),c=Pe.convert(r.type);let u;if(r.isData3DTexture)pe.setTexture3D(r,0),u=Oe.TEXTURE_3D;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");pe.setTexture2DArray(r,0),u=Oe.TEXTURE_2D_ARRAY}Oe.pixelStorei(Oe.UNPACK_FLIP_Y_WEBGL,r.flipY),Oe.pixelStorei(Oe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),Oe.pixelStorei(Oe.UNPACK_ALIGNMENT,r.unpackAlignment);const h=Oe.getParameter(Oe.UNPACK_ROW_LENGTH),d=Oe.getParameter(Oe.UNPACK_IMAGE_HEIGHT),p=Oe.getParameter(Oe.UNPACK_SKIP_PIXELS),f=Oe.getParameter(Oe.UNPACK_SKIP_ROWS),m=Oe.getParameter(Oe.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Oe.pixelStorei(Oe.UNPACK_ROW_LENGTH,g.width),Oe.pixelStorei(Oe.UNPACK_IMAGE_HEIGHT,g.height),Oe.pixelStorei(Oe.UNPACK_SKIP_PIXELS,e.min.x),Oe.pixelStorei(Oe.UNPACK_SKIP_ROWS,e.min.y),Oe.pixelStorei(Oe.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?Oe.texSubImage3D(u,i,t.x,t.y,t.z,o,s,a,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Oe.compressedTexSubImage3D(u,i,t.x,t.y,t.z,o,s,a,l,g.data)):Oe.texSubImage3D(u,i,t.x,t.y,t.z,o,s,a,l,c,g),Oe.pixelStorei(Oe.UNPACK_ROW_LENGTH,h),Oe.pixelStorei(Oe.UNPACK_IMAGE_HEIGHT,d),Oe.pixelStorei(Oe.UNPACK_SKIP_PIXELS,p),Oe.pixelStorei(Oe.UNPACK_SKIP_ROWS,f),Oe.pixelStorei(Oe.UNPACK_SKIP_IMAGES,m),0===i&&r.generateMipmaps&&Oe.generateMipmap(u),ue.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?pe.setTextureCube(e,0):e.isData3DTexture?pe.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?pe.setTexture2DArray(e,0):pe.setTexture2D(e,0),ue.unbindTexture()},this.resetState=function(){S=0,w=0,A=null,ue.reset(),Le.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return le}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===te?Q:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Q?te:ne}}(class extends Qo{}).prototype.isWebGL1Renderer=!0;class es extends $t{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}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}const ts=new Je,ns=new Xe,rs=new Xe,is=new Je,os=new At,ss=new Je,as=new yt,ls=new At,cs=new wt;class us extends $n{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new At,this.bindMatrixInverse=new At,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new et),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)ss.fromBufferAttribute(t,e),this.applyBoneTransform(e,ss),this.boundingBox.expandByPoint(ss)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new yt),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)ss.fromBufferAttribute(t,e),this.applyBoneTransform(e,ss),this.boundingSphere.expandByPoint(ss)}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 n=this.material,r=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),as.copy(this.boundingSphere),as.applyMatrix4(r),!1!==e.ray.intersectsSphere(as)&&(ls.copy(r).invert(),cs.copy(e.ray).applyMatrix4(ls),null!==this.boundingBox&&!1===cs.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,cs)))}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 Xe,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;ns.fromBufferAttribute(r.attributes.skinIndex,e),rs.fromBufferAttribute(r.attributes.skinWeight,e),ts.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const r=rs.getComponent(e);if(0!==r){const i=ns.getComponent(e);os.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(is.copy(ts).applyMatrix4(os),r)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class hs extends $t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ds extends je{constructor(e=null,t=1,n=1,r,i,o,s,a,l=1003,c=1003,u,h){super(null,o,s,a,l,c,r,i,u,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const ps=new At,fs=new At;class ms{constructor(e=[],t=[]){this.uuid=me(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,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){console.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 At)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new At;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,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){const i=e[r]?e[r].matrixWorld:fs;ps.multiplyMatrices(i,t[r]),ps.toArray(n,16*r)}null!==r&&(r.needsUpdate=!0)}clone(){return new ms(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=_e(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new ds(t,e,e,G,D);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const r=e.bones[n];let i=t[r];void 0===i&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),i=new hs),this.bones.push(i),this.boneInverses.push((new At).fromArray(e.boneInverses[n]))}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,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){const i=t[r];e.bones.push(i.uuid);const o=n[r];e.boneInverses.push(o.toArray())}return e}}class gs extends pn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yn(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 vs=new Je,ys=new Je,xs=new At,_s=new wt,Ts=new yt;class Es extends $t{constructor(e=new On,t=new gs){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=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)vs.fromBufferAttribute(t,e-1),ys.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=vs.distanceTo(ys);e.setAttribute("lineDistance",new wn(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ts.copy(n.boundingSphere),Ts.applyMatrix4(r),Ts.radius+=i,!1===e.ray.intersectsSphere(Ts))return;xs.copy(r).invert(),_s.copy(e.ray).applyMatrix4(xs);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,l=new Je,c=new Je,u=new Je,h=new Je,d=this.isLineSegments?2:1,p=n.index,f=n.attributes.position;if(null!==p){for(let n=Math.max(0,o.start),r=Math.min(p.count,o.start+o.count)-1;n<r;n+=d){const r=p.getX(n),i=p.getX(n+1);l.fromBufferAttribute(f,r),c.fromBufferAttribute(f,i);if(_s.distanceSqToSegment(l,c,h,u)>a)continue;h.applyMatrix4(this.matrixWorld);const o=e.ray.origin.distanceTo(h);o<e.near||o>e.far||t.push({distance:o,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,o.start),r=Math.min(f.count,o.start+o.count)-1;n<r;n+=d){l.fromBufferAttribute(f,n),c.fromBufferAttribute(f,n+1);if(_s.distanceSqToSegment(l,c,h,u)>a)continue;h.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(h);r<e.near||r>e.far||t.push({distance:r,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const Ms=new Je,bs=new Je;class Ss extends Es{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,n=[];for(let e=0,r=t.count;e<r;e+=2)Ms.fromBufferAttribute(t,e),bs.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+Ms.distanceTo(bs);e.setAttribute("lineDistance",new wn(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ws extends pn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new yn(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 As=new At,Cs=new wt,Rs=new yt,Is=new Je;class Ps extends $t{constructor(e=new On,t=new ws){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=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Rs.copy(n.boundingSphere),Rs.applyMatrix4(r),Rs.radius+=i,!1===e.ray.intersectsSphere(Rs))return;As.copy(r).invert(),Cs.copy(e.ray).applyMatrix4(As);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,o.start),i=Math.min(l.count,o.start+o.count);n<i;n++){const i=l.getX(n);Is.fromBufferAttribute(c,i),Ls(Is,i,a,r,e,t,this)}}else{for(let n=Math.max(0,o.start),i=Math.min(c.count,o.start+o.count);n<i;n++)Is.fromBufferAttribute(c,n),Ls(Is,n,a,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function Ls(e,t,n,r,i,o,s){const a=Cs.distanceSqToPoint(e);if(a<n){const n=new Je;Cs.closestPointToPoint(e,n),n.applyMatrix4(r);const l=i.ray.origin.distanceTo(n);if(l<i.near||l>i.far)return;o.push({distance:l,distanceToRay:Math.sqrt(a),point:n,index:t,face:null,object:s})}}class Ns{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),i=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const i=n.length;let o;o=t||e*n[i-1];let s,a=0,l=i-1;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),s=n[r]-o,s<0)a=r+1;else{if(!(s>0)){l=r;break}l=r-1}if(r=l,n[r]===o)return r/(i-1);const c=n[r];return(r+(o-c)/(n[r+1]-c))/(i-1)}getTangent(e,t){const n=1e-4;let r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);const o=this.getPoint(r),s=this.getPoint(i),a=t||(o.isVector2?new Se:new Je);return a.copy(s).sub(o).normalize(),a}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Je,r=[],i=[],o=[],s=new Je,a=new At;for(let t=0;t<=e;t++){const n=t/e;r[t]=this.getTangentAt(n,new Je)}i[0]=new Je,o[0]=new Je;let l=Number.MAX_VALUE;const c=Math.abs(r[0].x),u=Math.abs(r[0].y),h=Math.abs(r[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),h<=l&&n.set(0,0,1),s.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],s),o[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),o[t]=o[t-1].clone(),s.crossVectors(r[t-1],r[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(ge(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(a.makeRotationAxis(s,e))}o[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(ge(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(s.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(a.makeRotationAxis(r[n],t*n)),o[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Os extends Ns{constructor(e=0,t=0,n=1,r=1,i=0,o=2*Math.PI,s=!1,a=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=s,this.aRotation=a}getPoint(e,t){const n=t||new Se,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const o=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=o?0:r),!0!==this.aClockwise||o||(i===r?i=-r:i-=r);const s=this.aStartAngle+e*i;let a=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=a-this.aX,r=l-this.aY;a=n*e-r*t+this.aX,l=n*t+r*e+this.aY}return n.set(a,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}function Us(){let e=0,t=0,n=0,r=0;function i(i,o,s,a){e=i,t=s,n=-3*i+3*o-2*s-a,r=2*i-2*o+s+a}return{initCatmullRom:function(e,t,n,r,o){i(t,n,o*(n-e),o*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,o,s,a){let l=(t-e)/o-(n-e)/(o+s)+(n-t)/s,c=(n-t)/s-(r-t)/(s+a)+(r-n)/a;l*=s,c*=s,i(t,n,l,c)},calc:function(i){const o=i*i;return e+t*i+n*o+r*(o*i)}}}const Ds=new Je,ks=new Us,Fs=new Us,Gs=new Us;function Bs(e,t,n,r,i){const o=.5*(r-t),s=.5*(i-n),a=e*e;return(2*n-2*r+o+s)*(e*a)+(-3*n+3*r-2*o-s)*a+o*e+n}function Vs(e,t,n,r){return function(e,t){const n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,r)}function zs(e,t,n,r,i){return function(e,t){const n=1-e;return n*n*n*t}(e,t)+function(e,t){const n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,r)+function(e,t){return e*e*e*t}(e,i)}class Hs extends Ns{constructor(e=new Se,t=new Se,n=new Se,r=new Se){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Se){const n=t,r=this.v0,i=this.v1,o=this.v2,s=this.v3;return n.set(zs(e,r.x,i.x,o.x,s.x),zs(e,r.y,i.y,o.y,s.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Ws extends Ns{constructor(e=new Se,t=new Se){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Se){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Se){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class js extends Ns{constructor(e=new Se,t=new Se,n=new Se){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Se){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(Vs(e,r.x,i.x,o.x),Vs(e,r.y,i.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Xs extends Ns{constructor(e=new Je,t=new Je,n=new Je){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Je){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(Vs(e,r.x,i.x,o.x),Vs(e,r.y,i.y,o.y),Vs(e,r.z,i.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class qs extends Ns{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Se){const n=t,r=this.points,i=(r.length-1)*e,o=Math.floor(i),s=i-o,a=r[0===o?o:o-1],l=r[o],c=r[o>r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return n.set(Bs(s,a.x,l.x,c.x,u.x),Bs(s,a.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Se).fromArray(n))}return this}}var Ys=Object.freeze({__proto__:null,ArcCurve:class extends Os{constructor(e,t,n,r,i,o){super(e,t,n,n,r,i,o),this.isArcCurve=!0,this.type="ArcCurve"}},CatmullRomCurve3:class extends Ns{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new Je){const n=t,r=this.points,i=r.length,o=(i-(this.closed?0:1))*e;let s,a,l=Math.floor(o),c=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===c&&l===i-1&&(l=i-2,c=1),this.closed||l>0?s=r[(l-1)%i]:(Ds.subVectors(r[0],r[1]).add(r[0]),s=Ds);const u=r[l%i],h=r[(l+1)%i];if(this.closed||l+2<i?a=r[(l+2)%i]:(Ds.subVectors(r[i-1],r[i-2]).add(r[i-1]),a=Ds),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(s.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(h),e),r=Math.pow(h.distanceToSquared(a),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),ks.initNonuniformCatmullRom(s.x,u.x,h.x,a.x,t,n,r),Fs.initNonuniformCatmullRom(s.y,u.y,h.y,a.y,t,n,r),Gs.initNonuniformCatmullRom(s.z,u.z,h.z,a.z,t,n,r)}else"catmullrom"===this.curveType&&(ks.initCatmullRom(s.x,u.x,h.x,a.x,this.tension),Fs.initCatmullRom(s.y,u.y,h.y,a.y,this.tension),Gs.initCatmullRom(s.z,u.z,h.z,a.z,this.tension));return n.set(ks.calc(c),Fs.calc(c),Gs.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Je).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}},CubicBezierCurve:Hs,CubicBezierCurve3:class extends Ns{constructor(e=new Je,t=new Je,n=new Je,r=new Je){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Je){const n=t,r=this.v0,i=this.v1,o=this.v2,s=this.v3;return n.set(zs(e,r.x,i.x,o.x,s.x),zs(e,r.y,i.y,o.y,s.y),zs(e,r.z,i.z,o.z,s.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},EllipseCurve:Os,LineCurve:Ws,LineCurve3:class extends Ns{constructor(e=new Je,t=new Je){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new Je){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Je){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},QuadraticBezierCurve:js,QuadraticBezierCurve3:Xs,SplineCurve:qs});class Ks extends Ns{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Ws(t,e))}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let i=0;for(;i<r.length;){if(r[i]>=n){const e=r[i]-n,o=this.curves[i],s=o.getLength(),a=0===s?0:1-e/s;return o.getPointAt(a,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const o=i[r],s=o.isEllipseCurve?2*e:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,a=o.getPoints(s);for(let e=0;e<a.length;e++){const r=a[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new Ys[n.type]).fromJSON(n))}return this}}class Zs extends Ks{constructor(e){super(),this.type="Path",this.currentPoint=new Se,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Ws(this.currentPoint.clone(),new Se(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const i=new js(this.currentPoint.clone(),new Se(e,t),new Se(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,o){const s=new Hs(this.currentPoint.clone(),new Se(e,t),new Se(n,r),new Se(i,o));return this.curves.push(s),this.currentPoint.set(i,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new qs(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,o){const s=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(e+s,t+a,n,r,i,o),this}absarc(e,t,n,r,i,o){return this.absellipse(e,t,n,n,r,i,o),this}ellipse(e,t,n,r,i,o,s,a){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,r,i,o,s,a),this}absellipse(e,t,n,r,i,o,s,a){const l=new Os(e,t,n,r,i,o,s,a);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Js extends On{constructor(e=1,t=1,n=1,r=32,i=1,o=!1,s=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:o,thetaStart:s,thetaLength:a};const l=this;r=Math.floor(r),i=Math.floor(i);const c=[],u=[],h=[],d=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const i=p,o=new Se,f=new Je;let v=0;const y=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=r;e++)u.push(0,m*x,0),h.push(0,x,0),d.push(.5,.5),p++;const _=p;for(let e=0;e<=r;e++){const t=e/r*a+s,n=Math.cos(t),i=Math.sin(t);f.x=y*i,f.y=m*x,f.z=y*n,u.push(f.x,f.y,f.z),h.push(0,x,0),o.x=.5*n+.5,o.y=.5*i*x+.5,d.push(o.x,o.y),p++}for(let e=0;e<r;e++){const t=i+e,r=_+e;!0===n?c.push(r,r+1,t):c.push(r+1,r,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const o=new Je,v=new Je;let y=0;const x=(t-e)/n;for(let l=0;l<=i;l++){const c=[],g=l/i,y=g*(t-e)+e;for(let e=0;e<=r;e++){const t=e/r,i=t*a+s,l=Math.sin(i),f=Math.cos(i);v.x=y*l,v.y=-g*n+m,v.z=y*f,u.push(v.x,v.y,v.z),o.set(l,x,f).normalize(),h.push(o.x,o.y,o.z),d.push(t,1-g),c.push(p++)}f.push(c)}for(let e=0;e<r;e++)for(let t=0;t<i;t++){const n=f[t][e],r=f[t+1][e],i=f[t+1][e+1],o=f[t][e+1];c.push(n,r,o),c.push(r,i,o),y+=6}l.addGroup(g,y,0),g+=y}(),!1===o&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new wn(u,3)),this.setAttribute("normal",new wn(h,3)),this.setAttribute("uv",new wn(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Js(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class $s extends Js{constructor(e=1,t=1,n=32,r=1,i=!1,o=0,s=2*Math.PI){super(0,e,t,n,r,i,o,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:s}}static fromJSON(e){return new $s(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}const Qs=new Je,ea=new Je,ta=new Je,na=new hn;class ra extends On{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,r=Math.pow(10,n),i=Math.cos(pe*t),o=e.getIndex(),s=e.getAttribute("position"),a=o?o.count:s.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let e=0;e<a;e+=3){o?(l[0]=o.getX(e),l[1]=o.getX(e+1),l[2]=o.getX(e+2)):(l[0]=e,l[1]=e+1,l[2]=e+2);const{a:t,b:n,c:a}=na;if(t.fromBufferAttribute(s,l[0]),n.fromBufferAttribute(s,l[1]),a.fromBufferAttribute(s,l[2]),na.getNormal(ta),u[0]=`${Math.round(t.x*r)},${Math.round(t.y*r)},${Math.round(t.z*r)}`,u[1]=`${Math.round(n.x*r)},${Math.round(n.y*r)},${Math.round(n.z*r)}`,u[2]=`${Math.round(a.x*r)},${Math.round(a.y*r)},${Math.round(a.z*r)}`,u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let e=0;e<3;e++){const t=(e+1)%3,n=u[e],r=u[t],o=na[c[e]],s=na[c[t]],a=`${n}_${r}`,p=`${r}_${n}`;p in h&&h[p]?(ta.dot(h[p].normal)<=i&&(d.push(o.x,o.y,o.z),d.push(s.x,s.y,s.z)),h[p]=null):a in h||(h[a]={index0:l[e],index1:l[t],normal:ta.clone()})}}for(const e in h)if(h[e]){const{index0:t,index1:n}=h[e];Qs.fromBufferAttribute(s,t),ea.fromBufferAttribute(s,n),d.push(Qs.x,Qs.y,Qs.z),d.push(ea.x,ea.y,ea.z)}this.setAttribute("position",new wn(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class ia extends Zs{constructor(e){super(e),this.uuid=me(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new Zs).fromJSON(n))}return this}}const oa=function(e,t,n=2){const r=t&&t.length,i=r?t[0]*n:e.length;let o=sa(e,0,i,n,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c,u,h,d,p;if(r&&(o=function(e,t,n,r){const i=[];let o,s,a,l,c;for(o=0,s=t.length;o<s;o++)a=t[o]*r,l=o<s-1?t[o+1]*r:e.length,c=sa(e,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(va(c));for(i.sort(pa),o=0;o<i.length;o++)n=fa(i[o],n);return n}(e,t,o,n)),e.length>80*n){a=c=e[0],l=u=e[1];for(let t=n;t<i;t+=n)h=e[t],d=e[t+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-a,u-l),p=0!==p?32767/p:0}return la(o,s,n,a,l,p,0),s};function sa(e,t,n,r,i){let o,s;if(i===function(e,t,n,r){let i=0;for(let o=t,s=n-r;o<n;o+=r)i+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return i}(e,t,n,r)>0)for(o=t;o<n;o+=r)s=Aa(o,e[o],e[o+1],s);else for(o=n-r;o>=t;o-=r)s=Aa(o,e[o],e[o+1],s);return s&&Ta(s,s.next)&&(Ca(s),s=s.next),s}function aa(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!Ta(r,r.next)&&0!==_a(r.prev,r,r.next))r=r.next;else{if(Ca(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function la(e,t,n,r,i,o,s){if(!e)return;!s&&o&&function(e,t,n,r){let i=e;do{0===i.z&&(i.z=ga(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n,r,i,o,s,a,l,c=1;do{for(n=e,e=null,o=null,s=0;n;){for(s++,r=n,a=0,t=0;t<c&&(a++,r=r.nextZ,r);t++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,c*=2}while(s>1)}(i)}(e,r,i,o);let a,l,c=e;for(;e.prev!==e.next;)if(a=e.prev,l=e.next,o?ua(e,r,i,o):ca(e))t.push(a.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Ca(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?la(e=ha(aa(e),t,n),t,n,r,i,o,2):2===s&&da(e,t,n,r,i,o):la(aa(e),t,n,r,i,o,1);break}}function ca(e){const t=e.prev,n=e,r=e.next;if(_a(t,n,r)>=0)return!1;const i=t.x,o=n.x,s=r.x,a=t.y,l=n.y,c=r.y,u=i<o?i<s?i:s:o<s?o:s,h=a<l?a<c?a:c:l<c?l:c,d=i>o?i>s?i:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&ya(i,a,o,l,s,c,f.x,f.y)&&_a(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ua(e,t,n,r){const i=e.prev,o=e,s=e.next;if(_a(i,o,s)>=0)return!1;const a=i.x,l=o.x,c=s.x,u=i.y,h=o.y,d=s.y,p=a<l?a<c?a:c:l<c?l:c,f=u<h?u<d?u:d:h<d?h:d,m=a>l?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,v=ga(p,f,t,n,r),y=ga(m,g,t,n,r);let x=e.prevZ,_=e.nextZ;for(;x&&x.z>=v&&_&&_.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==s&&ya(a,u,l,h,c,d,x.x,x.y)&&_a(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==i&&_!==s&&ya(a,u,l,h,c,d,_.x,_.y)&&_a(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==i&&x!==s&&ya(a,u,l,h,c,d,x.x,x.y)&&_a(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=y;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==i&&_!==s&&ya(a,u,l,h,c,d,_.x,_.y)&&_a(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function ha(e,t,n){let r=e;do{const i=r.prev,o=r.next.next;!Ta(i,o)&&Ea(i,r,r.next,o)&&Sa(i,o)&&Sa(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),Ca(r),Ca(r.next),r=e=o),r=r.next}while(r!==e);return aa(r)}function da(e,t,n,r,i,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&xa(s,e)){let a=wa(s,e);return s=aa(s,s.next),a=aa(a,a.next),la(s,t,n,r,i,o,0),void la(a,t,n,r,i,o,0)}e=e.next}s=s.next}while(s!==e)}function pa(e,t){return e.x-t.x}function fa(e,t){const n=function(e,t){let n,r=t,i=-1/0;const o=e.x,s=e.y;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){const e=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=o&&e>i&&(i=e,n=r.x<r.next.x?r:r.next,e===o))return n}r=r.next}while(r!==t);if(!n)return null;const a=n,l=n.x,c=n.y;let u,h=1/0;r=n;do{o>=r.x&&r.x>=l&&o!==r.x&&ya(s<c?o:i,s,l,c,s<c?i:o,s,r.x,r.y)&&(u=Math.abs(s-r.y)/(o-r.x),Sa(r,e)&&(u<h||u===h&&(r.x>n.x||r.x===n.x&&ma(n,r)))&&(n=r,h=u)),r=r.next}while(r!==a);return n}(e,t);if(!n)return t;const r=wa(n,e);return aa(r,r.next),aa(n,n.next)}function ma(e,t){return _a(e.prev,e,t.prev)<0&&_a(t.next,e,e.next)<0}function ga(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function va(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function ya(e,t,n,r,i,o,s,a){return(i-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(o-a)>=(i-s)*(r-a)}function xa(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ea(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Sa(e,t)&&Sa(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(_a(e.prev,e,t.prev)||_a(e,t.prev,t))||Ta(e,t)&&_a(e.prev,e,e.next)>0&&_a(t.prev,t,t.next)>0)}function _a(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ta(e,t){return e.x===t.x&&e.y===t.y}function Ea(e,t,n,r){const i=ba(_a(e,t,n)),o=ba(_a(e,t,r)),s=ba(_a(n,r,e)),a=ba(_a(n,r,t));return i!==o&&s!==a||(!(0!==i||!Ma(e,n,t))||(!(0!==o||!Ma(e,r,t))||(!(0!==s||!Ma(n,e,r))||!(0!==a||!Ma(n,t,r)))))}function Ma(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ba(e){return e>0?1:e<0?-1:0}function Sa(e,t){return _a(e.prev,e,e.next)<0?_a(e,t,e.next)>=0&&_a(e,e.prev,t)>=0:_a(e,t,e.prev)<0||_a(e,e.next,t)<0}function wa(e,t){const n=new Ra(e.i,e.x,e.y),r=new Ra(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Aa(e,t,n,r){const i=new Ra(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ca(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ra(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Ia{static area(e){const t=e.length;let n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return.5*n}static isClockWise(e){return Ia.area(e)<0}static triangulateShape(e,t){const n=[],r=[],i=[];Pa(e),La(n,e);let o=e.length;t.forEach(Pa);for(let e=0;e<t.length;e++)r.push(o),o+=t[e].length,La(n,t[e]);const s=oa(n,r);for(let e=0;e<s.length;e+=3)i.push(s.slice(e,e+3));return i}}function Pa(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function La(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class Na extends On{constructor(e=new ia([new Se(.5,.5),new Se(-.5,.5),new Se(-.5,-.5),new Se(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){o(e[t])}function o(e){const o=[],s=void 0!==t.curveSegments?t.curveSegments:12,a=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:.2,h=void 0!==t.bevelSize?t.bevelSize:u-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const f=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:Oa;let g,v,y,x,_,T=!1;f&&(g=f.getSpacedPoints(a),T=!0,c=!1,v=f.computeFrenetFrames(a,!1),y=new Je,x=new Je,_=new Je),c||(p=0,u=0,h=0,d=0);const E=e.extractPoints(s);let M=E.shape;const b=E.holes;if(!Ia.isClockWise(M)){M=M.reverse();for(let e=0,t=b.length;e<t;e++){const t=b[e];Ia.isClockWise(t)&&(b[e]=t.reverse())}}const S=Ia.triangulateShape(M,b),w=M;for(let e=0,t=b.length;e<t;e++){const t=b[e];M=M.concat(t)}function A(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}const C=M.length,R=S.length;function I(e,t,n){let r,i,o;const s=e.x-t.x,a=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=s*s+a*a,h=s*c-a*l;if(Math.abs(h)>Number.EPSILON){const h=Math.sqrt(u),d=Math.sqrt(l*l+c*c),p=t.x-a/h,f=t.y+s/h,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(s*c-a*l);r=p+s*m-e.x,i=f+a*m-e.y;const g=r*r+i*i;if(g<=2)return new Se(r,i);o=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(a)===Math.sign(c)&&(e=!0),e?(r=-a,i=s,o=Math.sqrt(u)):(r=s,i=a,o=Math.sqrt(u/2))}return new Se(r/o,i/o)}const P=[];for(let e=0,t=w.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),P[e]=I(w[e],w[n],w[r]);const L=[];let N,O=P.concat();for(let e=0,t=b.length;e<t;e++){const t=b[e];N=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),N[e]=I(t[e],t[r],t[i]);L.push(N),O=O.concat(N)}for(let e=0;e<p;e++){const t=e/p,n=u*Math.cos(t*Math.PI/2),r=h*Math.sin(t*Math.PI/2)+d;for(let e=0,t=w.length;e<t;e++){const t=A(w[e],P[e],r);k(t.x,t.y,-n)}for(let e=0,t=b.length;e<t;e++){const t=b[e];N=L[e];for(let e=0,i=t.length;e<i;e++){const i=A(t[e],N[e],r);k(i.x,i.y,-n)}}}const U=h+d;for(let e=0;e<C;e++){const t=c?A(M[e],O[e],U):M[e];T?(x.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),_.copy(g[0]).add(x).add(y),k(_.x,_.y,_.z)):k(t.x,t.y,0)}for(let e=1;e<=a;e++)for(let t=0;t<C;t++){const n=c?A(M[t],O[t],U):M[t];T?(x.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),_.copy(g[e]).add(x).add(y),k(_.x,_.y,_.z)):k(n.x,n.y,l/a*e)}for(let e=p-1;e>=0;e--){const t=e/p,n=u*Math.cos(t*Math.PI/2),r=h*Math.sin(t*Math.PI/2)+d;for(let e=0,t=w.length;e<t;e++){const t=A(w[e],P[e],r);k(t.x,t.y,l+n)}for(let e=0,t=b.length;e<t;e++){const t=b[e];N=L[e];for(let e=0,i=t.length;e<i;e++){const i=A(t[e],N[e],r);T?k(i.x,i.y+g[a-1].y,g[a-1].x+n):k(i.x,i.y,l+n)}}}function D(e,t){let n=e.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=e.length-1);for(let e=0,n=a+2*p;e<n;e++){const n=C*e,o=C*(e+1);G(t+r+n,t+i+n,t+i+o,t+r+o)}}}function k(e,t,n){o.push(e),o.push(t),o.push(n)}function F(e,t,i){B(e),B(t),B(i);const o=r.length/3,s=m.generateTopUV(n,r,o-3,o-2,o-1);V(s[0]),V(s[1]),V(s[2])}function G(e,t,i,o){B(e),B(t),B(o),B(t),B(i),B(o);const s=r.length/3,a=m.generateSideWallUV(n,r,s-6,s-3,s-2,s-1);V(a[0]),V(a[1]),V(a[3]),V(a[1]),V(a[2]),V(a[3])}function B(e){r.push(o[3*e+0]),r.push(o[3*e+1]),r.push(o[3*e+2])}function V(e){i.push(e.x),i.push(e.y)}!function(){const e=r.length/3;if(c){let e=0,t=C*e;for(let e=0;e<R;e++){const n=S[e];F(n[2]+t,n[1]+t,n[0]+t)}e=a+2*p,t=C*e;for(let e=0;e<R;e++){const n=S[e];F(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<R;e++){const t=S[e];F(t[2],t[1],t[0])}for(let e=0;e<R;e++){const t=S[e];F(t[0]+C*a,t[1]+C*a,t[2]+C*a)}}n.addGroup(e,r.length/3-e,0)}(),function(){const e=r.length/3;let t=0;D(w,t),t+=w.length;for(let e=0,n=b.length;e<n;e++){const n=b[e];D(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}()}this.setAttribute("position",new wn(r,3)),this.setAttribute("uv",new wn(i,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){const r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){const i=t[e.shapes[r]];n.push(i)}const r=e.options.extrudePath;return void 0!==r&&(e.options.extrudePath=(new Ys[r.type]).fromJSON(r)),new Na(n,e.options)}}const Oa={generateTopUV:function(e,t,n,r,i){const o=t[3*n],s=t[3*n+1],a=t[3*r],l=t[3*r+1],c=t[3*i],u=t[3*i+1];return[new Se(o,s),new Se(a,l),new Se(c,u)]},generateSideWallUV:function(e,t,n,r,i,o){const s=t[3*n],a=t[3*n+1],l=t[3*n+2],c=t[3*r],u=t[3*r+1],h=t[3*r+2],d=t[3*i],p=t[3*i+1],f=t[3*i+2],m=t[3*o],g=t[3*o+1],v=t[3*o+2];return Math.abs(a-u)<Math.abs(s-c)?[new Se(s,1-l),new Se(c,1-h),new Se(d,1-f),new Se(m,1-v)]:[new Se(a,1-l),new Se(u,1-h),new Se(p,1-f),new Se(g,1-v)]}};class Ua extends On{constructor(e=1,t=32,n=16,r=0,i=2*Math.PI,o=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:o,thetaLength:s},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const a=Math.min(o+s,Math.PI);let l=0;const c=[],u=new Je,h=new Je,d=[],p=[],f=[],m=[];for(let d=0;d<=n;d++){const g=[],v=d/n;let y=0;0===d&&0===o?y=.5/t:d===n&&a===Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){const a=n/t;u.x=-e*Math.cos(r+a*i)*Math.sin(o+v*s),u.y=e*Math.cos(o+v*s),u.z=e*Math.sin(r+a*i)*Math.sin(o+v*s),p.push(u.x,u.y,u.z),h.copy(u).normalize(),f.push(h.x,h.y,h.z),m.push(a+y,1-v),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){const t=c[e][r+1],i=c[e][r],s=c[e+1][r],l=c[e+1][r+1];(0!==e||o>0)&&d.push(t,i,l),(e!==n-1||a<Math.PI)&&d.push(i,s,l)}this.setIndex(d),this.setAttribute("position",new wn(p,3)),this.setAttribute("normal",new wn(f,3)),this.setAttribute("uv",new wn(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ua(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Da extends pn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new yn(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 yn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Se(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 ka extends pn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yn(16777215),this.specular=new yn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=u,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Fa extends pn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new yn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=u,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function Ga(e,t,n){return Va(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function Ba(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Va(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function za(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Ha(e,t,n){const r=e.length,i=new e.constructor(r);for(let o=0,s=0;s!==r;++o){const r=n[o]*t;for(let n=0;n!==t;++n)i[s++]=e[r+n]}return i}function Wa(e,t,n,r){let i=1,o=e[0];for(;void 0!==o&&void 0===o[r];)o=e[i++];if(void 0===o)return;let s=o[r];if(void 0!==s)if(Array.isArray(s))do{s=o[r],void 0!==s&&(t.push(o.time),n.push.apply(n,s)),o=e[i++]}while(void 0!==o);else if(void 0!==s.toArray)do{s=o[r],void 0!==s&&(t.push(o.time),s.toArray(n,n.length)),o=e[i++]}while(void 0!==o);else do{s=o[r],void 0!==s&&(t.push(o.time),n.push(s)),o=e[i++]}while(void 0!==o)}class ja{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],i=t[n-1];e:{t:{let o;n:{r:if(!(e<r)){for(let o=n+2;;){if(void 0===r){if(e<i)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(i=r,r=t[++n],e<r)break t}o=t.length;break n}if(e>=i)break e;{const s=t[1];e<s&&(n=2,i=s);for(let o=n-2;;){if(void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(r=i,i=t[--n-1],e>=i)break t}o=n,n=0}}for(;n<o;){const r=n+o>>>1;e<t[r]?o=r:n=r+1}if(r=t[n],i=t[n-1],void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===r)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Xa extends ja{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Z,endingEnd:Z}}intervalChanged_(e,t,n){const r=this.parameterPositions;let i=e-2,o=e+1,s=r[i],a=r[o];if(void 0===s)switch(this.getSettings_().endingStart){case J:i=e,s=2*t-n;break;case $:i=r.length-2,s=t+r[i]-r[i+1];break;default:i=e,s=n}if(void 0===a)switch(this.getSettings_().endingEnd){case J:o=e,a=2*n-t;break;case $:o=1,a=n+r[1]-r[0];break;default:o=e-1,a=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(a-n),this._offsetPrev=i*c,this._offsetNext=o*c}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=this._offsetPrev,u=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-t)/(r-t),f=p*p,m=f*p,g=-h*m+2*h*f-h*p,v=(1+h)*m+(-1.5-2*h)*f+(-.5+h)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let e=0;e!==s;++e)i[e]=g*o[c+e]+v*o[l+e]+y*o[a+e]+x*o[u+e];return i}}class qa extends ja{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=(n-t)/(r-t),u=1-c;for(let e=0;e!==s;++e)i[e]=o[l+e]*u+o[a+e]*c;return i}}class Ya extends ja{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Ka{constructor(e,t,n,r){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=Ba(t,this.TimeBufferType),this.values=Ba(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ba(e.times,Array),values:Ba(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Ya(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new qa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Xa(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case q:t=this.InterpolantFactoryMethodDiscrete;break;case Y:t=this.InterpolantFactoryMethodLinear;break;case K: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 console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return q;case this.InterpolantFactoryMethodLinear:return Y;case this.InterpolantFactoryMethodSmooth:return K}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let i=0,o=r-1;for(;i!==r&&n[i]<e;)++i;for(;-1!==o&&n[o]>t;)--o;if(++o,0!==i||o!==r){i>=o&&(o=Math.max(o,1),i=o-1);const e=this.getValueSize();this.times=Ga(n,i,o),this.values=Ga(this.values,i*e,o*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let t=0;t!==i;t++){const r=n[t];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,r),e=!1;break}if(null!==o&&o>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,r,o),e=!1;break}o=r}if(void 0!==r&&Va(r))for(let t=0,n=r.length;t!==n;++t){const n=r[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=Ga(this.times),t=Ga(this.values),n=this.getValueSize(),r=this.getInterpolation()===K,i=e.length-1;let o=1;for(let s=1;s<i;++s){let i=!1;const a=e[s];if(a!==e[s+1]&&(1!==s||a!==e[0]))if(r)i=!0;else{const e=s*n,r=e-n,o=e+n;for(let s=0;s!==n;++s){const n=t[e+s];if(n!==t[r+s]||n!==t[o+s]){i=!0;break}}}if(i){if(s!==o){e[o]=e[s];const r=s*n,i=o*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++o}}if(i>0){e[o]=e[i];for(let e=i*n,r=o*n,s=0;s!==n;++s)t[r+s]=t[e+s];++o}return o!==e.length?(this.times=Ga(e,0,o),this.values=Ga(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=Ga(this.times,0),t=Ga(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Ka.prototype.TimeBufferType=Float32Array,Ka.prototype.ValueBufferType=Float32Array,Ka.prototype.DefaultInterpolation=Y;class Za extends Ka{}Za.prototype.ValueTypeName="bool",Za.prototype.ValueBufferType=Array,Za.prototype.DefaultInterpolation=q,Za.prototype.InterpolantFactoryMethodLinear=void 0,Za.prototype.InterpolantFactoryMethodSmooth=void 0;class Ja extends Ka{}Ja.prototype.ValueTypeName="color";class $a extends Ka{}$a.prototype.ValueTypeName="number";class Qa extends ja{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(n-t)/(r-t);let l=e*s;for(let e=l+s;l!==e;l+=4)Ze.slerpFlat(i,0,o,l-s,o,l,a);return i}}class el extends Ka{InterpolantFactoryMethodLinear(e){return new Qa(this.times,this.values,this.getValueSize(),e)}}el.prototype.ValueTypeName="quaternion",el.prototype.DefaultInterpolation=Y,el.prototype.InterpolantFactoryMethodSmooth=void 0;class tl extends Ka{}tl.prototype.ValueTypeName="string",tl.prototype.ValueBufferType=Array,tl.prototype.DefaultInterpolation=q,tl.prototype.InterpolantFactoryMethodLinear=void 0,tl.prototype.InterpolantFactoryMethodSmooth=void 0;class nl extends Ka{}nl.prototype.ValueTypeName="vector";class rl{constructor(e,t=-1,n,r=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=me(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(il(n[e]).scale(r));const i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push(Ka.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const i=t.length,o=[];for(let e=0;e<i;e++){let s=[],a=[];s.push((e+i-1)%i,e,(e+1)%i),a.push(0,1,0);const l=za(s);s=Ha(s,1,l),a=Ha(a,1,l),r||0!==s[0]||(s.push(i),a.push(a[0])),o.push(new $a(".morphTargetInfluences["+t[e].name+"]",s,a).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],o=n.name.match(i);if(o&&o.length>1){const e=o[1];let t=r[e];t||(r[e]=t=[]),t.push(n)}}const o=[];for(const e in r)o.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,r,i){if(0!==n.length){const o=[],s=[];Wa(n,o,s,r),0!==o.length&&i.push(new e(t,o,s))}},r=[],i=e.name||"default",o=e.fps||30,s=e.blendMode;let a=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const i=l[e].keys;if(i&&0!==i.length)if(i[0].morphTargets){const e={};let t;for(t=0;t<i.length;t++)if(i[t].morphTargets)for(let n=0;n<i[t].morphTargets.length;n++)e[i[t].morphTargets[n]]=-1;for(const n in e){const e=[],o=[];for(let r=0;r!==i[t].morphTargets.length;++r){const r=i[t];e.push(r.time),o.push(r.morphTarget===n?1:0)}r.push(new $a(".morphTargetInfluence["+n+"]",e,o))}a=e.length*o}else{const o=".bones["+t[e].name+"]";n(nl,o+".position",i,"pos",r),n(el,o+".quaternion",i,"rot",r),n(nl,o+".scale",i,"scl",r)}}if(0===r.length)return null;return new this(i,a,r,s)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<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 il(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $a;case"vector":case"vector2":case"vector3":case"vector4":return nl;case"color":return Ja;case"quaternion":return el;case"bool":case"boolean":return Za;case"string":return tl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];Wa(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const ol={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 sl{constructor(e,t,n){const r=this;let i,o=!1,s=0,a=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){a++,!1===o&&void 0!==r.onStart&&r.onStart(e,s,a),o=!0},this.itemEnd=function(e){s++,void 0!==r.onProgress&&r.onProgress(e,s,a),s===a&&(o=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],r=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}}const al=new sl;class ll{constructor(e){this.manager=void 0!==e?e:al,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(r,i){n.load(e,r,t,i)}))}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}}const cl={};class ul extends Error{constructor(e,t){super(e),this.response=t}}class hl extends ll{constructor(e){super(e)}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=ol.get(e);if(void 0!==i)return this.manager.itemStart(e),setTimeout((()=>{t&&t(i),this.manager.itemEnd(e)}),0),i;if(void 0!==cl[e])return void cl[e].push({onLoad:t,onProgress:n,onError:r});cl[e]=[],cl[e].push({onLoad:t,onProgress:n,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,a=this.responseType;fetch(o).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=cl[e],r=t.body.getReader(),i=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),o=i?parseInt(i):0,s=0!==o;let a=0;const l=new ReadableStream({start(e){!function t(){r.read().then((({done:r,value:i})=>{if(r)e.close();else{a+=i.byteLength;const r=new ProgressEvent("progress",{lengthComputable:s,loaded:a,total:o});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}}))}()}});return new Response(l)}throw new ul(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(a){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then((e=>r.decode(e)))}}})).then((t=>{ol.add(e,t);const n=cl[e];delete cl[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onLoad&&r.onLoad(t)}})).catch((t=>{const n=cl[e];if(void 0===n)throw this.manager.itemError(e),t;delete cl[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onError&&r.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 dl extends ll{constructor(e){super(e)}load(e,t,n,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,o=ol.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;const s=Re("img");function a(){c(),ol.add(e,this),t&&t(this),i.manager.itemEnd(e)}function l(t){c(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function c(){s.removeEventListener("load",a,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",a,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),i.manager.itemStart(e),s.src=e,s}}class pl extends ll{constructor(e){super(e)}load(e,t,n,r){const i=new ur;i.colorSpace=te;const o=new dl(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let s=0;function a(n){o.load(e[n],(function(e){i.images[n]=e,s++,6===s&&(i.needsUpdate=!0,t&&t(i))}),void 0,r)}for(let t=0;t<e.length;++t)a(t);return i}}class fl extends ll{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new ds,s=new hl(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(i.withCredentials),s.load(e,(function(e){const n=i.parse(e);n&&(void 0!==n.image?o.image=n.image:void 0!==n.data&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=void 0!==n.wrapS?n.wrapS:S,o.wrapT=void 0!==n.wrapT?n.wrapT:S,o.magFilter=void 0!==n.magFilter?n.magFilter:I,o.minFilter=void 0!==n.minFilter?n.minFilter:I,o.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace?o.colorSpace=n.colorSpace:void 0!==n.encoding&&(o.encoding=n.encoding),void 0!==n.flipY&&(o.flipY=n.flipY),void 0!==n.format&&(o.format=n.format),void 0!==n.type&&(o.type=n.type),void 0!==n.mipmaps&&(o.mipmaps=n.mipmaps,o.minFilter=P),1===n.mipmapCount&&(o.minFilter=I),void 0!==n.generateMipmaps&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,t&&t(o,n))}),n,r),o}}class ml extends ll{constructor(e){super(e)}load(e,t,n,r){const i=new je,o=new dl(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,(function(e){i.image=e,i.needsUpdate=!0,void 0!==t&&t(i)}),n,r),i}}class gl extends $t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new yn(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 vl=new At,yl=new Je,xl=new Je;class _l{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Se(512,512),this.map=null,this.mapPass=null,this.matrix=new At,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yr,this._frameExtents=new Se(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;yl.setFromMatrixPosition(e.matrixWorld),t.position.copy(yl),xl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(xl),t.updateMatrixWorld(),vl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vl),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(vl)}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 Tl extends _l{constructor(){super(new ar(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*fe*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;n===t.fov&&r===t.aspect&&i===t.far||(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class El extends gl{constructor(e,t,n=0,r=Math.PI/3,i=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy($t.DEFAULT_UP),this.updateMatrix(),this.target=new $t,this.distance=n,this.angle=r,this.penumbra=i,this.decay=o,this.map=null,this.shadow=new Tl}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 Ml=new At,bl=new Je,Sl=new Je;class wl extends _l{constructor(){super(new ar(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Se(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new Je(1,0,0),new Je(-1,0,0),new Je(0,0,1),new Je(0,0,-1),new Je(0,1,0),new Je(0,-1,0)],this._cubeUps=[new Je(0,1,0),new Je(0,1,0),new Je(0,1,0),new Je(0,1,0),new Je(0,0,1),new Je(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),bl.setFromMatrixPosition(e.matrixWorld),n.position.copy(bl),Sl.copy(n.position),Sl.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Sl),n.updateMatrixWorld(),r.makeTranslation(-bl.x,-bl.y,-bl.z),Ml.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ml)}}class Al extends gl{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new wl}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 Cl extends _l{constructor(){super(new Lr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Rl extends gl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy($t.DEFAULT_UP),this.updateMatrix(),this.target=new $t,this.shadow=new Cl}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Il extends gl{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Pl{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);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)}}const Ll="\\[\\]\\.:\\/",Nl=new RegExp("["+Ll+"]","g"),Ol="[^"+Ll+"]",Ul="[^"+Ll.replace("\\.","")+"]",Dl=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Ol)+/(WCOD+)?/.source.replace("WCOD",Ul)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ol)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ol)+"$"),kl=["material","materials","bones","map"];class Fl{constructor(e,t,n){this.path=t,this.parsedPath=n||Fl.parseTrackName(t),this.node=Fl.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Fl.Composite(e,t,n):new Fl(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Nl,"")}static parseTrackName(e){const t=Dl.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=n.nodeName.substring(r+1);-1!==kl.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let r=0;r<e.length;r++){const i=e[r];if(i.name===t||i.uuid===t)return i;const o=n(i.children);if(o)return o}return null},r=n(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 n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_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 n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=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,n=t.objectName,r=t.propertyName;let i=t.propertyIndex;if(e||(e=Fl.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let r=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.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 console.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===r){r=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.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[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==r){if(void 0===e[r])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[r]}}const o=e[r];if(void 0===o){const n=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+r+" but it wasn't found.",e)}let s=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?s=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(s=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[i]&&(i=e.morphTargetDictionary[i])}a=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=i}else void 0!==o.fromArray&&void 0!==o.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(a=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Fl.Composite=class{constructor(e,t,n){const r=n||Fl.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Fl.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Fl.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Fl.prototype.GetterByBindingType=[Fl.prototype._getValue_direct,Fl.prototype._getValue_array,Fl.prototype._getValue_arrayElement,Fl.prototype._getValue_toArray],Fl.prototype.SetterByBindingTypeAndVersioning=[[Fl.prototype._setValue_direct,Fl.prototype._setValue_direct_setNeedsUpdate,Fl.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Fl.prototype._setValue_array,Fl.prototype._setValue_array_setNeedsUpdate,Fl.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Fl.prototype._setValue_arrayElement,Fl.prototype._setValue_arrayElement_setNeedsUpdate,Fl.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Fl.prototype._setValue_fromArray,Fl.prototype._setValue_fromArray_setNeedsUpdate,Fl.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];new Float32Array(1);class Gl{constructor(e,t,n=0,r=1/0){this.ray=new wt(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Ft,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):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Vl(e,this,n,t),n.sort(Bl),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)Vl(e[r],this,n,t);return n.sort(Bl),n}}function Bl(e,t){return e.distance-t.distance}function Vl(e,t,n,r){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===r){const r=e.children;for(let e=0,i=r.length;e<i;e++)Vl(r[e],t,n,!0)}}const zl=new Se;class Hl{constructor(e=new Se(1/0,1/0),t=new Se(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=zl.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zl).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}class Wl{constructor(){this.type="ShapePath",this.color=new yn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Zs,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,o){return this.currentPath.bezierCurveTo(e,t,n,r,i,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let r=!1;for(let i=n-1,o=0;o<n;i=o++){let n=t[i],s=t[o],a=s.x-n.x,l=s.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[o],a=-a,s=t[i],l=-l),e.y<n.y||e.y>s.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-a*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return r}const n=Ia.isClockWise,r=this.subPaths;if(0===r.length)return[];let i,o,s;const a=[];if(1===r.length)return o=r[0],s=new ia,s.curves=o.curves,a.push(s),a;let l=!n(r[0].getPoints());l=e?!l:l;const c=[],u=[];let h,d,p=[],f=0;u[f]=void 0,p[f]=[];for(let t=0,s=r.length;t<s;t++)o=r[t],h=o.getPoints(),i=n(h),i=e?!i:i,i?(!l&&u[f]&&f++,u[f]={s:new ia,p:h},u[f].s.curves=o.curves,l&&f++,p[f]=[]):p[f].push({h:o,p:h[0]});if(!u[0])return function(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n],i=new ia;i.curves=r.curves,t.push(i)}return t}(r);if(u.length>1){let e=!1,n=0;for(let e=0,t=u.length;e<t;e++)c[e]=[];for(let r=0,i=u.length;r<i;r++){const i=p[r];for(let o=0;o<i.length;o++){const s=i[o];let a=!0;for(let i=0;i<u.length;i++)t(s.p,u[i].p)&&(r!==i&&n++,a?(a=!1,c[i].push(s)):e=!0);a&&c[r].push(s)}}n>0&&!1===e&&(p=c)}for(let e=0,t=u.length;e<t;e++){s=u[e].s,a.push(s),d=p[e];for(let e=0,t=d.length;e<t;e++)s.holes.push(d[e].h)}return a}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t);class jl extends fl{constructor(e){super(e)}parse(e){const t=0,n=1,r=2,i=3,o=9,s=10,a=11,l=48,c=4,u=0,h=1,d=2,p=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let f=0;const m=new Uint8Array(e),g={id_length:m[f++],colormap_type:m[f++],image_type:m[f++],colormap_index:m[f++]|m[f++]<<8,colormap_length:m[f++]|m[f++]<<8,colormap_size:m[f++],origin:[m[f++]|m[f++]<<8,m[f++]|m[f++]<<8],width:m[f++]|m[f++]<<8,height:m[f++]|m[f++]<<8,pixel_size:m[f++],flags:m[f++]};!function(e){switch(e.image_type){case n:case o:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case r:case i:case s:case a:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+f>e.length&&console.error("THREE.TGALoader: No data."),f+=g.id_length;let v=!1,y=!1,x=!1;switch(g.image_type){case o:v=!0,y=!0;break;case n:y=!0;break;case s:v=!0;break;case r:break;case a:v=!0,x=!0;break;case i:x=!0}const _=new Uint8Array(g.width*g.height*4),T=function(e,t,n,r,i){let o,s;const a=n.pixel_size>>3,l=n.width*n.height*a;if(t&&(s=i.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;o=new Uint8Array(l);let s=0;const c=new Uint8Array(a);for(;s<l;)if(e=i[r++],t=1+(127&e),128&e){for(n=0;n<a;++n)c[n]=i[r++];for(n=0;n<t;++n)o.set(c,s+n*a);s+=a*t}else{for(t*=a,n=0;n<t;++n)o[s+n]=i[r++];s+=t}}else o=i.subarray(r,r+=t?n.width*n.height:l);return{pixel_data:o,palettes:s}}(v,y,g,f,m);return function(e,t,n,r,i){let o,s,a,f,m,v;switch((g.flags&l)>>c){default:case d:o=0,a=1,m=t,s=0,f=1,v=n;break;case u:o=0,a=1,m=t,s=n-1,f=-1,v=-1;break;case p:o=t-1,a=-1,m=-1,s=0,f=1,v=n;break;case h:o=t-1,a=-1,m=-1,s=n-1,f=-1,v=-1}if(x)switch(g.pixel_size){case 8:!function(e,t,n,r,i,o,s,a){let l,c,u,h=0;const d=g.width;for(u=t;u!==r;u+=n)for(c=i;c!==s;c+=o,h++)l=a[h],e[4*(c+d*u)+0]=l,e[4*(c+d*u)+1]=l,e[4*(c+d*u)+2]=l,e[4*(c+d*u)+3]=255}(e,s,f,v,o,a,m,r);break;case 16:!function(e,t,n,r,i,o,s,a){let l,c,u=0;const h=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==s;l+=o,u+=2)e[4*(l+h*c)+0]=a[u+0],e[4*(l+h*c)+1]=a[u+0],e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+3]=a[u+1]}(e,s,f,v,o,a,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,r,i,o,s,a,l){const c=l;let u,h,d,p=0;const f=g.width;for(d=t;d!==r;d+=n)for(h=i;h!==s;h+=o,p++)u=a[p],e[4*(h+f*d)+3]=255,e[4*(h+f*d)+2]=c[3*u+0],e[4*(h+f*d)+1]=c[3*u+1],e[4*(h+f*d)+0]=c[3*u+2]}(e,s,f,v,o,a,m,r,i);break;case 16:!function(e,t,n,r,i,o,s,a){let l,c,u,h=0;const d=g.width;for(u=t;u!==r;u+=n)for(c=i;c!==s;c+=o,h+=2)l=a[h+0]+(a[h+1]<<8),e[4*(c+d*u)+0]=(31744&l)>>7,e[4*(c+d*u)+1]=(992&l)>>2,e[4*(c+d*u)+2]=(31&l)<<3,e[4*(c+d*u)+3]=32768&l?0:255}(e,s,f,v,o,a,m,r);break;case 24:!function(e,t,n,r,i,o,s,a){let l,c,u=0;const h=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==s;l+=o,u+=3)e[4*(l+h*c)+3]=255,e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+1]=a[u+1],e[4*(l+h*c)+0]=a[u+2]}(e,s,f,v,o,a,m,r);break;case 32:!function(e,t,n,r,i,o,s,a){let l,c,u=0;const h=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==s;l+=o,u+=4)e[4*(l+h*c)+2]=a[u+0],e[4*(l+h*c)+1]=a[u+1],e[4*(l+h*c)+0]=a[u+2],e[4*(l+h*c)+3]=a[u+3]}(e,s,f,v,o,a,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}}(_,g.width,g.height,T.pixel_data,T.palettes),{data:_,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:P}}}var Xl=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(Xl(""))}catch(e){Xl=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},function(e){return new Worker(e,{type:"module"})}}var ql=Uint8Array,Yl=Uint16Array,Kl=Uint32Array,Zl=new ql([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]),Jl=new ql([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]),$l=new ql([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ql=function(e,t){for(var n=new Yl(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new Kl(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return[n,i]},ec=Ql(Zl,2),tc=ec[0],nc=ec[1];tc[28]=258,nc[258]=28;for(var rc=Ql(Jl,0),ic=rc[0],oc=(rc[1],new Yl(32768)),sc=0;sc<32768;++sc){var ac=(43690&sc)>>>1|(21845&sc)<<1;ac=(61680&(ac=(52428&ac)>>>2|(13107&ac)<<2))>>>4|(3855&ac)<<4,oc[sc]=((65280&ac)>>>8|(255&ac)<<8)>>>1}var lc=function(e,t,n){for(var r=e.length,i=0,o=new Yl(t);i<r;++i)++o[e[i]-1];var s,a=new Yl(t);for(i=0;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;if(n){s=new Yl(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],u=t-e[i],h=a[e[i]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)s[oc[h]>>>l]=c}else for(s=new Yl(r),i=0;i<r;++i)e[i]&&(s[i]=oc[a[e[i]-1]++]>>>15-e[i]);return s},cc=new ql(288);for(sc=0;sc<144;++sc)cc[sc]=8;for(sc=144;sc<256;++sc)cc[sc]=9;for(sc=256;sc<280;++sc)cc[sc]=7;for(sc=280;sc<288;++sc)cc[sc]=8;var uc=new ql(32);for(sc=0;sc<32;++sc)uc[sc]=5;var hc=lc(cc,9,1),dc=lc(uc,5,1),pc=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},fc=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},mc=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},gc=function(e){return(e/8|0)+(7&e&&1)},vc=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Yl?Yl:e instanceof Kl?Kl:ql)(n-t);return r.set(e.subarray(t,n)),r},yc=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new ql(0);var i=!t||n,o=!n||n.i;n||(n={}),t||(t=new ql(3*r));var s=function(e){var n=t.length;if(e>n){var r=new ql(Math.max(2*n,e));r.set(t),t=r}},a=n.f||0,l=n.p||0,c=n.b||0,u=n.l,h=n.d,d=n.m,p=n.n,f=8*r;do{if(!u){n.f=a=fc(e,l,1);var m=fc(e,l+1,3);if(l+=3,!m){var g=e[(A=gc(l)+4)-4]|e[A-3]<<8,v=A+g;if(v>r){if(o)throw"unexpected EOF";break}i&&s(c+g),t.set(e.subarray(A,v),c),n.b=c+=g,n.p=l=8*v;continue}if(1==m)u=hc,h=dc,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=fc(e,l,31)+257,x=fc(e,l+10,15)+4,_=y+fc(e,l+5,31)+1;l+=14;for(var T=new ql(_),E=new ql(19),M=0;M<x;++M)E[$l[M]]=fc(e,l+3*M,7);l+=3*x;var b=pc(E),S=(1<<b)-1,w=lc(E,b,1);for(M=0;M<_;){var A,C=w[fc(e,l,S)];if(l+=15&C,(A=C>>>4)<16)T[M++]=A;else{var R=0,I=0;for(16==A?(I=3+fc(e,l,3),l+=2,R=T[M-1]):17==A?(I=3+fc(e,l,7),l+=3):18==A&&(I=11+fc(e,l,127),l+=7);I--;)T[M++]=R}}var P=T.subarray(0,y),L=T.subarray(y);d=pc(P),p=pc(L),u=lc(P,d,1),h=lc(L,p,1)}if(l>f){if(o)throw"unexpected EOF";break}}i&&s(c+131072);for(var N=(1<<d)-1,O=(1<<p)-1,U=l;;U=l){var D=(R=u[mc(e,l)&N])>>>4;if((l+=15&R)>f){if(o)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if(D<256)t[c++]=D;else{if(256==D){U=l,u=null;break}var k=D-254;if(D>264){var F=Zl[M=D-257];k=fc(e,l,(1<<F)-1)+tc[M],l+=F}var G=h[mc(e,l)&O],B=G>>>4;if(!G)throw"invalid distance";l+=15&G;L=ic[B];if(B>3){F=Jl[B];L+=mc(e,l)&(1<<F)-1,l+=F}if(l>f){if(o)throw"unexpected EOF";break}i&&s(c+131072);for(var V=c+k;c<V;c+=4)t[c]=t[c-L],t[c+1]=t[c+1-L],t[c+2]=t[c+2-L],t[c+3]=t[c+3-L];c=V}}n.l=u,n.p=U,n.b=c,u&&(a=1,n.m=d,n.d=h,n.n=p)}while(!a);return c==t.length?t:vc(t,0,c)},xc=new ql(0),_c=function(e,t){return e[t]|e[t+1]<<8},Tc=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Ec=function(e,t){return Tc(e,t)+4294967296*Tc(e,t+4)},Mc=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function bc(e,t){return yc(e,t)}function Sc(e,t){return yc((Mc(e),e.subarray(2,-4)),t)}var wc="undefined"!=typeof TextDecoder&&new TextDecoder;try{wc.decode(xc,{stream:!0}),1}catch(e){}var Ac=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return[t,vc(e,n-1)];i?3==i?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}};function Cc(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(wc)return wc.decode(e);var i=Ac(e),o=i[0];if(i[1].length)throw"invalid utf-8 data";return o}var Rc=function(e,t){return t+30+_c(e,t+26)+_c(e,t+28)},Ic=function(e,t,n){var r=_c(e,t+28),i=Cc(e.subarray(t+46,t+46+r),!(2048&_c(e,t+8))),o=t+46+r,s=Tc(e,t+20),a=n&&4294967295==s?Pc(e,o):[s,Tc(e,t+24),Tc(e,t+42)],l=a[0],c=a[1],u=a[2];return[_c(e,t+10),l,c,i,o+_c(e,t+30)+_c(e,t+32),u]},Pc=function(e,t){for(;1!=_c(e,t);t+=4+_c(e,t+2));return[Ec(e,t+12),Ec(e,t+4),Ec(e,t+20)]};function Lc(e){for(var t={},n=e.length-22;101010256!=Tc(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var r=_c(e,n+8);if(!r)return{};var i=Tc(e,n+16),o=4294967295==i;if(o){if(n=Tc(e,n-12),101075792!=Tc(e,n))throw"invalid zip file";r=Tc(e,n+32),i=Tc(e,n+48)}for(var s=0;s<r;++s){var a=Ic(e,i,o),l=a[0],c=a[1],u=a[2],h=a[3],d=a[4],p=a[5],f=Rc(e,p);if(i=d,l){if(8!=l)throw"unknown compression type "+l;t[h]=bc(e.subarray(f,f+c),new ql(u))}else t[h]=vc(e,f,f+c)}return t}function Nc(e,t,n){const r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let i=e,o=r,s=Math.floor((i+o)/2);for(;t<n[s]||t>=n[s+1];)t<n[s]?o=s:i=s,s=Math.floor((i+o)/2);return s}function Oc(e,t,n,r){const i=[],o=[],s=[];i[0]=1;for(let a=1;a<=n;++a){o[a]=t-r[e+1-a],s[a]=r[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=s[e+1],r=o[a-e],l=i[e]/(t+r);i[e]=n+t*l,n=r*l}i[a]=n}return i}function Uc(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function Dc(e,t,n,r,i){const o=function(e,t,n,r,i){const o=i<e?i:e,s=[],a=Nc(e,r,t),l=function(e,t,n,r,i){const o=[];for(let e=0;e<=n;++e)o[e]=0;const s=[];for(let e=0;e<=r;++e)s[e]=o.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=o.slice(0);a[0][0]=1;const l=o.slice(0),c=o.slice(0);for(let r=1;r<=n;++r){l[r]=t-i[e+1-r],c[r]=i[e+r]-t;let n=0;for(let e=0;e<r;++e){const t=c[e+1],i=l[r-e];a[r][e]=t+i;const o=a[e][r-1]/a[r][e];a[e][r]=n+t*o,n=i*o}a[r][r]=n}for(let e=0;e<=n;++e)s[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,i=1;const l=[];for(let e=0;e<=n;++e)l[e]=o.slice(0);l[0][0]=1;for(let o=1;o<=r;++o){let r=0;const c=e-o,u=n-o;e>=o&&(l[i][0]=l[t][0]/a[u+1][c],r=l[i][0]*a[c][u]);const h=e-1<=u?o-1:n-e;for(let e=c>=-1?1:-c;e<=h;++e)l[i][e]=(l[t][e]-l[t][e-1])/a[u+1][c+e],r+=l[i][e]*a[c+e][u];e<=u&&(l[i][o]=-l[t][o-1]/a[u+1][e],r+=l[i][o]*a[e][u]),s[o][e]=r;const d=t;t=i,i=d}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)s[e][t]*=u;u*=n-e}return s}(a,r,e,o,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,c[e]=t}for(let t=0;t<=o;++t){const n=c[a-e].clone().multiplyScalar(l[t][0]);for(let r=1;r<=e;++r)n.add(c[a-e+r].clone().multiplyScalar(l[t][r]));s[t]=n}for(let e=o+1;e<=i+1;++e)s[e]=new Xe(0,0,0);return s}(e,t,n,r,i);return function(e){const t=e.length,n=[],r=[];for(let i=0;i<t;++i){const t=e[i];n[i]=new Je(t.x,t.y,t.z),r[i]=t.w}const i=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(i[e-n].clone().multiplyScalar(Uc(e,n)*r[n]));i[e]=t.divideScalar(r[0])}return i}(o)}class kc extends Ns{constructor(e,t,n,r,i){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new Xe(t.x,t.y,t.z,t.w)}}getPoint(e,t=new Je){const n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(e,t,n,r){const i=Nc(e,r,t),o=Oc(i,r,e,t),s=new Xe(0,0,0,0);for(let t=0;t<=e;++t){const r=n[i-e+t],a=o[t],l=r.w*a;s.x+=r.x*l,s.y+=r.y*l,s.z+=r.z*l,s.w+=r.w*a}return s}(this.degree,this.knots,this.controlPoints,r);return 1!==i.w&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(e,t=new Je){const n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=Dc(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}}let Fc,Gc,Bc;class Vc extends ll{constructor(e){super(e)}load(e,t,n,r){const i=this,o=""===i.path?Pl.extractUrlBase(e):i.path,s=new hl(this.manager);s.setPath(i.path),s.setResponseType("arraybuffer"),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(n){try{t(i.parse(n,o))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e,t){if(function(e){const t="Kaydara FBX Binary  \0";return e.byteLength>=t.length&&t===iu(e,0,t.length)}(e))Fc=(new Xc).parse(e);else{const t=iu(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(t){const r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e){if(r(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Kc(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Kc(t));Fc=(new jc).parse(t)}const n=new ml(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new zc(n,this.manager).parse(Fc)}}class zc{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Gc=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),i=(new Hc).parse(r);return this.parseScene(r,i,n),Bc}parseConnections(){const e=new Map;if("Connections"in Fc){Fc.Connections.connections.forEach((function(t){const n=t[0],r=t[1],i=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const o={ID:r,relationship:i};e.get(n).parents.push(o),e.has(r)||e.set(r,{parents:[],children:[]});const s={ID:n,relationship:i};e.get(r).children.push(s)}))}return e}parseImages(){const e={},t={};if("Video"in Fc.Objects){const n=Fc.Objects.Video;for(const r in n){const i=n[r];if(e[parseInt(r)]=i.RelativeFilename||i.Filename,"Content"in i){const e=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,o="string"==typeof i.Content&&""!==i.Content;if(e||o){const e=this.parseImage(n[r]);t[i.RelativeFilename||i.Filename]=e}}}}for(const n in e){const r=e[n];void 0!==t[r]?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof t)return"data:"+i+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e){const t=new Map;if("Texture"in Fc.Objects){const n=Fc.Objects.Texture;for(const r in n){const i=this.parseTexture(n[r],e);t.set(parseInt(r),i)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,i=e.WrapModeV,o=void 0!==r?r.value:0,s=void 0!==i?i.value:0;if(n.wrapS=0===o?b:S,n.wrapT=0===s?b:S,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n;const r=this.textureLoader.path,i=Gc.get(e.id).children;let o;void 0!==i&&i.length>0&&void 0!==t[i[0].ID]&&(n=t[i[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const s=e.FileName.slice(-3).toLowerCase();if("tga"===s){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),o=new je):(t.setPath(this.textureLoader.path),o=t.load(n))}else"psd"===s?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),o=new je):o=this.textureLoader.load(n);return this.textureLoader.setPath(r),o}parseMaterials(e){const t=new Map;if("Material"in Fc.Objects){const n=Fc.Objects.Material;for(const r in n){const i=this.parseMaterial(n[r],e);null!==i&&t.set(parseInt(r),i)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let i=e.ShadingModel;if("object"==typeof i&&(i=i.value),!Gc.has(n))return null;const o=this.parseParameters(e,t,n);let s;switch(i.toLowerCase()){case"phong":s=new ka;break;case"lambert":s=new Fa;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),s=new ka}return s.setValues(o),s.name=r,s}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=(new yn).fromArray(e.Diffuse.value).convertSRGBToLinear():!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(r.color=(new yn).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=(new yn).fromArray(e.Emissive.value).convertSRGBToLinear():!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(r.emissive=(new yn).fromArray(e.EmissiveColor.value).convertSRGBToLinear()),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(r.opacity=parseFloat(e.Opacity.value)),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=(new yn).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(r.specular=(new yn).fromArray(e.SpecularColor.value).convertSRGBToLinear());const i=this;return Gc.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":r.bumpMap=i.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":r.aoMap=i.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=i.getTexture(t,e.ID),void 0!==r.map&&(r.map.colorSpace=te);break;case"DisplacementColor":r.displacementMap=i.getTexture(t,e.ID);break;case"EmissiveColor":r.emissiveMap=i.getTexture(t,e.ID),void 0!==r.emissiveMap&&(r.emissiveMap.colorSpace=te);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=i.getTexture(t,e.ID);break;case"ReflectionColor":r.envMap=i.getTexture(t,e.ID),void 0!==r.envMap&&(r.envMap.mapping=T,r.envMap.colorSpace=te);break;case"SpecularColor":r.specularMap=i.getTexture(t,e.ID),void 0!==r.specularMap&&(r.specularMap.colorSpace=te);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=i.getTexture(t,e.ID),r.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),r}getTexture(e,t){return"LayeredTexture"in Fc.Objects&&t in Fc.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Gc.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Fc.Objects){const n=Fc.Objects.Deformer;for(const r in n){const i=n[r],o=Gc.get(parseInt(r));if("Skin"===i.attrType){const t=this.parseSkeleton(o,n);t.ID=r,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=o.parents[0].ID,e[r]=t}else if("BlendShape"===i.attrType){const e={id:r};e.rawTargets=this.parseMorphTargets(o,n),e.id=r,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const r=t[e.ID];if("Cluster"!==r.attrType)return;const i={ID:e.ID,indices:[],weights:[],transformLink:(new At).fromArray(r.TransformLink.a)};"Indexes"in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const i=e.children[r],o=t[i.ID],s={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if("BlendShapeChannel"!==o.attrType)return;s.geoID=Gc.get(parseInt(i.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(s)}return n}parseScene(e,t,n){Bc=new jo;const r=this.parseModels(e.skeletons,t,n),i=Fc.Objects.Model,o=this;r.forEach((function(e){const t=i[e.ID];o.setLookAtProperties(e,t);Gc.get(e.ID).parents.forEach((function(t){const n=r.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&Bc.add(e)})),this.bindSkeleton(e.skeletons,t,r),this.createAmbientLight(),Bc.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=tu(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const s=(new Wc).parse();1===Bc.children.length&&Bc.children[0].isGroup&&(Bc.children[0].animations=s,Bc=Bc.children[0]),Bc.animations=s}parseModels(e,t,n){const r=new Map,i=Fc.Objects.Model;for(const o in i){const s=parseInt(o),a=i[o],l=Gc.get(s);let c=this.buildSkeleton(l,e,s,a.attrName);if(!c){switch(a.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new hs;break;default:c=new jo}c.name=a.attrName?Fl.sanitizeNodeName(a.attrName):"",c.ID=s}this.getTransformData(c,a),r.set(s,c)}return r}buildSkeleton(e,t,n,r){let i=null;return e.parents.forEach((function(e){for(const o in t){const s=t[o];s.rawBones.forEach((function(t,o){if(t.ID===e.ID){const e=i;i=new hs,i.matrixWorld.copy(t.transformLink),i.name=r?Fl.sanitizeNodeName(r):"",i.ID=n,s.bones[o]=i,null!==e&&i.add(e)}}))}})),i}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=Fc.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new $t;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);let i=1e3;void 0!==n.FarPlane&&(i=n.FarPlane.value/1e3);let o=window.innerWidth,s=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(o=n.AspectWidth.value,s=n.AspectHeight.value);const a=o/s;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new ar(l,a,r,i),null!==c&&t.setFocalLength(c);break;case 1:t=new Lr(-o/2,o/2,s/2,-s/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new $t}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=Fc.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new $t;else{let e;e=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=(new yn).fromArray(n.Color.value).convertSRGBToLinear());let i=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(i=0);let o=0;void 0!==n.FarAttenuationEnd&&(o=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const s=1;switch(e){case 0:t=new Al(r,i,o,s);break;case 1:t=new Rl(r,i);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=be.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=be.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new El(r,i,o,e,a,s);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Al(r,i)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,i=null,o=null;const s=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),n.has(e.ID)&&s.push(n.get(e.ID))})),s.length>1?o=s:s.length>0?o=s[0]:(o=new ka({color:13421772}),s.push(o)),"color"in i.attributes&&s.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(r=new us(i,o),r.normalizeSkinWeights()):r=new $n(i,o),r}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),r=new gs({color:3342591,linewidth:1});return new Es(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?nu(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){Gc.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const n=Fc.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Bc.add(e.target)):e.lookAt((new Je).fromArray(t))}}}))}}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const i in e){const o=e[i];Gc.get(parseInt(o.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;Gc.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new ms(o.bones),r[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in Fc.Objects){const t=Fc.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach((function(t){e[t.Node]=(new At).fromArray(t.Matrix.a)})):e[r.Node]=(new At).fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Fc&&"AmbientColor"in Fc.GlobalSettings){const e=Fc.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(0!==t||0!==n||0!==r){const e=new yn(t,n,r).convertSRGBToLinear();Bc.add(new Il(e,1))}}}}class Hc{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Fc.Objects){const n=Fc.Objects.Geometry;for(const r in n){const i=Gc.get(parseInt(r)),o=this.parseGeometry(i,n[r],e);t.set(parseInt(r),o)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,i=[],o=e.parents.map((function(e){return Fc.Objects.Model[e.ID]}));if(0===o.length)return;const s=e.children.reduce((function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&i.push(n.morphTargets[e.ID])}));const a=o[0],l={};"RotationOrder"in a&&(l.eulerOrder=nu(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const c=tu(l);return this.genGeometry(t,s,i,c)}genGeometry(e,t,n,r){const i=new On;e.attrName&&(i.name=e.attrName);const o=this.parseGeoNode(e,t),s=this.genBuffers(o),a=new wn(s.vertex,3);if(a.applyMatrix4(r),i.setAttribute("position",a),s.colors.length>0&&i.setAttribute("color",new wn(s.colors,3)),t&&(i.setAttribute("skinIndex",new bn(s.weightsIndices,4)),i.setAttribute("skinWeight",new wn(s.vertexWeights,4)),i.FBX_Deformer=t),s.normal.length>0){const e=(new we).getNormalMatrix(r),t=new wn(s.normal,3);t.applyNormalMatrix(e),i.setAttribute("normal",t)}if(s.uvs.forEach((function(e,t){const n=0===t?"uv":`uv${t}`;i.setAttribute(n,new wn(s.uvs[t],2))})),o.material&&"AllSame"!==o.material.mappingType){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach((function(n,r){n!==e&&(i.addGroup(t,r-t,e),e=n,t=r)})),i.groups.length>0){const t=i.groups[i.groups.length-1],n=t.start+t.count;n!==s.materialIndex.length&&i.addGroup(n,s.materialIndex.length-n,e)}0===i.groups.length&&i.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(i,e,n,r),i}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[i]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,o=[],s=[],a=[],l=[],c=[],u=[];const h=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(o.push(3*d,3*d+1,3*d+2),e.color){const t=$c(p,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,r){let i=n,o=g[r];t.forEach((function(t,n,r){if(i>t){r[n]=i,i=t;const s=e[n];e[n]=o,o=s}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)c.push(v[e]),u.push(g[e])}if(e.normal){const t=$c(p,n,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=$c(p,n,d,e.material)[0],f<0&&(h.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){const r=$c(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(r[0]),l[t].push(r[1])})),r++,m&&(r>4&&console.warn("THREE.FBXLoader: Polygons with more than four sides are not supported. Make sure to triangulate the geometry during export."),h.genFace(t,e,o,f,s,a,l,c,u,r),n++,r=0,o=[],s=[],a=[],l=[],c=[],u=[])})),t}genFace(e,t,n,r,i,o,s,a,l,c){for(let u=2;u<c;u++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(u-1)]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[n[3*u]]),e.vertex.push(t.vertexPositions[n[3*u+1]]),e.vertex.push(t.vertexPositions[n[3*u+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(u-1)]),e.vertexWeights.push(a[4*(u-1)+1]),e.vertexWeights.push(a[4*(u-1)+2]),e.vertexWeights.push(a[4*(u-1)+3]),e.vertexWeights.push(a[4*u]),e.vertexWeights.push(a[4*u+1]),e.vertexWeights.push(a[4*u+2]),e.vertexWeights.push(a[4*u+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[3*(u-1)]),e.colors.push(o[3*(u-1)+1]),e.colors.push(o[3*(u-1)+2]),e.colors.push(o[3*u]),e.colors.push(o[3*u+1]),e.colors.push(o[3*u+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[3*(u-1)]),e.normal.push(i[3*(u-1)+1]),e.normal.push(i[3*(u-1)+2]),e.normal.push(i[3*u]),e.normal.push(i[3*u+1]),e.normal.push(i[3*u+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(s[n][0]),e.uvs[n].push(s[n][1]),e.uvs[n].push(s[n][2*(u-1)]),e.uvs[n].push(s[n][2*(u-1)+1]),e.uvs[n].push(s[n][2*u]),e.uvs[n].push(s[n][2*u+1])}))}addMorphTargets(e,t,n,r){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const i=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const o=Fc.Objects.Geometry[n.geoID];void 0!==o&&i.genMorphGeometry(e,t,o,r,n.name)}))}))}genMorphGeometry(e,t,n,r,i){const o=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],s=void 0!==n.Vertices?n.Vertices.a:[],a=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<a.length;e++){const t=3*a[e];c[t]=s[3*e],c[t+1]=s[3*e+1],c[t+2]=s[3*e+2]}const u={vertexIndices:o,vertexPositions:c},h=this.genBuffers(u),d=new wn(h.vertex,3);d.name=i||n.attrName,d.applyMatrix4(r),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let i=[];return"IndexToDirect"===n&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let i=[];return"IndexToDirect"===n&&(i=e.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let i=[];"IndexToDirect"===n&&(i=e.ColorIndex.a);for(let e=0,t=new yn;e<r.length;e+=4)t.fromArray(r,e).convertSRGBToLinear().toArray(r,e);return{dataSize:4,buffer:r,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,i=[];for(let e=0;e<r.length;++e)i.push(e);return{dataSize:1,buffer:r,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new On;const n=t-1,r=e.KnotVector.a,i=[],o=e.Points.a;for(let e=0,t=o.length;e<t;e+=4)i.push((new Xe).fromArray(o,e));let s,a;if("Closed"===e.Form)i.push(i[0]);else if("Periodic"===e.Form){s=n,a=r.length-1-s;for(let e=0;e<n;++e)i.push(i[e])}const l=new kc(n,r,i,s,a).getPoints(12*i.length);return(new On).setFromPoints(l)}}class Wc{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const r=t[n],i=this.addClip(r);e.push(i)}return e}parseClips(){if(void 0===Fc.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Fc.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Fc.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(Zc),values:t[n].KeyValueFloat.a},i=Gc.get(r.id);if(void 0!==i){const t=i.parents[0].ID,n=i.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=r:n.match(/Y/)?e.get(t).curves.y=r:n.match(/Z/)?e.get(t).curves.z=r:n.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=r)}}}parseAnimationLayers(e){const t=Fc.Objects.AnimationLayer,n=new Map;for(const r in t){const t=[],i=Gc.get(parseInt(r));if(void 0!==i){i.children.forEach((function(n,r){if(e.has(n.ID)){const i=e.get(n.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===t[r]){const e=Gc.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const i=Fc.Objects.Model[e.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const o={modelName:i.attrName?Fl.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Bc.traverse((function(e){e.ID===i.id&&(o.transform=e.matrix,e.userData.transformData&&(o.eulerOrder=e.userData.transformData.eulerOrder))})),o.transform||(o.transform=new At),"PreRotation"in i&&(o.preRotation=i.PreRotation.value),"PostRotation"in i&&(o.postRotation=i.PostRotation.value),t[r]=o}}t[r]&&(t[r][i.attr]=i)}else if(void 0!==i.curves.morph){if(void 0===t[r]){const e=Gc.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,i=Gc.get(e).parents[0].ID,o=Gc.get(i).parents[0].ID,s=Gc.get(o).parents[0].ID,a=Fc.Objects.Model[s],l={modelName:a.attrName?Fl.sanitizeNodeName(a.attrName):"",morphName:Fc.Objects.Deformer[e].attrName};t[r]=l}t[r][i.attr]=i}}})),n.set(parseInt(r),t)}}return n}parseAnimStacks(e){const t=Fc.Objects.AnimationStack,n={};for(const r in t){const i=Gc.get(parseInt(r)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=e.get(i[0].ID);n[r]={name:t[r].attrName,layer:o}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new rl(e.name,-1,t)}generateTracks(e){const t=[];let n=new Je,r=new Ze,i=new Je;if(e.transform&&e.transform.decompose(n,r,i),n=n.toArray(),r=(new kt).setFromQuaternion(r,e.eulerOrder).toArray(),i=i.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==r&&t.push(r)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,r){const i=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(i,t,n);return new nl(e+"."+r,i,o)}generateRotationTrack(e,t,n,r,i,o){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(be.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(be.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(be.degToRad));const s=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(s,t,n);void 0!==r&&((r=r.map(be.degToRad)).push(o),r=(new kt).fromArray(r),r=(new Ze).setFromEuler(r)),void 0!==i&&((i=i.map(be.degToRad)).push(o),i=(new kt).fromArray(i),i=(new Ze).setFromEuler(i).invert());const l=new Ze,c=new kt,u=[];for(let e=0;e<a.length;e+=3)c.set(a[e],a[e+1],a[e+2],o),l.setFromEuler(c),void 0!==r&&l.premultiply(r),void 0!==i&&l.multiply(i),l.toArray(u,e/3*4);return new el(e+".quaternion",s,u)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),r=Bc.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new $a(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){const i=t[r];i!==n&&(t[e]=i,n=i,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const r=n,i=[];let o=-1,s=-1,a=-1;return e.forEach((function(e){if(t.x&&(o=t.x.times.indexOf(e)),t.y&&(s=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==o){const e=t.x.values[o];i.push(e),r[0]=e}else i.push(r[0]);if(-1!==s){const e=t.y.values[s];i.push(e),r[1]=e}else i.push(r[1]);if(-1!==a){const e=t.z.values[a];i.push(e),r[2]=e}else i.push(r[2])})),i}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],r=e.values[t]-n,i=Math.abs(r);if(i>=180){const o=i/180,s=r/o;let a=n+s;const l=e.times[t-1],c=(e.times[t]-l)/o;let u=l+c;const h=[],d=[];for(;u<e.times[t];)h.push(u),u+=c,d.push(a),a+=s;e.times=ou(e.times,t,h),e.values=ou(e.values,t,d)}}}}class jc{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Yc,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,r){const i=e.match(/^[\s\t]*;/),o=e.match(/^[\s\t]*$/);if(i||o)return;const s=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");s?t.parseNodeBegin(e,s):a?t.parseNodeProperty(e,a,n[++r]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),i={name:n},o=this.parseNodeAttr(r),s=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,i):n in s?("PoseNode"===n?s.PoseNode.push(i):void 0!==s[n].id&&(s[n]={},s[n][s[n].id]=s[n]),""!==o.id&&(s[n][o.id]=i)):"number"==typeof o.id?(s[n]={},s[n][o.id]=i):"Properties70"!==n&&(s[n]="PoseNode"===n?[i]:i),"number"==typeof o.id&&(i.id=o.id),""!==o.name&&(i.attrName=o.name),""!==o.type&&(i.attrType=o.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===r){const e=i.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let s=i.split(",").slice(3);s=s.map((function(e){return e.trim().replace(/^"/,"")})),r="connections",i=[t,n],function(e,t){for(let n=0,r=e.length,i=t.length;n<i;n++,r++)e[r]=t[n]}(i,s),void 0===o[r]&&(o[r]=[])}"Node"===r&&(o.id=i),r in o&&Array.isArray(o[r])?o[r].push(i):"a"!==r?o[r]=i:o.a=i,this.setCurrentProp(o,r),"a"===r&&","!==i.slice(-1)&&(o.a=ru(i))}else this.parseNodeSpecialProperty(e,r,i)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=ru(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),i=r[0],o=r[1],s=r[2],a=r[3];let l=r[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=ru(l)}this.getPrevNode()[i]={type:o,type2:s,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class Xc{parse(e){const t=new qc(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new Yc;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),s=e.getString(o);if(0===r)return null;const a=[];for(let t=0;t<i;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(n.singleProperty=1===i&&e.getOffset()===r;r>e.getOffset();){const r=this.parseNode(e,t);null!==r&&this.parseSubNode(s,n,r)}return n.propertyList=a,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==u&&(n.attrType=u),""!==s&&(n.name=s),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],o=n.propertyList[3];let s;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),s="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:i,flag:o,value:s}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),i=e.getUint32(),o=e.getUint32();if(0===i)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}const s=Sc(new Uint8Array(e.getArrayBuffer(o))),a=new qc(s.buffer);switch(t){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class qc{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}}class Yc{add(e,t){this[e]=t}}function Kc(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Zc(e){return e/46186158e3}const Jc=[];function $c(e,t,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=e;break;case"ByPolygon":i=t;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const o=i*r.dataSize,s=o+r.dataSize;return function(e,t,n,r){for(let i=n,o=0;i<r;i++,o++)e[o]=t[i];return e}(Jc,r.buffer,o,s)}const Qc=new kt,eu=new Je;function tu(e){const t=new At,n=new At,r=new At,i=new At,o=new At,s=new At,a=new At,l=new At,c=new At,u=new At,h=new At,d=new At,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(eu.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(be.degToRad);t.push(e.eulerOrder||kt.DEFAULT_ORDER),n.makeRotationFromEuler(Qc.fromArray(t))}if(e.rotation){const t=e.rotation.map(be.degToRad);t.push(e.eulerOrder||kt.DEFAULT_ORDER),r.makeRotationFromEuler(Qc.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(be.degToRad);t.push(e.eulerOrder||kt.DEFAULT_ORDER),i.makeRotationFromEuler(Qc.fromArray(t)),i.invert()}e.scale&&o.scale(eu.fromArray(e.scale)),e.scalingOffset&&a.setPosition(eu.fromArray(e.scalingOffset)),e.scalingPivot&&s.setPosition(eu.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(eu.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(eu.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(h.copy(e.parentMatrix),u.copy(e.parentMatrixWorld));const f=n.clone().multiply(r).multiply(i),m=new At;m.extractRotation(u);const g=new At;g.copyPosition(u);const v=g.clone().invert().multiply(u),y=m.clone().invert().multiply(v),x=o,_=new At;if(0===p)_.copy(m).multiply(f).multiply(y).multiply(x);else if(1===p)_.copy(m).multiply(y).multiply(f).multiply(x);else{const e=(new At).scale((new Je).setFromMatrixScale(h)).clone().invert(),t=y.clone().multiply(e);_.copy(m).multiply(f).multiply(t).multiply(x)}const T=c.clone().invert(),E=s.clone().invert();let M=t.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(T).multiply(a).multiply(s).multiply(o).multiply(E);const b=(new At).copyPosition(M),S=u.clone().multiply(b);return d.copyPosition(S),M=d.clone().multiply(_),M.premultiply(u.invert()),M}function nu(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function ru(e){return e.split(",").map((function(e){return parseFloat(e)}))}function iu(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}function ou(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class su extends ll{constructor(e){super(e)}load(e,t,n,r){const i=this,o=""===i.path?Pl.extractUrlBase(e):i.path,s=new hl(i.manager);s.setPath(i.path),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(n){try{t(i.parse(n,o))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e,t){function n(e,t){const n=[],r=e.childNodes;for(let e=0,i=r.length;e<i;e++){const i=r[e];i.nodeName===t&&n.push(i)}return n}function r(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=t[e];return n}function i(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseFloat(t[e]);return n}function o(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let e=0,r=t.length;e<r;e++)n[e]=parseInt(t[e]);return n}function a(e){return e.substring(1)}function c(e){return 0===Object.keys(e).length}function u(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function h(e){return void 0!==e?e.textContent:"Y_UP"}function d(e,t,r,i){const o=n(e,t)[0];if(void 0!==o){const e=n(o,r);for(let t=0;t<e.length;t++)i(e[t])}}function p(e,t){for(const n in e){e[n].build=t(e[n])}}function f(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function m(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=a(r.getAttribute("source")),n=r.getAttribute("semantic");t.inputs[n]=e}}return t}function g(e){const t={};let n=e.getAttribute("target").split("/");const r=n.shift();let i=n.shift();const o=-1!==i.indexOf("("),s=-1!==i.indexOf(".");if(s)n=i.split("."),i=n.shift(),t.member=n.shift();else if(o){const e=i.split("(");i=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=r,t.sid=i,t.arraySyntax=o,t.memberSyntax=s,t.sampler=a(e.getAttribute("source")),t}function v(e){const t=[],n=e.channels,r=e.samplers,i=e.sources;for(const e in n)if(n.hasOwnProperty(e)){const o=n[e],s=r[o.sampler],a=s.inputs.INPUT,l=s.inputs.OUTPUT;M(x(o,i[a],i[l]),t)}return t}function y(e){return f(at.animations[e],v)}function x(e,t,n){const r=at.nodes[e.id],i=We(r.id),o=r.transforms[e.sid],s=r.matrix.clone().transpose();let a,l,c,u,h,d;const p={};switch(o){case"matrix":for(c=0,u=t.array.length;c<u;c++)if(a=t.array[c],l=c*n.stride,void 0===p[a]&&(p[a]={}),!0===e.arraySyntax){const t=n.array[l],r=e.indices[0]+4*e.indices[1];p[a][r]=t}else for(h=0,d=n.stride;h<d;h++)p[a][h]=n.array[l+h];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',o)}const f=function(e,t){const n=[];for(const t in e)n.push({time:parseFloat(t),value:e[t]});n.sort(r);for(let e=0;e<16;e++)w(n,e,t.elements[e]);return n;function r(e,t){return e.time-t.time}}(p,s);return{name:i.uuid,keyframes:f}}const _=new Je,T=new Je,E=new Ze;function M(e,t){const n=e.keyframes,r=e.name,i=[],o=[],s=[],a=[];for(let e=0,t=n.length;e<t;e++){const t=n[e],r=t.time,l=t.value;Ne.fromArray(l).transpose(),Ne.decompose(_,E,T),i.push(r),o.push(_.x,_.y,_.z),s.push(E.x,E.y,E.z,E.w),a.push(T.x,T.y,T.z)}return o.length>0&&t.push(new nl(r+".position",i,o)),s.length>0&&t.push(new el(r+".quaternion",i,s)),a.length>0&&t.push(new nl(r+".scale",i,a)),t}function w(e,t,n){let r,i,o,s=!0;for(i=0,o=e.length;i<o;i++)r=e[i],void 0===r.value[t]?r.value[t]=null:s=!1;if(!0===s)for(i=0,o=e.length;i<o;i++)r=e[i],r.value[t]=n;else!function(e,t){let n,r;for(let i=0,o=e.length;i<o;i++){const o=e[i];if(null===o.value[t]){if(n=A(e,i,t),r=C(e,i,t),null===n){o.value[t]=r.value[t];continue}if(null===r){o.value[t]=n.value[t];continue}R(o,n,r,t)}}}(e,t)}function A(e,t,n){for(;t>=0;){const r=e[t];if(null!==r.value[n])return r;t--}return null}function C(e,t,n){for(;t<e.length;){const r=e[t];if(null!==r.value[n])return r;t++}return null}function R(e,t,n,r){n.time-t.time!=0?e.value[r]=(e.time-t.time)*(n.value[r]-t.value[r])/(n.time-t.time)+t.value[r]:e.value[r]=t.value[r]}function I(e){const t=[],n=e.name,r=e.end-e.start||-1,i=e.animations;for(let e=0,n=i.length;e<n;e++){const n=y(i[e]);for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return new rl(n,r,t)}function P(e){return f(at.clips[e],I)}function L(e){const t={sources:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=i(r.textContent);break;case"source":const e=r.getAttribute("id");t.sources[e]=he(r);break;case"joints":t.joints=N(r);break;case"vertex_weights":t.vertexWeights=O(r)}}return t}function N(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"input"===r.nodeName){const e=r.getAttribute("semantic"),n=a(r.getAttribute("source"));t.inputs[e]=n}}return t}function O(e){const t={inputs:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=r.getAttribute("semantic"),n=a(r.getAttribute("source")),i=parseInt(r.getAttribute("offset"));t.inputs[e]={id:n,offset:i};break;case"vcount":t.vcount=o(r.textContent);break;case"v":t.v=o(r.textContent)}}return t}function U(e){const t={id:e.id},n=at.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){const t=4,n={joints:[],indices:{array:[],stride:t},weights:{array:[],stride:t}},r=e.sources,i=e.vertexWeights,o=i.vcount,s=i.v,a=i.inputs.JOINT.offset,l=i.inputs.WEIGHT.offset,c=e.sources[e.joints.inputs.JOINT],u=e.sources[e.joints.inputs.INV_BIND_MATRIX],h=r[i.inputs.WEIGHT.id].array;let d,p,f,m=0;for(d=0,f=o.length;d<f;d++){const e=o[d],r=[];for(p=0;p<e;p++){const e=s[m+a],t=h[s[m+l]];r.push({index:e,weight:t}),m+=2}for(r.sort(g),p=0;p<t;p++){const e=r[p];void 0!==e?(n.indices.array.push(e.index),n.weights.array.push(e.weight)):(n.indices.array.push(0),n.weights.array.push(0))}}e.bindShapeMatrix?n.bindMatrix=(new At).fromArray(e.bindShapeMatrix).transpose():n.bindMatrix=(new At).identity();for(d=0,f=c.array.length;d<f;d++){const e=c.array[d],t=(new At).fromArray(u.array,d*u.stride).transpose();n.joints.push({name:e,boneInverse:t})}return n;function g(e,t){return t.weight-e.weight}}(e.skin),n.sources.skinIndices=t.skin.indices,n.sources.skinWeights=t.skin.weights),t}function D(e){return f(at.controllers[e],U)}function k(e){return void 0!==e.build?e.build:e.init_from}function F(e){const t=at.images[e];return void 0!==t?f(t,k):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function G(e){const t={surfaces:{},samplers:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"newparam":B(r,t);break;case"technique":t.technique=H(r);break;case"extra":t.extra=K(r)}}return t}function B(e,t){const n=e.getAttribute("sid");for(let r=0,i=e.childNodes.length;r<i;r++){const i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"surface":t.surfaces[n]=V(i);break;case"sampler2D":t.samplers[n]=z(i)}}}function V(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"init_from"===r.nodeName)t.init_from=r.textContent}return t}function z(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"source"===r.nodeName)t.source=r.textContent}return t}function H(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=r.nodeName,t.parameters=W(r);break;case"extra":t.extra=K(r)}}return t}function W(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[r.nodeName]=j(r);break;case"transparent":t[r.nodeName]={opaque:r.hasAttribute("opaque")?r.getAttribute("opaque"):"A_ONE",data:j(r)}}}return t}function j(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"color":t[r.nodeName]=i(r.textContent);break;case"float":t[r.nodeName]=parseFloat(r.textContent);break;case"texture":t[r.nodeName]={id:r.getAttribute("texture"),extra:X(r)}}}return t}function X(e){const t={technique:{}};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"extra"===r.nodeName)q(r,t)}return t}function q(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)Y(r,t)}}function Y(e,t){for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[r.nodeName]=parseFloat(r.textContent);break;case"wrapU":case"wrapV":"TRUE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=1:"FALSE"===r.textContent.toUpperCase()?t.technique[r.nodeName]=0:t.technique[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=J(r)}}}function K(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique"===r.nodeName)t.technique=Z(r)}return t}function Z(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"double_sided":t[r.nodeName]=parseInt(r.textContent);break;case"bump":t[r.nodeName]=J(r)}}return t}function J(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"texture"===r.nodeName)t[r.nodeName]={id:r.getAttribute("texture"),texcoord:r.getAttribute("texcoord"),extra:X(r)}}return t}function $(e){return e}function Q(e){const t=function(e){return f(at.effects[e],$)}(e.url),n=t.profile.technique;let r;switch(n.type){case"phong":case"blinn":r=new ka;break;case"lambert":r=new Fa;break;default:r=new _n}function i(e,n=null){const r=t.profile.samplers[e.id];let i=null;if(void 0!==r){i=F(t.profile.surfaces[r.source].init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),i=F(e.id);if(null!==i){const t=function(e){let t,n=e.slice(2+(e.lastIndexOf(".")-1>>>0));n=n.toLowerCase(),t="tga"===n?nt:tt;return t}(i);if(void 0!==t){const r=t.load(i),o=e.extra;if(void 0!==o&&void 0!==o.technique&&!1===c(o.technique)){const e=o.technique;r.wrapS=e.wrapU?b:S,r.wrapT=e.wrapV?b:S,r.offset.set(e.offsetU||0,e.offsetV||0),r.repeat.set(e.repeatU||1,e.repeatV||1)}else r.wrapS=b,r.wrapT=b;return null!==n&&(r.colorSpace=n),r}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",i),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}r.name=e.name||"";const o=n.parameters;for(const e in o){const t=o[e];switch(e){case"diffuse":t.color&&r.color.fromArray(t.color),t.texture&&(r.map=i(t.texture,te));break;case"specular":t.color&&r.specular&&r.specular.fromArray(t.color),t.texture&&(r.specularMap=i(t.texture));break;case"bump":t.texture&&(r.normalMap=i(t.texture));break;case"ambient":t.texture&&(r.lightMap=i(t.texture,te));break;case"shininess":t.float&&r.shininess&&(r.shininess=t.float);break;case"emission":t.color&&r.emissive&&r.emissive.fromArray(t.color),t.texture&&(r.emissiveMap=i(t.texture,te))}}r.color.convertSRGBToLinear(),r.specular&&r.specular.convertSRGBToLinear(),r.emissive&&r.emissive.convertSRGBToLinear();let a=o.transparent,u=o.transparency;if(void 0===u&&a&&(u={float:1}),void 0===a&&u&&(a={opaque:"A_ONE",data:{color:[1,1,1,1]}}),a&&u)if(a.data.texture)r.transparent=!0;else{const e=a.data.color;switch(a.opaque){case"A_ONE":r.opacity=e[3]*u.float;break;case"RGB_ZERO":r.opacity=1-e[0]*u.float;break;case"A_ZERO":r.opacity=1-e[3]*u.float;break;case"RGB_ONE":r.opacity=e[0]*u.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',a.opaque)}r.opacity<1&&(r.transparent=!0)}if(void 0!==n.extra&&void 0!==n.extra.technique){const e=n.extra.technique;for(const t in e){const n=e[t];switch(t){case"double_sided":r.side=1===n?l:s;break;case"bump":r.normalMap=i(n.texture),r.normalScale=new Se(1,1)}}}return r}function ee(e){return f(at.materials[e],Q)}function ne(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("technique_common"===n.nodeName)return re(n)}return{}}function re(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"perspective":case"orthographic":t.technique=r.nodeName,t.parameters=ie(r)}}return t}function ie(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[r.nodeName]=parseFloat(r.textContent)}}return t}function oe(e){let t;switch(e.optics.technique){case"perspective":t=new ar(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":let n=e.optics.parameters.ymag,r=e.optics.parameters.xmag;const i=e.optics.parameters.aspect_ratio;r=void 0===r?n*i:r,n=void 0===n?r/i:n,r*=.5,n*=.5,t=new Lr(-r,r,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new ar}return t.name=e.name||"",t}function se(e){const t=at.cameras[e];return void 0!==t?f(t,oe):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function ae(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=r.nodeName,t.parameters=le(r)}}return t}function le(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"color":const e=i(r.textContent);t.color=(new yn).fromArray(e).convertSRGBToLinear();break;case"falloff_angle":t.falloffAngle=parseFloat(r.textContent);break;case"quadratic_attenuation":const n=parseFloat(r.textContent);t.distance=n?Math.sqrt(1/n):0}}return t}function ce(e){let t;switch(e.technique){case"directional":t=new Rl;break;case"point":t=new Al;break;case"spot":t=new El;break;case"ambient":t=new Il}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function ue(e){const t=at.lights[e];return void 0!==t?f(t,ce):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function he(e){const t={array:[],stride:3};for(let o=0;o<e.childNodes.length;o++){const s=e.childNodes[o];if(1===s.nodeType)switch(s.nodeName){case"float_array":t.array=i(s.textContent);break;case"Name_array":t.array=r(s.textContent);break;case"technique_common":const e=n(s,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function de(e){const t={};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];1===r.nodeType&&(t[r.getAttribute("semantic")]=a(r.getAttribute("source")))}return t}function pe(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"input":const e=a(r.getAttribute("source")),n=r.getAttribute("semantic"),i=parseInt(r.getAttribute("offset")),s=parseInt(r.getAttribute("set")),l=s>0?n+s:n;t.inputs[l]={id:e,offset:i},t.stride=Math.max(t.stride,i+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=o(r.textContent);break;case"p":t.p=o(r.textContent)}}return t}function fe(e){let t=0;for(let n=0,r=e.length;n<r;n++){!0===e[n].hasUV&&t++}t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function me(e){const t={},n=e.sources,r=e.vertices,i=e.primitives;if(0===i.length)return{};const o=function(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];void 0===t[r.type]&&(t[r.type]=[]),t[r.type].push(r)}return t}(i);for(const e in o){const i=o[e];fe(i),t[e]=ge(i,n,r)}return t}function ge(e,t,n){const r={},i={array:[],stride:0},o={array:[],stride:0},s={array:[],stride:0},a={array:[],stride:0},l={array:[],stride:0},c=[],u=4,h=[],d=4,p=new On,f=[];let m=0;for(let r=0;r<e.length;r++){const u=e[r],d=u.inputs;let g=0;switch(u.type){case"lines":case"linestrips":g=2*u.count;break;case"triangles":g=3*u.count;break;case"polylist":for(let e=0;e<u.count;e++){const t=u.vcount[e];switch(t){case 3:g+=3;break;case 4:g+=6;break;default:g+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",u.type)}p.addGroup(m,g,r),m+=g,u.material&&f.push(u.material);for(const r in d){const p=d[r];switch(r){case"VERTEX":for(const r in n){const d=n[r];switch(r){case"POSITION":const n=i.array.length;if(ve(u,t[d],p.offset,i.array),i.stride=t[d].stride,t.skinWeights&&t.skinIndices&&(ve(u,t.skinIndices,p.offset,c),ve(u,t.skinWeights,p.offset,h)),!1===u.hasUV&&!0===e.uvsNeedsFix){const e=(i.array.length-n)/i.stride;for(let t=0;t<e;t++)s.array.push(0,0)}break;case"NORMAL":ve(u,t[d],p.offset,o.array),o.stride=t[d].stride;break;case"COLOR":ve(u,t[d],p.offset,l.array),l.stride=t[d].stride;break;case"TEXCOORD":ve(u,t[d],p.offset,s.array),s.stride=t[d].stride;break;case"TEXCOORD1":ve(u,t[d],p.offset,a.array),s.stride=t[d].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',r)}}break;case"NORMAL":ve(u,t[p.id],p.offset,o.array),o.stride=t[p.id].stride;break;case"COLOR":ve(u,t[p.id],p.offset,l.array,!0),l.stride=t[p.id].stride;break;case"TEXCOORD":ve(u,t[p.id],p.offset,s.array),s.stride=t[p.id].stride;break;case"TEXCOORD1":ve(u,t[p.id],p.offset,a.array),a.stride=t[p.id].stride}}}return i.array.length>0&&p.setAttribute("position",new wn(i.array,i.stride)),o.array.length>0&&p.setAttribute("normal",new wn(o.array,o.stride)),l.array.length>0&&p.setAttribute("color",new wn(l.array,l.stride)),s.array.length>0&&p.setAttribute("uv",new wn(s.array,s.stride)),a.array.length>0&&p.setAttribute("uv1",new wn(a.array,a.stride)),c.length>0&&p.setAttribute("skinIndex",new wn(c,u)),h.length>0&&p.setAttribute("skinWeight",new wn(h,d)),r.data=p,r.type=e[0].type,r.materialKeys=f,r}function ve(e,t,n,r,i=!1){const o=e.p,s=e.stride,a=e.vcount;function l(e){let t=o[e+n]*u;const s=t+u;for(;t<s;t++)r.push(c[t]);if(i){const e=r.length-u-1;rt.setRGB(r[e+0],r[e+1],r[e+2]).convertSRGBToLinear(),r[e+0]=rt.r,r[e+1]=rt.g,r[e+2]=rt.b}}const c=t.array,u=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=a.length;t<n;t++){const n=a[t];if(4===n){const t=e+1*s,n=e+2*s,r=e+3*s;l(e+0*s),l(t),l(r),l(t),l(n),l(r)}else if(3===n){const t=e+1*s,n=e+2*s;l(e+0*s),l(t),l(n)}else if(n>4)for(let t=1,r=n-2;t<=r;t++){const n=e+s*t,r=e+s*(t+1);l(e+0*s),l(n),l(r)}e+=s*n}}else for(let e=0,t=o.length;e<t;e+=s)l(e)}function ye(e){return f(at.geometries[e],me)}function xe(e){return void 0!==e.build?e.build:e}function _e(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"joint":t.joints[r.getAttribute("sid")]=Te(r);break;case"link":t.links.push(Me(r))}}}function Te(e){let t;for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"prismatic":case"revolute":t=Ee(r)}}return t}function Ee(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new Je,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"axis":const e=i(r.textContent);t.axis.fromArray(e);break;case"limits":const n=r.getElementsByTagName("max")[0],o=r.getElementsByTagName("min")[0];t.limits.max=parseFloat(n.textContent),t.limits.min=parseFloat(o.textContent)}}return t.limits.min>=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function Me(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"attachment_full":t.attachments.push(we(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(Ae(r))}}return t}function we(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"link":t.links.push(Me(r));break;case"matrix":case"translate":case"rotate":t.transforms.push(Ae(r))}}return t}function Ae(e){const t={type:e.nodeName},n=i(e.textContent);switch(t.type){case"matrix":t.obj=new At,t.obj.fromArray(n).transpose();break;case"translate":t.obj=new Je,t.obj.fromArray(n);break;case"rotate":t.obj=new Je,t.obj.fromArray(n),t.angle=be.degToRad(n[3])}return t}function Ce(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)Re(r,t)}}function Re(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"inertia":t.inertia=i(r.textContent);break;case"mass":t.mass=i(r.textContent)[0]}}}function Ie(e){const t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"axis"===r.nodeName){const e=r.getElementsByTagName("param")[0];t.axis=e.textContent;const n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substring(0,n.length-1)}}return t}function Pe(e){return void 0!==e.build?e.build:e}function Le(e){const t=[],n=Ke.querySelector('[id="'+e.id+'"]');for(let e=0;e<n.childNodes.length;e++){const r=n.childNodes[e];if(1!==r.nodeType)continue;let o,s;switch(r.nodeName){case"matrix":o=i(r.textContent);const e=(new At).fromArray(o).transpose();t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:e});break;case"translate":case"scale":o=i(r.textContent),s=(new Je).fromArray(o),t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:s});break;case"rotate":o=i(r.textContent),s=(new Je).fromArray(o);const n=be.degToRad(o[3]);t.push({sid:r.getAttribute("sid"),type:r.nodeName,obj:s,angle:n})}}return t}const Ne=new At,Oe=new Je;function Ue(e){const t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new At,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1!==r.nodeType)continue;let o;switch(r.nodeName){case"node":t.nodes.push(r.getAttribute("id")),Ue(r);break;case"instance_camera":t.instanceCameras.push(a(r.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(De(r));break;case"instance_light":t.instanceLights.push(a(r.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(De(r));break;case"instance_node":t.instanceNodes.push(a(r.getAttribute("url")));break;case"matrix":o=i(r.textContent),t.matrix.multiply(Ne.fromArray(o).transpose()),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"translate":o=i(r.textContent),Oe.fromArray(o),t.matrix.multiply(Ne.makeTranslation(Oe.x,Oe.y,Oe.z)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"rotate":o=i(r.textContent);const e=be.degToRad(o[3]);t.matrix.multiply(Ne.makeRotationAxis(Oe.fromArray(o),e)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"scale":o=i(r.textContent),t.matrix.scale(Oe.fromArray(o)),t.transforms[r.getAttribute("sid")]=r.nodeName;break;case"extra":break;default:console.log(r)}}return He(t.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",t.id):at.nodes[t.id]=t,t}function De(e){const t={id:a(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];switch(r.nodeName){case"bind_material":const e=r.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){const r=e[n],i=r.getAttribute("symbol"),o=r.getAttribute("target");t.materials[i]=a(o)}break;case"skeleton":t.skeletons.push(a(r.textContent))}}return t}function ke(e,t){const n=[],r=[];let i,o,s;for(i=0;i<e.length;i++){const r=e[i];let o;if(He(r))o=We(r),Fe(o,t,n);else if(Xe(r)){const e=at.visualScenes[r].children;for(let r=0;r<e.length;r++){const i=e[r];if("JOINT"===i.type){Fe(We(i.id),t,n)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",r)}for(i=0;i<t.length;i++)for(o=0;o<n.length;o++)if(s=n[o],s.bone.name===t[i].name){r[i]=s,s.processed=!0;break}for(i=0;i<n.length;i++)s=n[i],!1===s.processed&&(r.push(s),s.processed=!0);const a=[],l=[];for(i=0;i<r.length;i++)s=r[i],a.push(s.bone),l.push(s.boneInverse);return new ms(a,l)}function Fe(e,t,n){e.traverse((function(e){if(!0===e.isBone){let r;for(let n=0;n<t.length;n++){const i=t[n];if(i.name===e.name){r=i.boneInverse;break}}void 0===r&&(r=new At),n.push({bone:e,boneInverse:r,processed:!1})}}))}function Ge(e){const t=[],n=e.matrix,r=e.nodes,i=e.type,o=e.instanceCameras,s=e.instanceControllers,a=e.instanceLights,l=e.instanceGeometries,c=e.instanceNodes;for(let e=0,n=r.length;e<n;e++)t.push(We(r[e]));for(let e=0,n=o.length;e<n;e++){const n=se(o[e]);null!==n&&t.push(n.clone())}for(let e=0,n=s.length;e<n;e++){const n=s[e],r=D(n.id),i=ze(ye(r.id),n.materials),o=ke(n.skeletons,r.skin.joints);for(let e=0,n=i.length;e<n;e++){const n=i[e];n.isSkinnedMesh&&(n.bind(o,r.skin.bindMatrix),n.normalizeSkinWeights()),t.push(n)}}for(let e=0,n=a.length;e<n;e++){const n=ue(a[e]);null!==n&&t.push(n.clone())}for(let e=0,n=l.length;e<n;e++){const n=l[e],r=ze(ye(n.id),n.materials);for(let e=0,n=r.length;e<n;e++)t.push(r[e])}for(let e=0,n=c.length;e<n;e++)t.push(We(c[e]).clone());let u;if(0===r.length&&1===t.length)u=t[0];else{u="JOINT"===i?new hs:new jo;for(let e=0;e<t.length;e++)u.add(t[e])}return u.name="JOINT"===i?e.sid:e.name,u.matrix.copy(n),u.matrix.decompose(u.position,u.quaternion,u.scale),u}const Be=new _n({color:16711935});function Ve(e,t){const n=[];for(let r=0,i=e.length;r<i;r++){const i=t[e[r]];void 0===i?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[r]),n.push(Be)):n.push(ee(i))}return n}function ze(e,t){const n=[];for(const r in e){const i=e[r],o=Ve(i.materialKeys,t);if(0===o.length&&("lines"===r||"linestrips"===r?o.push(new gs):o.push(new ka)),"lines"===r||"linestrips"===r)for(let e=0,t=o.length;e<t;e++){const t=o[e];if(!0===t.isMeshPhongMaterial||!0===t.isMeshLambertMaterial){const n=new gs;n.color.copy(t.color),n.opacity=t.opacity,n.transparent=t.transparent,o[e]=n}}const s=void 0!==i.data.attributes.skinIndex,a=1===o.length?o[0]:o;let l;switch(r){case"lines":l=new Ss(i.data,a);break;case"linestrips":l=new Es(i.data,a);break;case"triangles":case"polylist":l=s?new us(i.data,a):new $n(i.data,a)}n.push(l)}return n}function He(e){return void 0!==at.nodes[e]}function We(e){return f(at.nodes[e],Ge)}function je(e){const t=new jo;t.name=e.name;const n=e.children;for(let e=0;e<n.length;e++){const r=n[e];t.add(We(r.id))}return t}function Xe(e){return void 0!==at.visualScenes[e]}function qe(e){return f(at.visualScenes[e],je)}if(0===e.length)return{scene:new es};const Ye=(new DOMParser).parseFromString(e,"application/xml"),Ke=n(Ye,"COLLADA")[0],$e=Ye.getElementsByTagName("parsererror")[0];if(void 0!==$e){const e=n($e,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const n=[e];for(;n.length;){const e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}($e),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",t),null}const Qe=Ke.getAttribute("version");console.debug("THREE.ColladaLoader: File version",Qe);const et=function(e){return{unit:u(n(e,"unit")[0]),upAxis:h(n(e,"up_axis")[0])}}(n(Ke,"asset")[0]),tt=new ml(this.manager);let nt;tt.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),jl&&(nt=new jl(this.manager),nt.setPath(this.resourcePath||t));const rt=new yn,it=[];let ot={},st=0;const at={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};d(Ke,"library_animations","animation",(function e(t){const n={sources:{},samplers:{},channels:{}};let r=!1;for(let i=0,o=t.childNodes.length;i<o;i++){const o=t.childNodes[i];if(1!==o.nodeType)continue;let s;switch(o.nodeName){case"source":s=o.getAttribute("id"),n.sources[s]=he(o);break;case"sampler":s=o.getAttribute("id"),n.samplers[s]=m(o);break;case"channel":s=o.getAttribute("target"),n.channels[s]=g(o);break;case"animation":e(o),r=!0;break;default:console.log(o)}}!1===r&&(at.animations[t.getAttribute("id")||be.generateUUID()]=n)})),d(Ke,"library_animation_clips","animation_clip",(function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"instance_animation"===r.nodeName)t.animations.push(a(r.getAttribute("url")))}at.clips[e.getAttribute("id")]=t})),d(Ke,"library_controllers","controller",(function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"skin":t.id=a(r.getAttribute("source")),t.skin=L(r);break;case"morph":t.id=a(r.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}at.controllers[e.getAttribute("id")]=t})),d(Ke,"library_images","image",(function(e){const t={init_from:n(e,"init_from")[0].textContent};at.images[e.getAttribute("id")]=t})),d(Ke,"library_effects","effect",(function(e){const t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"profile_COMMON"===r.nodeName)t.profile=G(r)}at.effects[e.getAttribute("id")]=t})),d(Ke,"library_materials","material",(function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"instance_effect"===r.nodeName)t.url=a(r.getAttribute("url"))}at.materials[e.getAttribute("id")]=t})),d(Ke,"library_cameras","camera",(function(e){const t={name:e.getAttribute("name")};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"optics"===r.nodeName)t.optics=ne(r)}at.cameras[e.getAttribute("id")]=t})),d(Ke,"library_lights","light",(function(e){let t={};for(let n=0,r=e.childNodes.length;n<r;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)t=ae(r)}at.lights[e.getAttribute("id")]=t})),d(Ke,"library_geometries","geometry",(function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},r=n(e,"mesh")[0];if(void 0!==r){for(let e=0;e<r.childNodes.length;e++){const n=r.childNodes[e];if(1!==n.nodeType)continue;const i=n.getAttribute("id");switch(n.nodeName){case"source":t.sources[i]=he(n);break;case"vertices":t.vertices=de(n);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",n.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(pe(n));break;default:console.log(n)}}at.geometries[e.getAttribute("id")]=t}})),d(Ke,"library_nodes","node",Ue),d(Ke,"library_visual_scenes","visual_scene",(function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let e=0;e<t.length;e++){const n=t[e];!1===n.hasAttribute("id")&&n.setAttribute("id","three_default_"+st++)}}(e);const r=n(e,"node");for(let e=0;e<r.length;e++)t.children.push(Ue(r[e]));at.visualScenes[e.getAttribute("id")]=t})),d(Ke,"library_kinematics_models","kinematics_model",(function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"technique_common"===r.nodeName)_e(r,t)}at.kinematicsModels[e.getAttribute("id")]=t})),d(Ke,"library_physics_models","physics_model",(function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"rigid_body"===r.nodeName)t.rigidBodies[r.getAttribute("name")]={},Ce(r,t.rigidBodies[r.getAttribute("name")])}at.physicsModels[e.getAttribute("id")]=t})),d(Ke,"scene","instance_kinematics_scene",(function(e){const t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(1===r.nodeType&&"bind_joint_axis"===r.nodeName)t.bindJointAxis.push(Ie(r))}at.kinematicsScenes[a(e.getAttribute("url"))]=t})),p(at.animations,v),p(at.clips,I),p(at.controllers,U),p(at.images,k),p(at.effects,$),p(at.materials,Q),p(at.cameras,oe),p(at.lights,ce),p(at.geometries,me),p(at.visualScenes,je),function(){const e=at.clips;if(!0===c(e)){if(!1===c(at.animations)){const e=[];for(const t in at.animations){const n=y(t);for(let t=0,r=n.length;t<r;t++)e.push(n[t])}it.push(new rl("default",-1,e))}}else for(const t in e)it.push(P(t))}(),function(){const e=Object.keys(at.kinematicsModels)[0],t=Object.keys(at.kinematicsScenes)[0],n=Object.keys(at.visualScenes)[0];if(void 0===e||void 0===t)return;const r=function(e){return f(at.kinematicsModels[e],xe)}(e),i=function(e){return f(at.kinematicsScenes[e],Pe)}(t),o=qe(n),s=i.bindJointAxis,a={};for(let e=0,t=s.length;e<t;e++){const t=s[e],n=Ke.querySelector('[sid="'+t.target+'"]');if(n){const e=n.parentElement;l(t.jointIndex,e)}}function l(e,t){const n=t.getAttribute("name"),i=r.joints[e];o.traverse((function(r){r.name===n&&(a[e]={object:r,transforms:Le(t),joint:i,position:i.zeroPosition})}))}const c=new At;ot={joints:r&&r.joints,getJointValue:function(e){const t=a[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(e,t){const n=a[e];if(n){const r=n.joint;if(t>r.limits.max||t<r.limits.min)console.warn("THREE.ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+r.limits.min+", max: "+r.limits.max+").");else if(r.static)console.warn("THREE.ColladaLoader: Joint "+e+" is static.");else{const i=n.object,o=r.axis,s=n.transforms;Ne.identity();for(let n=0;n<s.length;n++){const i=s[n];if(i.sid&&-1!==i.sid.indexOf(e))switch(r.type){case"revolute":Ne.multiply(c.makeRotationAxis(o,be.degToRad(t)));break;case"prismatic":Ne.multiply(c.makeTranslation(o.x*t,o.y*t,o.z*t));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+r.type)}else switch(i.type){case"matrix":Ne.multiply(i.obj);break;case"translate":Ne.multiply(c.makeTranslation(i.obj.x,i.obj.y,i.obj.z));break;case"scale":Ne.scale(i.obj);break;case"rotate":Ne.multiply(c.makeRotationAxis(i.obj,i.angle))}}i.matrix.copy(Ne),i.matrix.decompose(i.position,i.quaternion,i.scale),a[e].position=t}}else console.log("THREE.ColladaLoader: "+e+" does not exist.")}}}();const lt=function(e){return qe(a(n(e,"instance_visual_scene")[0].getAttribute("url")))}(n(Ke,"scene")[0]);return lt.animations=it,"Z_UP"===et.upAxis&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),lt.rotation.set(-Math.PI/2,0,0)),lt.scale.multiplyScalar(et.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),it},kinematics:ot,library:at,scene:lt}}}var au=n(594);class lu extends ll{constructor(e){super(e)}load(e,t,n,r){const i=this,o=""===i.path?Pl.extractUrlBase(e):i.path,s=new hl(i.manager);s.setPath(i.path),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(n){try{t(i.parse(n,o))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e,t){const n={};function r(e){e.DEF&&(n[e.DEF]=e);const t=e.fields;for(let e=0,n=t.length;e<n;e++){const n=t[e];if("node"===n.type){const e=n.values;for(let t=0,n=e.length;t<n;t++)r(e[t])}}}function i(e){return e.USE?function(e){const t=n[e],r=i(t);return r.isObject3D||r.isMaterial?r.clone():r}(e.USE):(void 0!==e.build||(e.build=function(e){const t=e.name;let n;switch(t){case"Anchor":case"Group":case"Transform":case"Collision":n=function(e){const t=new jo,n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],i=r.name,o=r.values;switch(i){case"bboxCenter":case"bboxSize":case"center":case"description":case"collide":case"parameter":case"scaleOrientation":case"proxy":case"url":break;case"children":u(o,t);break;case"rotation":const e=new Je(o[0],o[1],o[2]),n=o[3];t.quaternion.setFromAxisAngle(e,n);break;case"scale":t.scale.set(o[0],o[1],o[2]);break;case"translation":t.position.set(o[0],o[1],o[2]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}return t}(e);break;case"Background":n=function(e){const t=new jo;let n,r,i,o;const s=e.fields;for(let e=0,t=s.length;e<t;e++){const t=s[e],a=t.name,l=t.values;switch(a){case"groundAngle":n=l;break;case"groundColor":r=l;break;case"backUrl":case"bottomUrl":case"frontUrl":case"leftUrl":case"rightUrl":case"topUrl":break;case"skyAngle":i=l;break;case"skyColor":o=l;break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}const l=1e4;if(o){const e=new Ua(l,32,16),n=new _n({fog:!1,side:a,depthWrite:!1,depthTest:!1});o.length>3?(O(e,l,i,L(o),!0),n.vertexColors=!0):(n.color.setRGB(o[0],o[1],o[2]),n.color.convertSRGBToLinear());const r=new $n(e,n);t.add(r)}if(r&&r.length>0){const e=new Ua(l,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),i=new _n({fog:!1,side:a,vertexColors:!0,depthWrite:!1,depthTest:!1});O(e,l,n,L(r),!1);const o=new $n(e,i);t.add(o)}return t.renderOrder=-1/0,t}(e);break;case"Shape":n=function(e){const t=e.fields;let n,r,o=new _n({color:0});for(let e=0,r=t.length;e<r;e++){const r=t[e],s=r.name,a=r.values;switch(s){case"appearance":null!==a[0]&&(o=i(a[0]));break;case"geometry":null!==a[0]&&(n=i(a[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}if(n&&n.attributes.position){const e=n._type;if("points"===e){const e=new ws({color:16777215});void 0!==n.attributes.color?e.vertexColors=!0:o.isMeshPhongMaterial&&e.color.copy(o.emissive),r=new Ps(n,e)}else if("line"===e){const e=new gs({color:16777215});void 0!==n.attributes.color?e.vertexColors=!0:o.isMeshPhongMaterial&&e.color.copy(o.emissive),r=new Ss(n,e)}else void 0!==n._solid&&(o.side=n._solid?s:l),void 0!==n.attributes.color&&(o.vertexColors=!0),r=new $n(n,o)}else r=new $t,r.visible=!1;return r}(e);break;case"Appearance":n=function(e){let t,n=new ka;const r=e.fields;for(let e=0,o=r.length;e<o;e++){const o=r[e],s=o.name,a=o.values;switch(s){case"material":if(null!==a[0]){const e=i(a[0]);e.diffuseColor&&n.color.copy(e.diffuseColor),e.emissiveColor&&n.emissive.copy(e.emissiveColor),e.shininess&&(n.shininess=e.shininess),e.specularColor&&n.specular.copy(e.specularColor),e.transparency&&(n.opacity=1-e.transparency),e.transparency>0&&(n.transparent=!0)}else n=new _n({color:0});break;case"texture":const e=a[0];null!==e&&("ImageTexture"!==e.name&&"PixelTexture"!==e.name||(n.map=i(e)));break;case"textureTransform":null!==a[0]&&(t=i(a[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}if(n.map){if(n.map.__type){switch(n.map.__type){case pu.INTENSITY_ALPHA:n.opacity=1;break;case pu.RGB:n.color.set(16777215);break;case pu.RGBA:n.color.set(16777215),n.opacity=1}delete n.map.__type}t&&(n.map.center.copy(t.center),n.map.rotation=t.rotation,n.map.repeat.copy(t.scale),n.map.offset.copy(t.translation))}return n}(e);break;case"Material":n=function(e){const t={},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],i=r.name,o=r.values;switch(i){case"ambientIntensity":break;case"diffuseColor":t.diffuseColor=new yn(o[0],o[1],o[2]),t.diffuseColor.convertSRGBToLinear();break;case"emissiveColor":t.emissiveColor=new yn(o[0],o[1],o[2]),t.emissiveColor.convertSRGBToLinear();break;case"shininess":t.shininess=o[0];break;case"specularColor":t.specularColor=new yn(o[0],o[1],o[2]),t.specularColor.convertSRGBToLinear();break;case"transparency":t.transparency=o[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}return t}(e);break;case"ImageTexture":n=function(e){let t,n=b,r=b;const i=e.fields;for(let e=0,o=i.length;e<o;e++){const o=i[e],s=o.name,a=o.values;switch(s){case"url":const e=a[0];e&&(t=U.load(e));break;case"repeatS":!1===a[0]&&(n=S);break;case"repeatT":!1===a[0]&&(r=S);break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}t&&(t.wrapS=n,t.wrapT=r,t.colorSpace=te);return t}(e);break;case"PixelTexture":n=function(e){let t,n=b,r=b;const i=e.fields;for(let e=0,s=i.length;e<s;e++){const s=i[e],a=s.name,l=s.values;switch(a){case"image":const e=l[0],i=l[1],s=c(l[2]),u=new Uint8Array(4*e*i),h={r:0,g:0,b:0,a:0};for(let e=3,t=0,n=l.length;e<n;e++,t++){o(l[e],s,h);const n=4*t;u[n+0]=h.r,u[n+1]=h.g,u[n+2]=h.b,u[n+3]=h.a}t=new ds(u,e,i),t.colorSpace=te,t.needsUpdate=!0,t.__type=s;break;case"repeatS":!1===l[0]&&(n=S);break;case"repeatT":!1===l[0]&&(r=S);break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}t&&(t.wrapS=n,t.wrapT=r);return t}(e);break;case"TextureTransform":n=function(e){const t={center:new Se,rotation:new Se,scale:new Se,translation:new Se},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],i=r.name,o=r.values;switch(i){case"center":t.center.set(o[0],o[1]);break;case"rotation":t.rotation=o[0];break;case"scale":t.scale.set(o[0],o[1]);break;case"translation":t.translation.set(o[0],o[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}return t}(e);break;case"IndexedFaceSet":n=function(e){let t,n,r,o,s,a,l,c,u=!0,f=!0,m=0,g=!0,v=!0;const y=e.fields;for(let e=0,h=y.length;e<h;e++){const h=y[e],d=h.name,p=h.values;switch(d){case"color":const e=p[0];null!==e&&(t=i(e));break;case"coord":const h=p[0];null!==h&&(n=i(h));break;case"normal":const y=p[0];null!==y&&(r=i(y));break;case"texCoord":const x=p[0];null!==x&&(o=i(x));break;case"ccw":u=p[0];break;case"colorIndex":s=p;break;case"colorPerVertex":g=p[0];break;case"convex":break;case"coordIndex":a=p;break;case"creaseAngle":m=p[0];break;case"normalIndex":l=p;break;case"normalPerVertex":v=p[0];break;case"solid":f=p[0];break;case"texCoordIndex":c=p;break;default:console.warn("THREE.VRMLLoader: Unknown field:",d)}}if(void 0===a)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new On;const x=h(a,u);let _,T,b;if(t){if(!0===g)if(s&&s.length>0){_=E(x,h(s,u),t,3)}else _=A(x,new wn(t,3));else if(s&&s.length>0){_=M(x,d(p(t,s),a))}else{_=M(x,d(t,a))}N(_)}if(r)if(!0===v)if(l&&l.length>0){T=E(x,h(l,u),r,3)}else T=A(x,new wn(r,3));else if(l&&l.length>0){T=M(x,d(p(r,l),a))}else{T=M(x,d(r,a))}else T=I(x,n,m);if(o)if(c&&c.length>0){b=E(x,h(c,u),o,2)}else b=A(x,new wn(o,2));const S=new On,w=A(x,new wn(n,3));S.setAttribute("position",w),S.setAttribute("normal",T),_&&S.setAttribute("color",_);b&&S.setAttribute("uv",b);return S._solid=f,S._type="mesh",S}(e);break;case"IndexedLineSet":n=function(e){let t,n,r,o,s=!0;const a=e.fields;for(let e=0,l=a.length;e<l;e++){const l=a[e],c=l.name,u=l.values;switch(c){case"color":const e=u[0];null!==e&&(t=i(e));break;case"coord":const a=u[0];null!==a&&(n=i(a));break;case"colorIndex":r=u;break;case"colorPerVertex":s=u[0];break;case"coordIndex":o=u;break;default:console.warn("THREE.VRMLLoader: Unknown field:",c)}}let l;const c=f(o);if(t){if(!0===s)if(r.length>0){l=E(c,f(r),t,3)}else l=A(c,new wn(t,3));else if(r.length>0){l=w(c,m(p(t,r),o))}else{l=w(c,m(t,o))}N(l)}const u=new On,h=A(c,new wn(n,3));u.setAttribute("position",h),l&&u.setAttribute("color",l);return u._type="line",u}(e);break;case"PointSet":n=function(e){let t,n;const r=e.fields;for(let e=0,o=r.length;e<o;e++){const o=r[e],s=o.name,a=o.values;switch(s){case"color":const e=a[0];null!==e&&(t=i(e));break;case"coord":const r=a[0];null!==r&&(n=i(r));break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}const o=new On;if(o.setAttribute("position",new wn(n,3)),t){const e=new wn(t,3);N(e),o.setAttribute("color",e)}return o._type="points",o}(e);break;case"Box":n=function(e){const t=new Je(2,2,2),n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],i=r.name,o=r.values;if("size"===i)t.x=o[0],t.y=o[1],t.z=o[2];else console.warn("THREE.VRMLLoader: Unknown field:",i)}return new er(t.x,t.y,t.z)}(e);break;case"Cone":n=function(e){let t=1,n=2,r=!1;const i=e.fields;for(let e=0,o=i.length;e<o;e++){const o=i[e],s=o.name,a=o.values;switch(s){case"bottom":r=!a[0];break;case"bottomRadius":t=a[0];break;case"height":n=a[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}return new $s(t,n,16,1,r)}(e);break;case"Cylinder":n=function(e){let t=1,n=2;const r=e.fields;for(let e=0,i=r.length;e<i;e++){const i=r[e],o=i.name,s=i.values;switch(o){case"bottom":case"side":case"top":break;case"radius":t=s[0];break;case"height":n=s[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return new Js(t,t,n,16,1)}(e);break;case"Sphere":n=function(e){let t=1;const n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],i=r.name,o=r.values;if("radius"===i)t=o[0];else console.warn("THREE.VRMLLoader: Unknown field:",i)}return new Ua(t,16,16)}(e);break;case"ElevationGrid":n=function(e){let t,n,r,o,s=!0,a=!0,l=!0,c=!0,u=0,h=2,d=2,p=1,f=1;const m=e.fields;for(let e=0,g=m.length;e<g;e++){const g=m[e],v=g.name,y=g.values;switch(v){case"color":const e=y[0];null!==e&&(t=i(e));break;case"normal":const m=y[0];null!==m&&(n=i(m));break;case"texCoord":const g=y[0];null!==g&&(r=i(g));break;case"height":o=y;break;case"ccw":c=y[0];break;case"colorPerVertex":s=y[0];break;case"creaseAngle":u=y[0];break;case"normalPerVertex":a=y[0];break;case"solid":l=y[0];break;case"xDimension":h=y[0];break;case"xSpacing":p=y[0];break;case"zDimension":d=y[0];break;case"zSpacing":f=y[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",v)}}const g=[],v=[],y=[],x=[];for(let e=0;e<d;e++)for(let i=0;i<h;i++){const l=e*h+i,c=p*e,u=o[l],m=f*i;if(g.push(c,u,m),t&&!0===s){const e=t[3*l+0],n=t[3*l+1],r=t[3*l+2];y.push(e,n,r)}if(n&&!0===a){const e=n[3*l+0],t=n[3*l+1],r=n[3*l+2];v.push(e,t,r)}if(r){const e=r[2*l+0],t=r[2*l+1];x.push(e,t)}else x.push(e/(h-1),i/(d-1))}const _=[];for(let e=0;e<h-1;e++)for(let t=0;t<d-1;t++){const n=e+t*h,r=e+(t+1)*h,i=e+1+(t+1)*h,o=e+1+t*h;!0===c?(_.push(n,i,r),_.push(i,n,o)):(_.push(n,r,i),_.push(i,o,n))}const T=A(_,new wn(g,3)),E=A(_,new wn(x,2));let M,b;if(t){if(!1===s){for(let e=0;e<h-1;e++)for(let n=0;n<d-1;n++){const r=e+n*(h-1),i=t[3*r+0],o=t[3*r+1],s=t[3*r+2];y.push(i,o,s),y.push(i,o,s),y.push(i,o,s),y.push(i,o,s),y.push(i,o,s),y.push(i,o,s)}M=new wn(y,3)}else M=A(_,new wn(y,3));N(M)}if(n)if(!1===a){for(let e=0;e<h-1;e++)for(let t=0;t<d-1;t++){const r=e+t*(h-1),i=n[3*r+0],o=n[3*r+1],s=n[3*r+2];v.push(i,o,s),v.push(i,o,s),v.push(i,o,s),v.push(i,o,s),v.push(i,o,s),v.push(i,o,s)}b=new wn(v,3)}else b=A(_,new wn(v,3));else b=I(_,g,u);const S=new On;S.setAttribute("position",T),S.setAttribute("normal",b),S.setAttribute("uv",E),M&&S.setAttribute("color",M);return S._solid=l,S._type="mesh",S}(e);break;case"Extrusion":n=function(e){let t,n,r=[1,1,1,-1,-1,-1,-1,1,1,1],i=[0,0,0,0,1,0],o=!0,s=!0,a=0,l=!0,c=!0;const u=e.fields;for(let e=0,h=u.length;e<h;e++){const h=u[e],d=h.name,p=h.values;switch(d){case"beginCap":o=p[0];break;case"ccw":s=p[0];break;case"convex":break;case"creaseAngle":a=p[0];break;case"crossSection":r=p;break;case"endCap":l=p[0];break;case"orientation":n=p;break;case"scale":t=p;break;case"solid":c=p[0];break;case"spine":i=p;break;default:console.warn("THREE.VRMLLoader: Unknown field:",d)}}const h=r[0]===r[r.length-2]&&r[1]===r[r.length-1],d=[],p=new Je,f=new Je,m=new Je,g=new Je,v=new Ze;for(let e=0,o=0,s=0,a=i.length;e<a;e+=3,o+=2,s+=4){p.fromArray(i,e),f.x=t?t[o+0]:1,f.y=1,f.z=t?t[o+1]:1,m.x=n?n[s+0]:0,m.y=n?n[s+1]:0,m.z=n?n[s+2]:1;const a=n?n[s+3]:0;for(let e=0,t=r.length;e<t;e+=2)g.x=r[e+0],g.y=0,g.z=r[e+1],g.multiply(f),v.setFromAxisAngle(m,a),g.applyQuaternion(v),g.add(p),d.push(g.x,g.y,g.z)}const y=[],x=i.length/3,_=r.length/2;for(let e=0;e<x-1;e++)for(let t=0;t<_-1;t++){const n=t+e*_;let r=t+1+e*_;const i=t+(e+1)*_;let o=t+1+(e+1)*_;t===_-2&&!0===h&&(r=e*_,o=(e+1)*_),!0===s?(y.push(n,r,i),y.push(i,r,o)):(y.push(n,i,r),y.push(i,o,r))}if(!0===o||!0===l){const e=[];for(let t=0,n=r.length;t<n;t+=2)e.push(new Se(r[t],r[t+1]));const t=Ia.triangulateShape(e,[]),n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e];n.push(r[0],r[1],r[2])}if(!0===o)for(let e=0,t=n.length;e<t;e+=3)!0===s?y.push(n[e+0],n[e+1],n[e+2]):y.push(n[e+0],n[e+2],n[e+1]);if(!0===l){const e=_*(x-1);for(let t=0,r=n.length;t<r;t+=3)!0===s?y.push(e+n[t+0],e+n[t+2],e+n[t+1]):y.push(e+n[t+0],e+n[t+1],e+n[t+2])}}const T=A(y,new wn(d,3)),E=I(y,d,a),M=new On;return M.setAttribute("position",T),M.setAttribute("normal",E),M._solid=c,M._type="mesh",M}(e);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":n=function(e){return e.fields[0].values}(e);break;case"WorldInfo":n=function(e){const t={},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],i=r.name,o=r.values;switch(i){case"title":t.title=o[0];break;case"info":t.info=o;break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}return t}(e);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",t)}void 0!==n&&void 0!==e.DEF&&!0===n.hasOwnProperty("name")&&(n.name=e.DEF);return n}(e)),e.build)}function o(e,t,n){let r;switch(t){case pu.INTENSITY:r=parseInt(e),n.r=r,n.g=r,n.b=r,n.a=1;break;case pu.INTENSITY_ALPHA:r=parseInt("0x"+e.substring(2,4)),n.r=r,n.g=r,n.b=r,n.a=parseInt("0x"+e.substring(4,6));break;case pu.RGB:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8)),n.a=1;break;case pu.RGBA:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8)),n.a=parseInt("0x"+e.substring(8,10))}}function c(e){let t;switch(e){case 1:t=pu.INTENSITY;break;case 2:t=pu.INTENSITY_ALPHA;break;case 3:t=pu.RGB;break;case 4:t=pu.RGBA}return t}function u(e,t){for(let n=0,r=e.length;n<r;n++){const r=i(e[n]);r instanceof $t&&t.add(r)}}function h(e,t){const n=[];let r=0;for(let i=0,o=e.length;i<o;i++){const s=e[r],a=e[i+(t?1:2)],l=e[i+(t?2:1)];n.push(s,a,l),(-1===e[i+3]||i+3>=o)&&(i+=3,r=i+1)}return n}function d(e,t){const n=[];let r=0;for(let i=0,o=t.length;i<o;i++){const s=3*r,a=e[s],l=e[s+1],c=e[s+2];n.push(a,l,c),(-1===t[i+3]||i+3>=o)&&(i+=3,r++)}return n}function p(e,t){const n=[];for(let r=0,i=t.length;r<i;r++){const i=3*t[r],o=e[i],s=e[i+1],a=e[i+2];n.push(o,s,a)}return n}function f(e){const t=[];for(let n=0,r=e.length;n<r;n++){const i=e[n],o=e[n+1];t.push(i,o),(-1===e[n+2]||n+2>=r)&&(n+=2)}return t}function m(e,t){const n=[];let r=0;for(let i=0,o=t.length;i<o;i++){const s=3*r,a=e[s],l=e[s+1],c=e[s+2];n.push(a,l,c),(-1===t[i+2]||i+2>=o)&&(i+=2,r++)}return n}const g=new Je,v=new Je,y=new Je,x=new Se,_=new Se,T=new Se;function E(e,t,n,r){const i=[];for(let o=0,s=e.length;o<s;o+=3){const e=t[o],s=t[o+1],a=t[o+2];2===r?(x.fromArray(n,e*r),_.fromArray(n,s*r),T.fromArray(n,a*r),i.push(x.x,x.y),i.push(_.x,_.y),i.push(T.x,T.y)):(g.fromArray(n,e*r),v.fromArray(n,s*r),y.fromArray(n,a*r),i.push(g.x,g.y,g.z),i.push(v.x,v.y,v.z),i.push(y.x,y.y,y.z))}return new wn(i,r)}function M(e,t){const n=[];for(let r=0,i=0,o=e.length;r<o;r+=3,i++)g.fromArray(t,3*i),n.push(g.x,g.y,g.z),n.push(g.x,g.y,g.z),n.push(g.x,g.y,g.z);return new wn(n,3)}function w(e,t){const n=[];for(let r=0,i=0,o=e.length;r<o;r+=2,i++)g.fromArray(t,3*i),n.push(g.x,g.y,g.z),n.push(g.x,g.y,g.z);return new wn(n,3)}function A(e,t){const n=t.array,r=t.itemSize,i=new n.constructor(e.length*r);let o=0,s=0;for(let t=0,a=e.length;t<a;t++){o=e[t]*r;for(let e=0;e<r;e++)i[s++]=n[o++]}return new wn(i,r)}const C=new Je,R=new Je;function I(e,t,n){const r=[],i={};for(let n=0,o=e.length;n<o;n+=3){const o=e[n],s=e[n+1],a=e[n+2],l=new du(o,s,a);g.fromArray(t,3*o),v.fromArray(t,3*s),y.fromArray(t,3*a),R.subVectors(y,v),C.subVectors(g,v),R.cross(C),R.normalize(),l.normal.copy(R),void 0===i[o]&&(i[o]=[]),void 0===i[s]&&(i[s]=[]),void 0===i[a]&&(i[a]=[]),i[o].push(l.normal),i[s].push(l.normal),i[a].push(l.normal),r.push(l)}const o=[];for(let e=0,s=r.length;e<s;e++){const s=r[e],a=P(i[s.a],s.normal,n),l=P(i[s.b],s.normal,n),c=P(i[s.c],s.normal,n);g.fromArray(t,3*s.a),v.fromArray(t,3*s.b),y.fromArray(t,3*s.c),o.push(a.x,a.y,a.z),o.push(l.x,l.y,l.z),o.push(c.x,c.y,c.z)}return new wn(o,3)}function P(e,t,n){const r=new Je;if(0===n)r.copy(t);else for(let i=0,o=e.length;i<o;i++)e[i].angleTo(t)<n&&r.add(e[i]);return r.normalize()}function L(e){const t=[];for(let n=0,r=e.length;n<r;n+=3)t.push(new yn(e[n],e[n+1],e[n+2]));return t}function N(e){const t=new yn;for(let n=0;n<e.count;n++)t.fromBufferAttribute(e,n),t.convertSRGBToLinear(),e.setXYZ(n,t.r,t.g,t.b)}function O(e,t,n,r,i){const o=[],s=!0===i?0:Math.PI;for(let e=0,a=r.length;e<a;e++){let r=0===e?0:n[e-1];r=!0===i?r:s-r;const a=new Je;a.setFromSphericalCoords(t,r,0),o.push(a)}const a=e.index,l=e.attributes.position,c=new Mn(new Float32Array(3*e.attributes.position.count),3),u=new Je,h=new yn;for(let e=0;e<a.count;e++){const t=a.getX(e);let n,s;u.fromBufferAttribute(l,t);let d=1;for(let e=1;e<o.length;e++){n=e-1,s=e;const t=o[n],r=o[s];if(!0===i){if(u.y<=t.y&&u.y>r.y){d=Math.abs(t.y-u.y)/Math.abs(t.y-r.y);break}}else if(u.y>=t.y&&u.y<r.y){d=Math.abs(t.y-u.y)/Math.abs(t.y-r.y);break}}const p=r[n],f=r[s];h.copy(p).lerp(f,d).convertSRGBToLinear(),c.setXYZ(t,h.r,h.g,h.b)}e.setAttribute("color",c)}const U=new ml(this.manager);if(U.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),-1===e.indexOf("#VRML V2.0"))throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");const D=function(e){const t=function(){const e=au.Z.createToken,t=e({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),n=e({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/,longer_alt:t}),r=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],i=e({name:"Version",pattern:/#VRML.*/,longer_alt:n}),o=e({name:"NodeName",pattern:new RegExp(r.join("|")),longer_alt:n}),s=e({name:"DEF",pattern:/DEF/,longer_alt:n}),a=e({name:"USE",pattern:/USE/,longer_alt:n}),l=e({name:"ROUTE",pattern:/ROUTE/,longer_alt:n}),c=e({name:"TO",pattern:/TO/,longer_alt:n}),u=e({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),h=e({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),d=e({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),p=e({name:"TrueLiteral",pattern:/TRUE/}),f=e({name:"FalseLiteral",pattern:/FALSE/}),m=e({name:"NullLiteral",pattern:/NULL/}),g=e({name:"LSquare",pattern:/\[/}),v=e({name:"RSquare",pattern:/]/}),y=e({name:"LCurly",pattern:/{/}),x=e({name:"RCurly",pattern:/}/}),_=e({name:"Comment",pattern:/#.*/,group:au.Z.Lexer.SKIPPED}),T=[e({name:"WhiteSpace",pattern:/[ ,\s]/,group:au.Z.Lexer.SKIPPED}),o,s,a,l,c,p,f,m,i,n,t,u,h,d,g,v,y,x,_],E={};for(let e=0,t=T.length;e<t;e++){const t=T[e];E[t.name]=t}return{tokens:T,tokenVocabulary:E}}(),n=new cu(t.tokens),r=new hu(t.tokenVocabulary),i=function(e){class t extends e{constructor(){super(),this.validateVisitor()}vrml(e){const t={version:this.visit(e.version),nodes:[],routes:[]};for(let n=0,r=e.node.length;n<r;n++){const r=e.node[n];t.nodes.push(this.visit(r))}if(e.route)for(let n=0,r=e.route.length;n<r;n++){const r=e.route[n];t.routes.push(this.visit(r))}return t}version(e){return e.Version[0].image}node(e){const t={name:e.NodeName[0].image,fields:[]};if(e.field)for(let n=0,r=e.field.length;n<r;n++){const r=e.field[n];t.fields.push(this.visit(r))}return e.def&&(t.DEF=this.visit(e.def[0])),t}field(e){const t={name:e.Identifier[0].image,type:null,values:null};let n;return e.singleFieldValue&&(n=this.visit(e.singleFieldValue[0])),e.multiFieldValue&&(n=this.visit(e.multiFieldValue[0])),t.type=n.type,t.values=n.values,t}def(e){return(e.Identifier||e.NodeName)[0].image}use(e){return{USE:(e.Identifier||e.NodeName)[0].image}}singleFieldValue(e){return n(this,e)}multiFieldValue(e){return n(this,e)}route(e){return{FROM:e.RouteIdentifier[0].image,TO:e.RouteIdentifier[1].image}}}function n(e,t){const n={type:null,values:[]};if(t.node){n.type="node";for(let r=0,i=t.node.length;r<i;r++){const i=t.node[r];n.values.push(e.visit(i))}}if(t.use){n.type="use";for(let r=0,i=t.use.length;r<i;r++){const i=t.use[r];n.values.push(e.visit(i))}}if(t.StringLiteral){n.type="string";for(let e=0,r=t.StringLiteral.length;e<r;e++){const r=t.StringLiteral[e];n.values.push(r.image.replace(/'|"/g,""))}}if(t.NumberLiteral){n.type="number";for(let e=0,r=t.NumberLiteral.length;e<r;e++){const r=t.NumberLiteral[e];n.values.push(parseFloat(r.image))}}if(t.HexLiteral){n.type="hex";for(let e=0,r=t.HexLiteral.length;e<r;e++){const r=t.HexLiteral[e];n.values.push(r.image)}}if(t.TrueLiteral){n.type="boolean";for(let e=0,r=t.TrueLiteral.length;e<r;e++){"TRUE"===t.TrueLiteral[e].image&&n.values.push(!0)}}if(t.FalseLiteral){n.type="boolean";for(let e=0,r=t.FalseLiteral.length;e<r;e++){"FALSE"===t.FalseLiteral[e].image&&n.values.push(!1)}}return t.NullLiteral&&(n.type="null",t.NullLiteral.forEach((function(){n.values.push(null)}))),n}return new t}(r.getBaseCstVisitorConstructor()),o=n.lex(e);r.input=o.tokens;const s=r.vrml();if(r.errors.length>0)throw console.error(r.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return i.visit(s)}(e),k=function(e){const t=e.nodes,n=new es;for(let e=0,n=t.length;e<n;e++){r(t[e])}for(let e=0,r=t.length;e<r;e++){const r=t[e],o=i(r);o instanceof $t&&n.add(o),"WorldInfo"===r.name&&(n.userData.worldInfo=o)}return n}(D);return k}}class cu{constructor(e){this.lexer=new au.Z.Lexer(e)}lex(e){const t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}}const uu=au.Z.CstParser;class hu extends uu{constructor(e){super(e);const t=this,n=e.Version,r=e.LCurly,i=e.RCurly,o=e.LSquare,s=e.RSquare,a=e.Identifier,l=e.RouteIdentifier,c=e.StringLiteral,u=e.HexLiteral,h=e.NumberLiteral,d=e.TrueLiteral,p=e.FalseLiteral,f=e.NullLiteral,m=e.DEF,g=e.USE,v=e.ROUTE,y=e.TO,x=e.NodeName;t.RULE("vrml",(function(){t.SUBRULE(t.version),t.AT_LEAST_ONE((function(){t.SUBRULE(t.node)})),t.MANY((function(){t.SUBRULE(t.route)}))})),t.RULE("version",(function(){t.CONSUME(n)})),t.RULE("node",(function(){t.OPTION((function(){t.SUBRULE(t.def)})),t.CONSUME(x),t.CONSUME(r),t.MANY((function(){t.SUBRULE(t.field)})),t.CONSUME(i)})),t.RULE("field",(function(){t.CONSUME(a),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])})),t.RULE("def",(function(){t.CONSUME(m),t.OR([{ALT:function(){t.CONSUME(a)}},{ALT:function(){t.CONSUME(x)}}])})),t.RULE("use",(function(){t.CONSUME(g),t.OR([{ALT:function(){t.CONSUME(a)}},{ALT:function(){t.CONSUME(x)}}])})),t.RULE("singleFieldValue",(function(){t.AT_LEAST_ONE((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(f)}}])}))})),t.RULE("multiFieldValue",(function(){t.CONSUME(o),t.MANY((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(f)}}])})),t.CONSUME(s)})),t.RULE("route",(function(){t.CONSUME(v),t.CONSUME(l),t.CONSUME(y),t.CONSUME2(l)})),this.performSelfAnalysis()}}class du{constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.normal=new Je}}const pu={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4},fu=te;class mu extends ll{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,r){const i=this,o=new hl(i.manager);o.setPath(i.path),o.setResponseType("arraybuffer"),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t=this,n=new ml(this.manager);function r(e){const t=[],n=(new DOMParser).parseFromString(e,"application/xml").querySelectorAll("Relationship");for(let e=0;e<n.length;e++){const r=n[e],i={target:r.getAttribute("Target"),id:r.getAttribute("Id"),type:r.getAttribute("Type")};t.push(i)}return t}function i(e){const t={id:e.getAttribute("id"),basematerials:[]},n=e.querySelectorAll("base");for(let e=0;e<n.length;e++){const r=l(n[e]);r.index=e,t.basematerials.push(r)}return t}function o(e){const t={id:e.getAttribute("id"),texid:e.getAttribute("texid"),displaypropertiesid:e.getAttribute("displaypropertiesid")},n=e.querySelectorAll("tex2coord"),r=[];for(let e=0;e<n.length;e++){const t=n[e],i=t.getAttribute("u"),o=t.getAttribute("v");r.push(parseFloat(i),parseFloat(o))}return t.uvs=new Float32Array(r),t}function s(e){const t={id:e.getAttribute("id"),displaypropertiesid:e.getAttribute("displaypropertiesid")},n=e.querySelectorAll("color"),r=[],i=new yn;for(let e=0;e<n.length;e++){const t=n[e].getAttribute("color");i.setStyle(t.substring(0,7),fu),r.push(i.r,i.g,i.b)}return t.colors=new Float32Array(r),t}function a(e){const t={id:e.getAttribute("id")},n=e.querySelectorAll("pbmetallic"),r=[];for(let e=0;e<n.length;e++){const t=n[e];r.push({name:t.getAttribute("name"),metallicness:parseFloat(t.getAttribute("metallicness")),roughness:parseFloat(t.getAttribute("roughness"))})}return t.data=r,t}function l(e){const t={};return t.name=e.getAttribute("name"),t.displaycolor=e.getAttribute("displaycolor"),t.displaypropertiesid=e.getAttribute("displaypropertiesid"),t}function c(e){const t={};t.objectId=e.getAttribute("objectid");const n=e.getAttribute("transform");return n&&(t.transform=u(n)),t}function u(e){const t=[];e.split(" ").forEach((function(e){t.push(parseFloat(e))}));const n=new At;return n.set(t[0],t[3],t[6],t[9],t[1],t[4],t[7],t[10],t[2],t[5],t[8],t[11],0,0,0,1),n}function h(e){const t={type:e.getAttribute("type")},n=e.getAttribute("id");n&&(t.id=n);const r=e.getAttribute("pid");r&&(t.pid=r);const i=e.getAttribute("pindex");i&&(t.pindex=i);const o=e.getAttribute("thumbnail");o&&(t.thumbnail=o);const s=e.getAttribute("partnumber");s&&(t.partnumber=s);const a=e.getAttribute("name");a&&(t.name=a);const l=e.querySelector("mesh");l&&(t.mesh=function(e){const t={},n=[],r=e.querySelectorAll("vertices vertex");for(let e=0;e<r.length;e++){const t=r[e],i=t.getAttribute("x"),o=t.getAttribute("y"),s=t.getAttribute("z");n.push(parseFloat(i),parseFloat(o),parseFloat(s))}t.vertices=new Float32Array(n);const i=[],o=[],s=e.querySelectorAll("triangles triangle");for(let e=0;e<s.length;e++){const t=s[e],n=t.getAttribute("v1"),r=t.getAttribute("v2"),a=t.getAttribute("v3"),l=t.getAttribute("p1"),c=t.getAttribute("p2"),u=t.getAttribute("p3"),h=t.getAttribute("pid"),d={};d.v1=parseInt(n,10),d.v2=parseInt(r,10),d.v3=parseInt(a,10),o.push(d.v1,d.v2,d.v3),l&&(d.p1=parseInt(l,10)),c&&(d.p2=parseInt(c,10)),u&&(d.p3=parseInt(u,10)),h&&(d.pid=h),0<Object.keys(d).length&&i.push(d)}return t.triangleProperties=i,t.triangles=new Uint32Array(o),t}(l));const u=e.querySelector("components");return u&&(t.components=function(e){const t=[],n=e.querySelectorAll("component");for(let e=0;e<n.length;e++){const r=c(n[e]);t.push(r)}return t}(u)),t}function d(e){const t={unit:e.getAttribute("unit")||"millimeter"},n=e.querySelectorAll("metadata");n&&(t.metadata=function(e){const t={};for(let n=0;n<e.length;n++){const r=e[n],i=r.getAttribute("name");0<=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate"].indexOf(i)&&(t[i]=r.textContent)}return t}(n));const r=e.querySelector("resources");r&&(t.resources=function(e){const t={basematerials:{}},n=e.querySelectorAll("basematerials");for(let e=0;e<n.length;e++){const r=i(n[e]);t.basematerials[r.id]=r}t.texture2d={};const r=e.querySelectorAll("texture2d");for(let e=0;e<r.length;e++){const n={id:(l=r[e]).getAttribute("id"),path:l.getAttribute("path"),contenttype:l.getAttribute("contenttype"),tilestyleu:l.getAttribute("tilestyleu"),tilestylev:l.getAttribute("tilestylev"),filter:l.getAttribute("filter")};t.texture2d[n.id]=n}var l;t.colorgroup={};const c=e.querySelectorAll("colorgroup");for(let e=0;e<c.length;e++){const n=s(c[e]);t.colorgroup[n.id]=n}t.pbmetallicdisplayproperties={};const u=e.querySelectorAll("pbmetallicdisplayproperties");for(let e=0;e<u.length;e++){const n=a(u[e]);t.pbmetallicdisplayproperties[n.id]=n}t.texture2dgroup={};const d=e.querySelectorAll("texture2dgroup");for(let e=0;e<d.length;e++){const n=o(d[e]);t.texture2dgroup[n.id]=n}t.object={};const p=e.querySelectorAll("object");for(let e=0;e<p.length;e++){const n=h(p[e]);t.object[n.id]=n}return t}(r));const l=e.querySelector("build");return l&&(t.build=function(e){const t=[],n=e.querySelectorAll("item");for(let e=0;e<n.length;e++){const r=n[e],i={objectId:r.getAttribute("objectid")},o=r.getAttribute("transform");o&&(i.transform=u(o)),t.push(i)}return t}(l)),t}function p(e,t,r,i){const o=e.texid,s=r.resources.texture2d[o];if(s){const e=i[s.path],t=s.contenttype,r=new Blob([e],{type:t}),o=URL.createObjectURL(r),a=n.load(o,(function(){URL.revokeObjectURL(o)}));switch(a.colorSpace=fu,s.tilestyleu){case"wrap":default:a.wrapS=b;break;case"mirror":a.wrapS=w;break;case"none":case"clamp":a.wrapS=S}switch(s.tilestylev){case"wrap":default:a.wrapT=b;break;case"mirror":a.wrapT=w;break;case"none":case"clamp":a.wrapT=S}switch(s.filter){case"auto":default:a.magFilter=I,a.minFilter=P;break;case"linear":a.magFilter=I,a.minFilter=I;break;case"nearest":a.magFilter=A,a.minFilter=A}return a}return null}function f(e,t,n,r,i,o,s){const a=s.pindex,l={};for(let e=0,n=t.length;e<n;e++){const n=t[e],r=void 0!==n.p1?n.p1:a;void 0===l[r]&&(l[r]=[]),l[r].push(n)}const c=Object.keys(l),u=[];for(let t=0,a=c.length;t<a;t++){const a=c[t],h=l[a],d=_(e.basematerials[a],r,i,o,s,T),p=new On,f=[],m=n.vertices;for(let e=0,t=h.length;e<t;e++){const t=h[e];f.push(m[3*t.v1+0]),f.push(m[3*t.v1+1]),f.push(m[3*t.v1+2]),f.push(m[3*t.v2+0]),f.push(m[3*t.v2+1]),f.push(m[3*t.v2+2]),f.push(m[3*t.v3+0]),f.push(m[3*t.v3+1]),f.push(m[3*t.v3+2])}p.setAttribute("position",new wn(f,3));const g=new $n(p,d);u.push(g)}return u}function m(e,t,n,r,i,o,s){const a=new On,l=[],c=[],u=n.vertices,h=e.uvs;for(let e=0,n=t.length;e<n;e++){const n=t[e];l.push(u[3*n.v1+0]),l.push(u[3*n.v1+1]),l.push(u[3*n.v1+2]),l.push(u[3*n.v2+0]),l.push(u[3*n.v2+1]),l.push(u[3*n.v2+2]),l.push(u[3*n.v3+0]),l.push(u[3*n.v3+1]),l.push(u[3*n.v3+2]),c.push(h[2*n.p1+0]),c.push(h[2*n.p1+1]),c.push(h[2*n.p2+0]),c.push(h[2*n.p2+1]),c.push(h[2*n.p3+0]),c.push(h[2*n.p3+1])}a.setAttribute("position",new wn(l,3)),a.setAttribute("uv",new wn(c,2));const d=_(e,r,i,o,s,p),f=new ka({map:d,flatShading:!0});return new $n(a,f)}function g(e,t,n,r){const i=new On,o=[],s=[],a=n.vertices,l=e.colors;for(let e=0,n=t.length;e<n;e++){const n=t[e],i=n.v1,c=n.v2,u=n.v3;o.push(a[3*i+0]),o.push(a[3*i+1]),o.push(a[3*i+2]),o.push(a[3*c+0]),o.push(a[3*c+1]),o.push(a[3*c+2]),o.push(a[3*u+0]),o.push(a[3*u+1]),o.push(a[3*u+2]);const h=void 0!==n.p1?n.p1:r.pindex,d=void 0!==n.p2?n.p2:h,p=void 0!==n.p3?n.p3:h;s.push(l[3*h+0]),s.push(l[3*h+1]),s.push(l[3*h+2]),s.push(l[3*d+0]),s.push(l[3*d+1]),s.push(l[3*d+2]),s.push(l[3*p+0]),s.push(l[3*p+1]),s.push(l[3*p+2])}i.setAttribute("position",new wn(o,3)),i.setAttribute("color",new wn(s,3));const c=new ka({vertexColors:!0,flatShading:!0});return new $n(i,c)}function v(e){const t=new On;t.setIndex(new Mn(e.triangles,1)),t.setAttribute("position",new Mn(e.vertices,3));const n=new ka({color:16777215,flatShading:!0});return new $n(t,n)}function y(e,t){return void 0!==t.resources.texture2dgroup[e]?"texture":void 0!==t.resources.basematerials[e]?"material":void 0!==t.resources.colorgroup[e]?"vertexColors":"default"===e?"default":void 0}function x(e,t,n,r,i){const o=new jo,s=function(e,t){const n={},r=e.triangleProperties,i=t.pid;for(let e=0,t=r.length;e<t;e++){const t=r[e];let o=void 0!==t.pid?t.pid:i;void 0===o&&(o="default"),void 0===n[o]&&(n[o]=[]),n[o].push(t)}return n}(e,i),a=function(e,t,n,r,i,o){const s=Object.keys(e),a=[];for(let l=0,c=s.length;l<c;l++){const c=s[l],u=e[c];switch(y(c,r)){case"material":const e=f(r.resources.basematerials[c],u,t,n,r,i,o);for(let t=0,n=e.length;t<n;t++)a.push(e[t]);break;case"texture":const s=r.resources.texture2dgroup[c];a.push(m(s,u,t,n,r,i,o));break;case"vertexColors":const l=r.resources.colorgroup[c];a.push(g(l,u,t,o));break;case"default":a.push(v(t));break;default:console.error("THREE.3MFLoader: Unsupported resource type.")}}if(o.name)for(let e=0;e<a.length;e++)a[e].name=o.name;return a}(s,e,t,n,r,i);for(let e=0,t=a.length;e<t;e++)o.add(a[e]);return o}function _(e,t,n,r,i,o){return void 0!==e.build||(e.build=o(e,t,n,r,i)),e.build}function T(e,t,n){let r;const i=e.displaypropertiesid,o=n.resources.pbmetallicdisplayproperties;if(null!==i&&void 0!==o[i]){const t=o[i].data[e.index];r=new Da({flatShading:!0,roughness:t.roughness,metalness:t.metallicness})}else r=new ka({flatShading:!0});r.name=e.name;const s=e.displaycolor,a=s.substring(0,7);return r.color.setStyle(a,fu),9===s.length&&(r.opacity=parseInt(s.charAt(7)+s.charAt(8),16)/255),r}function E(e,t,n,r){const i=new jo;for(let o=0;o<e.length;o++){const s=e[o];let a=t[s.objectId];void 0===a&&(M(s.objectId,t,n,r),a=t[s.objectId]);const l=a.clone(),c=s.transform;c&&l.applyMatrix4(c),i.add(l)}return i}function M(e,n,r,i){const o=r.resources.object[e];if(o.mesh){const e=o.mesh;!function(e,n,r){if(!e)return;const i=[],o=Object.keys(e);for(let e=0;e<o.length;e++){const n=o[e];for(let e=0;e<t.availableExtensions.length;e++){const r=t.availableExtensions[e];r.ns===n&&i.push(r)}}for(let t=0;t<i.length;t++){const o=i[t];o.apply(r,e[o.ns],n)}}(r.extensions,e,r.xml),n[o.id]=_(e,n,r,i,o,x)}else{const e=o.components;n[o.id]=_(e,n,r,i,o,E)}o.name&&(n[o.id].name=o.name)}const C=function(e){let t,n,i=null,o=null;const s=[],a=[];let l;const c={},u={},h=new TextDecoder;try{i=Lc(new Uint8Array(e))}catch(e){if(e instanceof ReferenceError)return console.error("THREE.3MFLoader: fflate missing and file is compressed."),null}for(o in i)o.match(/\_rels\/.rels$/)?t=o:o.match(/3D\/_rels\/.*\.model\.rels$/)?n=o:o.match(/^3D\/.*\.model$/)?s.push(o):o.match(/^3D\/Textures?\/.*/)&&a.push(o);const p=i[t],f=r(h.decode(p));if(n){const e=i[n];l=r(h.decode(e))}for(let e=0;e<s.length;e++){const t=s[e],n=i[t],r=h.decode(n),o=(new DOMParser).parseFromString(r,"application/xml");"model"!==o.documentElement.nodeName.toLowerCase()&&console.error("THREE.3MFLoader: Error loading 3MF - no 3MF document found: ",t);const a=o.querySelector("model"),l={};for(let e=0;e<a.attributes.length;e++){const t=a.attributes[e];t.name.match(/^xmlns:(.+)$/)&&(l[t.value]=RegExp.$1)}const u=d(a);u.xml=a,0<Object.keys(l).length&&(u.extensions=l),c[t]=u}for(let e=0;e<a.length;e++){const t=a[e];u[t]=i[t].buffer}return{rels:f,modelRels:l,model:c,printTicket:{},texture:u}}(e),R=function(e){const t=e.model,n=e.modelRels,r={},i=Object.keys(t),o={};if(n)for(let t=0,r=n.length;t<r;t++){const r=n[t],i=r.target.substring(1);e.texture[i]&&(o[r.target]=e.texture[i])}for(let e=0;e<i.length;e++){const n=t[i[e]],s=Object.keys(n.resources.object);for(let e=0;e<s.length;e++){M(s[e],r,n,o)}}return r}(C);return function(e,t){const n=new jo,r=function(e){for(let t=0;t<e.length;t++){const n=e[t];if("model"===n.target.split(".").pop().toLowerCase())return n}}(t.rels),i=t.model[r.target.substring(1)].build;for(let t=0;t<i.length;t++){const r=i[t],o=e[r.objectId].clone(),s=r.transform;s&&o.applyMatrix4(s),n.add(o)}return n}(R,C)}addExtension(e){this.availableExtensions.push(e)}}class gu extends ll{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new hl(i.manager);o.setPath(i.path),o.setResponseType("arraybuffer"),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){function t(e){let t="AMF Material";const r=e.attributes.id.textContent;let i={r:1,g:1,b:1,a:1},o=null;for(let r=0;r<e.childNodes.length;r++){const o=e.childNodes[r];"metadata"===o.nodeName&&void 0!==o.attributes.type?"name"===o.attributes.type.value&&(t=o.textContent):"color"===o.nodeName&&(i=n(o))}return o=new ka({flatShading:!0,color:new yn(i.r,i.g,i.b),name:t}),1!==i.a&&(o.transparent=!0,o.opacity=i.a),{id:r,material:o}}function n(e){const t={r:1,g:1,b:1,a:1};for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];"r"===r.nodeName?t.r=r.textContent:"g"===r.nodeName?t.g=r.textContent:"b"===r.nodeName?t.b=r.textContent:"a"===r.nodeName&&(t.a=r.textContent)}return t}function r(e){const t={name:"",triangles:[],materialid:null};let n=e.firstElementChild;for(void 0!==e.attributes.materialid&&(t.materialId=e.attributes.materialid.nodeValue);n;){if("metadata"===n.nodeName)void 0!==n.attributes.type&&"name"===n.attributes.type.value&&(t.name=n.textContent);else if("triangle"===n.nodeName){const e=n.getElementsByTagName("v1")[0].textContent,r=n.getElementsByTagName("v2")[0].textContent,i=n.getElementsByTagName("v3")[0].textContent;t.triangles.push(e,r,i)}n=n.nextElementSibling}return t}function i(e){const t=[],n=[];let r=e.firstElementChild;for(;r;){if("vertex"===r.nodeName){let e=r.firstElementChild;for(;e;){if("coordinates"===e.nodeName){const n=e.getElementsByTagName("x")[0].textContent,r=e.getElementsByTagName("y")[0].textContent,i=e.getElementsByTagName("z")[0].textContent;t.push(n,r,i)}else if("normal"===e.nodeName){const t=e.getElementsByTagName("nx")[0].textContent,r=e.getElementsByTagName("ny")[0].textContent,i=e.getElementsByTagName("nz")[0].textContent;n.push(t,r,i)}e=e.nextElementSibling}}r=r.nextElementSibling}return{vertices:t,normals:n}}function o(e){const t=e.attributes.id.textContent,o={name:"amfobject",meshes:[]};let s=null,a=e.firstElementChild;for(;a;){if("metadata"===a.nodeName)void 0!==a.attributes.type&&"name"===a.attributes.type.value&&(o.name=a.textContent);else if("color"===a.nodeName)s=n(a);else if("mesh"===a.nodeName){let e=a.firstElementChild;const t={vertices:[],normals:[],volumes:[],color:s};for(;e;){if("vertices"===e.nodeName){const n=i(e);t.normals=t.normals.concat(n.normals),t.vertices=t.vertices.concat(n.vertices)}else"volume"===e.nodeName&&t.volumes.push(r(e));e=e.nextElementSibling}o.meshes.push(t)}a=a.nextElementSibling}return{id:t,obj:o}}const s=function(e){let t=new DataView(e);if("PK"===String.fromCharCode(t.getUint8(0),t.getUint8(1))){let n=null,r=null;console.log("THREE.AMFLoader: Loading Zip");try{n=Lc(new Uint8Array(e))}catch(e){if(e instanceof ReferenceError)return console.log("THREE.AMFLoader: fflate missing and file is compressed."),null}for(r in n)if(".amf"===r.toLowerCase().slice(-4))break;console.log("THREE.AMFLoader: Trying to load file asset: "+r),t=new DataView(n[r].buffer)}const n=(new TextDecoder).decode(t),r=(new DOMParser).parseFromString(n,"application/xml");return"amf"!==r.documentElement.nodeName.toLowerCase()?(console.log("THREE.AMFLoader: Error loading AMF - no AMF document found."),null):r}(e);let a="",l="";const c=function(e){let t=1,n="millimeter";void 0!==e.documentElement.attributes.unit&&(n=e.documentElement.attributes.unit.value.toLowerCase());const r={millimeter:1,inch:25.4,feet:304.8,meter:1e3,micron:.001};return void 0!==r[n]&&(t=r[n]),console.log("THREE.AMFLoader: Unit scale: "+t),t}(s),u={},h={},d=s.documentElement.childNodes;let p,f;for(p=0;p<d.length;p++){const e=d[p];if("metadata"===e.nodeName)void 0!==e.attributes.type&&("name"===e.attributes.type.value?a=e.textContent:"author"===e.attributes.type.value&&(l=e.textContent));else if("material"===e.nodeName){const n=t(e);u[n.id]=n.material}else if("object"===e.nodeName){const t=o(e);h[t.id]=t.obj}}const m=new jo,g=new ka({color:11184895,flatShading:!0});m.name=a,m.userData.author=l,m.userData.loader="AMF";for(const e in h){const t=h[e],n=t.meshes,r=new jo;for(r.name=t.name||"",p=0;p<n.length;p++){let e=g;const t=n[p],i=new wn(t.vertices,3);let o=null;if(t.normals.length&&(o=new wn(t.normals,3)),t.color){const n=t.color;e=g.clone(),e.color=new yn(n.r,n.g,n.b),1!==n.a&&(e.transparent=!0,e.opacity=n.a)}const s=t.volumes;for(f=0;f<s.length;f++){const t=s[f],n=new On;let a=e;n.setIndex(t.triangles),n.setAttribute("position",i.clone()),o&&n.setAttribute("normal",o.clone()),void 0!==u[t.materialId]&&(a=u[t.materialId]),n.scale(c,c,c),r.add(new $n(n,a.clone()))}}m.add(r)}return m}}var vu=Uint8Array,yu=Uint16Array,xu=Int32Array,_u=new vu([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]),Tu=new vu([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]),Eu=new vu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mu=function(e,t){for(var n=new yu(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new xu(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return{b:n,r:i}},bu=Mu(_u,2),Su=bu.b,wu=bu.r;Su[28]=258,wu[258]=28;for(var Au=Mu(Tu,0),Cu=Au.b,Ru=(Au.r,new yu(32768)),Iu=0;Iu<32768;++Iu){var Pu=(43690&Iu)>>1|(21845&Iu)<<1;Pu=(61680&(Pu=(52428&Pu)>>2|(13107&Pu)<<2))>>4|(3855&Pu)<<4,Ru[Iu]=((65280&Pu)>>8|(255&Pu)<<8)>>1}var Lu=function(e,t,n){for(var r=e.length,i=0,o=new yu(t);i<r;++i)e[i]&&++o[e[i]-1];var s,a=new yu(t);for(i=1;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;if(n){s=new yu(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],u=t-e[i],h=a[e[i]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)s[Ru[h]>>l]=c}else for(s=new yu(r),i=0;i<r;++i)e[i]&&(s[i]=Ru[a[e[i]-1]++]>>15-e[i]);return s},Nu=new vu(288);for(Iu=0;Iu<144;++Iu)Nu[Iu]=8;for(Iu=144;Iu<256;++Iu)Nu[Iu]=9;for(Iu=256;Iu<280;++Iu)Nu[Iu]=7;for(Iu=280;Iu<288;++Iu)Nu[Iu]=8;var Ou=new vu(32);for(Iu=0;Iu<32;++Iu)Ou[Iu]=5;var Uu=Lu(Nu,9,1),Du=Lu(Ou,5,1),ku=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Fu=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Gu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Bu=function(e){return(e+7)/8|0},Vu=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new vu(n-t);return r.set(e.subarray(t,n)),r},zu=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Hu=function(e,t,n){var r=new Error(t||zu[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Hu),!n)throw r;return r},Wu=function(e,t,n,r){var i=e.length,o=r?r.length:0;if(!i||t.f&&!t.l)return n||new vu(0);var s=!n||2!=t.i,a=t.i;n||(n=new vu(3*i));var l=function(e){var t=n.length;if(e>t){var r=new vu(Math.max(2*t,e));r.set(n),n=r}},c=t.f||0,u=t.p||0,h=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,g=8*i;do{if(!d){c=Fu(e,u,1);var v=Fu(e,u+1,3);if(u+=3,!v){var y=e[(R=Bu(u)+4)-4]|e[R-3]<<8,x=R+y;if(x>i){a&&Hu(0);break}s&&l(h+y),n.set(e.subarray(R,x),h),t.b=h+=y,t.p=u=8*x,t.f=c;continue}if(1==v)d=Uu,p=Du,f=9,m=5;else if(2==v){var _=Fu(e,u,31)+257,T=Fu(e,u+10,15)+4,E=_+Fu(e,u+5,31)+1;u+=14;for(var M=new vu(E),b=new vu(19),S=0;S<T;++S)b[Eu[S]]=Fu(e,u+3*S,7);u+=3*T;var w=ku(b),A=(1<<w)-1,C=Lu(b,w,1);for(S=0;S<E;){var R,I=C[Fu(e,u,A)];if(u+=15&I,(R=I>>4)<16)M[S++]=R;else{var P=0,L=0;for(16==R?(L=3+Fu(e,u,3),u+=2,P=M[S-1]):17==R?(L=3+Fu(e,u,7),u+=3):18==R&&(L=11+Fu(e,u,127),u+=7);L--;)M[S++]=P}}var N=M.subarray(0,_),O=M.subarray(_);f=ku(N),m=ku(O),d=Lu(N,f,1),p=Lu(O,m,1)}else Hu(1);if(u>g){a&&Hu(0);break}}s&&l(h+131072);for(var U=(1<<f)-1,D=(1<<m)-1,k=u;;k=u){var F=(P=d[Gu(e,u)&U])>>4;if((u+=15&P)>g){a&&Hu(0);break}if(P||Hu(2),F<256)n[h++]=F;else{if(256==F){k=u,d=null;break}var G=F-254;if(F>264){var B=_u[S=F-257];G=Fu(e,u,(1<<B)-1)+Su[S],u+=B}var V=p[Gu(e,u)&D],z=V>>4;V||Hu(3),u+=15&V;O=Cu[z];if(z>3){B=Tu[z];O+=Gu(e,u)&(1<<B)-1,u+=B}if(u>g){a&&Hu(0);break}s&&l(h+131072);var H=h+G;if(h<O){var W=o-O,j=Math.min(O,H);for(W+h<0&&Hu(3);h<j;++h)n[h]=r[W+h]}for(;h<H;h+=4)n[h]=n[h-O],n[h+1]=n[h+1-O],n[h+2]=n[h+2-O],n[h+3]=n[h+3-O];h=H}}t.l=d,t.p=k,t.b=h,t.f=c,d&&(c=1,t.m=f,t.d=p,t.n=m)}while(!c);return h==n.length?n:Vu(n,0,h)},ju=new vu(0),Xu=function(e,t){return e[t]|e[t+1]<<8},qu=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Yu=function(e,t){return qu(e,t)+4294967296*qu(e,t+4)};function Ku(e,t){return Wu(e,{i:2},t&&t.out,t&&t.dictionary)}var Zu="undefined"!=typeof TextDecoder&&new TextDecoder;try{Zu.decode(ju,{stream:!0}),1}catch(e){}var Ju=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Vu(e,n-1)};i?3==i?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}};function $u(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(Zu)return Zu.decode(e);var i=Ju(e),o=i.s;return(n=i.r).length&&Hu(8),o}var Qu=function(e,t){return t+30+Xu(e,t+26)+Xu(e,t+28)},eh=function(e,t,n){var r=Xu(e,t+28),i=$u(e.subarray(t+46,t+46+r),!(2048&Xu(e,t+8))),o=t+46+r,s=qu(e,t+20),a=n&&4294967295==s?th(e,o):[s,qu(e,t+24),qu(e,t+42)],l=a[0],c=a[1],u=a[2];return[Xu(e,t+10),l,c,i,o+Xu(e,t+30)+Xu(e,t+32),u]},th=function(e,t){for(;1!=Xu(e,t);t+=4+Xu(e,t+2));return[Yu(e,t+12),Yu(e,t+4),Yu(e,t+20)]};"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;function nh(e,t){for(var n={},r=e.length-22;101010256!=qu(e,r);--r)(!r||e.length-r>65558)&&Hu(13);var i=Xu(e,r+8);if(!i)return{};var o=qu(e,r+16),s=4294967295==o||65535==i;if(s){var a=qu(e,r-12);(s=101075792==qu(e,a))&&(i=qu(e,a+32),o=qu(e,a+48))}for(var l=t&&t.filter,c=0;c<i;++c){var u=eh(e,o,s),h=u[0],d=u[1],p=u[2],f=u[3],m=u[4],g=u[5],v=Qu(e,g);o=m,l&&!l({name:f,size:d,originalSize:p,compression:h})||(h?8==h?n[f]=Ku(e.subarray(v,v+d),{out:new vu(p)}):Hu(14,"unknown compression type "+h):n[f]=Vu(e,v,v+d))}return n}const rh=te;class ih extends ll{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,r){const i=this,o=new hl(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t=this;function n(e,t,n,i,o,s,a,l){if(0==t||0==n)return void e.lineTo(l.x,l.y);i=i*Math.PI/180,t=Math.abs(t),n=Math.abs(n);const c=(a.x-l.x)/2,u=(a.y-l.y)/2,h=Math.cos(i)*c+Math.sin(i)*u,d=-Math.sin(i)*c+Math.cos(i)*u;let p=t*t,f=n*n;const m=h*h,g=d*d,v=m/p+g/f;if(v>1){const e=Math.sqrt(v);p=(t*=e)*t,f=(n*=e)*n}const y=p*g+f*m,x=(p*f-y)/y;let _=Math.sqrt(Math.max(0,x));o===s&&(_=-_);const T=_*t*d/n,E=-_*n*h/t,M=Math.cos(i)*T-Math.sin(i)*E+(a.x+l.x)/2,b=Math.sin(i)*T+Math.cos(i)*E+(a.y+l.y)/2,S=r(1,0,(h-T)/t,(d-E)/n),w=r((h-T)/t,(d-E)/n,(-h-T)/t,(-d-E)/n)%(2*Math.PI);e.currentPath.absellipse(M,b,t,n,S,S+w,0===s,i)}function r(e,t,n,r){const i=e*n+t*r,o=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r);let s=Math.acos(Math.max(-1,Math.min(1,i/o)));return e*r-t*n<0&&(s=-s),s}function i(e,t){t=Object.assign({},t);let n={};if(e.hasAttribute("class")){const t=e.getAttribute("class").split(/\s/).filter(Boolean).map((e=>e.trim()));for(let e=0;e<t.length;e++)n=Object.assign(n,m["."+t[e]])}function r(r,i,o){void 0===o&&(o=function(e){return e.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),e}),e.hasAttribute(r)&&(t[i]=o(e.getAttribute(r))),n[r]&&(t[i]=o(n[r])),e.style&&""!==e.style[r]&&(t[i]=o(e.style[r]))}function i(e){return Math.max(0,Math.min(1,c(e)))}function o(e){return Math.max(0,c(e))}return e.hasAttribute("id")&&(n=Object.assign(n,m["#"+e.getAttribute("id")])),r("fill","fill"),r("fill-opacity","fillOpacity",i),r("fill-rule","fillRule"),r("opacity","opacity",i),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",i),r("stroke-width","strokeWidth",o),r("stroke-linejoin","strokeLineJoin"),r("stroke-linecap","strokeLineCap"),r("stroke-miterlimit","strokeMiterLimit",o),r("visibility","visibility"),t}function o(e,t){return e-(t-e)}function s(e,t,n){if("string"!=typeof e)throw new TypeError("Invalid input: "+typeof e);const r={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};let i=0,o=!0,s="",a="";const l=[];function c(e,t,n){const r=new SyntaxError('Unexpected character "'+e+'" at index '+t+".");throw r.partial=n,r}function u(){""!==s&&(""===a?l.push(Number(s)):l.push(Number(s)*Math.pow(10,Number(a)))),s="",a=""}let h;const d=e.length;for(let p=0;p<d;p++)if(h=e[p],Array.isArray(t)&&t.includes(l.length%n)&&r.FLAGS.test(h))i=1,s=h,u();else{if(0===i){if(r.WHITESPACE.test(h))continue;if(r.DIGIT.test(h)||r.SIGN.test(h)){i=1,s=h;continue}if(r.POINT.test(h)){i=2,s=h;continue}r.COMMA.test(h)&&(o&&c(h,p,l),o=!0)}if(1===i){if(r.DIGIT.test(h)){s+=h;continue}if(r.POINT.test(h)){s+=h,i=2;continue}if(r.EXP.test(h)){i=3;continue}r.SIGN.test(h)&&1===s.length&&r.SIGN.test(s[0])&&c(h,p,l)}if(2===i){if(r.DIGIT.test(h)){s+=h;continue}if(r.EXP.test(h)){i=3;continue}r.POINT.test(h)&&"."===s[s.length-1]&&c(h,p,l)}if(3===i){if(r.DIGIT.test(h)){a+=h;continue}if(r.SIGN.test(h)){if(""===a){a+=h;continue}1===a.length&&r.SIGN.test(a)&&c(h,p,l)}}r.WHITESPACE.test(h)?(u(),i=0,o=!1):r.COMMA.test(h)?(u(),i=0,o=!0):r.SIGN.test(h)?(u(),i=1,s=h):r.POINT.test(h)?(u(),i=2,s=h):c(h,p,l)}return u(),l}const a=["mm","cm","in","pt","pc","px"],l={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:12,pc:1,px:-1},px:{px:1}};function c(e){let n,r="px";if("string"==typeof e||e instanceof String)for(let t=0,n=a.length;t<n;t++){const n=a[t];if(e.endsWith(n)){r=n,e=e.substring(0,e.length-n.length);break}}return"px"===r&&"px"!==t.defaultUnit?n=l.in[t.defaultUnit]/t.defaultDPI:(n=l[r][t.defaultUnit],n<0&&(n=l[r].in*t.defaultDPI)),n*parseFloat(e)}function u(e){const t=e.elements;return t[0]*t[4]-t[1]*t[3]<0}function h(e){const t=e.elements,n=t[0]*t[3]+t[1]*t[4];if(0===n)return!1;const r=d(e),i=p(e);return Math.abs(n/(r*i))>Number.EPSILON}function d(e){const t=e.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function p(e){const t=e.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}const f=[],m={},g=[],v=new we,y=new we,x=new we,_=new we,T=new Se,E=new Je,M=new we,b=(new DOMParser).parseFromString(e,"image/svg+xml");!function e(t,r){if(1!==t.nodeType)return;const a=function(e){if(!(e.hasAttribute("transform")||"use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))))return null;const t=function(e){const t=new we,n=v;if("use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))){const n=c(e.getAttribute("x")),r=c(e.getAttribute("y"));t.translate(n,r)}if(e.hasAttribute("transform")){const r=e.getAttribute("transform").split(")");for(let e=r.length-1;e>=0;e--){const i=r[e].trim();if(""===i)continue;const o=i.indexOf("("),a=i.length;if(o>0&&o<a){const e=i.slice(0,o),t=s(i.slice(o+1));switch(n.identity(),e){case"translate":if(t.length>=1){const e=t[0];let r=0;t.length>=2&&(r=t[1]),n.translate(e,r)}break;case"rotate":if(t.length>=1){let e=0,r=0,i=0;e=t[0]*Math.PI/180,t.length>=3&&(r=t[1],i=t[2]),y.makeTranslation(-r,-i),x.makeRotation(e),_.multiplyMatrices(x,y),y.makeTranslation(r,i),n.multiplyMatrices(y,_)}break;case"scale":if(t.length>=1){const e=t[0];let r=e;t.length>=2&&(r=t[1]),n.scale(e,r)}break;case"skewX":1===t.length&&n.set(1,Math.tan(t[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":1===t.length&&n.set(1,0,0,Math.tan(t[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":6===t.length&&n.set(t[0],t[2],t[4],t[1],t[3],t[5],0,0,1)}}t.premultiply(n)}}return t}(e);g.length>0&&t.premultiply(g[g.length-1]);return M.copy(t),g.push(t),t}(t);let l=!1,b=null;switch(t.nodeName){case"svg":case"g":r=i(t,r);break;case"style":!function(e){if(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length)return;for(let t=0;t<e.sheet.cssRules.length;t++){const n=e.sheet.cssRules[t];if(1!==n.type)continue;const r=n.selectorText.split(/,/gm).filter(Boolean).map((e=>e.trim()));for(let e=0;e<r.length;e++){const t=Object.fromEntries(Object.entries(n.style).filter((([,e])=>""!==e)));m[r[e]]=Object.assign(m[r[e]]||{},t)}}}(t);break;case"path":r=i(t,r),t.hasAttribute("d")&&(b=function(e){const t=new Wl,r=new Se,i=new Se,a=new Se;let l=!0,c=!1;const u=e.getAttribute("d");if(""===u||"none"===u)return null;const h=u.match(/[a-df-z][^a-df-z]*/gi);for(let e=0,u=h.length;e<u;e++){const u=h[e],d=u.charAt(0),p=u.slice(1).trim();let f;switch(!0===l&&(c=!0,l=!1),d){case"M":f=s(p);for(let e=0,n=f.length;e<n;e+=2)r.x=f[e+0],r.y=f[e+1],i.x=r.x,i.y=r.y,0===e?t.moveTo(r.x,r.y):t.lineTo(r.x,r.y),0===e&&a.copy(r);break;case"H":f=s(p);for(let e=0,n=f.length;e<n;e++)r.x=f[e],i.x=r.x,i.y=r.y,t.lineTo(r.x,r.y),0===e&&!0===c&&a.copy(r);break;case"V":f=s(p);for(let e=0,n=f.length;e<n;e++)r.y=f[e],i.x=r.x,i.y=r.y,t.lineTo(r.x,r.y),0===e&&!0===c&&a.copy(r);break;case"L":f=s(p);for(let e=0,n=f.length;e<n;e+=2)r.x=f[e+0],r.y=f[e+1],i.x=r.x,i.y=r.y,t.lineTo(r.x,r.y),0===e&&!0===c&&a.copy(r);break;case"C":f=s(p);for(let e=0,n=f.length;e<n;e+=6)t.bezierCurveTo(f[e+0],f[e+1],f[e+2],f[e+3],f[e+4],f[e+5]),i.x=f[e+2],i.y=f[e+3],r.x=f[e+4],r.y=f[e+5],0===e&&!0===c&&a.copy(r);break;case"S":f=s(p);for(let e=0,n=f.length;e<n;e+=4)t.bezierCurveTo(o(r.x,i.x),o(r.y,i.y),f[e+0],f[e+1],f[e+2],f[e+3]),i.x=f[e+0],i.y=f[e+1],r.x=f[e+2],r.y=f[e+3],0===e&&!0===c&&a.copy(r);break;case"Q":f=s(p);for(let e=0,n=f.length;e<n;e+=4)t.quadraticCurveTo(f[e+0],f[e+1],f[e+2],f[e+3]),i.x=f[e+0],i.y=f[e+1],r.x=f[e+2],r.y=f[e+3],0===e&&!0===c&&a.copy(r);break;case"T":f=s(p);for(let e=0,n=f.length;e<n;e+=2){const n=o(r.x,i.x),s=o(r.y,i.y);t.quadraticCurveTo(n,s,f[e+0],f[e+1]),i.x=n,i.y=s,r.x=f[e+0],r.y=f[e+1],0===e&&!0===c&&a.copy(r)}break;case"A":f=s(p,[3,4],7);for(let e=0,o=f.length;e<o;e+=7){if(f[e+5]==r.x&&f[e+6]==r.y)continue;const o=r.clone();r.x=f[e+5],r.y=f[e+6],i.x=r.x,i.y=r.y,n(t,f[e],f[e+1],f[e+2],f[e+3],f[e+4],o,r),0===e&&!0===c&&a.copy(r)}break;case"m":f=s(p);for(let e=0,n=f.length;e<n;e+=2)r.x+=f[e+0],r.y+=f[e+1],i.x=r.x,i.y=r.y,0===e?t.moveTo(r.x,r.y):t.lineTo(r.x,r.y),0===e&&a.copy(r);break;case"h":f=s(p);for(let e=0,n=f.length;e<n;e++)r.x+=f[e],i.x=r.x,i.y=r.y,t.lineTo(r.x,r.y),0===e&&!0===c&&a.copy(r);break;case"v":f=s(p);for(let e=0,n=f.length;e<n;e++)r.y+=f[e],i.x=r.x,i.y=r.y,t.lineTo(r.x,r.y),0===e&&!0===c&&a.copy(r);break;case"l":f=s(p);for(let e=0,n=f.length;e<n;e+=2)r.x+=f[e+0],r.y+=f[e+1],i.x=r.x,i.y=r.y,t.lineTo(r.x,r.y),0===e&&!0===c&&a.copy(r);break;case"c":f=s(p);for(let e=0,n=f.length;e<n;e+=6)t.bezierCurveTo(r.x+f[e+0],r.y+f[e+1],r.x+f[e+2],r.y+f[e+3],r.x+f[e+4],r.y+f[e+5]),i.x=r.x+f[e+2],i.y=r.y+f[e+3],r.x+=f[e+4],r.y+=f[e+5],0===e&&!0===c&&a.copy(r);break;case"s":f=s(p);for(let e=0,n=f.length;e<n;e+=4)t.bezierCurveTo(o(r.x,i.x),o(r.y,i.y),r.x+f[e+0],r.y+f[e+1],r.x+f[e+2],r.y+f[e+3]),i.x=r.x+f[e+0],i.y=r.y+f[e+1],r.x+=f[e+2],r.y+=f[e+3],0===e&&!0===c&&a.copy(r);break;case"q":f=s(p);for(let e=0,n=f.length;e<n;e+=4)t.quadraticCurveTo(r.x+f[e+0],r.y+f[e+1],r.x+f[e+2],r.y+f[e+3]),i.x=r.x+f[e+0],i.y=r.y+f[e+1],r.x+=f[e+2],r.y+=f[e+3],0===e&&!0===c&&a.copy(r);break;case"t":f=s(p);for(let e=0,n=f.length;e<n;e+=2){const n=o(r.x,i.x),s=o(r.y,i.y);t.quadraticCurveTo(n,s,r.x+f[e+0],r.y+f[e+1]),i.x=n,i.y=s,r.x=r.x+f[e+0],r.y=r.y+f[e+1],0===e&&!0===c&&a.copy(r)}break;case"a":f=s(p,[3,4],7);for(let e=0,o=f.length;e<o;e+=7){if(0==f[e+5]&&0==f[e+6])continue;const o=r.clone();r.x+=f[e+5],r.y+=f[e+6],i.x=r.x,i.y=r.y,n(t,f[e],f[e+1],f[e+2],f[e+3],f[e+4],o,r),0===e&&!0===c&&a.copy(r)}break;case"Z":case"z":t.currentPath.autoClose=!0,t.currentPath.curves.length>0&&(r.copy(a),t.currentPath.currentPoint.copy(r),l=!0);break;default:console.warn(u)}c=!1}return t}(t));break;case"rect":r=i(t,r),b=function(e){const t=c(e.getAttribute("x")||0),n=c(e.getAttribute("y")||0),r=c(e.getAttribute("rx")||e.getAttribute("ry")||0),i=c(e.getAttribute("ry")||e.getAttribute("rx")||0),o=c(e.getAttribute("width")),s=c(e.getAttribute("height")),a=.448084975506,l=new Wl;l.moveTo(t+r,n),l.lineTo(t+o-r,n),(0!==r||0!==i)&&l.bezierCurveTo(t+o-r*a,n,t+o,n+i*a,t+o,n+i);l.lineTo(t+o,n+s-i),(0!==r||0!==i)&&l.bezierCurveTo(t+o,n+s-i*a,t+o-r*a,n+s,t+o-r,n+s);l.lineTo(t+r,n+s),(0!==r||0!==i)&&l.bezierCurveTo(t+r*a,n+s,t,n+s-i*a,t,n+s-i);l.lineTo(t,n+i),(0!==r||0!==i)&&l.bezierCurveTo(t,n+i*a,t+r*a,n,t+r,n);return l}(t);break;case"polygon":r=i(t,r),b=function(e){function t(e,t,n){const o=c(t),s=c(n);0===i?r.moveTo(o,s):r.lineTo(o,s),i++}const n=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,r=new Wl;let i=0;return e.getAttribute("points").replace(n,t),r.currentPath.autoClose=!0,r}(t);break;case"polyline":r=i(t,r),b=function(e){function t(e,t,n){const o=c(t),s=c(n);0===i?r.moveTo(o,s):r.lineTo(o,s),i++}const n=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,r=new Wl;let i=0;return e.getAttribute("points").replace(n,t),r.currentPath.autoClose=!1,r}(t);break;case"circle":r=i(t,r),b=function(e){const t=c(e.getAttribute("cx")||0),n=c(e.getAttribute("cy")||0),r=c(e.getAttribute("r")||0),i=new Zs;i.absarc(t,n,r,0,2*Math.PI);const o=new Wl;return o.subPaths.push(i),o}(t);break;case"ellipse":r=i(t,r),b=function(e){const t=c(e.getAttribute("cx")||0),n=c(e.getAttribute("cy")||0),r=c(e.getAttribute("rx")||0),i=c(e.getAttribute("ry")||0),o=new Zs;o.absellipse(t,n,r,i,0,2*Math.PI);const s=new Wl;return s.subPaths.push(o),s}(t);break;case"line":r=i(t,r),b=function(e){const t=c(e.getAttribute("x1")||0),n=c(e.getAttribute("y1")||0),r=c(e.getAttribute("x2")||0),i=c(e.getAttribute("y2")||0),o=new Wl;return o.moveTo(t,n),o.lineTo(r,i),o.currentPath.autoClose=!1,o}(t);break;case"defs":l=!0;break;case"use":r=i(t,r);const a=(t.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),u=t.viewportElement.getElementById(a);u?e(u,r):console.warn("SVGLoader: 'use node' references non-existent node id: "+a)}b&&(void 0!==r.fill&&"none"!==r.fill&&b.color.setStyle(r.fill,rh),function(e,t){function n(e){E.set(e.x,e.y,1).applyMatrix3(t),e.set(E.x,E.y)}function r(e){const n=e.xRadius,r=e.yRadius,i=Math.cos(e.aRotation),o=Math.sin(e.aRotation),s=new Je(n*i,n*o,0),a=new Je(-r*o,r*i,0),l=s.applyMatrix3(t),c=a.applyMatrix3(t),h=v.set(l.x,c.x,0,l.y,c.y,0,0,0,1),d=y.copy(h).invert(),p=x.copy(d).transpose().multiply(d).elements,f=function(e,t,n){let r,i,o,s,a;const l=e+n,c=e-n,u=Math.sqrt(c*c+4*t*t);l>0?(r=.5*(l+u),a=1/r,i=e*a*n-t*a*t):l<0?i=.5*(l-u):(r=.5*u,i=-.5*u);o=c>0?c+u:c-u;Math.abs(o)>2*Math.abs(t)?(a=-2*t/o,s=1/Math.sqrt(1+a*a),o=a*s):0===Math.abs(t)?(o=1,s=0):(a=-.5*o/t,o=1/Math.sqrt(1+a*a),s=a*o);c>0&&(a=o,o=-s,s=a);return{rt1:r,rt2:i,cs:o,sn:s}}(p[0],p[1],p[4]),m=Math.sqrt(f.rt1),g=Math.sqrt(f.rt2);e.xRadius=1/m,e.yRadius=1/g,e.aRotation=Math.atan2(f.sn,f.cs);if(!((e.aEndAngle-e.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const n=y.set(m,0,0,0,g,0,0,0,1),r=x.set(f.cs,f.sn,0,-f.sn,f.cs,0,0,0,1),i=n.multiply(r).multiply(h),o=e=>{const{x:t,y:n}=new Je(Math.cos(e),Math.sin(e),0).applyMatrix3(i);return Math.atan2(n,t)};e.aStartAngle=o(e.aStartAngle),e.aEndAngle=o(e.aEndAngle),u(t)&&(e.aClockwise=!e.aClockwise)}}function i(e){const n=d(t),r=p(t);e.xRadius*=n,e.yRadius*=r;const i=n>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);e.aRotation+=i,u(t)&&(e.aStartAngle*=-1,e.aEndAngle*=-1,e.aClockwise=!e.aClockwise)}const o=e.subPaths;for(let e=0,s=o.length;e<s;e++){const s=o[e].curves;for(let e=0;e<s.length;e++){const o=s[e];o.isLineCurve?(n(o.v1),n(o.v2)):o.isCubicBezierCurve?(n(o.v0),n(o.v1),n(o.v2),n(o.v3)):o.isQuadraticBezierCurve?(n(o.v0),n(o.v1),n(o.v2)):o.isEllipseCurve&&(T.set(o.aX,o.aY),n(T),o.aX=T.x,o.aY=T.y,h(t)?r(o):i(o))}}}(b,M),f.push(b),b.userData={node:t,style:r});const S=t.childNodes;for(let t=0;t<S.length;t++){const n=S[t];l&&"style"!==n.nodeName&&"defs"!==n.nodeName||e(n,r)}a&&(g.pop(),g.length>0?M.copy(g[g.length-1]):M.identity())}(b.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4});return{paths:f,xml:b.documentElement}}static createShapes(e){const t=999999999,n=0,r=1,i=2,o=3,s=4,a=5,l=6,c={loc:n,t:0};function u(e,t,r,o){const s=e.x,a=t.x,l=r.x,u=o.x,d=e.y,p=t.y,f=r.y,m=o.y,g=(u-l)*(d-f)-(m-f)*(s-l),v=(m-f)*(a-s)-(u-l)*(p-d),y=g/v,x=((a-s)*(d-f)-(p-d)*(s-l))/v;if(0===v&&0!==g||y<=0||y>=1||x<0||x>1)return null;if(0===g&&0===v){for(let l=0;l<2;l++){if(h(0===l?r:o,e,t),c.loc==n){const e=0===l?r:o;return{x:e.x,y:e.y,t:c.t}}if(c.loc==i){return{x:+(s+c.t*(a-s)).toPrecision(10),y:+(d+c.t*(p-d)).toPrecision(10),t:c.t}}}return null}for(let i=0;i<2;i++)if(h(0===i?r:o,e,t),c.loc==n){const e=0===i?r:o;return{x:e.x,y:e.y,t:c.t}}return{x:+(s+y*(a-s)).toPrecision(10),y:+(d+y*(p-d)).toPrecision(10),t:y}}function h(e,t,u){const h=u.x-t.x,d=u.y-t.y,p=e.x-t.x,f=e.y-t.y,m=h*f-p*d;if(e.x===t.x&&e.y===t.y)return c.loc=n,void(c.t=0);if(e.x===u.x&&e.y===u.y)return c.loc=r,void(c.t=1);if(m<-Number.EPSILON)return void(c.loc=o);if(m>Number.EPSILON)return void(c.loc=s);if(h*p<0||d*f<0)return void(c.loc=a);if(Math.sqrt(h*h+d*d)<Math.sqrt(p*p+f*f))return void(c.loc=l);let g;g=0!==h?p/h:f/d,c.loc=i,c.t=g}function d(e,t,n){const r=new Se;t.getCenter(r);const i=[];return n.forEach((t=>{if(t.boundingBox.containsPoint(r)){const n=function(e,t){const n=[],r=[];for(let i=1;i<e.length;i++){const o=e[i-1],s=e[i];for(let e=1;e<t.length;e++){const i=u(o,s,t[e-1],t[e]);null!==i&&void 0===n.find((e=>e.t<=i.t+Number.EPSILON&&e.t>=i.t-Number.EPSILON))&&(n.push(i),r.push(new Se(i.x,i.y)))}}return r}(e,t.points);n.forEach((e=>{i.push({identifier:t.identifier,isCW:t.isCW,point:e})}))}})),i.sort(((e,t)=>e.point.x-t.point.x)),i}let p=t,f=-999999999,m=e.subPaths.map((e=>{const n=e.getPoints();let r=-999999999,i=t,o=-999999999,s=t;for(let e=0;e<n.length;e++){const t=n[e];t.y>r&&(r=t.y),t.y<i&&(i=t.y),t.x>o&&(o=t.x),t.x<s&&(s=t.x)}return f<=o&&(f=o+1),p>=s&&(p=s-1),{curves:e.curves,points:n,isCW:Ia.isClockWise(n),identifier:-1,boundingBox:new Hl(new Se(s,i),new Se(o,r))}}));m=m.filter((e=>e.points.length>1));for(let e=0;e<m.length;e++)m[e].identifier=e;const g=m.map((t=>function(e,t,n,r,i){null!=i&&""!==i||(i="nonzero");const o=new Se;e.boundingBox.getCenter(o);const s=d([new Se(n,o.y),new Se(r,o.y)],e.boundingBox,t);s.sort(((e,t)=>e.point.x-t.point.x));const a=[],l=[];s.forEach((t=>{t.identifier===e.identifier?a.push(t):l.push(t)}));const c=a[0].point.x,u=[];let h=0;for(;h<l.length&&l[h].point.x<c;)u.length>0&&u[u.length-1]===l[h].identifier?u.pop():u.push(l[h].identifier),h++;if(u.push(e.identifier),"evenodd"===i){const t=u.length%2==0,n=u[u.length-2];return{identifier:e.identifier,isHole:t,for:n}}if("nonzero"===i){let n=!0,r=null,i=null;for(let e=0;e<u.length;e++){const o=u[e];n?(i=t[o].isCW,n=!1,r=o):i!==t[o].isCW&&(i=t[o].isCW,n=!0)}return{identifier:e.identifier,isHole:n,for:r}}console.warn('fill-rule: "'+i+'" is currently not implemented.')}(t,m,p,f,e.userData?e.userData.style.fillRule:void 0))),v=[];return m.forEach((e=>{if(!g[e.identifier].isHole){const t=new ia;t.curves=e.curves;g.filter((t=>t.isHole&&t.for===e.identifier)).forEach((e=>{const n=m[e.identifier],r=new Zs;r.curves=n.curves,t.holes.push(r)})),v.push(t)}})),v}static getStrokeStyle(e,t,n,r,i){return{strokeColor:t=void 0!==t?t:"#000",strokeWidth:e=void 0!==e?e:1,strokeLineJoin:n=void 0!==n?n:"miter",strokeLineCap:r=void 0!==r?r:"butt",strokeMiterLimit:i=void 0!==i?i:4}}static pointsToStroke(e,t,n,r){const i=[],o=[],s=[];if(0===ih.pointsToStrokeWithBuffers(e,t,n,r,i,o,s))return null;const a=new On;return a.setAttribute("position",new wn(i,3)),a.setAttribute("normal",new wn(o,3)),a.setAttribute("uv",new wn(s,2)),a}static pointsToStrokeWithBuffers(e,t,n,r,i,o,s,a){const l=new Se,c=new Se,u=new Se,h=new Se,d=new Se,p=new Se,f=new Se,m=new Se,g=new Se,v=new Se,y=new Se,x=new Se,_=new Se,T=new Se,E=new Se,M=new Se,b=new Se;n=void 0!==n?n:12,r=void 0!==r?r:.001,a=void 0!==a?a:0,e=function(e){let t=!1;for(let n=1,i=e.length-1;n<i;n++)if(e[n].distanceTo(e[n+1])<r){t=!0;break}if(!t)return e;const n=[];n.push(e[0]);for(let t=1,i=e.length-1;t<i;t++)e[t].distanceTo(e[t+1])>=r&&n.push(e[t]);return n.push(e[e.length-1]),n}(e);const S=e.length;if(S<2)return 0;const w=e[0].equals(e[S-1]);let A,C,R=e[0];const I=t.strokeWidth/2,P=1/(S-1);let L,N,O,U,D=0,k=!1,F=0,G=3*a,B=2*a;V(e[0],e[1],l).multiplyScalar(I),m.copy(e[0]).sub(l),g.copy(e[0]).add(l),v.copy(m),y.copy(g);for(let n=1;n<S;n++){A=e[n],C=n===S-1?w?e[1]:void 0:e[n+1];const r=l;if(V(R,A,r),u.copy(r).multiplyScalar(I),x.copy(A).sub(u),_.copy(A).add(u),L=D+P,N=!1,void 0!==C){V(A,C,c),u.copy(c).multiplyScalar(I),T.copy(A).sub(u),E.copy(A).add(u),O=!0,u.subVectors(C,R),r.dot(u)<0&&(O=!1),1===n&&(k=O),u.subVectors(C,A),u.normalize();const e=Math.abs(r.dot(u));if(e>Number.EPSILON){const n=I/e;u.multiplyScalar(-n),h.subVectors(A,R),d.copy(h).setLength(n).add(u),M.copy(d).negate();const r=d.length(),i=h.length();h.divideScalar(i),p.subVectors(C,A);const o=p.length();switch(p.divideScalar(o),h.dot(M)<i&&p.dot(M)<o&&(N=!0),b.copy(d).add(A),M.add(A),U=!1,N?O?(E.copy(M),_.copy(M)):(T.copy(M),x.copy(M)):W(),t.strokeLineJoin){case"bevel":j(O,N,L);break;case"round":X(O,N),O?H(A,x,T,L,0):H(A,E,_,L,1);break;default:const e=I*t.strokeMiterLimit/r;if(e<1){if("miter-clip"!==t.strokeLineJoin){j(O,N,L);break}X(O,N),O?(p.subVectors(b,x).multiplyScalar(e).add(x),f.subVectors(b,T).multiplyScalar(e).add(T),z(x,L,0),z(p,L,0),z(A,L,.5),z(A,L,.5),z(p,L,0),z(f,L,0),z(A,L,.5),z(f,L,0),z(T,L,0)):(p.subVectors(b,_).multiplyScalar(e).add(_),f.subVectors(b,E).multiplyScalar(e).add(E),z(_,L,1),z(p,L,1),z(A,L,.5),z(A,L,.5),z(p,L,1),z(f,L,1),z(A,L,.5),z(f,L,1),z(E,L,1))}else N?(O?(z(g,D,1),z(m,D,0),z(b,L,0),z(g,D,1),z(b,L,0),z(M,L,1)):(z(g,D,1),z(m,D,0),z(b,L,1),z(m,D,0),z(M,L,0),z(b,L,1)),O?T.copy(b):E.copy(b)):O?(z(x,L,0),z(b,L,0),z(A,L,.5),z(A,L,.5),z(b,L,0),z(T,L,0)):(z(_,L,1),z(b,L,1),z(A,L,.5),z(A,L,.5),z(b,L,1),z(E,L,1)),U=!0}}else W()}else W();w||n!==S-1||q(e[0],v,y,O,!0,D),D=L,R=A,m.copy(T),g.copy(E)}if(w){if(N&&i){let e=b,t=M;k!==O&&(e=M,t=b),O?(U||k)&&(t.toArray(i,0),t.toArray(i,9),U&&e.toArray(i,3)):!U&&k||(t.toArray(i,3),t.toArray(i,9),U&&e.toArray(i,0))}}else q(A,x,_,O,!1,L);return F;function V(e,t,n){return n.subVectors(t,e),n.set(-n.y,n.x).normalize()}function z(e,t,n){i&&(i[G]=e.x,i[G+1]=e.y,i[G+2]=0,o&&(o[G]=0,o[G+1]=0,o[G+2]=1),G+=3,s&&(s[B]=t,s[B+1]=n,B+=2)),F+=3}function H(e,t,r,i,o){l.copy(t).sub(e).normalize(),c.copy(r).sub(e).normalize();let s=Math.PI;const a=l.dot(c);Math.abs(a)<1&&(s=Math.abs(Math.acos(a))),s/=n,u.copy(t);for(let t=0,r=n-1;t<r;t++)h.copy(u).rotateAround(e,s),z(u,i,o),z(h,i,o),z(e,i,.5),u.copy(h);z(h,i,o),z(r,i,o),z(e,i,.5)}function W(){z(g,D,1),z(m,D,0),z(x,L,0),z(g,D,1),z(x,L,1),z(_,L,0)}function j(e,t,n){t?e?(z(g,D,1),z(m,D,0),z(x,L,0),z(g,D,1),z(x,L,0),z(M,L,1),z(x,n,0),z(T,n,0),z(M,n,.5)):(z(g,D,1),z(m,D,0),z(_,L,1),z(m,D,0),z(M,L,0),z(_,L,1),z(_,n,1),z(E,n,0),z(M,n,.5)):e?(z(x,n,0),z(T,n,0),z(A,n,.5)):(z(_,n,1),z(E,n,0),z(A,n,.5))}function X(e,t){t&&(e?(z(g,D,1),z(m,D,0),z(x,L,0),z(g,D,1),z(x,L,0),z(M,L,1),z(x,D,0),z(A,L,.5),z(M,L,1),z(A,L,.5),z(T,D,0),z(M,L,1)):(z(g,D,1),z(m,D,0),z(_,L,1),z(m,D,0),z(M,L,0),z(_,L,1),z(_,D,1),z(M,L,0),z(A,L,.5),z(A,L,.5),z(M,L,0),z(E,D,1)))}function q(e,n,r,o,s,a){switch(t.strokeLineCap){case"round":s?H(e,r,n,a,.5):H(e,n,r,a,.5);break;case"square":if(s)l.subVectors(n,e),c.set(l.y,-l.x),u.addVectors(l,c).add(e),h.subVectors(c,l).add(e),o?(u.toArray(i,3),h.toArray(i,0),h.toArray(i,9)):(u.toArray(i,3),u.toArray(i,9),h.toArray(i,0));else{l.subVectors(r,e),c.set(l.y,-l.x),u.addVectors(l,c).add(e),h.subVectors(c,l).add(e);const t=i.length;o?(u.toArray(i,t-3),h.toArray(i,t-6),h.toArray(i,t-12)):(u.toArray(i,t-6),h.toArray(i,t-3),h.toArray(i,t-12))}}}}}function oh(e){return null!=e}function sh(e,t){return null==e?t:e}function ah(e,t){if(oh(e))for(let n of Object.keys(e))oh(e[n])&&(t[n]=e[n])}function lh(e){return 0===Object.keys(e).length}function ch(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;")}class uh{constructor(){this.eventListeners=new Map}AddEventListener(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}HasEventListener(e){return this.eventListeners.has(e)}GetEventNotifier(e){return()=>{this.NotifyEventListeners(e)}}NotifyEventListeners(e,...t){if(!this.eventListeners.has(e))return;let n=this.eventListeners.get(e);for(let e of n)e(...t)}}class hh{constructor(){this.count=null,this.current=null,this.callbacks=null}Run(e,t){this.count=e,this.current=0,this.callbacks=t,0===e?this.TaskReady():this.RunOnce()}RunBatch(e,t,n){let r=0;e>0&&(r=parseInt((e-1)/t,10)+1),this.Run(r,{runTask:(r,i)=>{const o=r*t,s=Math.min((r+1)*t,e)-1;n.runTask(o,s,i)},onReady:n.onReady})}RunOnce(){setTimeout((()=>{this.callbacks.runTask(this.current,this.TaskReady.bind(this))}),0)}TaskReady(){this.current+=1,this.current<this.count?this.RunOnce():this.callbacks.onReady&&this.callbacks.onReady()}}function dh(e){setTimeout((()=>{e()}),10)}function ph(e,t){(new hh).Run(e,t)}function fh(e,t,n){(new hh).RunBatch(e,t,n)}function mh(e){!function e(t){t()&&setTimeout((()=>{e(t)}),10)}(e)}let gh=null,vh=new Set;function yh(e){gh=e}function xh(e){return null===gh?null:gh+"/"+e}function _h(e){return new Promise(((t,n)=>{if(null===gh)return void n();if(vh.has(e))return void t();let r=document.createElement("script");r.type="text/javascript",r.src=xh(e),r.onload=()=>{vh.add(e),t()},r.onerror=()=>{n()},document.head.appendChild(r)}))}const Th={Url:1,File:2,Decompressed:3},Eh={Text:1,Binary:2};function Mh(e){let t=e,n=t.indexOf("?");-1!==n&&(t=t.substring(0,n));let r=t.lastIndexOf("/");return-1===r&&(r=t.lastIndexOf("\\")),-1!==r&&(t=t.substring(r+1)),decodeURI(t)}function bh(e){let t=Mh(e),n=t.lastIndexOf(".");return-1===n?"":t.substring(n+1).toLowerCase()}function Sh(e,t){return new Promise(((n,r)=>{let i=new XMLHttpRequest;i.open("GET",e,!0),i.onprogress=e=>{t(e.loaded,e.total)},i.onload=()=>{200===i.status?n(i.response):r()},i.onerror=()=>{r()},i.responseType="arraybuffer",i.send(null)}))}function wh(e,t){return new Promise(((n,r)=>{let i=new FileReader;i.onprogress=e=>{t(e.loaded,e.total)},i.onloadend=e=>{e.target.readyState===FileReader.DONE&&n(e.target.result)},i.onerror=()=>{r()},i.readAsArrayBuffer(e)}))}function Ah(e){for(let t=0;t<e.length;t++){let n=e[t];if(-1!==n.search(/www\.dropbox\.com/u)){n=n.replace("www.dropbox.com","dl.dropbox.com");let r=n.indexOf("?");-1!==r&&(n=n.substring(0,r)),e[t]=n}else if(-1!==n.search(/github\.com/u)){n=n.replace("github.com","raw.githubusercontent.com"),n=n.replace("/blob","");let r=n.indexOf("?");-1!==r&&(n=n.substring(0,r)),e[t]=n}}}function Ch(e){return null!==e.match(/^https?:\/\/\S+$/g)}const Rh=1e-8,Ih=1e-4,Ph=57.29577951308232,Lh=.017453292519943;function Nh(e){return Math.abs(e)<Rh}function Oh(e,t){return t-e>Rh}function Uh(e,t){return e-t>Rh}function Dh(e,t){return t-e>-Rh}function kh(e,t){return e-t>-Rh}function Fh(e,t){return Math.abs(t-e)<Rh}function Gh(e,t,n){return Math.abs(t-e)<n}function Bh(e){return e>Rh}function Vh(e){return e<-Rh}const zh={X:1,Y:2,Z:3};class Hh{constructor(e,t){this.x=e,this.y=t}Clone(){return new Hh(this.x,this.y)}}function Wh(e,t){return Fh(e.x,t.x)&&Fh(e.y,t.y)}function jh(e,t){return new Hh(e.x+t.x,e.y+t.y)}function Xh(e,t){return new Hh(e.x-t.x,e.y-t.y)}function qh(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))}class Yh{constructor(e,t,n){this.r=e,this.g=t,this.b=n}Set(e,t,n){this.r=e,this.g=t,this.b=n}Clone(){return new Yh(this.r,this.g,this.b)}}class Kh{constructor(e,t,n,r){this.r=e,this.g=t,this.b=n,this.a=r}Set(e,t,n,r){this.r=e,this.g=t,this.b=n,this.a=r}Clone(){return new Kh(this.r,this.g,this.b,this.a)}}function Zh(e){return parseInt(Math.round(255*e),10)}function Jh(e){return e/255}function $h(e,t,n){return new Yh(Zh(e),Zh(t),Zh(n))}function Qh(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function ed(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function td(e){let t=parseInt(e,10).toString(16);for(;t.length<2;)t="0"+t;return t}function nd(e){return td(e.r)+td(e.g)+td(e.b)}function rd(e){return td(e.r)+td(e.g)+td(e.b)+td(e.a)}function id(e){if(6!==e.length)return null;let t=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16);return new Yh(t,n,r)}function od(e){if(6!==e.length&&8!==e.length)return null;let t=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16),i=255;return 8===e.length&&(i=parseInt(e.substring(6,8),16)),new Kh(t,n,r,i)}function sd(e){return new Yh(e[0],e[1],e[2])}function ad(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b}class ld{constructor(){this.name=null,this.mimeType=null,this.buffer=null,this.offset=new Hh(0,0),this.scale=new Hh(1,1),this.rotation=0}IsValid(){return null!==this.name&&null!==this.buffer}HasTransformation(){return!Wh(this.offset,new Hh(0,0))||(!Wh(this.scale,new Hh(1,1))||!Fh(this.rotation,0))}IsEqual(e){return this.name===e.name&&(this.mimeType===e.mimeType&&(!!Wh(this.offset,e.offset)&&(!!Wh(this.scale,e.scale)&&!!Fh(this.rotation,e.rotation))))}}function cd(e,t){return null===e&&null===t||null!==e&&null!==t&&e.IsEqual(t)}const ud={Phong:1,Physical:2};class hd{constructor(e){this.type=e,this.isDefault=!1,this.name="",this.color=new Yh(0,0,0),this.vertexColors=!1}IsEqual(e){return this.type===e.type&&(this.isDefault===e.isDefault&&(this.name===e.name&&(!!ad(this.color,e.color)&&this.vertexColors===e.vertexColors)))}}class dd extends hd{constructor(e){super(e),this.emissive=new Yh(0,0,0),this.opacity=1,this.transparent=!1,this.diffuseMap=null,this.bumpMap=null,this.normalMap=null,this.emissiveMap=null,this.alphaTest=0,this.multiplyDiffuseMap=!1}IsEqual(e){return!!super.IsEqual(e)&&(!!ad(this.emissive,e.emissive)&&(!!Fh(this.opacity,e.opacity)&&(this.transparent===e.transparent&&(!!cd(this.diffuseMap,e.diffuseMap)&&(!!cd(this.bumpMap,e.bumpMap)&&(!!cd(this.normalMap,e.normalMap)&&(!!cd(this.emissiveMap,e.emissiveMap)&&(!!Fh(this.alphaTest,e.alphaTest)&&this.multiplyDiffuseMap===e.multiplyDiffuseMap))))))))}}class pd extends dd{constructor(){super(ud.Phong),this.ambient=new Yh(0,0,0),this.specular=new Yh(0,0,0),this.shininess=0,this.specularMap=null}IsEqual(e){return!!super.IsEqual(e)&&(!!ad(this.ambient,e.ambient)&&(!!ad(this.specular,e.specular)&&(!!Fh(this.shininess,e.shininess)&&!!cd(this.specularMap,e.specularMap))))}}class fd extends dd{constructor(){super(ud.Physical),this.metalness=0,this.roughness=1,this.metalnessMap=null}IsEqual(e){return!!super.IsEqual(e)&&(!!Fh(this.metalness,e.metalness)&&(!!Fh(this.roughness,e.roughness)&&!!cd(this.metalnessMap,e.metalnessMap)))}}function md(e,t){return e.name===t.name&&(e.mimeType===t.mimeType&&(!!Wh(e.offset,t.offset)&&(!!Wh(e.scale,t.scale)&&!!Fh(e.rotation,t.rotation))))}class gd{constructor(e,t,n){this.x=e,this.y=t,this.z=n}Length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}MultiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}Normalize(){let e=this.Length();return e>0&&this.MultiplyScalar(1/e),this}Offset(e,t){let n=e.Clone().Normalize();return this.x+=n.x*t,this.y+=n.y*t,this.z+=n.z*t,this}Rotate(e,t,n){let r=e.Clone().Normalize(),i=r.x,o=r.y,s=r.z,a=this.x-n.x,l=this.y-n.y,c=this.z-n.z,u=Math.sin(t),h=Math.cos(t);return this.x=-i*(-i*a-o*l-s*c)*(1-h)+a*h+(-s*l+o*c)*u,this.y=-o*(-i*a-o*l-s*c)*(1-h)+l*h+(s*a-i*c)*u,this.z=-s*(-i*a-o*l-s*c)*(1-h)+c*h+(-o*a+i*l)*u,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}Clone(){return new gd(this.x,this.y,this.z)}}function vd(e,t){return Fh(e.x,t.x)&&Fh(e.y,t.y)&&Fh(e.z,t.z)}function yd(e,t){return new gd(e.x+t.x,e.y+t.y,e.z+t.z)}function xd(e,t){return new gd(e.x-t.x,e.y-t.y,e.z-t.z)}function _d(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)+(e.z-t.z)*(e.z-t.z))}function Td(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Ed(e,t){let n=e.Clone().Normalize(),r=t.Clone().Normalize();if(vd(n,r))return 0;let i=Td(n,r);return Math.acos(i)}function Md(e,t){let n=new gd(0,0,0);return n.x=e.y*t.z-e.z*t.y,n.y=e.z*t.x-e.x*t.z,n.z=e.x*t.y-e.y*t.x,n}function bd(e,t,n){return Math.sqrt(e*e+t*t+n*n)}function Sd(e){return new gd(e[0],e[1],e[2])}class wd{constructor(){this.indices=[],this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.material=null}GetBounds(){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let n=0;n<this.vertices.length/3;n++)for(let r=0;r<3;r++)e[r]=Math.min(e[r],this.vertices[3*n+r]),t[r]=Math.max(t[r],this.vertices[3*n+r]);return{min:e,max:t}}GetByteLength(e,t){return this.indices.length*e+(this.vertices.length+this.colors.length+this.normals.length+this.uvs.length)*t}}class Ad{constructor(){this.primitives=[]}PrimitiveCount(){return this.primitives.length}GetPrimitive(e){return this.primitives[e]}GetByteLength(e,t){let n=0;for(let r=0;r<this.primitives.length;r++){n+=this.primitives[r].GetByteLength(e,t)}return n}}function Cd(e){function t(e,t,n,r){function i(e,t,n){return null!==t?e.GetVertexColor(t):n?new Yh(0,0,0):null}function o(e,t,n){return null!==t?e.GetTextureUV(t):n?new Hh(0,0):null}function s(e,t,n){let r=e.VertexColorCount()>0,s=e.TextureUVCount()>0,a=e.GetVertex(t.vertex),l=e.GetNormal(t.normal),c=n.vertices.length/3;n.indices.push(c),n.vertices.push(a.x,a.y,a.z);let u=i(e,t.color,r);null!==u&&n.colors.push(u.r/255,u.g/255,u.b/255),n.normals.push(l.x,l.y,l.z);let h=o(e,t.uv,s);return null!==h&&n.uvs.push(h.x,h.y),{index:c,color:u,normal:l,uv:h}}if(r.has(t.vertex)){let a=r.get(t.vertex),l=function(e,t,n){function r(e,t,n){return null===n&&null===t||ad(n,i(e,t,!0))}function s(e,t,n){return vd(n,e.GetNormal(t))}function a(e,t,n){return null===n&&null===t||Wh(n,o(e,t,!0))}for(let i=0;i<t.length;i++){let o=t[i],l=r(e,n.color,o.color),c=s(e,n.normal,o.normal),u=a(e,n.uv,o.uv);if(l&&c&&u)return o}return null}(e,a,t);if(null!==l)n.indices.push(l.index);else{let r=s(e,t,n);a.push(r)}}else{let i=s(e,t,n);r.set(t.vertex,[i])}}let n=new Ad,r=e.TriangleCount();if(0===r)return null;let i=[];for(let e=0;e<r;e++)i.push(e);i.sort(((t,n)=>{let r=e.GetTriangle(t),i=e.GetTriangle(n);return r.mat-i.mat}));let o=null,s=null;for(let r=0;r<i.length;r++){let a=i[r],l=e.GetTriangle(a);null!==o&&o.material===l.mat||(o=new wd,o.material=l.mat,s=new Map,n.primitives.push(o));let c={vertex:l.v0,color:l.c0,normal:l.n0,uv:l.u0},u={vertex:l.v1,color:l.c1,normal:l.n1,uv:l.u1},h={vertex:l.v2,color:l.c2,normal:l.n2,uv:l.u2};t(e,c,o,s),t(e,u,o,s),t(e,h,o,s)}return n}function Rd(e){return new TextDecoder("utf-8").decode(e)}function Id(e){let t="",n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return t}function Pd(e){let t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return t}function Ld(e){return(new TextEncoder).encode(e).buffer}function Nd(e){let t="data:";if(!e.startsWith(t))return null;let n=e.indexOf(";");if(-1===n)return null;let r=e.indexOf(",");if(-1===r)return null;let i=e.substring(5,5+n-5),o=atob(e.substring(r+1)),s=new ArrayBuffer(o.length),a=new Uint8Array(s);for(let e=0;e<o.length;e++)a[e]=o.charCodeAt(e);return{mimeType:i,buffer:s}}function Od(e){if(null==e)return"";let t=e.split("/");return 0===t.length?"":t[t.length-1]}function Ud(e){let t=new Blob([e]);return URL.createObjectURL(t)}function Dd(e,t){let n=new Blob([e],{type:t});return URL.createObjectURL(n)}function kd(e){URL.revokeObjectURL(e)}class Fd{constructor(e){this.name=e,this.content=null}GetName(){return this.name}SetName(e){this.name=e}GetTextContent(){return Rd(this.content)}GetBufferContent(){return this.content}SetTextContent(e){let t=Ld(e);this.content=t}SetBufferContent(e){this.content=e}}class Gd{constructor(){}CanExport(e,t){return!1}Export(e,t,n){let r=[];this.ExportContent(e,t,r,(()=>{n(r)}))}ExportContent(e,t,n,r){}GetExportedMaterialName(e){return this.GetExportedName(e,"Material")}GetExportedMeshName(e){return this.GetExportedName(e,"Mesh")}GetExportedName(e,t){return 0===e.length?t:e}}class Bd extends Gd{constructor(){super(),this.rhino=null}CanExport(e,t){return e===Eh.Binary&&"3dm"===t}ExportContent(e,t,n,r){null===this.rhino?_h("loaders/rhino3dm.min.js").then((()=>{rhino3dm().then((t=>{this.rhino=t,this.ExportRhinoContent(e,n,r)}))})).catch((()=>{r()})):this.ExportRhinoContent(e,n,r)}ExportRhinoContent(e,t,n){function r(e){return{r:e.r,g:e.g,b:e.b,a:255}}let i=new Fd("model.3dm");t.push(i);let o=new this.rhino.File3dm;e.EnumerateTransformedMeshInstances((t=>{let n=Cd(t);for(let i=0;i<n.PrimitiveCount();i++){let s=n.GetPrimitive(i),a={data:{attributes:{position:{itemSize:3,type:"Float32Array",array:s.vertices},normal:{itemSize:3,type:"Float32Array",array:s.normals}},index:{type:"Uint16Array",array:s.indices}}},l=e.GetMaterial(s.material),c=new this.rhino.Material;c.name=this.GetExportedMaterialName(l.name),l.type===ud.Phong&&(c.ambientColor=r(l.ambient),c.specularColor=r(l.specular)),c.diffuseColor=r(l.color),c.transparency=1-l.opacity;let u=o.materials().count();o.materials().add(c);let h=new this.rhino.Mesh.createFromThreejsJSON(a),d=new this.rhino.ObjectAttributes;d.name=this.GetExportedMeshName(t.GetName()),d.materialSource=this.rhino.ObjectMaterialSource.MaterialFromObject,d.materialIndex=u,o.objects().add(h,d)}}));let s=new this.rhino.File3dmWriteOptions;s.version=6;let a=o.toByteArray(s);i.SetBufferContent(a),n()}}const Vd={Text:1,Integer:2,Number:3,Boolean:4,Percent:5,Color:6};class zd{constructor(e,t,n){this.type=e,this.name=t,this.value=n}Clone(){const e=this.type===Vd.Color;return new zd(this.type,this.name,e?this.value.Clone():this.value)}}class Hd{constructor(e){this.name=e,this.properties=[]}PropertyCount(){return this.properties.length}AddProperty(e){this.properties.push(e)}GetProperty(e){return this.properties[e]}Clone(){let e=new Hd(this.name);for(let t of this.properties)e.AddProperty(t.Clone());return e}}function Wd(e){return e.type===Vd.Text?ch(e.value):e.type===Vd.Integer?e.value.toLocaleString():e.type===Vd.Number?e.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):e.type===Vd.Boolean?e.value?"True":"False":e.type===Vd.Percent?parseInt(100*e.value,10).toString()+"%":e.type===Vd.Color?"#"+nd(e.value):null}class jd extends Gd{constructor(){super()}CanExport(e,t){return e===Eh.Text&&"bim"===t}ExportContent(e,t,n,r){let i={schema_version:"1.1.0",meshes:[],elements:[],info:{}};this.ExportProperties(e.GetModel(),i.info);let o=0;e.EnumerateTransformedMeshInstances((t=>{let n={mesh_id:o,coordinates:[],indices:[]};t.EnumerateVertices((e=>{n.coordinates.push(e.x,e.y,e.z)})),t.EnumerateTriangleVertexIndices(((e,t,r)=>{n.indices.push(e,t,r)}));let r={mesh_id:o,type:"Other",color:{r:200,g:200,b:200,a:255},vector:{x:0,y:0,z:0},rotation:{qx:0,qy:0,qz:0,qw:1},guid:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),info:{}},s=null,a=!0,l=[];for(let n=0;n<t.TriangleCount();n++){let r=t.GetTriangle(n),i=e.GetMaterial(r.mat),o={r:i.color.r,g:i.color.g,b:i.color.b,a:Zh(i.opacity)};l.push(o.r,o.g,o.b,o.a),a&&(null===s?s=o:s.r===o.r&&s.g===o.g&&s.b===o.b&&s.a===o.a||(a=!1,s=null))}a?r.color=s:r.face_colors=l,r.info.Name=t.GetName(),this.ExportProperties(t,r.info),i.meshes.push(n),i.elements.push(r),o+=1}));let s=new Fd("model.bim");s.SetTextContent(JSON.stringify(i,null,4)),n.push(s),r()}ExportProperties(e,t){for(let n=0;n<e.PropertyGroupCount();n++){let r=e.GetPropertyGroup(n);for(let e=0;e<r.PropertyCount();e++){let n=r.GetProperty(e);t[n.name]=Wd(n)}}}}class Xd{constructor(e,t){this.arrayBuffer=new ArrayBuffer(e),this.dataView=new DataView(this.arrayBuffer),this.isLittleEndian=t,this.position=0}GetPosition(){return this.position}SetPosition(e){this.position=e}End(){return this.position>=this.arrayBuffer.byteLength}GetBuffer(){return this.arrayBuffer}WriteArrayBuffer(e){let t=new Uint8Array(e);new Uint8Array(this.arrayBuffer).set(t,this.position),this.position+=e.byteLength}WriteBoolean8(e){this.dataView.setInt8(this.position,e?1:0),this.position=this.position+1}WriteCharacter8(e){this.dataView.setInt8(this.position,e),this.position=this.position+1}WriteUnsignedCharacter8(e){this.dataView.setUint8(this.position,e),this.position=this.position+1}WriteInteger16(e){this.dataView.setInt16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteUnsignedInteger16(e){this.dataView.setUint16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteInteger32(e){this.dataView.setInt32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteUnsignedInteger32(e){this.dataView.setUint32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteFloat32(e){this.dataView.setFloat32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteDouble64(e){this.dataView.setFloat64(this.position,e,this.isLittleEndian),this.position=this.position+8}}class qd{constructor(e,t,n,r){this.x=e,this.y=t,this.z=n,this.w=r}Clone(){return new qd(this.x,this.y,this.z,this.w)}}class Yd{constructor(e,t,n,r){this.x=e,this.y=t,this.z=n,this.w=r}}function Kd(e,t){return Fh(e.x,t.x)&&Fh(e.y,t.y)&&Fh(e.z,t.z)&&Fh(e.w,t.w)}function Zd(e){return new Yd(e[0],e[1],e[2],e[3])}function Jd(e,t){const n=t/2,r=Math.sin(n);return new Yd(e.x*r,e.y*r,e.z*r,Math.cos(n))}function $d(e,t,n,r){const i=Math.cos(e/2),o=Math.cos(t/2),s=Math.cos(n/2),a=Math.sin(e/2),l=Math.sin(t/2),c=Math.sin(n/2);let u=new Yd(0,0,0,1);if("XYZ"===r)u.x=a*o*s+i*l*c,u.y=i*l*s-a*o*c,u.z=i*o*c+a*l*s,u.w=i*o*s-a*l*c;else if("YXZ"===r)u.x=a*o*s+i*l*c,u.y=i*l*s-a*o*c,u.z=i*o*c-a*l*s,u.w=i*o*s+a*l*c;else if("ZXY"===r)u.x=a*o*s-i*l*c,u.y=i*l*s+a*o*c,u.z=i*o*c+a*l*s,u.w=i*o*s-a*l*c;else if("ZYX"===r)u.x=a*o*s-i*l*c,u.y=i*l*s+a*o*c,u.z=i*o*c-a*l*s,u.w=i*o*s+a*l*c;else if("YZX"===r)u.x=a*o*s+i*l*c,u.y=i*l*s+a*o*c,u.z=i*o*c-a*l*s,u.w=i*o*s-a*l*c;else{if("XZY"!==r)return null;u.x=a*o*s-i*l*c,u.y=i*l*s-a*o*c,u.z=i*o*c+a*l*s,u.w=i*o*s+a*l*c}return u}class Qd{constructor(e){this.matrix=null,null!=e&&(this.matrix=e)}IsValid(){return null!==this.matrix}Set(e){return this.matrix=e,this}Get(){return this.matrix}Clone(){let e=[this.matrix[0],this.matrix[1],this.matrix[2],this.matrix[3],this.matrix[4],this.matrix[5],this.matrix[6],this.matrix[7],this.matrix[8],this.matrix[9],this.matrix[10],this.matrix[11],this.matrix[12],this.matrix[13],this.matrix[14],this.matrix[15]];return new Qd(e)}CreateIdentity(){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this}IsIdentity(){let e=(new Qd).CreateIdentity().Get();for(let t=0;t<16;t++)if(!Fh(this.matrix[t],e[t]))return!1;return!0}CreateTranslation(e,t,n){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,e,t,n,1],this}CreateRotation(e,t,n,r){let i=e+e,o=t+t,s=n+n,a=e*i,l=e*o,c=e*s,u=t*o,h=t*s,d=n*s,p=r*i,f=r*o,m=r*s;return this.matrix=[1-(u+d),l+m,c-f,0,l-m,1-(a+d),h+p,0,c+f,h-p,1-(a+u),0,0,0,0,1],this}CreateRotationAxisAngle(e,t){let n=Jd(e,t);return this.CreateRotation(n.x,n.y,n.z,n.w)}CreateScale(e,t,n){return this.matrix=[e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1],this}ComposeTRS(e,t,n){let r=e.x,i=e.y,o=e.z,s=t.x,a=t.y,l=t.z,c=t.w,u=n.x,h=n.y,d=n.z,p=s+s,f=a+a,m=l+l,g=s*p,v=s*f,y=s*m,x=a*f,_=a*m,T=l*m,E=c*p,M=c*f,b=c*m;return this.matrix=[(1-(x+T))*u,(v+b)*u,(y-M)*u,0,(v-b)*h,(1-(g+T))*h,(_+E)*h,0,(y+M)*d,(_-E)*d,(1-(g+x))*d,0,r,i,o,1],this}DecomposeTRS(){let e=new gd(this.matrix[12],this.matrix[13],this.matrix[14]),t=bd(this.matrix[0],this.matrix[1],this.matrix[2]),n=bd(this.matrix[4],this.matrix[5],this.matrix[6]),r=bd(this.matrix[8],this.matrix[9],this.matrix[10]);Vh(this.Determinant())&&(t*=-1);let i=new gd(t,n,r),o=this.matrix[0]/t,s=this.matrix[4]/n,a=this.matrix[8]/r,l=this.matrix[1]/t,c=this.matrix[5]/n,u=this.matrix[9]/r,h=this.matrix[2]/t,d=this.matrix[6]/n,p=this.matrix[10]/r,f=null,m=o+c+p;if(m>0){let e=2*Math.sqrt(m+1);f=new Yd((d-u)/e,(a-h)/e,(l-s)/e,.25*e)}else if(o>c&&o>p){let e=2*Math.sqrt(1+o-c-p);f=new Yd(.25*e,(s+l)/e,(a+h)/e,(d-u)/e)}else if(c>p){let e=2*Math.sqrt(1+c-o-p);f=new Yd((s+l)/e,.25*e,(u+d)/e,(a-h)/e)}else{let e=2*Math.sqrt(1+p-o-c);f=new Yd((a+h)/e,(u+d)/e,.25*e,(l-s)/e)}return{translation:e,rotation:f,scale:i}}Determinant(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],r=this.matrix[3],i=this.matrix[4],o=this.matrix[5],s=this.matrix[6],a=this.matrix[7],l=this.matrix[8],c=this.matrix[9],u=this.matrix[10],h=this.matrix[11],d=this.matrix[12],p=this.matrix[13],f=this.matrix[14],m=this.matrix[15];return(e*o-t*i)*(u*m-h*f)-(e*s-n*i)*(c*m-h*p)+(e*a-r*i)*(c*f-u*p)+(t*s-n*o)*(l*m-h*d)-(t*a-r*o)*(l*f-u*d)+(n*a-r*s)*(l*p-c*d)}Invert(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],r=this.matrix[3],i=this.matrix[4],o=this.matrix[5],s=this.matrix[6],a=this.matrix[7],l=this.matrix[8],c=this.matrix[9],u=this.matrix[10],h=this.matrix[11],d=this.matrix[12],p=this.matrix[13],f=this.matrix[14],m=this.matrix[15],g=e*o-t*i,v=e*s-n*i,y=e*a-r*i,x=t*s-n*o,_=t*a-r*o,T=n*a-r*s,E=l*p-c*d,M=l*f-u*d,b=l*m-h*d,S=c*f-u*p,w=c*m-h*p,A=u*m-h*f,C=g*A-v*w+y*S+x*b-_*M+T*E;return Fh(C,0)?null:new Qd([(o*A-s*w+a*S)/C,(n*w-t*A-r*S)/C,(p*T-f*_+m*x)/C,(u*_-c*T-h*x)/C,(s*b-i*A-a*M)/C,(e*A-n*b+r*M)/C,(f*y-d*T-m*v)/C,(l*T-u*y+h*v)/C,(i*w-o*b+a*E)/C,(t*b-e*w-r*E)/C,(d*_-p*y+m*g)/C,(c*y-l*_-h*g)/C,(o*M-i*S-s*E)/C,(e*S-t*M+n*E)/C,(p*v-d*x-f*g)/C,(l*x-c*v+u*g)/C])}Transpose(){let e=[this.matrix[0],this.matrix[4],this.matrix[8],this.matrix[12],this.matrix[1],this.matrix[5],this.matrix[9],this.matrix[13],this.matrix[2],this.matrix[6],this.matrix[10],this.matrix[14],this.matrix[3],this.matrix[7],this.matrix[11],this.matrix[15]];return new Qd(e)}InvertTranspose(){let e=this.Invert();return null===e?null:e.Transpose()}MultiplyVector(e){let t=e.x,n=e.y,r=e.z,i=e.w,o=this.matrix[0],s=this.matrix[1],a=this.matrix[2],l=this.matrix[3],c=this.matrix[4],u=this.matrix[5],h=this.matrix[6],d=this.matrix[7],p=this.matrix[8],f=this.matrix[9],m=this.matrix[10],g=this.matrix[11],v=this.matrix[12],y=this.matrix[13],x=this.matrix[14],_=this.matrix[15];return new qd(t*o+n*c+r*p+i*v,t*s+n*u+r*f+i*y,t*a+n*h+r*m+i*x,t*l+n*d+r*g+i*_)}MultiplyMatrix(e){let t=this.matrix[0],n=this.matrix[1],r=this.matrix[2],i=this.matrix[3],o=this.matrix[4],s=this.matrix[5],a=this.matrix[6],l=this.matrix[7],c=this.matrix[8],u=this.matrix[9],h=this.matrix[10],d=this.matrix[11],p=this.matrix[12],f=this.matrix[13],m=this.matrix[14],g=this.matrix[15],v=e.matrix[0],y=e.matrix[1],x=e.matrix[2],_=e.matrix[3],T=e.matrix[4],E=e.matrix[5],M=e.matrix[6],b=e.matrix[7],S=e.matrix[8],w=e.matrix[9],A=e.matrix[10],C=e.matrix[11],R=e.matrix[12],I=e.matrix[13],P=e.matrix[14],L=e.matrix[15];return new Qd([t*v+n*T+r*S+i*R,t*y+n*E+r*w+i*I,t*x+n*M+r*A+i*P,t*_+n*b+r*C+i*L,o*v+s*T+a*S+l*R,o*y+s*E+a*w+l*I,o*x+s*M+a*A+l*P,o*_+s*b+a*C+l*L,c*v+u*T+h*S+d*R,c*y+u*E+h*w+d*I,c*x+u*M+h*A+d*P,c*_+u*b+h*C+d*L,p*v+f*T+m*S+g*R,p*y+f*E+m*w+g*I,p*x+f*M+m*A+g*P,p*_+f*b+m*C+g*L])}}function ep(e,t){const n=e.Get(),r=t.Get();for(let e=0;e<16;e++)if(!Fh(n[e],r[e]))return!1;return!0}class tp{constructor(e){null!=e?this.matrix=e:(this.matrix=new Qd,this.matrix.CreateIdentity())}SetMatrix(e){return this.matrix=e,this}GetMatrix(){return this.matrix}IsIdentity(){return this.matrix.IsIdentity()}AppendMatrix(e){return this.matrix=this.matrix.MultiplyMatrix(e),this}Append(e){return this.AppendMatrix(e.GetMatrix()),this}TransformCoord3D(e){let t=new qd(e.x,e.y,e.z,1),n=this.matrix.MultiplyVector(t);return new gd(n.x,n.y,n.z)}Clone(){const e=this.matrix.Clone();return new tp(e)}}function np(e,t){return ep(e.GetMatrix(),t.GetMatrix())}const rp={Empty:0,TriangleMesh:1};function ip(e){return e.TriangleCount()>0?rp.TriangleMesh:rp.Empty}function op(e,t,n){let r=Md(xd(t,e),xd(n,e));return r.Normalize(),r}function sp(e,t){if(!t.IsIdentity()){for(let n=0;n<e.VertexCount();n++){let r=e.GetVertex(n),i=t.TransformCoord3D(r);r.x=i.x,r.y=i.y,r.z=i.z}if(e.NormalCount()>0){let n=t.GetMatrix().InvertTranspose();if(null!==n){let t=new tp(n);for(let n=0;n<e.NormalCount();n++){let r=e.GetNormal(n),i=t.TransformCoord3D(r);r.x=i.x,r.y=i.y,r.z=i.z}}}}}function ap(e){for(let t=0;t<e.TriangleCount();t++){let n=e.GetTriangle(t),r=n.v1;n.v1=n.v2,n.v2=r}}class lp{constructor(){}VertexCount(){return 0}VertexColorCount(){return 0}NormalCount(){return 0}TextureUVCount(){return 0}TriangleCount(){return 0}EnumerateVertices(e){}EnumerateTriangleVertexIndices(e){}EnumerateTriangleVertices(e){}}class cp extends lp{constructor(){super(),this.name="",this.propertyGroups=[]}GetName(){return this.name}SetName(e){this.name=e}PropertyGroupCount(){return this.propertyGroups.length}AddPropertyGroup(e){return this.propertyGroups.push(e),this.propertyGroups.length-1}GetPropertyGroup(e){return this.propertyGroups[e]}CloneProperties(e){for(let t of this.propertyGroups)e.AddPropertyGroup(t.Clone())}}class up{constructor(e,t){this.nodeId=e,this.meshIndex=t}IsEqual(e){return this.nodeId===e.nodeId&&this.meshIndex===e.meshIndex}GetKey(){return this.nodeId.toString()+":"+this.meshIndex.toString()}}class hp extends cp{constructor(e,t,n){super(),this.id=e,this.node=t,this.mesh=n}GetId(){return this.id}GetTransformation(){return this.node.GetWorldTransformation()}GetMesh(){return this.mesh}VertexCount(){return this.mesh.VertexCount()}VertexColorCount(){return this.mesh.VertexColorCount()}NormalCount(){return this.mesh.NormalCount()}TextureUVCount(){return this.mesh.TextureUVCount()}TriangleCount(){return this.mesh.TriangleCount()}EnumerateVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateVertices(e):this.mesh.EnumerateVertices((n=>{const r=t.TransformCoord3D(n);e(r)}))}EnumerateTriangleVertexIndices(e){this.mesh.EnumerateTriangleVertexIndices(e)}EnumerateTriangleVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateTriangleVertices(e):this.mesh.EnumerateTriangleVertices(((n,r,i)=>{const o=t.TransformCoord3D(n),s=t.TransformCoord3D(r),a=t.TransformCoord3D(i);e(o,s,a)}))}PropertyGroupCount(){return this.mesh.PropertyGroupCount()}AddPropertyGroup(e){return this.mesh.AddPropertyGroup(e)}GetPropertyGroup(e){return this.mesh.GetPropertyGroup(e)}GetTransformedMesh(){let e=this.node.GetWorldTransformation(),t=this.mesh.Clone();return sp(t,e),t}}const dp=5125,pp=5126,fp=34962,mp=34963;class gp extends Gd{constructor(){super(),this.components={index:{type:dp,size:4},number:{type:pp,size:4}}}CanExport(e,t){return e===Eh.Text&&"gltf"===t||e===Eh.Binary&&"glb"===t}ExportContent(e,t,n,r){t===Eh.Text?this.ExportAsciiContent(e,n):t===Eh.Binary&&this.ExportBinaryContent(e,n),r()}ExportAsciiContent(e,t){let n=new Fd("model.gltf"),r=new Fd("model.bin");t.push(n),t.push(r);let i=this.GetMeshData(e),o=this.GetMainBuffer(i),s=this.GetMainJson(e,i);s.buffers.push({uri:r.GetName(),byteLength:o.byteLength});let a=new Map;this.ExportMaterials(e,s,(e=>{let n=Mh(e.name);if(a.has(n))return a.get(n);{let r=new Fd(n);r.SetBufferContent(e.buffer),t.push(r);let i=s.textures.length;return a.set(n,i),s.images.push({uri:n}),s.textures.push({source:i}),i}})),n.SetTextContent(JSON.stringify(s,null,4)),r.SetBufferContent(o)}ExportBinaryContent(e,t){function n(e){let t=e%4;return 0===t?e:e+(4-t)}function r(e,t,n){for(let r=0;r<n;r++)e.WriteUnsignedCharacter8(t)}let i=new Fd("model.glb");t.push(i);let o=this.GetMeshData(e),s=this.GetMainBuffer(o),a=this.GetMainJson(e,o),l=[],c=s.byteLength,u=new Map;this.ExportMaterials(e,a,(e=>{let t=Mh(e.name),n=bh(e.name);if(u.has(t))return u.get(t);{let r=a.bufferViews.length,i=a.textures.length;u.set(t,i);let o=e.buffer;return l.push(o),a.bufferViews.push({buffer:0,byteOffset:c,byteLength:o.byteLength}),c+=o.byteLength,a.images.push({bufferView:r,mimeType:"image/"+n}),a.textures.push({source:i}),i}}));let h=s.byteLength;for(let e=0;e<l.length;e++){h+=l[e].byteLength}let d=n(h);a.buffers.push({byteLength:d});let p=Ld(JSON.stringify(a)),f=p.byteLength,m=n(f),g=20+m+8+d,v=new Xd(g,!0);v.WriteUnsignedInteger32(1179937895),v.WriteUnsignedInteger32(2),v.WriteUnsignedInteger32(g),v.WriteUnsignedInteger32(m),v.WriteUnsignedInteger32(1313821514),v.WriteArrayBuffer(p),r(v,32,m-f),v.WriteUnsignedInteger32(d),v.WriteUnsignedInteger32(5130562),v.WriteArrayBuffer(s);for(let e=0;e<l.length;e++){let t=l[e];v.WriteArrayBuffer(t)}r(v,0,d-h),i.SetBufferContent(v.GetBuffer())}GetMeshData(e){let t=[];return e.EnumerateMeshes((e=>{let n=Cd(e);t.push({name:e.GetName(),buffer:n,offsets:[],sizes:[]})})),t}GetMainBuffer(e){let t=0;for(let n of e)t+=n.buffer.GetByteLength(this.components.index.size,this.components.number.size);let n=new Xd(t,!0);for(let t of e)for(let e=0;e<t.buffer.PrimitiveCount();e++){let r=t.buffer.GetPrimitive(e),i=n.GetPosition();for(let e=0;e<r.indices.length;e++)n.WriteUnsignedInteger32(r.indices[e]);for(let e=0;e<r.vertices.length;e++)n.WriteFloat32(r.vertices[e]);for(let e=0;e<r.colors.length;e++)n.WriteFloat32(Qh(r.colors[e]));for(let e=0;e<r.normals.length;e++)n.WriteFloat32(r.normals[e]);for(let e=0;e<r.uvs.length;e++){let t=r.uvs[e];e%2==1&&(t*=-1),n.WriteFloat32(t)}t.offsets.push(i),t.sizes.push(n.GetPosition()-i)}return n.GetBuffer()}GetMainJson(e,t){class n{constructor(e,t){this.mainJson=e,this.byteOffset=t}AddBufferView(e,t){let n={buffer:0,byteOffset:this.byteOffset,byteLength:e,target:t};return this.mainJson.bufferViews.push(n),this.byteOffset+=e,this.mainJson.bufferViews.length-1}}function r(e,t){for(let n of t.GetMeshIndices()){let r=new up(t.GetId(),n);if(e.IsMeshInstanceVisible(r))return!0}for(let n of t.GetChildNodes())if(r(e,n))return!0;return!1}function i(e,t,n,i){if(i.IsMeshNode())for(let r of i.GetMeshIndices())o(e,t,n,i,r,!0);else if(r(e,i)){let r={},o=i.GetName();o.length>0&&(r.name=o),i.GetTransformation().IsIdentity()||(r.matrix=i.GetTransformation().GetMatrix().Get()),n.push(r),t.push(n.length-1),r.children=[],s(e,r.children,n,i)}}function o(e,t,n,r,i,o){let s=new up(r.GetId(),i);if(!e.IsMeshInstanceVisible(s))return;let a={mesh:e.MapMeshIndex(i)};if(o){r.GetTransformation().IsIdentity()||(a.matrix=r.GetTransformation().GetMatrix().Get())}n.push(a),t.push(n.length-1)}function s(e,t,n,r){for(let o of r.GetChildNodes())i(e,t,n,o);for(let i of r.GetMeshIndices())o(e,t,n,r,i,!1)}let a={asset:{generator:"https://3dviewer.net",version:"2.0"},scene:0,scenes:[{nodes:[]}],nodes:[],materials:[],meshes:[],buffers:[],bufferViews:[],accessors:[]},l=e.GetModel().GetRootNode();s(e,a.scenes[0].nodes,a.nodes,l);for(let e of t){let t={name:this.GetExportedMeshName(e.name),primitives:[]},r=e.buffer.primitives;for(let i=0;i<r.length;i++){let o=r[i],s=new n(a,e.offsets[i]),l=s.AddBufferView(o.indices.length*this.components.index.size,mp),c=s.AddBufferView(o.vertices.length*this.components.number.size,fp),u=null;o.colors.length>0&&(u=s.AddBufferView(o.colors.length*this.components.number.size,fp));let h=s.AddBufferView(o.normals.length*this.components.number.size,fp),d=null;o.uvs.length>0&&(d=s.AddBufferView(o.uvs.length*this.components.number.size,fp));let p={attributes:{},mode:4,material:o.material},f=o.GetBounds();a.accessors.push({bufferView:l,byteOffset:0,componentType:this.components.index.type,count:o.indices.length,type:"SCALAR"}),p.indices=a.accessors.length-1,a.accessors.push({bufferView:c,byteOffset:0,componentType:this.components.number.type,count:o.vertices.length/3,min:f.min,max:f.max,type:"VEC3"}),p.attributes.POSITION=a.accessors.length-1,null!==u&&(a.accessors.push({bufferView:u,byteOffset:0,componentType:this.components.number.type,count:o.colors.length/3,type:"VEC3"}),p.attributes.COLOR_0=a.accessors.length-1),a.accessors.push({bufferView:h,byteOffset:0,componentType:this.components.number.type,count:o.normals.length/3,type:"VEC3"}),p.attributes.NORMAL=a.accessors.length-1,null!==d&&(a.accessors.push({bufferView:d,byteOffset:0,componentType:this.components.number.type,count:o.uvs.length/2,type:"VEC2"}),p.attributes.TEXCOORD_0=a.accessors.length-1),t.primitives.push(p)}a.meshes.push(t)}return a}ExportMaterials(e,t,n){function r(e,t,n,r){function i(e,t){return[Qh(e.r/255),Qh(e.g/255),Qh(e.b/255),t]}function o(e,t,n){if(null===t||!t.IsValid())return null;void 0===e.images&&(e.images=[]),void 0===e.textures&&(e.textures=[]);let r={index:n(t)};if(t.HasTransformation()){let n="KHR_texture_transform";void 0===e.extensionsUsed&&(e.extensionsUsed=[]),-1===e.extensionsUsed.indexOf(n)&&e.extensionsUsed.push(n),r.extensions={KHR_texture_transform:{offset:[t.offset.x,-t.offset.y],scale:[t.scale.x,t.scale.y],rotation:-t.rotation}}}return r}let s={name:e.GetExportedMaterialName(n.name),pbrMetallicRoughness:{baseColorFactor:i(n.color,n.opacity)},emissiveFactor:(a=n.emissive,[Qh(a.r/255),Qh(a.g/255),Qh(a.b/255)]),doubleSided:!0,alphaMode:"OPAQUE"};var a;n.transparent&&(s.alphaMode="BLEND");let l=o(t,n.diffuseMap,r);if(null!==l&&(n.multiplyDiffuseMap||(s.pbrMetallicRoughness.baseColorFactor=i(new Yh(255,255,255),n.opacity)),s.pbrMetallicRoughness.baseColorTexture=l),n.type===ud.Physical){let e=o(t,n.metalnessMap,r);null!==e?s.pbrMetallicRoughness.metallicRoughnessTexture=e:(s.pbrMetallicRoughness.metallicFactor=n.metalness,s.pbrMetallicRoughness.roughnessFactor=n.roughness)}let c=o(t,n.normalMap,r);null!==c&&(s.normalTexture=c);let u=o(t,n.emissiveMap,r);null!==u&&(s.emissiveTexture=u),t.materials.push(s)}for(let i=0;i<e.MaterialCount();i++){r(this,t,e.GetMaterial(i),n)}}}class vp{constructor(e){this.transformation=new tp,this.isMeshVisible=e=>!0,ah(e,this)}}class yp{constructor(e,t){this.model=e,this.settings=t||new vp,this.visibleMeshes=null,this.meshToVisibleMeshIndex=null}GetModel(){return this.model}MaterialCount(){return this.model.MaterialCount()}GetMaterial(e){return this.model.GetMaterial(e)}VertexCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=t.VertexCount()})),e}TriangleCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=t.TriangleCount()})),e}MeshCount(){let e=0;return this.EnumerateMeshes((t=>{e+=1})),e}EnumerateMeshes(e){this.FillVisibleMeshCache();for(let t=0;t<this.model.MeshCount();t++)if(this.visibleMeshes.has(t)){e(this.model.GetMesh(t))}}MapMeshIndex(e){return this.FillVisibleMeshCache(),this.meshToVisibleMeshIndex.get(e)}IsMeshInstanceVisible(e){return this.settings.isMeshVisible(e)}MeshInstanceCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=1})),e}EnumerateMeshInstances(e){this.model.EnumerateMeshInstances((t=>{this.settings.isMeshVisible(t.GetId())&&e(t)}))}EnumerateTransformedMeshInstances(e){this.EnumerateMeshInstances((t=>{let n=t.GetTransformation();this.settings.transformation.IsIdentity()||n.Append(this.settings.transformation);let r=t.GetMesh().Clone();n.IsIdentity()||sp(r,n),e(r)}))}EnumerateVerticesAndTriangles(e){let t=[];this.EnumerateTransformedMeshInstances((e=>{t.push(e)}));for(let n of t)n.EnumerateVertices((t=>{e.onVertex(t.x,t.y,t.z)}));let n=0;for(let r of t)r.EnumerateTriangleVertexIndices(((t,r,i)=>{e.onTriangle(t+n,r+n,i+n)})),n+=r.VertexCount()}EnumerateTrianglesWithNormals(e){this.EnumerateTransformedMeshInstances((t=>{t.EnumerateTriangleVertices(((t,n,r)=>{let i=op(t,n,r);e(t,n,r,i)}))}))}FillVisibleMeshCache(){if(null!==this.visibleMeshes&&null!==this.meshToVisibleMeshIndex)return;this.visibleMeshes=new Set,this.model.EnumerateMeshInstances((e=>{let t=e.GetId();this.settings.isMeshVisible(t)&&this.visibleMeshes.add(t.meshIndex)})),this.meshToVisibleMeshIndex=new Map;let e=0;for(let t=0;t<this.model.MeshCount();t++)this.visibleMeshes.has(t)&&(this.meshToVisibleMeshIndex.set(t,e),e+=1)}}class xp{constructor(){this.text="",this.indentation=0}GetText(){return this.text}Indent(e){this.indentation+=e}WriteArrayLine(e){this.WriteLine(e.join(" "))}WriteLine(e){this.WriteIndentation(),this.Write(e+"\n")}WriteIndentation(){for(let e=0;e<this.indentation;e++)this.Write("  ")}Write(e){this.text+=e}}class _p extends Gd{constructor(){super()}CanExport(e,t){return e===Eh.Text&&"obj"===t}ExportContent(e,t,n,r){function i(e,t,n,r){if(null===n||!n.IsValid())return;let i=Mh(n.name);if(e.WriteArrayLine([t,i]),-1===r.findIndex((e=>e.GetName()===i))){let e=new Fd(i);e.SetBufferContent(n.buffer),r.push(e)}}let o=new Fd("model.mtl"),s=new Fd("model.obj");n.push(o),n.push(s);let a=new xp;a.WriteLine(this.GetHeaderText());for(let t=0;t<e.MaterialCount();t++){let r=e.GetMaterial(t);a.WriteArrayLine(["newmtl",this.GetExportedMaterialName(r.name)]),a.WriteArrayLine(["Kd",r.color.r/255,r.color.g/255,r.color.b/255]),a.WriteArrayLine(["d",r.opacity]),r.type===ud.Phong&&(a.WriteArrayLine(["Ka",r.ambient.r/255,r.ambient.g/255,r.ambient.b/255]),a.WriteArrayLine(["Ks",r.specular.r/255,r.specular.g/255,r.specular.b/255]),a.WriteArrayLine(["Ns",1e3*r.shininess])),i(a,"map_Kd",r.diffuseMap,n),r.type===ud.Phong&&i(a,"map_Ks",r.specularMap,n),i(a,"bump",r.bumpMap,n)}o.SetTextContent(a.GetText());let l=new xp;l.WriteLine(this.GetHeaderText()),l.WriteArrayLine(["mtllib",o.GetName()]);let c=0,u=0,h=0,d=null;e.EnumerateTransformedMeshInstances((t=>{l.WriteArrayLine(["g",this.GetExportedMeshName(t.GetName())]);for(let e=0;e<t.VertexCount();e++){let n=t.GetVertex(e);l.WriteArrayLine(["v",n.x,n.y,n.z])}for(let e=0;e<t.NormalCount();e++){let n=t.GetNormal(e);l.WriteArrayLine(["vn",n.x,n.y,n.z])}for(let e=0;e<t.TextureUVCount();e++){let n=t.GetTextureUV(e);l.WriteArrayLine(["vt",n.x,n.y])}for(let n=0;n<t.TriangleCount();n++){let r=t.GetTriangle(n),i=r.v0+c+1,o=r.v1+c+1,s=r.v2+c+1,a=r.n0+u+1,p=r.n1+u+1,f=r.n2+u+1;if(null!==r.mat){let t=e.GetMaterial(r.mat),n=this.GetExportedMaterialName(t.name);n!==d&&(l.WriteArrayLine(["usemtl",n]),d=n)}let m="",g="",v="";r.HasTextureUVs()&&(m=r.u0+h+1,g=r.u1+h+1,v=r.u2+h+1),l.WriteArrayLine(["f",[i,m,a].join("/"),[o,g,p].join("/"),[s,v,f].join("/")])}c+=t.VertexCount(),u+=t.NormalCount(),h+=t.TextureUVCount()})),s.SetTextContent(l.GetText()),r()}GetHeaderText(){return"# exported by https://3dviewer.net"}}class Tp extends Gd{constructor(){super()}CanExport(e,t){return e===Eh.Text&&"off"===t}ExportContent(e,t,n,r){let i=new Fd("model.off");n.push(i);let o=new xp;o.WriteLine("OFF"),o.WriteArrayLine([e.VertexCount(),e.TriangleCount(),0]),e.EnumerateVerticesAndTriangles({onVertex:function(e,t,n){o.WriteArrayLine([e,t,n])},onTriangle:function(e,t,n){o.WriteArrayLine([3,e,t,n])}}),i.SetTextContent(o.GetText()),r()}}class Ep extends Gd{constructor(){super()}CanExport(e,t){return(e===Eh.Text||e===Eh.Binary)&&"ply"===t}ExportContent(e,t,n,r){t===Eh.Text?this.ExportText(e,n):this.ExportBinary(e,n),r()}ExportText(e,t){let n=new Fd("model.ply");t.push(n);let r=new xp,i=e.VertexCount(),o=e.TriangleCount(),s=this.GetHeaderText("ascii",i,o);r.Write(s),e.EnumerateVerticesAndTriangles({onVertex:function(e,t,n){r.WriteArrayLine([e,t,n])},onTriangle:function(e,t,n){r.WriteArrayLine([3,e,t,n])}}),n.SetTextContent(r.GetText())}ExportBinary(e,t){let n=new Fd("model.ply");t.push(n);let r=e.VertexCount(),i=e.TriangleCount(),o=this.GetHeaderText("binary_little_endian",r,i),s=o.length+3*r*4+13*i,a=new Xd(s,!0);for(let e=0;e<o.length;e++)a.WriteUnsignedCharacter8(o.charCodeAt(e));e.EnumerateVerticesAndTriangles({onVertex:function(e,t,n){a.WriteFloat32(e),a.WriteFloat32(t),a.WriteFloat32(n)},onTriangle:function(e,t,n){a.WriteUnsignedCharacter8(3),a.WriteInteger32(e),a.WriteInteger32(t),a.WriteInteger32(n)}}),n.SetBufferContent(a.GetBuffer())}GetHeaderText(e,t,n){let r=new xp;return r.WriteLine("ply"),r.WriteLine("format "+e+" 1.0"),r.WriteLine("element vertex "+t),r.WriteLine("property float x"),r.WriteLine("property float y"),r.WriteLine("property float z"),r.WriteLine("element face "+n),r.WriteLine("property list uchar int vertex_index"),r.WriteLine("end_header"),r.GetText()}}class Mp extends Gd{constructor(){super()}CanExport(e,t){return(e===Eh.Text||e===Eh.Binary)&&"stl"===t}ExportContent(e,t,n,r){t===Eh.Text?this.ExportText(e,n):this.ExportBinary(e,n),r()}ExportText(e,t){let n=new Fd("model.stl");t.push(n);let r=new xp;r.WriteLine("solid Model"),e.EnumerateTrianglesWithNormals(((e,t,n,i)=>{r.WriteArrayLine(["facet","normal",i.x,i.y,i.z]),r.Indent(1),r.WriteLine("outer loop"),r.Indent(1),r.WriteArrayLine(["vertex",e.x,e.y,e.z]),r.WriteArrayLine(["vertex",t.x,t.y,t.z]),r.WriteArrayLine(["vertex",n.x,n.y,n.z]),r.Indent(-1),r.WriteLine("endloop"),r.Indent(-1),r.WriteLine("endfacet")})),r.WriteLine("endsolid Model"),n.SetTextContent(r.GetText())}ExportBinary(e,t){let n=new Fd("model.stl");t.push(n);let r=e.TriangleCount(),i=new Xd(84+50*r,!0);for(let e=0;e<80;e++)i.WriteUnsignedCharacter8(0);i.WriteUnsignedInteger32(r),e.EnumerateTrianglesWithNormals(((e,t,n,r)=>{i.WriteFloat32(r.x),i.WriteFloat32(r.y),i.WriteFloat32(r.z),i.WriteFloat32(e.x),i.WriteFloat32(e.y),i.WriteFloat32(e.z),i.WriteFloat32(t.x),i.WriteFloat32(t.y),i.WriteFloat32(t.z),i.WriteFloat32(n.x),i.WriteFloat32(n.y),i.WriteFloat32(n.z),i.WriteUnsignedInteger16(0)})),n.SetBufferContent(i.GetBuffer())}}class bp{constructor(){this.exporters=[new _p,new Mp,new Ep,new Tp,new gp,new Bd,new jd]}AddExporter(e){this.exporters.push(e)}Export(e,t,n,r,i){let o=null;for(let e=0;e<this.exporters.length;e++){let t=this.exporters[e];if(t.CanExport(n,r)){o=t;break}}if(null===o)return void i.onError();let s=new yp(e,t);o.Export(s,n,(e=>{0===e.length?i.onError():i.onSuccess(e)}))}}class Sp{constructor(e,t){this.min=e,this.max=t}GetMin(){return this.min}GetMax(){return this.max}GetCenter(){return new gd((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,(this.min.z+this.max.z)/2)}}class wp{constructor(){this.box=new Sp(new gd(1/0,1/0,1/0),new gd(-1/0,-1/0,-1/0)),this.isValid=!1}GetBox(){return this.isValid?this.box:null}AddPoint(e){this.box.min.x=Math.min(this.box.min.x,e.x),this.box.min.y=Math.min(this.box.min.y,e.y),this.box.min.z=Math.min(this.box.min.z,e.z),this.box.max.x=Math.max(this.box.max.x,e.x),this.box.max.y=Math.max(this.box.max.y,e.y),this.box.max.z=Math.max(this.box.max.z,e.z),this.isValid=!0}}class Ap{constructor(e,t){this.boundingBox=e,this.level=t,this.pointItems=[],this.childNodes=[]}AddPoint(e,t,n){let r=this.FindNodeForPoint(e);if(null===r)return!1;if(null!==r.FindPointDirectly(e))return!1;if(r.pointItems.length<n.maxPointsPerNode||r.level>=n.maxTreeDepth)return r.AddPointDirectly(e,t),!0;{r.CreateChildNodes();let i=r.pointItems;r.pointItems=[];for(let e=0;e<i.length;e++){let t=i[e];if(!r.AddPoint(t.point,t.data,n))return!1}return r.AddPoint(e,t,n)}}FindPoint(e){let t=this.FindNodeForPoint(e);return null===t?null:t.FindPointDirectly(e)}AddPointDirectly(e,t){this.pointItems.push({point:e,data:t})}FindPointDirectly(e){for(let t=0;t<this.pointItems.length;t++){let n=this.pointItems[t];if(vd(e,n.point))return n.data}return null}FindNodeForPoint(e){if(!this.IsPointInBounds(e))return null;if(0===this.childNodes.length)return this;for(let t=0;t<this.childNodes.length;t++){let n=this.childNodes[t].FindNodeForPoint(e);if(null!==n)return n}return null}CreateChildNodes(){function e(e,t,n,r,i,o,s){let a=new Sp(new gd(t,n,r),new gd(t+i,n+o,r+s));e.childNodes.push(new Ap(a,e.level+1))}let t=this.boundingBox.min,n=this.boundingBox.GetCenter(),r=(this.boundingBox.max.x-this.boundingBox.min.x)/2,i=(this.boundingBox.max.y-this.boundingBox.min.y)/2,o=(this.boundingBox.max.z-this.boundingBox.min.z)/2;e(this,t.x,t.y,t.z,r,i,o),e(this,n.x,t.y,t.z,r,i,o),e(this,t.x,n.y,t.z,r,i,o),e(this,n.x,n.y,t.z,r,i,o),e(this,t.x,t.y,n.z,r,i,o),e(this,n.x,t.y,n.z,r,i,o),e(this,t.x,n.y,n.z,r,i,o),e(this,n.x,n.y,n.z,r,i,o)}IsPointInBounds(e){return kh(e.x,this.boundingBox.min.x)&&kh(e.y,this.boundingBox.min.y)&&kh(e.z,this.boundingBox.min.z)&&Dh(e.x,this.boundingBox.max.x)&&Dh(e.y,this.boundingBox.max.y)&&Dh(e.z,this.boundingBox.max.z)}}class Cp{constructor(e,t){this.options={maxPointsPerNode:10,maxTreeDepth:10},void 0!==t&&(void 0!==t.maxPointsPerNode&&(this.options.maxPointsPerNode=t.maxPointsPerNode),void 0!==t.maxTreeDepth&&(this.options.maxTreeDepth=t.maxTreeDepth)),this.rootNode=new Ap(e,0)}AddPoint(e,t){return this.rootNode.AddPoint(e,t,this.options)}FindPoint(e){return this.rootNode.FindPoint(e)}}function Rp(e,t,n){let r=t/n;return e*(r*r*(3-2*r))}function Ip(e,t,n){return t*e/n}function Pp(e,t,n){let r=t/n,i=r*r;return e*(i/(2*(i-r)+1))}function Lp(e,t,n,r){let i=xd(t,e).Normalize(),o=_d(e,t),s=[];for(let t=0;t<n;t++){let a=r(o,t,n-1);s.push(e.Clone().Offset(i,a))}return s}class Np{constructor(e,t,n){this.name=e,this.source=t,this.data=n}}function Op(e){let t=[];for(let n of e){let e=Mh(n);t.push(new Np(e,Th.Url,n))}return t}function Up(e){let t=[];for(let n of e){let e=Mh(n.name);t.push(new Np(e,Th.File,n))}return t}class Dp{constructor(e,t,n){this.name=Mh(e),this.extension=bh(e),this.source=t,this.data=n,this.content=null}SetContent(e){this.content=e}}class kp{constructor(){this.files=[]}FillFromInputFiles(e){this.files=[];for(let t of e){let e=new Dp(t.name,t.source,t.data);this.files.push(e)}}ExtendFromFileList(e){let t=e.GetFiles();for(let e=0;e<t.length;e++){let n=t[e];this.ContainsFileByPath(n.name)||this.files.push(n)}}GetFiles(){return this.files}GetContent(e){ph(this.files.length,{runTask:(t,n)=>{e.onFileListProgress(t,this.files.length),this.GetFileContent(this.files[t],{onReady:n,onProgress:e.onFileLoadProgress})},onReady:e.onReady})}ContainsFileByPath(e){return null!==this.FindFileByPath(e)}FindFileByPath(e){let t=Mh(e).toLowerCase();for(let e=0;e<this.files.length;e++){let n=this.files[e];if(n.name.toLowerCase()===t)return n}return null}IsOnlyUrlSource(){if(0===this.files.length)return!1;for(let e=0;e<this.files.length;e++){let t=this.files[e];if(t.source!==Th.Url&&t.source!==Th.Decompressed)return!1}return!0}AddFile(e){this.files.push(e)}GetFileContent(e,t){if(null!==e.content)return void t.onReady();let n=null;if(e.source===Th.Url)n=Sh(e.data,t.onProgress);else{if(e.source!==Th.File)return void t.onReady();n=wh(e.data,t.onProgress)}n.then((t=>{e.SetContent(t)})).catch((()=>{})).finally((()=>{t.onReady()}))}}class Fp{constructor(){this.nextId=0}GenerateId(){const e=this.nextId;return this.nextId+=1,e}}class Gp{constructor(){this.name="",this.parent=null,this.transformation=new tp,this.childNodes=[],this.meshIndices=[],this.idGenerator=new Fp,this.id=this.idGenerator.GenerateId()}IsEmpty(){return 0===this.childNodes.length&&0===this.meshIndices.length}IsMeshNode(){return 0===this.childNodes.length&&1===this.meshIndices.length}GetId(){return this.id}GetName(){return this.name}SetName(e){this.name=e}HasParent(){return null!==this.parent}GetParent(){return this.parent}GetTransformation(){return this.transformation}GetWorldTransformation(){let e=this.transformation.Clone(),t=this.parent;for(;null!==t;)e.Append(t.transformation),t=t.parent;return e}SetTransformation(e){this.transformation=e}AddChildNode(e){return e.parent=this,e.idGenerator=this.idGenerator,e.id=e.idGenerator.GenerateId(),this.childNodes.push(e),this.childNodes.length-1}RemoveChildNode(e){e.parent=null;let t=this.childNodes.indexOf(e);this.childNodes.splice(t,1)}GetChildNodes(){return this.childNodes}ChildNodeCount(){return this.childNodes.length}GetChildNode(e){return this.childNodes[e]}AddMeshIndex(e){return this.meshIndices.push(e),this.meshIndices.length-1}MeshIndexCount(){return this.meshIndices.length}GetMeshIndex(e){return this.meshIndices[e]}GetMeshIndices(){return this.meshIndices}Enumerate(e){e(this);for(const t of this.childNodes)t.Enumerate(e)}EnumerateChildren(e){for(const t of this.childNodes)e(t),t.EnumerateChildren(e)}EnumerateMeshIndices(e){for(const t of this.meshIndices)e(t);for(const t of this.childNodes)t.EnumerateMeshIndices(e)}}class Bp extends cp{constructor(){super(),this.root=new Gp,this.materials=[],this.meshes=[]}GetRootNode(){return this.root}NodeCount(){let e=0;return this.root.Enumerate((t=>{e+=1})),e-1}MaterialCount(){return this.materials.length}MeshCount(){return this.meshes.length}MeshInstanceCount(){let e=0;return this.root.Enumerate((t=>{e+=t.MeshIndexCount()})),e}VertexCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=t.VertexCount()})),e}VertexColorCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=t.VertexColorCount()})),e}NormalCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=t.NormalCount()})),e}TextureUVCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=t.TextureUVCount()})),e}TriangleCount(){let e=0;return this.EnumerateMeshInstances((t=>{e+=t.TriangleCount()})),e}AddMaterial(e){return this.materials.push(e),this.materials.length-1}GetMaterial(e){return this.materials[e]}AddMesh(e){return this.meshes.push(e),this.meshes.length-1}AddMeshToRootNode(e){const t=this.AddMesh(e);return this.root.AddMeshIndex(t),t}RemoveMesh(e){this.meshes.splice(e,1),this.root.Enumerate((t=>{for(let n=0;n<t.meshIndices.length;n++)t.meshIndices[n]===e?(t.meshIndices.splice(n,1),n-=1):t.meshIndices[n]>e&&(t.meshIndices[n]-=1)}))}GetMesh(e){return this.meshes[e]}GetMeshInstance(e){let t=null;if(this.root.Enumerate((n=>{n.GetId()===e.nodeId&&(t=n)})),null===t)return null;if(-1===t.GetMeshIndices().indexOf(e.meshIndex))return null;let n=this.GetMesh(e.meshIndex),r=new up(t.GetId(),e.meshIndex);return new hp(r,t,n)}EnumerateMeshes(e){for(const t of this.meshes)e(t)}EnumerateMeshInstances(e){this.root.Enumerate((t=>{for(let n of t.GetMeshIndices()){let r=new up(t.GetId(),n),i=this.GetMesh(n),o=new hp(r,t,i);e(o)}}))}EnumerateTransformedMeshInstances(e){this.EnumerateMeshInstances((t=>{const n=t.GetTransformedMesh();e(n)}))}EnumerateVertices(e){this.EnumerateMeshInstances((t=>{t.EnumerateVertices(e)}))}EnumerateTriangleVertexIndices(e){this.EnumerateMeshInstances((t=>{t.EnumerateTriangleVertexIndices(e)}))}EnumerateTriangleVertices(e){this.EnumerateMeshInstances((t=>{t.EnumerateTriangleVertices(e)}))}}class Vp{constructor(){this.edges=[],this.triangles=[]}}class zp{constructor(e,t){this.vertex1=e,this.vertex2=t,this.triangles=[]}}class Hp{constructor(e,t){this.edge=e,this.reversed=t}}class Wp{constructor(){this.triEdge1=null,this.triEdge2=null,this.triEdge3=null}}class jp{constructor(){this.vertices=[],this.edges=[],this.triangleEdges=[],this.triangles=[],this.edgeStartToEndVertexMap=new Map}AddVertex(){return this.vertices.push(new Vp),this.vertices.length-1}AddTriangle(e,t,n){function r(e,t,n){e[t].triangles.push(n)}function i(e,t,n,r){let i=e[n],o=t[r];i.edges.push(o.edge)}function o(e,t,n,r){e[t[n].edge].triangles.push(r)}let s=this.triangles.length,a=new Wp;a.triEdge1=this.AddTriangleEdge(e,t),a.triEdge2=this.AddTriangleEdge(t,n),a.triEdge3=this.AddTriangleEdge(n,e),r(this.vertices,e,s),r(this.vertices,t,s),r(this.vertices,n,s),i(this.vertices,this.triangleEdges,e,a.triEdge1),i(this.vertices,this.triangleEdges,t,a.triEdge2),i(this.vertices,this.triangleEdges,n,a.triEdge3),o(this.edges,this.triangleEdges,a.triEdge1,s),o(this.edges,this.triangleEdges,a.triEdge2,s),o(this.edges,this.triangleEdges,a.triEdge3,s),this.triangles.push(a)}AddTriangleEdge(e,t){let n=e,r=t,i=!1;t<e&&(n=t,r=e,i=!0);let o=this.AddEdge(n,r);return this.triangleEdges.push(new Hp(o,i)),this.triangleEdges.length-1}AddEdge(e,t){this.edgeStartToEndVertexMap.has(e)||this.edgeStartToEndVertexMap.set(e,[]);let n=this.edgeStartToEndVertexMap.get(e);for(let e=0;e<n.length;e++){let r=n[e];if(r.endVertex===t)return r.edgeIndex}let r=this.edges.length;return n.push({endVertex:t,edgeIndex:r}),this.edges.push(new zp(e,t)),r}}function Xp(e){let t=!0;return e.EnumerateMeshInstances((e=>{ip(e)!==rp.Empty&&(t=!1)})),t}function qp(e){let t=new wp;return e.EnumerateVertices((e=>{t.AddPoint(e)})),t.GetBox()}function Yp(e){function t(e,t,n){let r=t.FindPoint(e);return null===r&&(r=n.AddVertex(),t.AddPoint(e,r)),r}let n=qp(e),r=new Cp(n),i=new jp;return e.EnumerateTriangleVertices(((e,n,o)=>{let s=t(e,r,i),a=t(n,r,i),l=t(o,r,i);i.AddTriangle(s,a,l)})),i}function Kp(e){function t(e,t,n){const r=e.triangles[t],i=e.triangleEdges[r.triEdge1],o=e.triangleEdges[r.triEdge2],s=e.triangleEdges[r.triEdge3];return i.edge===n?i.reversed:o.edge===n?o.reversed:s.edge===n?s.reversed:null}if(e instanceof Bp){let t=!0;return e.EnumerateMeshInstances((e=>{t&&(t=Kp(e))})),t}{const n=Yp(e);for(let e=0;e<n.edges.length;e++){const r=n.edges[e];if(2!==r.triangles.length)return!1;let i=t(n,r.triangles[0],e),o=t(n,r.triangles[1],e);if(null===i||null===o||i===o)return!1}return!0}}function Zp(e){for(let t=0;t<e.MaterialCount();t++){let n=e.GetMaterial(t);if(n.isDefault&&!n.vertexColors)return!0}return!1}function Jp(e,t){for(let n=0;n<e.MaterialCount();n++){let r=e.GetMaterial(n);r.isDefault&&(r.color=t)}}class $p extends cp{constructor(){super(),this.vertices=[],this.vertexColors=[],this.normals=[],this.uvs=[],this.triangles=[]}VertexCount(){return this.vertices.length}VertexColorCount(){return this.vertexColors.length}NormalCount(){return this.normals.length}TextureUVCount(){return this.uvs.length}TriangleCount(){return this.triangles.length}AddVertex(e){return this.vertices.push(e),this.vertices.length-1}SetVertex(e,t){this.vertices[e]=t}GetVertex(e){return this.vertices[e]}AddVertexColor(e){return this.vertexColors.push(e),this.vertexColors.length-1}SetVertexColor(e,t){this.vertexColors[e]=t}GetVertexColor(e){return this.vertexColors[e]}AddNormal(e){return this.normals.push(e),this.normals.length-1}SetNormal(e,t){this.normals[e]=t}GetNormal(e){return this.normals[e]}AddTextureUV(e){return this.uvs.push(e),this.uvs.length-1}SetTextureUV(e,t){this.uvs[e]=t}GetTextureUV(e){return this.uvs[e]}AddTriangle(e){return this.triangles.push(e),this.triangles.length-1}GetTriangle(e){return this.triangles[e]}EnumerateVertices(e){for(const t of this.vertices)e(t)}EnumerateTriangleVertexIndices(e){for(const t of this.triangles)e(t.v0,t.v1,t.v2)}EnumerateTriangleVertices(e){for(const t of this.triangles){e(this.vertices[t.v0],this.vertices[t.v1],this.vertices[t.v2])}}Clone(){let e=new $p;e.SetName(this.GetName()),this.CloneProperties(e);for(let t=0;t<this.VertexCount();t++){let n=this.GetVertex(t);e.AddVertex(n.Clone())}for(let t=0;t<this.VertexColorCount();t++){let n=this.GetVertexColor(t);e.AddVertexColor(n.Clone())}for(let t=0;t<this.NormalCount();t++){let n=this.GetNormal(t);e.AddNormal(n.Clone())}for(let t=0;t<this.TextureUVCount();t++){let n=this.GetTextureUV(t);e.AddTextureUV(n.Clone())}for(let t=0;t<this.TriangleCount();t++){let n=this.GetTriangle(t);e.AddTriangle(n.Clone())}return e}}class Qp{constructor(e,t,n){this.v0=e,this.v1=t,this.v2=n,this.c0=null,this.c1=null,this.c2=null,this.n0=null,this.n1=null,this.n2=null,this.u0=null,this.u1=null,this.u2=null,this.mat=null,this.curve=null}HasVertices(){return null!==this.v0&&null!==this.v1&&null!==this.v2}HasVertexColors(){return null!==this.c0&&null!==this.c1&&null!==this.c2}HasNormals(){return null!==this.n0&&null!==this.n1&&null!==this.n2}HasTextureUVs(){return null!==this.u0&&null!==this.u1&&null!==this.u2}SetVertices(e,t,n){return this.v0=e,this.v1=t,this.v2=n,this}SetVertexColors(e,t,n){return this.c0=e,this.c1=t,this.c2=n,this}SetNormals(e,t,n){return this.n0=e,this.n1=t,this.n2=n,this}SetTextureUVs(e,t,n){return this.u0=e,this.u1=t,this.u2=n,this}SetMaterial(e){return this.mat=e,this}SetCurve(e){return this.curve=e,this}Clone(){let e=new Qp(this.v0,this.v1,this.v2);return e.SetVertexColors(this.c0,this.c1,this.c2),e.SetNormals(this.n0,this.n1,this.n2),e.SetTextureUVs(this.u0,this.u1,this.u2),e.SetMaterial(this.mat),e.SetCurve(this.curve),e}}function ef(){let e=document.createElement("canvas");document.body.appendChild(e);let t=new Qo({canvas:e,antialias:!0});t.outputColorSpace=ne,t.setClearColor("#ffffff",1),t.setSize(10,10);let n=new es,r=new Il(8947848);n.add(r);let i=new Rl(8947848);i.position.set(0,0,1),n.add(i);let o=new ar(45,1,.1,1e3);o.position.set(0,0,1),o.up.set(0,1,0),o.lookAt(new Je(0,0,0)),n.add(o);let s=new Tr(1,1),a=new $n(s,new ka({color:13369344}));n.add(a),t.render(n,o);let l=t.getContext(),c=new Uint8Array(4);l.readPixels(5,5,1,1,l.RGBA,l.UNSIGNED_BYTE,c),document.body.removeChild(e);return c[0]<50&&c[1]<50&&c[2]<50}const tf={Phong:1,Physical:2};function nf(e){let t=0,n=0;for(let r=0;r<e.MaterialCount();r++){let i=e.GetMaterial(r);i.type===ud.Phong?t+=1:i.type===ud.Physical&&(n+=1)}return t>=n?tf.Phong:tf.Physical}class rf{Convert(e){return null}}class of extends rf{Convert(e){return(new yn).copyLinearToSRGB(e)}}class sf extends rf{Convert(e){return(new yn).copySRGBToLinear(e)}}function af(e){return $h(e.r,e.g,e.b)}function lf(e){return new yn(e.r/255,e.g/255,e.b/255)}function cf(e,t,n){let r=new $p,i=e.attributes.position.array,o=e.attributes.position.itemSize||3;for(let e=0;e<i.length;e+=o){let t=i[e],n=i[e+1],o=i[e+2];r.AddVertex(new gd(t,n,o))}let s=void 0!==e.attributes.color;if(s){let t=e.attributes.color.array,i=e.attributes.color.itemSize||3;for(let e=0;e<t.length;e+=i){let i=new yn(t[e],t[e+1],t[e+2]);null!==n&&(i=n.Convert(i)),r.AddVertexColor(af(i))}}let a=void 0!==e.attributes.normal;if(a){let t=e.attributes.normal.array,n=e.attributes.normal.itemSize||3;for(let e=0;e<t.length;e+=n){let n=t[e],i=t[e+1],o=t[e+2];r.AddNormal(new gd(n,i,o))}}let l=void 0!==e.attributes.uv;if(l){let t=e.attributes.uv.array,n=e.attributes.uv.itemSize||2;for(let e=0;e<t.length;e+=n){let n=t[e],i=t[e+1];r.AddTextureUV(new Hh(n,i))}}let c=null;if(null!==e.index)c=e.index.array;else{c=[];for(let e=0;e<i.length/3;e++)c.push(e)}for(let e=0;e<c.length;e+=3){let n=c[e],i=c[e+1],o=c[e+2],u=new Qp(n,i,o);s&&u.SetVertexColors(n,i,o),a&&u.SetNormals(n,i,o),l&&u.SetTextureUVs(n,i,o),null!==t&&u.SetMaterial(t),r.AddTriangle(u)}return r}function uf(e){null!==e&&e.traverse((e=>{if(e.isMesh||e.isLineSegments){if(Array.isArray(e.material))for(let t of e.material)t.dispose();else e.material.dispose();e.userData=null,e.geometry.dispose()}}))}class hf{constructor(e){this.params={getDefaultMaterialColor:()=>new Yh(0,0,0)},ah(e,this.params),this.defaultMaterialIndex=null}Finalize(e){this.Reset(),this.FinalizeMeshes(e),this.FinalizeMaterials(e),this.FinalizeNodes(e)}FinalizeMaterials(e){if(0===e.VertexColorCount())return;let t=new Map;for(let n=0;n<e.MeshCount();n++){let r=e.GetMesh(n);for(let e=0;e<r.TriangleCount();e++){let n=r.GetTriangle(e),i=n.HasVertexColors();t.has(n.mat)?i||t.set(n.mat,!1):t.set(n.mat,i)}}for(let[n,r]of t){e.GetMaterial(n).vertexColors=r}}FinalizeMeshes(e){for(let t=0;t<e.MeshCount();t++){let n=e.GetMesh(t);ip(n)!==rp.Empty?this.FinalizeMesh(e,n):(e.RemoveMesh(t),t-=1)}}FinalizeMesh(e,t){let n={calculateCurveNormals:!1};for(let r=0;r<t.TriangleCount();r++){let i=t.GetTriangle(r);this.FinalizeTriangle(t,i,n),null===i.mat&&(i.mat=this.GetDefaultMaterialIndex(e))}n.calculateCurveNormals&&function(e){function t(e,t,n,r,i){function o(e,t){for(let n=0;n<e.length;n++)if(vd(e[n],t))return!0;return!1}let s=[],a=i.get(n);for(let n=0;n<a.length;n++){let i=a[n],l=e.GetTriangle(i);if(t.curve===l.curve){let e=r[i];o(s,e)||s.push(e)}}let l=new gd(0,0,0);for(let e=0;e<s.length;e++)l=yd(l,s[e]);return l.MultiplyScalar(1/s.length),l.Normalize(),e.AddNormal(l)}let n=[],r=new Map;for(let t=0;t<e.VertexCount();t++)r.set(t,[]);for(let t=0;t<e.TriangleCount();t++){let i=e.GetTriangle(t),o=op(e.GetVertex(i.v0),e.GetVertex(i.v1),e.GetVertex(i.v2));n.push(o),r.get(i.v0).push(t),r.get(i.v1).push(t),r.get(i.v2).push(t)}for(let i=0;i<e.TriangleCount();i++){let o=e.GetTriangle(i);if(!o.HasNormals()){let i=t(e,o,o.v0,n,r),s=t(e,o,o.v1,n,r),a=t(e,o,o.v2,n,r);o.SetNormals(i,s,a)}}}(t)}FinalizeTriangle(e,t,n){if(!t.HasNormals())if(null===t.curve||0===t.curve){let n=op(e.GetVertex(t.v0),e.GetVertex(t.v1),e.GetVertex(t.v2)),r=e.AddNormal(n);t.SetNormals(r,r,r)}else n.calculateCurveNormals=!0;null===t.curve&&(t.curve=0)}FinalizeNodes(e){let t=e.GetRootNode(),n=[];t.EnumerateChildren((e=>{e.IsEmpty()&&n.push(e)}));for(let e=0;e<n.length;e++){let t=n[e],r=t.GetParent();null!==r&&(r.RemoveChildNode(t),r.IsEmpty()&&n.push(r))}}GetDefaultMaterialIndex(e){if(null===this.defaultMaterialIndex){let t=this.params.getDefaultMaterialColor(),n=new pd;n.color=t,n.isDefault=!0,this.defaultMaterialIndex=e.AddMaterial(n)}return this.defaultMaterialIndex}Reset(){this.defaultMaterialIndex=null}}function df(e,t){new hf(t).Finalize(e)}function pf(e){function t(e){return!!function(e){return null!=e}(e)&&!isNaN(e)}function n(e,n){return!!t(e)&&!(e<0||e>=n)}function r(e,r){function i(e,r,i){if(!n(i.v0,r.VertexCount()))return!1;if(!n(i.v1,r.VertexCount()))return!1;if(!n(i.v2,r.VertexCount()))return!1;if(i.HasVertexColors()){if(!n(i.c0,r.VertexColorCount()))return!1;if(!n(i.c1,r.VertexColorCount()))return!1;if(!n(i.c2,r.VertexColorCount()))return!1}if(!n(i.n0,r.NormalCount()))return!1;if(!n(i.n1,r.NormalCount()))return!1;if(!n(i.n2,r.NormalCount()))return!1;if(i.HasTextureUVs()){if(!n(i.u0,r.TextureUVCount()))return!1;if(!n(i.u1,r.TextureUVCount()))return!1;if(!n(i.u2,r.TextureUVCount()))return!1}return!!n(i.mat,e.MaterialCount())&&!!t(i.curve)}for(let e=0;e<r.VertexCount();e++){let n=r.GetVertex(e);if(!t(n.x))return!1;if(!t(n.y))return!1;if(!t(n.z))return!1}for(let e=0;e<r.VertexColorCount();e++){let n=r.GetVertexColor(e);if(!t(n.r))return!1;if(!t(n.g))return!1;if(!t(n.b))return!1}for(let e=0;e<r.NormalCount();e++){let n=r.GetNormal(e);if(!t(n.x))return!1;if(!t(n.y))return!1;if(!t(n.z))return!1}for(let e=0;e<r.TextureUVCount();e++){let n=r.GetTextureUV(e);if(!t(n.x))return!1;if(!t(n.y))return!1}for(let t=0;t<r.TriangleCount();t++){let n=r.GetTriangle(t);if(!i(e,r,n))return!1}return!0}for(let t=0;t<e.MeshCount();t++){let n=e.GetMesh(t);if(!r(e,n))return!1}return!0}class ff{constructor(){this.name=null,this.extension=null,this.callbacks=null,this.model=null,this.error=null,this.message=null}Import(e,t,n,r){this.Clear(),this.name=e,this.extension=t,this.callbacks=r,this.model=new Bp,this.error=!1,this.message=null,this.ResetContent(),this.ImportContent(n,(()=>{this.CreateResult(r)}))}Clear(){this.name=null,this.extension=null,this.callbacks=null,this.model=null,this.error=null,this.message=null,this.ClearContent()}CreateResult(e){return this.error?(e.onError(),void e.onComplete()):Xp(this.model)?(this.SetError("The model doesn't contain any meshes."),e.onError(),void e.onComplete()):(df(this.model,{getDefaultMaterialColor:this.callbacks.getDefaultMaterialColor}),e.onSuccess(),void e.onComplete())}CanImportExtension(e){return!1}GetUpDirection(){return zh.Z}ClearContent(){}ResetContent(){}ImportContent(e,t){}GetModel(){return this.model}SetError(e){this.error=!0,null!=e&&(this.message=e)}WasError(){return this.error}GetErrorMessage(){return this.message}}function mf(e,t,n){let r=e.substring(t),i=r.indexOf(n);return-1!==i&&(r=r.substring(0,i)),r.trim()}function gf(e,t){if(null!==t){let n=e.indexOf(t);-1!==n&&(e=e.substring(0,n).trim())}return e.split(/\s+/u)}function vf(e,t){function n(e,t){let n=e.trim();n.length>0&&t(n)}let r=0,i=e.indexOf("\n",r);for(;-1!==i;)n(e.substring(r,i),t),r=i+1,i=e.indexOf("\n",r);n(e.substring(r),t)}function yf(e){return 0==(e&e-1)}function xf(e){if(yf(e))return e;let t=Math.pow(2,Math.ceil(Math.log(e)/Math.log(2)));return parseInt(t,10)}function _f(e){e.transparent=!1,Oh(e.opacity,1)&&(e.transparent=!0)}class Tf{constructor(e){this.model=e,this.colorToMaterialIndex=new Map}GetMaterialIndex(e,t,n,r){let i=td(e)+td(t)+td(n),o=null!=r;if(o&&(i+=td(r)),this.colorToMaterialIndex.has(i))return this.colorToMaterialIndex.get(i);{let s=new pd;s.name=i.toUpperCase(),s.color=new Yh(e,t,n),o&&r<255&&(s.opacity=r/255,_f(s));let a=this.model.AddMaterial(s);return this.colorToMaterialIndex.set(i,a),a}}}class Ef extends ff{constructor(){super(),this.rhino=null}CanImportExtension(e){return"3dm"===e}GetUpDirection(){return zh.Z}ClearContent(){this.instanceIdToObject=null,this.instanceIdToDefinition=null}ResetContent(){this.instanceIdToObject=new Map,this.instanceIdToDefinition=new Map}ImportContent(e,t){null===this.rhino?_h("loaders/rhino3dm.min.js").then((()=>{rhino3dm().then((n=>{this.rhino=n,this.ImportRhinoContent(e),t()}))})).catch((()=>{this.SetError("Failed to load rhino3dm."),t()})):(this.ImportRhinoContent(e),t())}ImportRhinoContent(e){let t=this.rhino.File3dm.fromByteArray(e);null!==t?(this.ImportRhinoDocument(t),Xp(this.model)&&this.SetError("The model doesn't contain any 3D meshes. Try to save the model while you are in shaded view in Rhino.")):this.SetError("Failed to read Rhino file.")}ImportRhinoDocument(e){this.InitRhinoInstances(e),this.ImportRhinoUserStrings(e),this.ImportRhinoGeometry(e)}InitRhinoInstances(e){let t=e.objects();for(let e=0;e<t.count;e++){let n=t.get(e),r=n.attributes();r.isInstanceDefinitionObject&&this.instanceIdToObject.set(r.id,n)}let n=e.instanceDefinitions();for(let e=0;e<n.count();e++){let t=n.get(e);this.instanceIdToDefinition.set(t.id,t)}}ImportRhinoUserStrings(e){let t=e.strings();if(t.count()>0){let e=new Hd("Document user texts");for(let n=0;n<t.count();n++){let r=t.get(n);e.AddProperty(new zd(Vd.Text,r[0],r[1]))}this.model.AddPropertyGroup(e)}}ImportRhinoGeometry(e){let t=e.objects();for(let n=0;n<t.count;n++){let r=t.get(n);this.ImportRhinoGeometryObject(e,r,[])}}ImportRhinoGeometryObject(e,t,n){let r=t.geometry(),i=t.attributes(),o=r.objectType;if(i.isInstanceDefinitionObject&&0===n.length)return;let s=null,a=!1;if(o===this.rhino.ObjectType.Mesh)s=r,a=!1;else if(o===this.rhino.ObjectType.Extrusion)s=r.getMesh(this.rhino.MeshType.Any),a=!0;else if(o===this.rhino.ObjectType.Brep){s=new this.rhino.Mesh;let e=r.faces();for(let t=0;t<e.count;t++){let n=e.get(t),r=n.getMesh(this.rhino.MeshType.Any);r&&(s.append(r),r.delete()),n.delete()}e.delete(),s.compact(),a=!0}else if(o===this.rhino.ObjectType.SubD)r.subdivide(3),s=this.rhino.Mesh.createFromSubDControlNet(r),a=!0;else if(o===this.rhino.ObjectType.InstanceReference){let i=r.parentIdefId;if(this.instanceIdToDefinition.has(i)){let r=this.instanceIdToDefinition.get(i).getObjectIds();for(let i=0;i<r.length;i++){let o=r[i];if(this.instanceIdToObject.has(o)){let r=this.instanceIdToObject.get(o);n.push(t),this.ImportRhinoGeometryObject(e,r,n),n.pop()}}}}null!==s&&(this.ImportRhinoMesh(e,s,t,n),a&&s.delete())}ImportRhinoMesh(e,t,n,r){let i=n.attributes(),o=this.GetMaterialIndex(e,n,r),s=cf(t.toThreejsJSON().data,o,null);s.SetName(i.name);let a=i.getUserStrings();if(a.length>0){let e=new Hd("User texts");for(let t=0;t<a.length;t++){let n=a[t];e.AddProperty(new zd(Vd.Text,n[0],n[1]))}s.AddPropertyGroup(e)}if(0!==r.length){let e=(new Qd).CreateIdentity();for(let t=r.length-1;t>=0;t--){let n=r[t].geometry().xform.toFloatArray(!1),i=new Qd(n);e=e.MultiplyMatrix(i)}sp(s,new tp(e))}this.model.AddMeshToRootNode(s)}GetMaterialIndex(e,t,n){let r=function t(n,r,i){let o=r.attributes();if(o.materialSource===n.ObjectMaterialSource.MaterialFromObject){let t=o.materialIndex;if(t>-1)return e.materials().get(t)}else if(o.materialSource===n.ObjectMaterialSource.MaterialFromLayer){let t=o.layerIndex;if(t>-1){let n=e.layers().get(t).renderMaterialIndex;if(n>-1)return e.materials().get(n)}}else if(o.materialSource===n.ObjectMaterialSource.MaterialFromParent&&0!==i.length)return t(n,i[0],[]);return null}(this.rhino,t,n);return null===r?null:function(e,t,n){let r=function(e,t){function n(e,t){e.Set(t.r,t.g,t.b)}function r(e){return 0===e.r&&0===e.g&&0===e.b}function i(e){return 255===e.r&&255===e.g&&255===e.b}let o=null,s=e.physicallyBased();s.supported?(o=new fd,o.metalness=s.metallic?1:0,o.roughness=s.roughness):(o=new pd,n(o.ambient,e.ambientColor),n(o.specular,e.specularColor)),o.name=e.name,n(o.color,e.diffuseColor),o.opacity=1-e.transparency,_f(o),r(o.color)&&!i(e.reflectionColor)&&n(o.color,e.reflectionColor),r(o.color)&&!i(e.transparentColor)&&n(o.color,e.transparentColor);let a=e.getBitmapTexture();if(a){let e=new ld,n=Mh(a.fileName),r=t.getFileBuffer(n);e.name=n,e.buffer=r,o.diffuseMap=e}return o}(t,n);for(let t=0;t<e.MaterialCount();t++){if(e.GetMaterial(t).IsEqual(r))return t}return e.AddMaterial(r)}(this.model,r,this.callbacks)}}class Mf{constructor(e,t){this.arrayBuffer=e,this.dataView=new DataView(e),this.isLittleEndian=t,this.position=0}GetPosition(){return this.position}SetPosition(e){this.position=e}GetByteLength(){return this.arrayBuffer.byteLength}Skip(e){this.position=this.position+e}End(){return this.position>=this.arrayBuffer.byteLength}ReadArrayBuffer(e){let t=new Uint8Array(this.arrayBuffer),n=new ArrayBuffer(e),r=new Uint8Array(n),i=t.subarray(this.position,this.position+e);return r.set(i,0),this.position+=e,n}ReadBoolean8(){let e=this.dataView.getInt8(this.position);return this.position=this.position+1,!!e}ReadCharacter8(){let e=this.dataView.getInt8(this.position);return this.position=this.position+1,e}ReadUnsignedCharacter8(){let e=this.dataView.getUint8(this.position);return this.position=this.position+1,e}ReadInteger16(){let e=this.dataView.getInt16(this.position,this.isLittleEndian);return this.position=this.position+2,e}ReadUnsignedInteger16(){let e=this.dataView.getUint16(this.position,this.isLittleEndian);return this.position=this.position+2,e}ReadInteger32(){let e=this.dataView.getInt32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadUnsignedInteger32(){let e=this.dataView.getUint32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadFloat32(){let e=this.dataView.getFloat32(this.position,this.isLittleEndian);return this.position=this.position+4,e}ReadDouble64(){let e=this.dataView.getFloat64(this.position,this.isLittleEndian);return this.position=this.position+8,e}}const bf=19789,Sf=15677,wf=45055,Af=40960,Cf=40976,Rf=40992,If=41008,Pf=41024,Lf=41025,Nf=41040,Of=16,Uf=17,Df=18,kf=19,Ff=41472,Gf=41728,Bf=41816,Vf=41818,zf=41812,Hf=41814,Wf=41820,jf=48,Xf=49,qf=16384,Yf=16640,Kf=16656,Zf=16704,Jf=16672,$f=16736,Qf=16688,em=16720,tm=45056,nm=45058,rm=45072,im=45073,om=45075,sm=45088,am=45089,lm=45090,cm=45104;class um{constructor(){this.id=-1,this.name="",this.flags=-1,this.parentId=-1,this.instanceName="",this.pivot=[0,0,0],this.positions=[],this.rotations=[],this.scales=[]}}class hm{constructor(){this.nodes=[],this.nodeIdToNode=new Map}IsEmpty(){return 0===this.nodes.length}AddNode(e){this.nodes.push(e),this.nodeIdToNode.set(e.nodeId,e)}GetNodes(){return this.nodes}}class dm extends ff{constructor(){super()}CanImportExtension(e){return"3ds"===e}GetUpDirection(){return zh.Z}ClearContent(){this.materialNameToIndex=null,this.meshNameToIndex=null,this.nodeList=null}ResetContent(){this.materialNameToIndex=new Map,this.meshNameToIndex=new Map,this.nodeList=new hm}ImportContent(e,t){this.ProcessBinary(e),t()}ProcessBinary(e){let t=new Mf(e,!0),n=t.GetByteLength();this.ReadChunks(t,n,((e,n)=>{e===bf?this.ReadMainChunk(t,n):this.SkipChunk(t,n)}))}ReadMainChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,((t,n)=>{t===Sf?this.ReadEditorChunk(e,n):t===tm?this.ReadKeyFrameChunk(e,n):this.SkipChunk(e,n)})),this.BuildNodeHierarchy()}ReadEditorChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,((t,n)=>{t===wf?this.ReadMaterialChunk(e,n):t===qf?this.ReadObjectChunk(e,n):this.SkipChunk(e,n)}))}ReadMaterialChunk(e,t){let n=new pd,r=this.GetChunkEnd(e,t),i=null,o=null;this.ReadChunks(e,r,((t,r)=>{t===Af?n.name=this.ReadName(e):t===Cf?n.ambient=this.ReadColorChunk(e,r):t===Rf?n.color=this.ReadColorChunk(e,r):t===If?n.specular=this.ReadColorChunk(e,r):t===Pf?i=this.ReadPercentageChunk(e,r):t===Lf?o=this.ReadPercentageChunk(e,r):t===Nf?(n.opacity=1-this.ReadPercentageChunk(e,r),_f(n)):t===Ff?(n.diffuseMap=this.ReadTextureMapChunk(e,r),_f(n)):this.SkipChunk(e,r)})),null!==i&&null!==o&&(n.shininess=i*o/10);let s=this.model.AddMaterial(n);this.materialNameToIndex.set(n.name,s)}ReadTextureMapChunk(e,t){let n=new ld,r=this.GetChunkEnd(e,t);return this.ReadChunks(e,r,((t,r)=>{if(t===Gf){let t=this.ReadName(e),r=this.callbacks.getFileBuffer(t);n.name=t,n.buffer=r}else t===Bf?n.offset.x=e.ReadFloat32():t===Vf?n.offset.y=e.ReadFloat32():t===zf?n.scale.x=e.ReadFloat32():t===Hf?n.scale.y=e.ReadFloat32():t===Wf?n.rotation=e.ReadFloat32()*Lh:this.SkipChunk(e,r)})),n}ReadColorChunk(e,t){let n=new Yh(0,0,0),r=this.GetChunkEnd(e,t),i=!1;return this.ReadChunks(e,r,((t,r)=>{t===Uf?i||(n.r=e.ReadUnsignedCharacter8(),n.g=e.ReadUnsignedCharacter8(),n.b=e.ReadUnsignedCharacter8()):t===Df?(n.r=e.ReadUnsignedCharacter8(),n.g=e.ReadUnsignedCharacter8(),n.b=e.ReadUnsignedCharacter8(),i=!0):t===Of?i||(n.r=Zh(e.ReadFloat32()),n.g=Zh(e.ReadFloat32()),n.b=Zh(e.ReadFloat32())):t===kf?(n.r=Zh(e.ReadFloat32()),n.g=Zh(e.ReadFloat32()),n.b=Zh(e.ReadFloat32()),i=!0):this.SkipChunk(e,r)})),n}ReadPercentageChunk(e,t){let n=0,r=this.GetChunkEnd(e,t);return this.ReadChunks(e,r,((t,r)=>{t===jf?n=e.ReadUnsignedInteger16()/100:t===Xf?n=e.ReadFloat32():this.SkipChunk(e,r)})),n}ReadObjectChunk(e,t){let n=this.GetChunkEnd(e,t),r=this.ReadName(e);this.ReadChunks(e,n,((t,n)=>{t===Yf?this.ReadMeshChunk(e,n,r):this.SkipChunk(e,n)}))}ReadMeshChunk(e,t,n){let r=new $p;r.SetName(n);let i=this.GetChunkEnd(e,t),o=null;if(this.ReadChunks(e,i,((t,n)=>{t===Kf?this.ReadVerticesChunk(r,e):t===Zf?this.ReadTextureVerticesChunk(r,e):t===Jf?this.ReadFacesChunk(r,e,n):t===$f?o=this.ReadTransformationChunk(e):this.SkipChunk(e,n)})),r.VertexCount()===r.TextureUVCount())for(let e=0;e<r.TriangleCount();e++){let t=r.GetTriangle(e);t.SetTextureUVs(t.v0,t.v1,t.v2)}let s=new Qd(o);!function(e,t){if(!t.IsValid())return;let n=Vh(t.Determinant());if(n){t=(new Qd).CreateScale(-1,1,1).MultiplyMatrix(t)}let r=t.Invert();null!==r&&(sp(e,new tp(r)),n&&ap(e))}(r,s);let a=this.model.AddMesh(r);this.meshNameToIndex.set(r.GetName(),a)}ReadVerticesChunk(e,t){let n=t.ReadUnsignedInteger16();for(let r=0;r<n;r++){let n=t.ReadFloat32(),r=t.ReadFloat32(),i=t.ReadFloat32();e.AddVertex(new gd(n,r,i))}}ReadTextureVerticesChunk(e,t){let n=t.ReadUnsignedInteger16();for(let r=0;r<n;r++){let n=t.ReadFloat32(),r=t.ReadFloat32();e.AddTextureUV(new Hh(n,r))}}ReadFacesChunk(e,t,n){let r=this.GetChunkEnd(t,n),i=t.ReadUnsignedInteger16();for(let n=0;n<i;n++){let n=t.ReadUnsignedInteger16(),r=t.ReadUnsignedInteger16(),i=t.ReadUnsignedInteger16();t.ReadUnsignedInteger16(),e.AddTriangle(new Qp(n,r,i))}this.ReadChunks(t,r,((n,r)=>{n===Qf?this.ReadFaceMaterialsChunk(e,t):n===em?this.ReadFaceSmoothingGroupsChunk(e,i,t):this.SkipChunk(t,r)}))}ReadFaceMaterialsChunk(e,t){let n=this.ReadName(t),r=this.materialNameToIndex.get(n),i=t.ReadUnsignedInteger16();for(let n=0;n<i;n++){let n=t.ReadUnsignedInteger16(),i=e.GetTriangle(n);void 0!==r&&(i.mat=r)}}ReadFaceSmoothingGroupsChunk(e,t,n){for(let r=0;r<t;r++){let t=n.ReadUnsignedInteger32();e.GetTriangle(r).curve=t}}ReadTransformationChunk(e){let t=[];for(let n=0;n<4;n++){for(let n=0;n<3;n++)t.push(e.ReadFloat32());n<3?t.push(0):t.push(1)}return t}ReadKeyFrameChunk(e,t){let n=this.GetChunkEnd(e,t);this.ReadChunks(e,n,((t,n)=>{t===nm?this.ReadObjectNodeChunk(e,n):this.SkipChunk(e,n)}))}BuildNodeHierarchy(){function e(e,t){let n=new Qd;if(n.ComposeTRS(Sd(function(e){return 0===e.positions.length?[0,0,0]:e.positions[0]}(e)),Zd(function(e){return 0===e.rotations.length?[0,0,0,1]:function(e){let t=[0,0,0,1],n=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);if(n>0){let r=-.5*e[3],i=Math.sin(r)/n;t=[i*e[0],i*e[1],i*e[2],Math.cos(r)]}return t}(e.rotations[0])}(e)),Sd(function(e){return 0===e.scales.length?[1,1,1]:e.scales[0]}(e))),t){let t=e.pivot;n=(new Qd).CreateTranslation(-t[0],-t[1],-t[2]).MultiplyMatrix(n)}return new tp(n)}let t=this.model.GetRootNode();if(this.nodeList.IsEmpty())for(let e=0;e<this.model.MeshCount();e++)t.AddMeshIndex(e);else{let n=new Map;for(let r of this.nodeList.GetNodes()){let i=new Gp;if(r.name.length>0&&"$$$DUMMY"!==r.name&&(i.SetName(r.name),r.instanceName.length>0&&i.SetName(i.GetName()+" "+r.instanceName)),65535!==r.parentId&&n.has(r.parentId)){n.get(r.parentId).AddChildNode(i)}else t.AddChildNode(i);n.set(r.id,i);let o=this.meshNameToIndex.has(r.name);i.SetTransformation(e(r,o)),o&&i.AddMeshIndex(this.meshNameToIndex.get(r.name))}}}ReadObjectNodeChunk(e,t){function n(e,t,n){let r=[];t.Skip(10);let i=t.ReadInteger32();for(let o=0;o<i;o++){t.ReadInteger32(),0!==t.ReadUnsignedInteger16()&&t.ReadFloat32();let i=null;if(n===am){let n=t.ReadFloat32();i=e.ReadVector(t),i[3]=n}else i=e.ReadVector(t);r.push(i)}return r}let r=new um,i=this.GetChunkEnd(e,t);this.ReadChunks(e,i,((t,i)=>{t===rm?(r.name=this.ReadName(e),r.flags=e.ReadUnsignedInteger32(),r.parentId=e.ReadUnsignedInteger16()):t===im?r.instanceName=this.ReadName(e):t===om?r.pivot=this.ReadVector(e):t===sm?r.positions=n(this,e,sm):t===am?r.rotations=n(this,e,am):t===lm?r.scales=n(this,e,lm):t===cm?r.id=e.ReadUnsignedInteger16():this.SkipChunk(e,i)})),this.nodeList.AddNode(r)}ReadName(e){let t="",n=0,r=0;for(;r<64&&(n=e.ReadCharacter8(),0!==n);)t+=String.fromCharCode(n),r+=1;return t}ReadVector(e){return[e.ReadFloat32(),e.ReadFloat32(),e.ReadFloat32()]}ReadChunks(e,t,n){for(;e.GetPosition()<=t-6;){n(e.ReadUnsignedInteger16(),e.ReadUnsignedInteger32())}}GetChunkEnd(e,t){return e.GetPosition()+t-6}SkipChunk(e,t){e.Skip(t-6)}}const pm=5120,fm=5121,mm=5122,gm=5123,vm=5125,ym=5126,xm=0,_m=1,Tm=2,Em=3,Mm=4,bm=5,Sm=6,wm=4,Am=5,Cm=6,Rm=1179937895,Im=1313821514,Pm=5130562;function Lm(e){return $h(ed(e[0]),ed(e[1]),ed(e[2]))}class Nm{constructor(e){this.reader=new Mf(e,!0),this.componentType=null,this.dataType=null,this.byteStride=null,this.dataCount=null,this.sparseReader=null}SetComponentType(e){this.componentType=e}SetDataType(e){"SCALAR"===e?this.dataType=xm:"VEC2"===e?this.dataType=_m:"VEC3"===e?this.dataType=Tm:"VEC4"===e?this.dataType=Em:"MAT2"===e?this.dataType=Mm:"MAT3"===e?this.dataType=bm:"MAT4"===e&&(this.dataType=Sm)}SetByteStride(e){this.byteStride=e}SetDataCount(e){this.dataCount=e}SetSparseReader(e,t){this.sparseReader={indexReader:e,valueReader:t}}ReadArrayBuffer(e){return this.reader.ReadArrayBuffer(e)}GetDataCount(){return this.dataCount}ReadData(){if(null===this.dataType)return null;if(this.dataType===xm){let e=this.ReadComponent();return this.SkipBytesByStride(1),e}if(this.dataType===_m){let e=this.ReadComponent(),t=this.ReadComponent();return this.SkipBytesByStride(2),new Hh(e,t)}if(this.dataType===Tm){let e=this.ReadComponent(),t=this.ReadComponent(),n=this.ReadComponent();return this.SkipBytesByStride(3),new gd(e,t,n)}if(this.dataType===Em){let e=this.ReadComponent(),t=this.ReadComponent(),n=this.ReadComponent(),r=this.ReadComponent();return this.SkipBytesByStride(4),new qd(e,t,n,r)}return null}EnumerateData(e){if(null===this.sparseReader)for(let t=0;t<this.dataCount;t++)e(this.ReadData());else{let t=[];for(let e=0;e<this.sparseReader.indexReader.GetDataCount();e++){let e=this.sparseReader.indexReader.ReadData(),n=this.sparseReader.valueReader.ReadData();t.push({index:e,value:n})}let n=0;for(let r=0;r<this.dataCount;r++){let i=this.ReadData();n<t.length&&t[n].index===r?(e(t[n].value),n+=1):e(i)}}}SkipBytes(e){this.reader.Skip(e)}ReadComponent(){return null===this.componentType?null:this.componentType===pm?this.reader.ReadCharacter8():this.componentType===fm?this.reader.ReadUnsignedCharacter8():this.componentType===mm?this.reader.ReadInteger16():this.componentType===gm?this.reader.ReadUnsignedInteger16():this.componentType===vm?this.reader.ReadInteger32():this.componentType===ym?this.reader.ReadFloat32():null}SkipBytesByStride(e){if(null===this.byteStride)return;let t=e*this.GetComponentSize();this.reader.Skip(this.byteStride-t)}GetComponentSize(){return this.componentType===pm||this.componentType===fm?1:this.componentType===mm||this.componentType===gm?2:this.componentType===vm||this.componentType===ym?4:0}}class Om{constructor(){this.supportedExtensions=["KHR_draco_mesh_compression","KHR_materials_pbrSpecularGlossiness","KHR_texture_transform"],this.draco=null}LoadLibraries(e,t){void 0!==e&&null===this.draco&&-1!==e.indexOf("KHR_draco_mesh_compression")?_h("loaders/draco_decoder.js").then((()=>{DracoDecoderModule().then((e=>{this.draco=e,t.onSuccess()}))})).catch((()=>{t.onError("Failed to load draco decoder.")})):t.onSuccess()}GetUnsupportedExtensions(e){let t=[];if(void 0===e)return t;for(let n=0;n<e.length;n++){let r=e[n];-1===this.supportedExtensions.indexOf(r)&&t.push(r)}return t}ProcessMaterial(e,t,n){if(void 0===e.extensions)return null;let r=e.extensions.KHR_materials_pbrSpecularGlossiness;if(void 0===r)return null;let i=new pd,o=r.diffuseFactor;void 0!==o&&(i.color=Lm(o),i.opacity=o[3]);let s=r.diffuseTexture;void 0!==s&&(i.diffuseMap=n(s));let a=r.specularFactor;void 0!==a&&(i.specular=Lm(a));let l=r.specularGlossinessTexture;void 0!==l&&(i.specularMap=n(l));let c=r.glossinessFactor;return void 0!==c&&(i.shininess=c),i}ProcessTexture(e,t){if(void 0===e.extensions)return;let n=e.extensions.KHR_texture_transform;void 0!==n&&(void 0!==n.offset&&(t.offset.x=n.offset[0],t.offset.y=-n.offset[1]),void 0!==n.scale&&(t.scale.x=n.scale[0],t.scale.y=n.scale[1]),void 0!==n.rotation&&(t.rotation=-n.rotation))}ProcessPrimitive(e,t,n,r){function i(e,t,n,r,i){let o=t.GetAttributeByUniqueId(n,r),s=o.num_components(),a=n.num_points()*s,l=4*a,c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,o,e.DT_FLOAT32,l,c);let u=new Float32Array(e.HEAPF32.buffer,c,a).slice();if(2===s)for(let e=0;e<u.length;e+=2)i(new Hh(u[e+0],u[e+1]));else if(3===s)for(let e=0;e<u.length;e+=3)i(new gd(u[e+0],u[e+1],u[e+2]));else if(4===s)for(let e=0;e<u.length;e+=4)i(new qd(u[e+0],u[e+1],u[e+2],u[e+3]));e._free(c)}if(null===this.draco)return!1;if(void 0===n.extensions||void 0===n.extensions.KHR_draco_mesh_compression)return!1;let o=new this.draco.Decoder,s=new this.draco.DecoderBuffer,a=n.extensions.KHR_draco_mesh_compression,l=t.bufferViews[a.bufferView],c=e.GetReaderFromBufferView(l).ReadArrayBuffer(l.byteLength);if(s.Init(new Int8Array(c),c.byteLength),o.GetEncodedGeometryType(s)!==this.draco.TRIANGULAR_MESH)return!0;let u=new this.draco.Mesh;if(!o.DecodeBufferToMesh(s,u).ok())return!0;let h=void 0!==a.attributes.POSITION,d=void 0!==a.attributes.NORMAL,p=void 0!==a.attributes.TEXCOORD_0;if(!h)return!0;let f=r.VertexCount(),m=r.VertexColorCount(),g=r.NormalCount(),v=r.TextureUVCount();i(this.draco,o,u,a.attributes.POSITION,(e=>{r.AddVertex(e)})),d&&i(this.draco,o,u,a.attributes.NORMAL,(e=>{r.AddNormal(e)})),p&&i(this.draco,o,u,a.attributes.TEXCOORD_0,(e=>{e.y=-e.y,r.AddTextureUV(e)}));let y=3*u.num_faces(),x=4*y,_=this.draco._malloc(x);o.GetTrianglesUInt32Array(u,x,_);let T=new Uint32Array(this.draco.HEAPU32.buffer,_,y).slice();for(let t=0;t<T.length;t+=3){let i=T[t],o=T[t+1],s=T[t+2];e.AddTriangle(n,r,i,o,s,false,d,p,f,m,g,v)}return this.draco._free(_),!0}}class Um extends ff{constructor(){super(),this.gltfExtensions=new Om}CanImportExtension(e){return"gltf"===e||"glb"===e}GetUpDirection(){return zh.Y}ClearContent(){this.bufferContents=null,this.imageIndexToTextureParams=null}ResetContent(){this.bufferContents=[],this.imageIndexToTextureParams=new Map}ImportContent(e,t){"gltf"===this.extension?this.ProcessGltf(e,t):"glb"===this.extension&&this.ProcessBinaryGltf(e,t)}ProcessGltf(e,t){let n=Rd(e),r=JSON.parse(n);if("2.0"!==r.asset.version)return this.SetError("Invalid glTF version."),void t();for(let e=0;e<r.buffers.length;e++){let n=null,i=r.buffers[e],o=Nd(i.uri);if(null!==o)n=o.buffer;else{let e=this.callbacks.getFileBuffer(i.uri);null!==e&&(n=e)}if(null===n)return this.SetError("One of the requested buffers is missing."),void t();this.bufferContents.push(n)}this.ProcessMainFile(r,t)}ProcessBinaryGltf(e,t){function n(e){let t=e.ReadUnsignedInteger32();return{type:e.ReadUnsignedInteger32(),buffer:e.ReadArrayBuffer(t)}}let r=new Mf(e,!0);if(r.ReadUnsignedInteger32()!==Rm)return this.SetError("Invalid glTF file."),void t();if(2!==r.ReadUnsignedInteger32())return this.SetError("Invalid glTF version."),void t();if(r.ReadUnsignedInteger32()!==r.GetByteLength())return this.SetError("Invalid glTF file."),void t();let i=null;for(;!r.End();){let e=n(r);e.type===Im?i=Rd(e.buffer):e.type===Pm&&this.bufferContents.push(e.buffer)}if(null!==i){let e=JSON.parse(i);this.ProcessMainFile(e,t)}}ProcessMainFile(e,t){let n=this.gltfExtensions.GetUnsupportedExtensions(e.extensionsRequired);if(n.length>0)return this.SetError("Unsupported extension: "+n.join(", ")+"."),void t();this.gltfExtensions.LoadLibraries(e.extensionsRequired,{onSuccess:()=>{this.ImportModel(e),t()},onError:e=>{this.SetError(e),t()}})}ImportModel(e){let t=e.materials;if(void 0!==t)for(let n of t)this.ImportMaterial(e,n);let n=e.meshes;if(void 0!==n)for(let t of n)this.ImportMesh(e,t);this.ImportProperties(this.model,e.asset,"Asset properties"),this.ImportScene(e)}ImportProperties(e,t,n){if(null==t)return;let r=new Hd(n);for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=null,i=t[e];"string"==typeof i?n=new zd(Vd.Text,e,i):"number"==typeof i&&(n=Number.isInteger(i)?new zd(Vd.Integer,e,i):new zd(Vd.Number,e,i)),null!==n&&r.AddProperty(n)}0!==r.PropertyCount()&&e.AddPropertyGroup(r)}GetDefaultScene(e){let t=e.scene||0;return t>=e.scenes.length?null:e.scenes[t]}ImportMaterial(e,t){let n=new fd;if(void 0!==t.name&&(n.name=t.name),n.color=Lm([1,1,1]),void 0!==t.pbrMetallicRoughness){let r=t.pbrMetallicRoughness.baseColorFactor;void 0!==r&&(n.color=Lm(r),n.opacity=r[3]);let i=t.pbrMetallicRoughness.metallicFactor;void 0!==i&&(n.metalness=i);let o=t.pbrMetallicRoughness.roughnessFactor;void 0!==o&&(n.roughness=o);let s=t.emissiveFactor;void 0!==s&&(n.emissive=Lm(s)),n.diffuseMap=this.ImportTexture(e,t.pbrMetallicRoughness.baseColorTexture),n.metalnessMap=this.ImportTexture(e,t.pbrMetallicRoughness.metallicRoughnessTexture),n.normalMap=this.ImportTexture(e,t.normalTexture),n.emissiveMap=this.ImportTexture(e,t.emissiveTexture),null!==n.diffuseMap&&(n.multiplyDiffuseMap=!0);let a=t.alphaMode;void 0!==a&&("BLEND"===a?n.transparent=!0:"MASK"===a&&(n.transparent=!0,n.alphaTest=t.alphaCutoff||.5))}let r=this.gltfExtensions.ProcessMaterial(t,n,(t=>this.ImportTexture(e,t)));null!==r&&(n=r),this.model.AddMaterial(n)}ImportTexture(e,t){if(null==t)return null;let n=new ld,r=e.textures[t.index].source,i=e.images[r],o=null;if(this.imageIndexToTextureParams.has(r))o=this.imageIndexToTextureParams.get(r);else{o={name:null,mimeType:null,buffer:null};let t=r.toString();if(void 0!==i.uri){let e=Nd(i.uri);if(null!==e)o.name="Embedded_"+t+"."+Od(e.mimeType),o.mimeType=e.mimeType,o.buffer=e.buffer;else{let e=this.callbacks.getFileBuffer(i.uri);o.name=i.uri,o.buffer=e}}else if(void 0!==i.bufferView){let n=e.bufferViews[i.bufferView],r=this.GetReaderFromBufferView(n);if(null!==r){let e=r.ReadArrayBuffer(n.byteLength);o.name="Binary_"+t+"."+Od(i.mimeType),o.mimeType=i.mimeType,o.buffer=e}}this.imageIndexToTextureParams.set(r,o)}return n.name=o.name,n.mimeType=o.mimeType,n.buffer=o.buffer,this.gltfExtensions.ProcessTexture(t,n),n}ImportMesh(e,t){let n=new $p;this.model.AddMesh(n),void 0!==t.name&&n.SetName(t.name);for(let r=0;r<t.primitives.length;r++){let i=t.primitives[r];this.ImportPrimitive(e,i,n)}this.ImportProperties(n,t.extras,"Mesh properties")}ImportPrimitive(e,t,n){function r(e,t,n){let r=t.attributes[n];if(void 0===r)return!1;let i=e.accessors[r];return void 0!==i&&0!==i.count}if(this.gltfExtensions.ProcessPrimitive(this,e,t,n))return;if(void 0===t.attributes)return;let i=r(e,t,"POSITION"),o=r(e,t,"COLOR_0"),s=r(e,t,"NORMAL"),a=r(e,t,"TEXCOORD_0"),l=void 0!==t.indices,c=wm;if(void 0!==t.mode&&(c=t.mode),c!==wm&&c!==Am&&c!==Cm)return;let u=n.VertexCount(),h=n.VertexColorCount(),d=n.NormalCount(),p=n.TextureUVCount();if(!i)return;{let r=e.accessors[t.attributes.POSITION],i=this.GetReaderFromAccessor(e,r);if(null===i)return;i.EnumerateData((e=>{n.AddVertex(e)}))}let f=n.VertexCount()-u;if(o){let r=e.accessors[t.attributes.COLOR_0],i=this.GetReaderFromAccessor(e,r);if(null===i)return;i.EnumerateData((e=>{let t=function(e,t){function n(e,t){let n=e;return t===fm?n/=255:t===gm&&(n/=65535),Zh(ed(n))}return new Yh(n(e[0],t),n(e[1],t),n(e[2],t))}([e.x,e.y,e.z],i.componentType);n.AddVertexColor(t)})),n.VertexColorCount()-h!==f&&(o=!1)}if(s){let r=e.accessors[t.attributes.NORMAL],i=this.GetReaderFromAccessor(e,r);if(null===i)return;i.EnumerateData((e=>{n.AddNormal(e)})),n.NormalCount()-d!==f&&(s=!1)}if(a){let r=e.accessors[t.attributes.TEXCOORD_0],i=this.GetReaderFromAccessor(e,r);if(null===i)return;i.EnumerateData((e=>{e.y=-e.y,n.AddTextureUV(e)})),n.TextureUVCount()-p!==f&&(a=!1)}let m=[];if(l){let n=e.accessors[t.indices],r=this.GetReaderFromAccessor(e,n);if(null===r)return;r.EnumerateData((e=>{m.push(e)}))}else{let e=n.VertexCount()-u;for(let t=0;t<e;t++)m.push(t)}if(c===wm)for(let e=0;e<m.length;e+=3){let r=m[e],i=m[e+1],l=m[e+2];this.AddTriangle(t,n,r,i,l,o,s,a,u,h,d,p)}else if(c===Am)for(let e=0;e<m.length-2;e++){let r=m[e],i=m[e+1],l=m[e+2];if(e%2==1){let e=i;i=l,l=e}this.AddTriangle(t,n,r,i,l,o,s,a,u,h,d,p)}else if(c===Cm)for(let e=1;e<m.length-1;e++){let r=m[0],i=m[e],l=m[e+1];this.AddTriangle(t,n,r,i,l,o,s,a,u,h,d,p)}}AddTriangle(e,t,n,r,i,o,s,a,l,c,u,h){let d=new Qp(l+n,l+r,l+i);o&&d.SetVertexColors(c+n,c+r,c+i),s&&d.SetNormals(u+n,u+r,u+i),a&&d.SetTextureUVs(h+n,h+r,h+i),void 0!==e.material&&(d.mat=e.material),t.AddTriangle(d)}ImportScene(e){let t=this.GetDefaultScene(e);if(null===t)return;let n=this.model.GetRootNode();for(let r of t.nodes){let t=e.nodes[r];this.ImportNode(e,t,n)}this.ImportProperties(this.model,t.extras,"Scene properties")}ImportNode(e,t,n){if(void 0===t.children&&void 0===t.mesh)return;let r=new Gp;if(void 0!==t.name&&r.SetName(t.name),r.SetTransformation(function(e){let t=(new Qd).CreateIdentity();if(void 0!==e.matrix)t.Set(e.matrix);else{let n=[0,0,0],r=[0,0,0,1],i=[1,1,1];void 0!==e.translation&&(n=e.translation),void 0!==e.rotation&&(r=e.rotation),void 0!==e.scale&&(i=e.scale),t.ComposeTRS(Sd(n),Zd(r),Sd(i))}return new tp(t)}(t)),n.AddChildNode(r),void 0!==t.children)for(let n of t.children){let t=e.nodes[n];this.ImportNode(e,t,r)}if(void 0!==t.mesh){let e=this.model.GetMesh(t.mesh);this.ImportProperties(e,t.extras,"Node properties"),r.AddMeshIndex(t.mesh)}}GetReaderFromBufferView(e){let t=e.buffer||0,n=this.bufferContents[t];if(null==n)return null;let r=new Nm(n);r.SkipBytes(e.byteOffset||0);let i=e.byteStride;return void 0!==i&&0!==i&&r.SetByteStride(i),r}GetReaderFromAccessor(e,t){let n=t.bufferView||0,r=e.bufferViews[n],i=this.GetReaderFromBufferView(r);if(null===i)return null;if(i.SetComponentType(t.componentType),i.SetDataType(t.type),i.SetDataCount(t.count),i.SkipBytes(t.byteOffset||0),void 0!==t.sparse){let n=this.GetReaderFromSparseAccessor(e,t.sparse.indices,t.sparse.indices.componentType,"SCALAR",t.sparse.count),r=this.GetReaderFromSparseAccessor(e,t.sparse.values,t.componentType,t.type,t.sparse.count);null!==n&&null!==r&&i.SetSparseReader(n,r)}return i}GetReaderFromSparseAccessor(e,t,n,r,i){if(void 0===t.bufferView)return null;let o=e.bufferViews[t.bufferView],s=this.GetReaderFromBufferView(o);return null===s?null:(s.SetComponentType(n),s.SetDataType(r),s.SetDataCount(i),s.SkipBytes(t.byteOffset||0),s)}}class Dm extends ff{constructor(){super(),this.ifc=null}CanImportExtension(e){return"ifc"===e}GetUpDirection(){return zh.Y}ClearContent(){this.expressIDToMesh=null,this.colorToMaterial=null}ResetContent(){this.expressIDToMesh=new Map,this.colorToMaterial=new Tf(this.model)}ImportContent(e,t){null===this.ifc?_h("loaders/web-ifc-api-browser.js").then((()=>{this.ifc=new WebIFC.IfcAPI,this.ifc.Init().then((()=>{this.ImportIfcContent(e),t()}))})).catch((()=>{this.SetError("Failed to load web-ifc."),t()})):(this.ImportIfcContent(e),t())}ImportIfcContent(e){const t=new Uint8Array(e),n=this.ifc.OpenModel(t,{COORDINATE_TO_ORIGIN:!0}),r=this.ifc.LoadAllGeometry(n);for(let e=0;e<r.size();e++){const t=r.get(e);t.geometries.size()>0&&this.ImportIfcMesh(n,t)}this.ImportProperties(n),this.ifc.CloseModel(n)}ImportIfcMesh(e,t){let n=new $p;n.SetName("Mesh "+t.expressID.toString());let r=0;const i=t.geometries;for(let t=0;t<i.size();t++){const o=i.get(t),s=this.ifc.GetGeometry(e,o.geometryExpressID),a=this.ifc.GetVertexArray(s.GetVertexData(),s.GetVertexDataSize()),l=this.ifc.GetIndexArray(s.GetIndexData(),s.GetIndexDataSize()),c=this.GetMaterialIndexByColor(o.color),u=new Qd(o.flatTransformation),h=new tp(u);for(let e=0;e<a.length;e+=6){const t=a[e],r=a[e+1],i=a[e+2],o=new gd(t,r,i),s=h.TransformCoord3D(o);n.AddVertex(s)}for(let e=0;e<l.length;e+=3){const t=l[e],i=l[e+1],o=l[e+2],s=new Qp(r+t,r+i,r+o);s.SetMaterial(c),n.AddTriangle(s)}r+=a.length/6}this.expressIDToMesh.set(t.expressID,n),this.model.AddMeshToRootNode(n)}ImportProperties(e){const t=this.ifc.GetLineIDsWithType(e,WebIFC.IFCRELDEFINESBYPROPERTIES);for(let n=0;n<t.size();n++){const r=t.get(n),i=this.ifc.GetLine(e,r);Array.isArray(i.RelatingPropertyDefinition)||i.RelatedObjects.forEach((t=>{let n=null;if(this.expressIDToMesh.has(t.value))n=this.expressIDToMesh.get(t.value);else{this.ifc.GetLine(e,t.value,!0).type===WebIFC.IFCBUILDING&&(n=this.model)}if(null===n)return;let r=i.RelatingPropertyDefinition,o=this.ifc.GetLine(e,r.value,!0);if(!o||!o.HasProperties)return;let s=new Hd(o.Name.value);o.HasProperties.forEach((e=>{if(!e||!e.Name)return;if(!e.NominalValue||!e.NominalValue.constructor)return;if(e.type!==WebIFC.IFCPROPERTYSINGLEVALUE)return;let t=this.GetIFCString(e.Name.value),n=null,r=null;switch(e.NominalValue.constructor.name){case"IfcText":case"IfcLabel":case"IfcIdentifier":case WebIFC.IFCLABEL:n=new zd(Vd.Text,t,this.GetIFCString(e.NominalValue.value));break;case"IfcBoolean":case"IfcLogical":r="Unknown","T"===e.NominalValue.value?r="True":"F"===e.NominalValue.value&&(r="False"),n=new zd(Vd.Text,t,r);break;case"IfcInteger":case"IfcCountMeasure":n=new zd(Vd.Integer,t,e.NominalValue.value);break;case"IfcReal":case"IfcLengthMeasure":case"IfcPositiveLengthMeasure":case"IfcAreaMeasure":case"IfcVolumeMeasure":case"IfcRatioMeasure":case"IfcPositiveRATIOMeasure":case"IfcMassMeasure":case"IfcMassPerLengthMeasure":case"IfcPlaneAngleMeasure":case"IfcThermalTransmittanceMeasure":n=new zd(Vd.Number,t,e.NominalValue.value);break;default:console.log(e)}null!==n&&s.AddProperty(n)})),s.PropertyCount()>0&&n.AddPropertyGroup(s)}))}}GetMaterialIndexByColor(e){const t=$h(e.x,e.y,e.z),n=parseInt(255*e.w,10);return this.colorToMaterial.GetMaterialIndex(t.r,t.g,t.b,n)}GetIFCString(e){let t=this.DecodeIFCString(e);return 0===t.length&&(t="-"),t}DecodeIFCString(e){const t=/\\X2\\(.*?)\\X0\\/giu;let n=e,r=t.exec(e);for(;r;){const i=String.fromCharCode(parseInt(r[1],16));n=n.replace(r[0],i),r=t.exec(e)}return n}}class km{constructor(e){this.mesh=e,this.globalToMeshVertices=new Map,this.globalToMeshVertexColors=new Map,this.globalToMeshNormals=new Map,this.globalToMeshUvs=new Map}AddVertex(e,t){return this.GetLocalIndex(e,t,this.globalToMeshVertices,(e=>this.mesh.AddVertex(new gd(e.x,e.y,e.z))))}AddVertexColor(e,t){return this.GetLocalIndex(e,t,this.globalToMeshVertexColors,(e=>this.mesh.AddVertexColor(new Yh(e.r,e.g,e.b))))}AddNormal(e,t){return this.GetLocalIndex(e,t,this.globalToMeshNormals,(e=>this.mesh.AddNormal(new gd(e.x,e.y,e.z))))}AddUV(e,t){return this.GetLocalIndex(e,t,this.globalToMeshUvs,(e=>this.mesh.AddTextureUV(new Hh(e.x,e.y))))}AddTriangle(e){this.mesh.AddTriangle(e)}GetLocalIndex(e,t,n,r){if(isNaN(e)||e<0||e>=t.length)return null;if(n.has(e))return n.get(e);{let i=r(t[e]);return n.set(e,i),i}}}function Fm(e,t,n){return $h(parseFloat(e),parseFloat(t),parseFloat(n))}class Gm extends ff{constructor(){super()}CanImportExtension(e){return"obj"===e}GetUpDirection(){return zh.Y}ClearContent(){this.globalVertices=null,this.globalVertexColors=null,this.globalNormals=null,this.globalUvs=null,this.currentMeshConverter=null,this.currentMaterial=null,this.currentMaterialIndex=null,this.meshNameToConverter=null,this.materialNameToIndex=null}ResetContent(){this.globalVertices=[],this.globalVertexColors=[],this.globalNormals=[],this.globalUvs=[],this.currentMeshConverter=null,this.currentMaterial=null,this.currentMaterialIndex=null,this.meshNameToConverter=new Map,this.materialNameToIndex=new Map}ImportContent(e,t){vf(Rd(e),(e=>{this.WasError()||this.ProcessLine(e)})),t()}ProcessLine(e){if("#"===e[0])return;let t=gf(e,"#");if(0===t.length)return;let n=t[0].toLowerCase();t.shift(),this.ProcessMeshParameter(n,t,e)||this.ProcessMaterialParameter(n,t,e)}AddNewMesh(e){if(this.meshNameToConverter.has(e))this.currentMeshConverter=this.meshNameToConverter.get(e);else{let t=new $p;t.SetName(e),this.model.AddMeshToRootNode(t),this.currentMeshConverter=new km(t),this.meshNameToConverter.set(e,this.currentMeshConverter)}}ProcessMeshParameter(e,t,n){if("g"===e||"o"===e){if(0===t.length)return!0;let r=mf(n,e.length,"#");return this.AddNewMesh(r),!0}return"v"===e?(t.length<3||(this.globalVertices.push(new gd(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]))),t.length>=6&&this.globalVertexColors.push(Fm(t[3],t[4],t[5]))),!0):"vn"===e?(t.length<3||this.globalNormals.push(new gd(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]))),!0):"vt"===e?(t.length<2||this.globalUvs.push(new Hh(parseFloat(t[0]),parseFloat(t[1]))),!0):"f"===e&&(t.length<3||this.ProcessFace(t),!0)}ProcessMaterialParameter(e,t,n){function r(e,t){let n=new ld,r=e[e.length-1],i=t.getFileBuffer(r);n.name=r,n.buffer=i;let o=function(e){let t=new Map,n=null;for(let r=0;r<e.length-1;r++){let i=e[r];i.startsWith("-")?(n=i,t.set(n,[])):null!==n&&t.get(n).push(i)}return t}(e);if(o.has("-o")){let e=o.get("-o");e.length>0&&(n.offset.x=parseFloat(e[0])),e.length>1&&(n.offset.y=parseFloat(e[1]))}if(o.has("-s")){let e=o.get("-s");e.length>0&&(n.scale.x=parseFloat(e[0])),e.length>1&&(n.scale.y=parseFloat(e[1]))}return n}if("newmtl"===e){if(0===t.length)return!0;let r=new pd,i=mf(n,e.length,"#"),o=this.model.AddMaterial(r);return r.name=i,this.currentMaterial=r,this.materialNameToIndex.set(i,o),!0}if("usemtl"===e){if(0===t.length)return!0;let r=mf(n,e.length,"#");return this.materialNameToIndex.has(r)&&(this.currentMaterialIndex=this.materialNameToIndex.get(r)),!0}if("mtllib"===e){if(0===t.length)return!0;let r=mf(n,e.length,"#"),i=this.callbacks.getFileBuffer(r);if(null!==i){vf(Rd(i),(e=>{this.WasError()||this.ProcessLine(e)}))}return!0}return"map_kd"===e?(null===this.currentMaterial||0===t.length||(this.currentMaterial.diffuseMap=r(t,this.callbacks),_f(this.currentMaterial)),!0):"map_ks"===e?(null===this.currentMaterial||0===t.length||(this.currentMaterial.specularMap=r(t,this.callbacks)),!0):"map_bump"===e||"bump"===e?(null===this.currentMaterial||0===t.length||(this.currentMaterial.bumpMap=r(t,this.callbacks)),!0):"ka"===e?(null===this.currentMaterial||t.length<3||(this.currentMaterial.ambient=Fm(t[0],t[1],t[2])),!0):"kd"===e?(null===this.currentMaterial||t.length<3||(this.currentMaterial.color=Fm(t[0],t[1],t[2])),!0):"ks"===e?(null===this.currentMaterial||t.length<3||(this.currentMaterial.specular=Fm(t[0],t[1],t[2])),!0):"ns"===e?(null===this.currentMaterial||t.length<1||(this.currentMaterial.shininess=parseFloat(t[0])/1e3),!0):"tr"===e?(null===this.currentMaterial||t.length<1||(this.currentMaterial.opacity=1-parseFloat(t[0]),_f(this.currentMaterial)),!0):"d"===e&&(null===this.currentMaterial||t.length<1||(this.currentMaterial.opacity=parseFloat(t[0]),_f(this.currentMaterial)),!0)}ProcessFace(e){function t(e,t){return e>0?e-1:t+e}let n=[],r=[],i=[],o=[];for(let s=0;s<e.length;s++){let a=e[s].split("/");n.push(t(parseInt(a[0],10),this.globalVertices.length)),this.globalVertices.length===this.globalVertexColors.length&&r.push(t(parseInt(a[0],10),this.globalVertices.length)),a.length>1&&a[1].length>0&&o.push(t(parseInt(a[1],10),this.globalUvs.length)),a.length>2&&a[2].length>0&&i.push(t(parseInt(a[2],10),this.globalNormals.length))}null===this.currentMeshConverter&&this.AddNewMesh("");for(let e=0;e<n.length-2;e++){let t=this.currentMeshConverter.AddVertex(n[0],this.globalVertices),s=this.currentMeshConverter.AddVertex(n[e+1],this.globalVertices),a=this.currentMeshConverter.AddVertex(n[e+2],this.globalVertices);if(null===t||null===s||null===a){this.SetError("Invalid vertex index.");break}let l=new Qp(t,s,a);if(r.length===n.length){let t=this.currentMeshConverter.AddVertexColor(r[0],this.globalVertexColors),n=this.currentMeshConverter.AddVertexColor(r[e+1],this.globalVertexColors),i=this.currentMeshConverter.AddVertexColor(r[e+2],this.globalVertexColors);if(null===t||null===n||null===i){this.SetError("Invalid vertex color index.");break}l.SetVertexColors(t,n,i)}if(i.length===n.length){let t=this.currentMeshConverter.AddNormal(i[0],this.globalNormals),n=this.currentMeshConverter.AddNormal(i[e+1],this.globalNormals),r=this.currentMeshConverter.AddNormal(i[e+2],this.globalNormals);if(null===t||null===n||null===r){this.SetError("Invalid normal index.");break}l.SetNormals(t,n,r)}if(o.length===n.length){let t=this.currentMeshConverter.AddUV(o[0],this.globalUvs),n=this.currentMeshConverter.AddUV(o[e+1],this.globalUvs),r=this.currentMeshConverter.AddUV(o[e+2],this.globalUvs);if(null===t||null===n||null===r){this.SetError("Invalid uv index.");break}l.SetTextureUVs(t,n,r)}null!==this.currentMaterialIndex&&(l.mat=this.currentMaterialIndex),this.currentMeshConverter.AddTriangle(l)}}}class Bm extends ff{constructor(){super()}CanImportExtension(e){return"off"===e}GetUpDirection(){return zh.Y}ClearContent(){this.mesh=null,this.status=null,this.colorToMaterial=null}ResetContent(){this.mesh=new $p,this.model.AddMeshToRootNode(this.mesh),this.status={vertexCount:0,faceCount:0,foundVertex:0,foundFace:0},this.colorToMaterial=new Tf(this.model)}ImportContent(e,t){vf(Rd(e),(e=>{this.WasError()||this.ProcessLine(e)})),t()}ProcessLine(e){function t(e){return-1!==e.indexOf(".")?Zh(parseFloat(e)):parseInt(e,10)}if("#"===e[0])return;let n=gf(e,"#");if(0===n.length)return;if("OFF"===n[0])return;if(0===this.status.vertexCount&&0===this.status.faceCount)return void(n.length>1&&(this.status.vertexCount=parseInt(n[0],10),this.status.faceCount=parseInt(n[1],10)));if(this.status.foundVertex<this.status.vertexCount)return n.length>=3&&(this.mesh.AddVertex(new gd(parseFloat(n[0]),parseFloat(n[1]),parseFloat(n[2]))),this.status.foundVertex+=1),void(n.length>=6&&this.mesh.AddVertexColor(new Yh(t(n[3]),t(n[4]),t(n[5]))));let r=this.mesh.VertexCount()===this.mesh.VertexColorCount();if(this.status.foundFace<this.status.faceCount){if(n.length>=4){let e=parseInt(n[0],10);if(n.length<e+1)return;let i=null;if(!r&&n.length>=e+4){let r=new Yh(t(n[e+1]),t(n[e+2]),t(n[e+3]));i=this.colorToMaterial.GetMaterialIndex(r.r,r.g,r.b)}for(let t=0;t<e-2;t++){let e=parseInt(n[1]),o=parseInt(n[t+2]),s=parseInt(n[t+3]),a=new Qp(e,o,s);r?a.SetVertexColors(e,o,s):a.SetMaterial(i),this.mesh.AddTriangle(a)}this.status.foundFace+=1}}else;}}const Vm=1,zm=2,Hm=3,Wm=4;class jm{constructor(){this.format=null,this.elements=[]}SetFormat(e){this.format=e}AddElement(e,t){this.elements.push({name:e,count:t,format:[]})}GetElements(){return this.elements}AddSingleFormat(e,t){this.elements[this.elements.length-1].format.push({name:t,isSingle:!0,elemType:e})}AddListFormat(e,t,n){this.elements[this.elements.length-1].format.push({name:n,isSingle:!1,countType:e,elemType:t})}GetElement(e){for(let t=0;t<this.elements.length;t++){let n=this.elements[t];if(n.name===e)return n}return null}Check(){let e=this.GetElement("vertex");if(null===e||0===e.length||e.format.length<3)return zm;let t=this.GetElement("face");if("ascii"===this.format){if(null===t||0===t.count||t.format.length<0)return Hm}else{if("binary_little_endian"!==this.format&&"binary_big_endian"!==this.format)return Wm;{let e=this.GetElement("tristrips"),n=null!==t&&t.count>0&&t.format.length>0,r=null!==e&&e.count>0&&e.format.length>0;if(!n&&!r)return Hm}}return Vm}}class Xm{constructor(e){this.model=e,this.colorToMaterial=new Map}GetMaterialIndexByColor(e){let t="Color "+td(e[0])+td(e[1])+td(e[2])+td(e[3]);if(this.colorToMaterial.has(t))return this.colorToMaterial.get(t);{let n=new pd;n.name=t,n.color=new Yh(e[0],e[1],e[2]),n.opacity=e[3]/255,_f(n);let r=this.model.AddMaterial(n);return this.colorToMaterial.set(t,r),r}}}class qm extends ff{constructor(){super()}CanImportExtension(e){return"ply"===e}GetUpDirection(){return zh.Y}ClearContent(){this.mesh=null}ResetContent(){this.mesh=new $p,this.model.AddMeshToRootNode(this.mesh)}ImportContent(e,t){let n=this.GetHeaderContent(e),r=this.ReadHeader(n),i=r.Check();if(i===Vm)if("ascii"===r.format){let t=Rd(e);t=t.substring(n.length),this.ReadAsciiContent(r,t)}else"binary_little_endian"!==r.format&&"binary_big_endian"!==r.format||this.ReadBinaryContent(r,e,n.length);else i===zm?this.SetError("The model contains no vertices."):i===Hm?this.SetError("The model contains no faces."):this.SetError("Invalid header information.");t()}GetHeaderContent(e){let t="",n=new Uint8Array(e),r=0;for(r=0;r<e.byteLength&&(t+=String.fromCharCode(n[r]),!t.endsWith("end_header"));r++);for(r+=1;r<e.byteLength;){let e=String.fromCharCode(n[r]);if(t+=e,r+=1,"\n"===e)break}return t}ReadHeader(e){let t=new jm;return vf(e,(e=>{let n=gf(e,null);0!==n.length&&"comment"!==n[0]&&"ply"!==n[0]&&("format"===n[0]&&n.length>=2?t.SetFormat(n[1]):"element"===n[0]&&n.length>=3?t.AddElement(n[1],parseInt(n[2],10)):"property"===n[0]&&n.length>=3&&("list"===n[1]&&n.length>=5?t.AddListFormat(n[2],n[3],n[4]):t.AddSingleFormat(n[1],n[2])))})),t}ReadAsciiContent(e,t){let n=e.GetElement("vertex"),r=e.GetElement("face"),i=0,o=0;vf(t,(e=>{if(this.WasError())return;let t=gf(e,null);if(0!==t.length&&"comment"!==t[0])if(i<n.count)t.length>=3&&(this.mesh.AddVertex(new gd(parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2]))),i+=1);else if(null!==r&&o<r.count){if(t.length>=4){let e=parseInt(t[0],10);if(t.length<e+1)return;for(let n=0;n<e-2;n++){let e=parseInt(t[1]),r=parseInt(t[n+2]),i=parseInt(t[n+3]),o=new Qp(e,r,i);this.mesh.AddTriangle(o)}o+=1}}else;}))}ReadBinaryContent(e,t,n){function r(e,t){function n(e,t){return"char"===t||"int8"===t?e.ReadCharacter8():"uchar"===t||"uint8"===t?e.ReadUnsignedCharacter8():"short"===t||"int16"===t?e.ReadInteger16():"ushort"===t||"uint16"===t?e.ReadUnsignedInteger16():"int"===t||"int32"===t?e.ReadInteger32():"uint"===t||"uint32"===t?e.ReadUnsignedInteger32():"float"===t||"float32"===t?e.ReadFloat32():"double"===t||"double64"===t?e.ReadDouble64():null}if(t.isSingle)return n(e,t.elemType);{let r=[],i=n(e,t.countType);for(let o=0;o<i;o++)r.push(n(e,t.elemType));return r}}function i(e,t,n){for(let i=n;i<t.length;i++)r(e,t[i])}function o(e,t,n){let i=null,o=null,s=null,a=255;for(let l=n;l<t.length;l++){let n=t[l],c=r(e,n);"red"===n.name?i=c:"green"===n.name?o=c:"blue"===n.name?s=c:"alpha"===n.name&&(a=c)}return null!==i&&null!==o&&null!==s?[i,o,s,a]:null}let s=null;if("binary_little_endian"===e.format)s=new Mf(t,!0);else{if("binary_big_endian"!==e.format)return;s=new Mf(t,!1)}s.Skip(n);let a=new Xm(this.model),l=e.GetElements();for(let e=0;e<l.length;e++){let t=l[e];if("vertex"===t.name)for(let e=0;e<t.count;e++){let e=r(s,t.format[0]),n=r(s,t.format[1]),i=r(s,t.format[2]),a=o(s,t.format,3);null!==a&&this.mesh.AddVertexColor(new Yh(a[0],a[1],a[2])),this.mesh.AddVertex(new gd(e,n,i))}else if("face"===t.name)for(let e=0;e<t.count;e++){let e=r(s,t.format[0]),n=o(s,t.format,1);for(let t=0;t<e.length-2;t++){let r=e[0],i=e[t+1],o=e[t+2],s=new Qp(r,i,o);null!==n?s.mat=a.GetMaterialIndexByColor(n):this.mesh.VertexColorCount()>0&&s.SetVertexColors(r,i,o),this.mesh.AddTriangle(s)}}else if("tristrips"===t.name)for(let e=0;e<t.count;e++){let e=r(s,t.format[0]);i(s,t.format,1);let n=!0;for(let t=0;t<e.length-2;t++){let r=e[t],i=e[t+1],o=e[t+2];if(-1===o){t+=2,n=!0;continue}if(!n){let e=i;i=o,o=e}n=!n;let s=new Qp(r,i,o);this.mesh.AddTriangle(s)}}else i(s,t.format,0)}}}class Ym extends ff{constructor(){super(),this.worker=null}CanImportExtension(e){return"stp"===e||"step"===e||"igs"===e||"iges"===e||"brp"===e||"brep"===e}GetUpDirection(){return zh.Y}ClearContent(){null!==this.worker&&(this.worker.terminate(),this.worker=null)}ResetContent(){this.worker=null}ImportContent(e,t){let n=xh("loaders/occt-import-js-worker.js");this.worker=new Worker(n),this.worker.addEventListener("message",(e=>{this.ImportResultJson(e.data,t)})),this.worker.addEventListener("error",(e=>{this.SetError("Failed to load occt-import-js."),t()}));let r=null;if("stp"===this.extension||"step"===this.extension)r="step";else if("igs"===this.extension||"iges"===this.extension)r="iges";else{if("brp"!==this.extension&&"brep"!==this.extension)return void t();r="brep"}let i=new Uint8Array(e);this.worker.postMessage({format:r,buffer:i,params:null})}ImportResultJson(e,t){if(!e.success)return void t();let n=new Tf(this.model),r=this.model.GetRootNode();this.ImportNode(e,e.root,r,n),t()}ImportNode(e,t,n,r){for(let i of t.meshes){let t=e.meshes[i],o=this.ImportMesh(t,r),s=this.model.AddMesh(o);n.AddMeshIndex(s)}for(let i of t.children){let t=new Gp;t.SetName(i.name),n.AddChildNode(t),this.ImportNode(e,i,t,r)}}ImportMesh(e,t){let n=null;if(e.color){let r=$h(e.color[0],e.color[1],e.color[2]);n=t.GetMaterialIndex(r.r,r.g,r.b,null)}let r=cf(e,n,null);e.name&&r.SetName(e.name);for(let n of e.brep_faces){if(null===n.color)continue;let e=$h(n.color[0],n.color[1],n.color[2]),i=t.GetMaterialIndex(e.r,e.g,e.b,null);for(let e=n.first;e<=n.last;e++){r.GetTriangle(e).SetMaterial(i)}}return r}}class Km extends ff{constructor(){super()}CanImportExtension(e){return"stl"===e}GetUpDirection(){return zh.Z}ClearContent(){this.mesh=null,this.triangle=null}ResetContent(){this.mesh=new $p,this.model.AddMeshToRootNode(this.mesh),this.triangle=null}ImportContent(e,t){if(this.IsBinaryStlFile(e))this.ProcessBinary(e);else{vf(Rd(e),(e=>{this.WasError()||this.ProcessLine(e)}))}t()}IsBinaryStlFile(e){let t=e.byteLength;if(t<84)return!1;let n=new Mf(e,!0);return n.Skip(80),t===50*n.ReadUnsignedInteger32()+84}ProcessLine(e){if("#"===e[0])return;let t=gf(e,"#");if(0===t.length)return;let n=t[0];if("solid"!==n){if("facet"!==n){if("vertex"!==n||null===this.triangle)return"endfacet"===n&&null!==this.triangle?(-1!==this.triangle.v0&&-1!==this.triangle.v1&&null!==this.triangle.v2&&this.mesh.AddTriangle(this.triangle),void(this.triangle=null)):void 0;if(t.length>=4){let e=this.mesh.AddVertex(new gd(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])));-1===this.triangle.v0?this.triangle.v0=e:-1===this.triangle.v1?this.triangle.v1=e:-1===this.triangle.v2&&(this.triangle.v2=e)}}else if(this.triangle=new Qp(-1,-1,-1),t.length>=5&&"normal"===t[1]){let e=new gd(parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4]));if(Bh(e.Length())){let t=this.mesh.AddNormal(e);this.triangle.SetNormals(t,t,t)}}}else if(t.length>1){let t=mf(e,n.length,"#");this.mesh.SetName(t)}}ProcessBinary(e){function t(e){let t=new gd;return t.x=e.ReadFloat32(),t.y=e.ReadFloat32(),t.z=e.ReadFloat32(),t}function n(e,n){let r=t(n);return e.AddVertex(r)}let r=new Mf(e,!0);r.Skip(80);let i=r.ReadUnsignedInteger32();for(let e=0;e<i;e++){let e=t(r),i=n(this.mesh,r),o=n(this.mesh,r),s=n(this.mesh,r);r.Skip(2);let a=new Qp(i,o,s);if(Bh(e.Length())){let t=this.mesh.AddNormal(e);a.SetNormals(t,t,t)}this.mesh.AddTriangle(a)}}}class Zm extends ff{constructor(){super()}CanImportExtension(e){return"bim"===e}GetUpDirection(){return zh.Z}ClearContent(){this.meshIdToMesh=null,this.colorToMaterial=null}ResetContent(){this.meshIdToMesh=new Map,this.colorToMaterial=new Tf(this.model)}ImportContent(e,t){let n=Rd(e),r=null;try{r=JSON.parse(n)}catch(e){return this.SetError("Failed to parse bim file."),void t()}for(let e of r.meshes)this.meshIdToMesh.set(e.mesh_id,e);this.ImportProperties(r,this.model);for(let e of r.elements){let t=this.ImportElement(e);t.SetName(e.type),this.ImportProperties(e,t)}t()}ImportElement(e){let t=this.colorToMaterial.GetMaterialIndex(e.color.r,e.color.g,e.color.b,e.color.a),n=this.model.GetRootNode(),r=this.meshIdToMesh.get(e.mesh_id),i=this.ImportMesh(r,(n=>{if(e.face_colors){return this.colorToMaterial.GetMaterialIndex(e.face_colors[4*n+0],e.face_colors[4*n+1],e.face_colors[4*n+2],e.face_colors[4*n+3])}return t})),o=this.model.AddMesh(i),s=new Gp;s.AddMeshIndex(o);let a=new gd(0,0,0);e.vector&&(a=new gd(e.vector.x,e.vector.y,e.vector.z));let l=new Yd(0,0,0,1);e.rotation&&(l=new Yd(e.rotation.qx,e.rotation.qy,e.rotation.qz,e.rotation.qw));let c=new gd(1,1,1),u=(new Qd).ComposeTRS(a,l,c);return s.SetTransformation(new tp(u)),n.AddChildNode(s),i}ImportMesh(e,t){let n=new $p;for(let t=0;t<e.coordinates.length;t+=3)n.AddVertex(new gd(e.coordinates[t+0],e.coordinates[t+1],e.coordinates[t+2]));for(let r=0;r<e.indices.length;r+=3){let i=new Qp(e.indices[r+0],e.indices[r+1],e.indices[r+2]);i.SetMaterial(t(r/3)),n.AddTriangle(i)}return n}ImportProperties(e,t){function n(e,t,n){if(null==n)return;let r=new zd(Vd.Text,t,n);e.AddProperty(r)}if(!e.info||lh(e.info))return;let r=e.info,i=new Hd("Info");n(i,"Guid",e.guid),n(i,"Type",e.type);for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&"string"==typeof r[e]&&n(i,e,r[e]);t.AddPropertyGroup(i)}}class Jm extends ff{constructor(){super(),this.colorConverter=null}CreateLoader(e){return null}GetMainObject(e){return e}IsMeshVisible(e){return!0}ClearContent(){this.loader=null,this.materialIdToIndex=null,this.objectUrlToFileName=null}ResetContent(){this.loader=null,this.materialIdToIndex=new Map,this.objectUrlToFileName=new Map}ImportContent(e,t){this.LoadModel(e,t)}LoadModel(e,t){let n=!1,r=new sl((()=>{n=!0}));const i=Ud(e);r.setURLModifier((e=>{if(e===i)return e;const t=Mh(e);if(bh(e).length>0){const n=this.callbacks.getFileBuffer(e);if(null!==n){let e=Ud(n);return this.objectUrlToFileName.set(e,t),e}}return e}));const o=this.CreateLoader(r);null!==o?o.load(i,(e=>{mh((()=>!n||(this.OnThreeObjectsLoaded(e,t),!1)))}),(()=>{}),(e=>{this.SetError(e),t()})):t()}OnThreeObjectsLoaded(e,t){function n(e){let t=(new Qd).CreateIdentity();return e.updateMatrix(),void 0!==e.matrix&&null!==e.matrix&&t.Set(e.matrix.elements),new tp(t)}function r(e,t,i,o){let s=new Gp;void 0!==i.name&&s.SetName(i.name),s.SetTransformation(n(i)),o.AddChildNode(s);for(let n of i.children)r(e,t,n,s);if(i.isMesh&&e.IsMeshVisible(i)){let n=e.ConvertThreeMesh(i),r=t.AddMesh(n);s.AddMeshIndex(r)}}let i=this.GetMainObject(e),o=this.model.GetRootNode();o.SetTransformation(n(i));for(let e of i.children)r(this,this.model,e,o);t()}ConvertThreeMesh(e){let t=null;if(Array.isArray(e.material)){if(t=cf(e.geometry,null,this.colorConverter),void 0===e.geometry.attributes.color||null===e.geometry.attributes.color){let n=[];for(let t=0;t<e.material.length;t++){const r=e.material[t],i=this.FindOrCreateMaterial(r);n.push(i)}for(let r=0;r<e.geometry.groups.length;r++){let i=e.geometry.groups[r],o=null;o=i.count===1/0?t.TriangleCount():i.start/3+i.count/3;for(let e=i.start/3;e<o;e++){t.GetTriangle(e).SetMaterial(n[i.materialIndex])}}}}else{const n=this.FindOrCreateMaterial(e.material);t=cf(e.geometry,n,this.colorConverter)}return void 0!==e.name&&null!==e.name&&t.SetName(e.name),t}FindOrCreateMaterial(e){if(this.materialIdToIndex.has(e.id))return this.materialIdToIndex.get(e.id);let t=this.ConvertThreeMaterial(e),n=this.model.AddMaterial(t);return this.materialIdToIndex.set(e.id,n),n}ConvertThreeMaterial(e){function t(e,t){if(null==e)return null;if(void 0===e.image||null===e.image)return null;try{const n=function(e){if(void 0!==e.data&&null!==e.data){let t=new ImageData(e.width,e.height),n=e.width*e.height*4;for(let r=0;r<n;r++)t.data[r]=e.data[r];return Be.getDataURL(t)}return Be.getDataURL(e)}(e.image),r=Nd(n);let i=new ld,o=null;return o=t.has(e.image.src)?t.get(e.image.src):void 0!==e.name&&null!==e.name?e.name+"."+Od(r.mimeType):"Embedded_"+e.id.toString()+"."+Od(r.mimeType),i.name=o,i.mimeType=r.mimeType,i.buffer=r.buffer,i.rotation=e.rotation,i.offset.x=e.offset.x,i.offset.y=e.offset.y,i.scale.x=e.repeat.x,i.scale.y=e.repeat.y,i}catch(e){return null}}let n=new pd;return n.name=e.name,n.color=this.ConvertThreeColor(e.color),n.opacity=e.opacity,n.transparent=e.transparent,n.alphaTest=e.alphaTest,"MeshPhongMaterial"===e.type&&(n.specular=this.ConvertThreeColor(e.specular),n.shininess=e.shininess/100),n.diffuseMap=t(e.map,this.objectUrlToFileName),n.normalMap=t(e.normalMap,this.objectUrlToFileName),n.bumpMap=t(e.bumpMap,this.objectUrlToFileName),n}ConvertThreeColor(e){return null!==this.colorConverter&&(e=this.colorConverter.Convert(e)),af(e)}}class $m extends Jm{constructor(){super(),this.colorConverter=new of}CanImportExtension(e){return"fbx"===e}GetUpDirection(){return zh.Y}CreateLoader(e){return e.addHandler(/\.tga$/i,new jl(e)),new Vc(e)}GetMainObject(e){return e}}class Qm extends Jm{constructor(){super()}CanImportExtension(e){return"dae"===e}GetUpDirection(){return zh.Y}CreateLoader(e){return e.addHandler(/\.tga$/i,new jl(e)),new su(e)}GetMainObject(e){return e.scene}}class eg extends Jm{constructor(){super(),this.colorConverter=new of}CanImportExtension(e){return"wrl"===e}GetUpDirection(){return zh.Y}CreateLoader(e){return new lu(e)}GetMainObject(e){return e}IsMeshVisible(e){let t=!0;if(Array.isArray(e.material)){for(let n=0;n<e.material.length;n++)if(e.material[n].side===a){t=!1;break}}else t=e.material.side!==a;return t}}class tg extends Jm{constructor(){super(),this.colorConverter=new sf}CanImportExtension(e){return"3mf"===e}GetUpDirection(){return zh.Z}CreateLoader(e){return new mu(e)}GetMainObject(e){return e}}class ng extends Jm{constructor(){super()}CanImportExtension(e){return"amf"===e}GetUpDirection(){return zh.Z}CreateLoader(e){return new gu(e)}GetMainObject(e){return e}}const rg=0,ig=1;class og{constructor(e,t){this.name=e,this.type=t,this.shapeName=null,this.isVisible=!1,this.color=null,this.fileName=null,this.fileContent=null,this.inLinkCount=0,this.properties=null}IsConvertible(){return null!==this.fileName&&null!==this.fileContent&&(!!this.isVisible&&!(this.inLinkCount>0))}}class sg{constructor(){this.files=null,this.properties=null,this.objectNames=[],this.objectData=new Map}Init(e){let t=new Uint8Array(e);return this.files=nh(t),this.LoadDocumentXml()?(this.LoadGuiDocumentXml(),rg):ig}GetObjectListToConvert(){let e=[];for(let t of this.objectNames){let n=this.objectData.get(t);n.IsConvertible()&&e.push(n)}return e}IsSupportedType(e){return!(!e.startsWith("Part::")&&!e.startsWith("PartDesign::"))&&-1===e.indexOf("Part2D")}HasFile(e){return e in this.files}LoadDocumentXml(){let e=this.GetXMLContent("Document.xml");if(null===e)return!1;this.properties=new Hd("Properties");let t=e.getElementsByTagName("Document");for(let e of t)for(let t of e.childNodes)"Properties"===t.tagName&&this.GetPropertiesFromElement(t,this.properties);let n=e.getElementsByTagName("Objects");for(let e of n){let t=e.getElementsByTagName("Object");for(let e of t){let t=e.getAttribute("name"),n=e.getAttribute("type");if(!this.IsSupportedType(n))continue;let r=new og(t,n);this.objectNames.push(t),this.objectData.set(t,r)}}let r=e.getElementsByTagName("ObjectData");for(let e of r){let t=e.getElementsByTagName("Object");for(let e of t){let t=e.getAttribute("name");if(!this.objectData.has(t))continue;let n=this.objectData.get(t);n.properties=new Hd("Properties");for(let t of e.childNodes)"Properties"===t.tagName&&this.GetPropertiesFromElement(t,n.properties);let r=e.getElementsByTagName("Property");for(let e of r){let t=e.getAttribute("name");if("Label"===t)n.shapeName=this.GetFirstChildValue(e,"String","value");else if("Visibility"===t){let t=this.GetFirstChildValue(e,"Bool","value");n.isVisible="true"===t}else if("Visible"===t){let t=this.GetFirstChildValue(e,"Bool","value");n.isVisible="true"===t}else if("Shape"===t){let t=this.GetFirstChildValue(e,"Part","file");if(!this.HasFile(t))continue;let r=bh(t);if("brp"!==r&&"brep"!==r)continue;n.fileName=t,n.fileContent=this.files[t]}}let i=e.getElementsByTagName("Link");for(let e of i){let t=e.getAttribute("value");if(this.objectData.has(t)){this.objectData.get(t).inLinkCount+=1}}}}return!0}LoadGuiDocumentXml(){let e=this.GetXMLContent("GuiDocument.xml");if(null===e)return!1;let t=e.getElementsByTagName("ViewProvider");for(let e of t){let t=e.getAttribute("name");if(!this.objectData.has(t))continue;let n=this.objectData.get(t),r=e.getElementsByTagName("Property");for(let e of r){let t=e.getAttribute("name");if("Visibility"===t){let t=this.GetFirstChildValue(e,"Bool","value");n.isVisible="true"===t}else if("ShapeColor"===t){let t=this.GetFirstChildValue(e,"PropertyColor","value"),r=parseInt(t,10);n.color=new Kh(r>>24&255,r>>16&255,r>>8&255,255)}}}return!0}GetPropertiesFromElement(e,t){let n=e.getElementsByTagName("Property");for(let e of n){let n=e.getAttribute("name"),r=e.getAttribute("type"),i=null;if("App::PropertyBool"===r){let t=this.GetFirstChildValue(e,"String","bool");null!==t&&t.length>0&&(i=new zd(Vd.Boolean,n,"true"===t))}else if("App::PropertyInteger"===r){let t=this.GetFirstChildValue(e,"Integer","value");null!==t&&t.length>0&&(i=new zd(Vd.Integer,n,parseInt(t)))}else if("App::PropertyString"===r){let t=this.GetFirstChildValue(e,"String","value");null!==t&&t.length>0&&(i=new zd(Vd.Text,n,t))}else if("App::PropertyUUID"===r){let t=this.GetFirstChildValue(e,"Uuid","value");null!==t&&t.length>0&&(i=new zd(Vd.Text,n,t))}else if("App::PropertyFloat"===r||"App::PropertyLength"===r||"App::PropertyDistance"===r||"App::PropertyArea"===r||"App::PropertyVolume"===r){let t=this.GetFirstChildValue(e,"Float","value");null!==t&&t.length>0&&(i=new zd(Vd.Number,n,parseFloat(t)))}null!==i&&t.AddProperty(i)}}GetXMLContent(e){if(!this.HasFile(e))return null;let t=new DOMParser,n=Rd(this.files[e]);return t.parseFromString(n,"text/xml")}GetFirstChildValue(e,t,n){let r=e.getElementsByTagName(t);return 0===r.length?null:r[0].getAttribute(n)}}class ag extends ff{constructor(){super(),this.worker=null,this.document=null}CanImportExtension(e){return"fcstd"===e}GetUpDirection(){return zh.Z}ClearContent(){null!==this.worker&&(this.worker.terminate(),this.worker=null),this.document=null}ResetContent(){this.worker=null,this.document=new sg}ImportContent(e,t){if(this.document.Init(e)===ig)return this.SetError("No Document.xml found."),void t();null!==this.document.properties&&this.document.properties.PropertyCount()>0&&this.model.AddPropertyGroup(this.document.properties);let n=this.document.GetObjectListToConvert();if(0===n.length)return this.SetError("No importable object found."),void t();this.ConvertObjects(n,t)}ConvertObjects(e,t){let n=xh("loaders/occt-import-js-worker.js");this.worker=new Worker(n);let r=0,i=new Tf(this.model),o=n=>{if(null!==n){let t=e[r];this.OnFileConverted(t,n,i)}if(r+=1,r===e.length)t();else{let t=e[r];this.worker.postMessage({format:"brep",buffer:t.fileContent})}};this.worker.addEventListener("message",(e=>{o(e.data)})),this.worker.addEventListener("error",(e=>{o(null)}));let s=e[r];this.worker.postMessage({format:"brep",buffer:s.fileContent})}OnFileConverted(e,t,n){if(!t.success||0===t.meshes.length)return;let r=new Gp;null!==e.shapeName&&r.SetName(e.shapeName);let i=1;for(let o of t.meshes){let t=null;null!==e.color&&(t=n.GetMaterialIndex(e.color.r,e.color.g,e.color.b,e.color.a));let s=cf(o,t,null);if(null!==e.shapeName){let t=i.toString().padStart(3,"0");s.SetName(e.shapeName+" "+t)}null!==e.properties&&e.properties.PropertyCount()>0&&s.AddPropertyGroup(e.properties);let a=this.model.AddMesh(s);r.AddMeshIndex(a),i+=1}this.model.GetRootNode().AddChildNode(r)}}class lg{constructor(){this.defaultColor=new Yh(200,200,200)}}const cg={NoImportableFile:1,FailedToLoadFile:2,ImportFailed:3,UnknownError:4};class ug{constructor(e){this.code=e,this.mainFile=null,this.message=null}}class hg{constructor(){this.model=null,this.mainFile=null,this.upVector=null,this.usedFiles=null,this.missingFiles=null}}class dg{constructor(e){this.getBufferCallback=e,this.fileBuffers=new Map}GetFileBuffer(e){let t=Mh(e);if(this.fileBuffers.has(t))return this.fileBuffers.get(t);let n=this.getBufferCallback(t);return this.fileBuffers.set(t,n),n}}class pg{constructor(){this.importers=[new Gm,new Km,new Bm,new qm,new dm,new Um,new Zm,new Ef,new Dm,new Ym,new ag,new $m,new Qm,new eg,new tg,new ng],this.fileList=new kp,this.model=null,this.usedFiles=[],this.missingFiles=[]}AddImporter(e){this.importers.push(e)}ImportFiles(e,t,n){n.onLoadStart(),this.LoadFiles(e,{onReady:()=>{n.onImportStart(),dh((()=>{this.DecompressArchives(this.fileList,(()=>{this.ImportLoadedFiles(t,n)}))}))},onFileListProgress:n.onFileListProgress,onFileLoadProgress:n.onFileLoadProgress})}LoadFiles(e,t){let n=new kp;n.FillFromInputFiles(e);let r=!1;if(this.HasImportableFile(n))r=!0;else{let e=!1;for(let t=0;t<this.missingFiles.length;t++){let r=this.missingFiles[t];n.ContainsFileByPath(r)&&(e=!0)}e?(this.fileList.ExtendFromFileList(n),r=!1):r=!0}r&&(this.fileList=n),this.fileList.GetContent({onReady:t.onReady,onFileListProgress:t.onFileListProgress,onFileLoadProgress:t.onFileLoadProgress})}ImportLoadedFiles(e,t){let n=this.GetImportableFiles(this.fileList);if(0!==n.length)if(1!==n.length&&t.onSelectMainFile){let r=n.map((e=>e.file.name));t.onSelectMainFile(r,(r=>{null!==r?dh((()=>{let i=n[r];this.ImportLoadedMainFile(i,e,t)})):t.onImportError(new ug(cg.NoImportableFile))}))}else{let r=n[0];this.ImportLoadedMainFile(r,e,t)}else t.onImportError(new ug(cg.NoImportableFile))}ImportLoadedMainFile(e,t,n){if(null===e||null===e.file||null===e.file.content){let t=new ug(cg.FailedToLoadFile);return null!==e&&null!==e.file&&(t.mainFile=e.file.name),void n.onImportError(t)}this.model=null,this.usedFiles=[],this.missingFiles=[],this.usedFiles.push(e.file.name);let r=e.importer,i=new dg((e=>{let t=null,n=this.fileList.FindFileByPath(e);return null===n||null===n.content?(this.missingFiles.push(e),t=null):(this.usedFiles.push(e),t=n.content),t}));r.Import(e.file.name,e.file.extension,e.file.content,{getDefaultMaterialColor:()=>t.defaultColor,getFileBuffer:e=>i.GetFileBuffer(e),onSuccess:()=>{this.model=r.GetModel();let t=new hg;t.mainFile=e.file.name,t.model=this.model,t.usedFiles=this.usedFiles,t.missingFiles=this.missingFiles,t.upVector=r.GetUpDirection(),n.onImportSuccess(t)},onError:()=>{let t=new ug(cg.ImportFailed);t.mainFile=e.file.name,t.message=r.GetErrorMessage(),n.onImportError(t)},onComplete:()=>{r.Clear()}})}DecompressArchives(e,t){let n=e.GetFiles(),r=[];for(let e of n)"zip"===e.extension&&r.push(e);if(0!==r.length){for(let t=0;t<r.length;t++){const n=r[t],i=nh(new Uint8Array(n.content));for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){let n=new Dp(t,Th.Decompressed,null);n.SetContent(i[t].buffer),e.AddFile(n)}}t()}else t()}GetFileList(){return this.fileList}HasImportableFile(e){return this.GetImportableFiles(e).length>0}GetImportableFiles(e){function t(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.CanImportExtension(e.extension))return r}return null}let n=[],r=e.GetFiles();for(let e=0;e<r.length;e++){let i=r[e],o=t(i,this.importers);null!==o&&n.push({file:i,importer:o})}return n}}class fg extends Jm{constructor(){super()}CanImportExtension(e){return"svg"===e}GetUpDirection(){return zh.Z}CreateLoader(e){return new ih(e)}GetMainObject(e){function t(e){const t=e.userData.style;return void 0!==t.fill&&"none"!==t.fill}function n(e,t,n){let r=null;for(let i of e)if(i.style===t&&i.opacity===n){r=i.material;break}return null===r&&(r=new ka({color:(new yn).setStyle(t),opacity:n,transparent:n<1}),e.push({style:t,opacity:n,material:r})),r}let r=[],i=new $t;i.rotation.x=Math.PI;for(let o of e.paths){const e=ih.createShapes(o);if(t(o)){let t=o.userData.style,s=n(r,t.fill,t.opacity);for(const t of e){const e=new Na(t,{depth:10,bevelEnabled:!1}),n=new $n(e,s);n.name=o.userData.node.id,i.add(n)}}}return i}}class mg{constructor(){this.name=null,this.material=null}SetName(e){return this.name=e,this}SetMaterial(e){return this.material=e,this}}class gg{constructor(e){this.params=e||new mg,this.mesh=new $p,null!==this.params.name&&this.mesh.SetName(this.params.name),this.curve=null}GetMesh(){return this.mesh}AddVertex(e,t,n){let r=new gd(e,t,n);return this.mesh.AddVertex(r)}AddVertices(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(this.AddVertex(r.x,r.y,r.z))}return t}SetCurve(e){this.curve=e}ResetCurve(){this.curve=null}AddTriangle(e,t,n){let r=new Qp(e,t,n);return null!==this.params.material&&(r.mat=this.params.material),null!==this.curve&&r.SetCurve(this.curve),this.mesh.AddTriangle(r)}AddTriangleInverted(e,t,n){this.AddTriangle(e,n,t)}AddConvexPolygon(e){for(let t=0;t<e.length-2;t++)this.AddTriangle(e[0],e[t+1],e[t+2])}AddConvexPolygonInverted(e){for(let t=0;t<e.length-2;t++)this.AddTriangleInverted(e[0],e[t+1],e[t+2])}}class vg{constructor(e){this.generator=e}GenerateSurfaceBetweenPolygons(e,t){if(e.length!==t.length)return;const n=e.length;for(let r=0;r<n;r++){const i=r,o=r<n-1?i+1:0;this.generator.AddConvexPolygon([e[i],e[o],t[o],t[i]])}}GenerateTriangleFan(e,t){const n=e.length;for(let r=0;r<n;r++){const i=r,o=r<n-1?i+1:0;this.generator.AddTriangle(t,e[i],e[o])}}}function yg(e,t){return new Hh(e*Math.cos(t),e*Math.sin(t))}function xg(e,t,n,r){if(!Bh(t)||!Bh(n)||!Bh(r))return null;let i=new gg(e);return i.AddVertex(0,0,0),i.AddVertex(t,0,0),i.AddVertex(t,n,0),i.AddVertex(0,n,0),i.AddVertex(0,0,r),i.AddVertex(t,0,r),i.AddVertex(t,n,r),i.AddVertex(0,n,r),i.AddConvexPolygon([0,3,2,1]),i.AddConvexPolygon([0,1,5,4]),i.AddConvexPolygon([1,2,6,5]),i.AddConvexPolygon([2,3,7,6]),i.AddConvexPolygon([3,0,4,7]),i.AddConvexPolygon([4,5,6,7]),i.GetMesh()}function _g(e,t,n,r,i,o){if(Vh(t)||Vh(n))return null;if(!Bh(r)||i<3)return null;let s=Nh(t),a=Nh(n);if(s&&a)return null;let l=new gg(e),c=new vg(l);const u=2*Math.PI/i,h=o?1:null;let d=[];if(s)d.push(l.AddVertex(0,0,r));else for(let e=0;e<i;e++){let n=yg(t,e*u);d.push(l.AddVertex(n.x,n.y,r))}let p=[];if(a)p.push(l.AddVertex(0,0,0));else for(let e=0;e<i;e++){let t=yg(n,e*u);p.push(l.AddVertex(t.x,t.y,0))}return s?(l.SetCurve(h),c.GenerateTriangleFan(p,d[0]),l.ResetCurve(),l.AddConvexPolygonInverted(p)):a?(l.SetCurve(h),c.GenerateTriangleFan(d.slice().reverse(),p[0]),l.ResetCurve(),l.AddConvexPolygon(d)):(l.SetCurve(h),c.GenerateSurfaceBetweenPolygons(p,d),l.ResetCurve(),l.AddConvexPolygonInverted(p),l.AddConvexPolygon(d)),l.GetMesh()}function Tg(e,t,n,r,i){return _g(e,t,t,n,r,i)}function Eg(e,t,n,r){function i(e,t,n){return new gd(e*Math.sin(t)*Math.cos(n),e*Math.sin(t)*Math.sin(n),e*Math.cos(t))}if(!Bh(t)||n<3)return null;let o=new gg(e),s=new vg(o);o.SetCurve(r?1:null);let a=[],l=n+1;const c=Math.PI/n,u=2*Math.PI/n;for(let e=1;e<l-1;e++){let r=[],l=e*c;for(let e=0;e<n;e++){let n=i(t,l,-(e*u));r.push(o.AddVertex(n.x,n.y,n.z))}e>1&&s.GenerateSurfaceBetweenPolygons(a[a.length-1],r),a.push(r)}let h=o.AddVertex(0,0,t),d=o.AddVertex(0,0,-t);return s.GenerateTriangleFan(a[0].slice().reverse(),h),s.GenerateTriangleFan(a[a.length-1],d),o.ResetCurve(),o.GetMesh()}function Mg(e,t,n){function r(e,t,n,r,i){let o=new gd(n,r,i);o.MultiplyScalar(t/o.Length()),e.AddVertex(o.x,o.y,o.z)}if(!Bh(n))return null;let i=new gg(e);if("tetrahedron"===t){let e=1;r(i,n,+e,+e,+e),r(i,n,-e,-e,+e),r(i,n,-e,+e,-e),r(i,n,+e,-e,-e),i.AddTriangle(0,1,3),i.AddTriangle(0,2,1),i.AddTriangle(0,3,2),i.AddTriangle(1,2,3)}else if("hexahedron"===t){let e=1;r(i,n,+e,+e,+e),r(i,n,+e,+e,-e),r(i,n,+e,-e,+e),r(i,n,+e,-e,-e),r(i,n,-e,+e,+e),r(i,n,-e,+e,-e),r(i,n,-e,-e,+e),r(i,n,-e,-e,-e),i.AddConvexPolygon([0,1,5,4]),i.AddConvexPolygon([0,2,3,1]),i.AddConvexPolygon([0,4,6,2]),i.AddConvexPolygon([1,3,7,5]),i.AddConvexPolygon([2,6,7,3]),i.AddConvexPolygon([4,5,7,6])}else if("octahedron"===t){let e=1,t=0;r(i,n,+e,+t,+t),r(i,n,-e,+t,+t),r(i,n,+t,+e,+t),r(i,n,+t,-e,+t),r(i,n,+t,+t,+e),r(i,n,+t,+t,-e),i.AddTriangle(0,2,4),i.AddTriangle(0,3,5),i.AddTriangle(0,4,3),i.AddTriangle(0,5,2),i.AddTriangle(1,2,5),i.AddTriangle(1,3,4),i.AddTriangle(1,4,2),i.AddTriangle(1,5,3)}else if("dodecahedron"===t){let e=1,t=0,o=(1+Math.sqrt(5))/2,s=1/o;r(i,n,+e,+e,+e),r(i,n,+e,+e,-e),r(i,n,+e,-e,+e),r(i,n,-e,+e,+e),r(i,n,+e,-e,-e),r(i,n,-e,+e,-e),r(i,n,-e,-e,+e),r(i,n,-e,-e,-e),r(i,n,+t,+s,+o),r(i,n,+t,+s,-o),r(i,n,+t,-s,+o),r(i,n,+t,-s,-o),r(i,n,+s,+o,+t),r(i,n,+s,-o,+t),r(i,n,-s,+o,+t),r(i,n,-s,-o,+t),r(i,n,+o,+t,+s),r(i,n,-o,+t,+s),r(i,n,+o,+t,-s),r(i,n,-o,+t,-s),i.AddConvexPolygon([0,8,10,2,16]),i.AddConvexPolygon([0,16,18,1,12]),i.AddConvexPolygon([0,12,14,3,8]),i.AddConvexPolygon([1,9,5,14,12]),i.AddConvexPolygon([1,18,4,11,9]),i.AddConvexPolygon([2,10,6,15,13]),i.AddConvexPolygon([2,13,4,18,16]),i.AddConvexPolygon([3,14,5,19,17]),i.AddConvexPolygon([3,17,6,10,8]),i.AddConvexPolygon([4,13,15,7,11]),i.AddConvexPolygon([5,9,11,7,19]),i.AddConvexPolygon([6,17,19,7,15])}else if("icosahedron"===t){let e=1,t=0,o=(1+Math.sqrt(5))/2;r(i,n,+t,+e,+o),r(i,n,+t,+e,-o),r(i,n,+t,-e,+o),r(i,n,+t,-e,-o),r(i,n,+e,+o,+t),r(i,n,+e,-o,+t),r(i,n,-e,+o,+t),r(i,n,-e,-o,+t),r(i,n,+o,+t,+e),r(i,n,+o,+t,-e),r(i,n,-o,+t,+e),r(i,n,-o,+t,-e),i.AddTriangle(0,2,8),i.AddTriangle(0,4,6),i.AddTriangle(0,6,10),i.AddTriangle(0,8,4),i.AddTriangle(0,10,2),i.AddTriangle(1,3,11),i.AddTriangle(1,4,9),i.AddTriangle(1,6,4),i.AddTriangle(1,9,3),i.AddTriangle(1,11,6),i.AddTriangle(2,5,8),i.AddTriangle(2,7,5),i.AddTriangle(2,10,7),i.AddTriangle(3,5,7),i.AddTriangle(3,7,11),i.AddTriangle(3,9,5),i.AddTriangle(4,8,9),i.AddTriangle(5,9,8),i.AddTriangle(6,11,10),i.AddTriangle(7,10,11)}return i.GetMesh()}function bg(e,t,n){const r=_d(e,t),i=_d(t,n),o=_d(e,n),s=(r+i+o)/2,a=s*(s-r)*(s-i)*(s-o);return a<0?0:Math.sqrt(a)}function Sg(e,t,n){return Td(e,Md(t,n))/6}function wg(e){if(e instanceof Bp){let t=0;return e.EnumerateMeshInstances((e=>{t+=wg(e)})),t}{let t=0;return e.EnumerateTriangleVertices(((e,n,r)=>{t+=Sg(e,n,r)})),t}}function Ag(e){let t=0;return e.EnumerateTriangleVertices(((e,n,r)=>{t+=bg(e,n,r)})),t}const Cg={Perspective:1,Orthographic:2};class Rg{constructor(e,t,n,r){this.eye=e,this.center=t,this.up=n,this.fov=r}Clone(){return new Rg(this.eye.Clone(),this.center.Clone(),this.up.Clone(),this.fov)}}function Ig(e,t){return vd(e.eye,t.eye)&&vd(e.center,t.center)&&vd(e.up,t.up)&&Fh(e.fov,t.fov)}function Pg(e,t){function n(e,t){for(let n of e)n.polygonOffset=t,n.polygonOffsetUnit=1,n.polygonOffsetFactor=1}n(e.material,t),e.userData.threeMaterials&&n(e.userData.threeMaterials,t)}class Lg{constructor(e){this.scene=e,this.rootObject=null}IsEmpty(){return null===this.rootObject}SetRootObject(e){null!==this.rootObject&&this.Clear(),this.rootObject=e,this.scene.add(this.rootObject)}GetRootObject(){return this.rootObject}AddObject(e){if(null===this.rootObject){let e=new $t;this.SetRootObject(e)}this.rootObject.add(e)}Traverse(e){null!==this.rootObject&&this.rootObject.traverse((t=>{e(t)}))}UpdateWorldMatrix(){null!==this.rootObject&&this.rootObject.updateWorldMatrix(!0,!0)}Clear(){uf(this.rootObject),this.scene.remove(this.rootObject),this.rootObject=null}}class Ng{constructor(e,t,n){this.showEdges=e,this.edgeColor=t,this.edgeThreshold=n}Clone(){return new Ng(this.showEdges,this.edgeColor.Clone(),this.edgeThreshold)}}class Og{constructor(e){this.scene=e,this.mainModel=new Lg(this.scene),this.edgeModel=new Lg(this.scene),this.edgeSettings=new Ng(!1,new Yh(0,0,0),1)}SetMainObject(e){this.mainModel.SetRootObject(e),this.edgeSettings.showEdges&&this.GenerateEdgeModel()}UpdateWorldMatrix(){this.mainModel.UpdateWorldMatrix(),this.edgeModel.UpdateWorldMatrix()}SetEdgeSettings(e){let t=!1;if(!e.showEdges||this.edgeSettings.showEdges&&this.edgeSettings.edgeThreshold===e.edgeThreshold||(t=!0),this.edgeSettings=e,!this.mainModel.IsEmpty())if(this.edgeSettings.showEdges)if(t)this.ClearEdgeModel(),this.GenerateEdgeModel();else{let e=lf(this.edgeSettings.edgeColor);this.EnumerateEdges((t=>{t.material.color=e}))}else this.ClearEdgeModel()}GenerateEdgeModel(){let e=lf(this.edgeSettings.edgeColor);this.UpdateWorldMatrix(),this.EnumerateMeshes((t=>{Pg(t,!0);let n=new ra(t.geometry,this.edgeSettings.edgeThreshold),r=new Ss(n,new gs({color:e}));r.applyMatrix4(t.matrixWorld),r.userData=t.userData,r.visible=t.visible,this.edgeModel.AddObject(r)}))}GetBoundingBox(e){let t=!1,n=new et;return this.EnumerateMeshes((r=>{e(r.userData)&&(n.union((new et).setFromObject(r)),t=!0)})),t?n:null}GetBoundingSphere(e){let t=this.GetBoundingBox(e);if(null===t)return null;let n=new yt;return t.getBoundingSphere(n),n}Clear(){this.mainModel.Clear(),this.ClearEdgeModel()}ClearEdgeModel(){this.edgeModel.IsEmpty()||(this.EnumerateMeshes((e=>{Pg(e,!1)})),this.edgeModel.Clear())}EnumerateMeshes(e){this.mainModel.Traverse((t=>{t.isMesh&&e(t)}))}EnumerateEdges(e){this.edgeModel.Traverse((t=>{t.isLineSegments&&e(t)}))}GetMeshIntersectionUnderMouse(e,t,n,r){if(this.mainModel.IsEmpty())return null;if(e.x<0||e.x>n||e.y<0||e.y>r)return null;let i=new Gl,o=new Se;o.x=e.x/n*2-1,o.y=-e.y/r*2+1,i.setFromCamera(o,t);let s=i.intersectObject(this.mainModel.GetRootObject(),!0);for(let e=0;e<s.length;e++){let t=s[e];if(t.object.isMesh&&t.object.visible)return t}return null}}let Ug={IntegerToString:e=>e.toString(),StringToInteger:e=>parseInt(e,10),NumberToString:e=>e.toFixed(5),StringToNumber:e=>parseFloat(e),ModelUrlsToString:function(e){return null===e?null:e.join(",")},StringToModelUrls:function(e){return null===e||0===e.length?null:e.split(",")},CameraToString:function(e){if(null===e)return null;return[this.NumberToString(e.eye.x),this.NumberToString(e.eye.y),this.NumberToString(e.eye.z),this.NumberToString(e.center.x),this.NumberToString(e.center.y),this.NumberToString(e.center.z),this.NumberToString(e.up.x),this.NumberToString(e.up.y),this.NumberToString(e.up.z),this.NumberToString(e.fov)].join(",")},CameraModeToString:function(e){return e===Cg.Perspective?"perspective":e===Cg.Orthographic?"orthographic":null},StringToCamera:function(e){if(null===e||0===e.length)return null;let t=e.split(",");if(9!==t.length&&10!==t.length)return null;let n=45;return t.length>=10&&(n=this.StringToNumber(t[9])),new Rg(new gd(this.StringToNumber(t[0]),this.StringToNumber(t[1]),this.StringToNumber(t[2])),new gd(this.StringToNumber(t[3]),this.StringToNumber(t[4]),this.StringToNumber(t[5])),new gd(this.StringToNumber(t[6]),this.StringToNumber(t[7]),this.StringToNumber(t[8])),n)},StringToCameraMode:function(e){return"perspective"===e?Cg.Perspective:"orthographic"===e?Cg.Orthographic:null},RGBColorToString:function(e){return null===e?null:[this.IntegerToString(e.r),this.IntegerToString(e.g),this.IntegerToString(e.b)].join(",")},RGBAColorToString:function(e){return null===e?null:[this.IntegerToString(e.r),this.IntegerToString(e.g),this.IntegerToString(e.b),this.IntegerToString(e.a)].join(",")},StringToRGBColor:function(e){if(null===e||0===e.length)return null;let t=e.split(",");return 3!==t.length?null:new Yh(this.StringToInteger(t[0]),this.StringToInteger(t[1]),this.StringToInteger(t[2]))},StringToRGBAColor:function(e){if(null===e||0===e.length)return null;let t=e.split(",");if(3!==t.length&&4!==t.length)return null;let n=new Kh(this.StringToInteger(t[0]),this.StringToInteger(t[1]),this.StringToInteger(t[2]),255);return 4===t.length&&(n.a=this.StringToInteger(t[3])),n},EnvironmentSettingsToString(e){if(null===e)return null;return[e.environmentMapName,e.backgroundIsEnvMap?"on":"off"].join(",")},StringToEnvironmentSettings:function(e){if(null===e||0===e.length)return null;let t=e.split(",");return 2!==t.length?null:{environmentMapName:t[0],backgroundIsEnvMap:"on"===t[1]}},EdgeSettingsToString:function(e){if(null===e)return null;return[e.showEdges?"on":"off",this.RGBColorToString(e.edgeColor),this.IntegerToString(e.edgeThreshold)].join(",")},StringToEdgeSettings:function(e){if(null===e||0===e.length)return null;let t=e.split(",");return 5!==t.length?null:new Ng("on"===t[0],new Yh(this.StringToInteger(t[1]),this.StringToInteger(t[2]),this.StringToInteger(t[3])),this.StringToInteger(t[4]))}};class Dg{constructor(e){this.separator=e,this.paramList=""}AddModelUrls(e){return this.AddUrlPart("model",Ug.ModelUrlsToString(e)),this}AddCamera(e){return this.AddUrlPart("camera",Ug.CameraToString(e)),this}AddCameraMode(e){return this.AddUrlPart("cameramode",Ug.CameraModeToString(e)),this}AddEnvironmentSettings(e){return this.AddUrlPart("envsettings",Ug.EnvironmentSettingsToString(e)),this}AddBackgroundColor(e){return this.AddUrlPart("backgroundcolor",Ug.RGBAColorToString(e)),this}AddDefaultColor(e){return this.AddUrlPart("defaultcolor",Ug.RGBColorToString(e)),this}AddEdgeSettings(e){return this.AddUrlPart("edgesettings",Ug.EdgeSettingsToString(e)),this}AddUrlPart(e,t){null!==e&&null!==t&&(this.paramList.length>0&&(this.paramList+=this.separator),this.paramList+=e+"="+t)}GetParameterList(){return this.paramList}}class kg{constructor(e,t){this.separator=t,this.paramList=e}GetModelUrls(){if(-1===this.paramList.indexOf("="))return this.paramList.split(",");let e=this.GetKeywordParams("model");return Ug.StringToModelUrls(e)}GetCamera(){let e=this.GetKeywordParams("camera");return Ug.StringToCamera(e)}GetCameraMode(){let e=this.GetKeywordParams("cameramode");return Ug.StringToCameraMode(e)}GetEnvironmentSettings(){let e=this.GetKeywordParams("envsettings");return Ug.StringToEnvironmentSettings(e)}GetBackgroundColor(){let e=this.GetKeywordParams("backgroundcolor");return Ug.StringToRGBAColor(e)}GetDefaultColor(){let e=this.GetKeywordParams("defaultcolor");return Ug.StringToRGBColor(e)}GetEdgeSettings(){let e=this.GetKeywordParams("edgesettings");return Ug.StringToEdgeSettings(e)}GetKeywordParams(e){if(null===this.paramList||0===this.paramList.length)return null;let t=e+"=",n=this.paramList.split(this.separator);for(let e=0;e<n.length;e++){let r=n[e];if(r.startsWith(t))return r.substring(t.length)}return null}}function Fg(){return new Dg("$")}function Gg(e){return new kg(e,"$")}function Bg(e){let t=Fg();return t.AddModelUrls(e),t.GetParameterList()}class Vg{constructor(){this.forceMediumpForMaterials=!1}}class zg{constructor(){this.defaultMaterial=null,this.objectUrls=[]}}class Hg{constructor(e){this.callbacks=e,this.texturesNeeded=0,this.texturesLoaded=0,this.threeObject=null}OnTextureNeeded(){this.texturesNeeded+=1}OnTextureLoaded(){this.texturesLoaded+=1,this.callbacks.onTextureLoaded(),this.Finish()}OnModelLoaded(e){this.threeObject=e,this.Finish()}Finish(){null!==this.threeObject&&this.texturesNeeded===this.texturesLoaded&&this.callbacks.onModelLoaded(this.threeObject)}}class Wg{constructor(e,t){this.model=e,this.threeNodeItems=[],this.AddNode(e.GetRootNode(),t)}AddNode(e,t){let n=e.GetTransformation().GetMatrix(),r=(new At).fromArray(n.Get());t.applyMatrix4(r);for(let n of e.GetChildNodes()){let e=new $t;t.add(e),this.AddNode(n,e)}for(let n of e.GetMeshIndices()){let r=new up(e.GetId(),n),i=this.model.GetMesh(n);this.threeNodeItems.push({meshInstance:new hp(r,e,i),threeNode:t})}}GetNodeItems(){return this.threeNodeItems}}function jg(e,t,n,r){function i(e,t,n,r,i,o){function s(e,t,n,r,i){if(null===n||!n.IsValid())return;let o=new ml;e.OnTextureNeeded();let s=null;s=null!==n.mimeType?Dd(n.buffer,n.mimeType):Ud(n.buffer),r.objectUrls.push(s),o.load(s,(r=>{!function(e,t){t.wrapS=b,t.wrapT=b,t.rotation=e.rotation,t.offset.x=e.offset.x,t.offset.y=e.offset.y,t.repeat.x=e.scale.x,t.repeat.y=e.scale.y}(n,r),t.needsUpdate=!0,i(r),e.OnTextureLoaded()}),null,(t=>{e.OnTextureLoaded()}))}let a=t.GetMaterial(n),c=lf(a.color);a.vertexColors&&c.setRGB(1,1,1);let u={color:c,vertexColors:a.vertexColors,opacity:a.opacity,transparent:a.transparent,alphaTest:a.alphaTest,side:l};i.forceMediumpForMaterials&&(u.precision="mediump");let h=null;if(r===tf.Phong){if(h=new ka(u),a.type===ud.Phong){let t=lf(a.specular);Fh(a.shininess,0)&&t.setRGB(0,0,0),h.specular=t,h.shininess=100*a.shininess,s(e,h,a.specularMap,o,(e=>{h.specularMap=e}))}}else r===tf.Physical&&(h=new Da(u),a.type===ud.Physical&&(h.metalness=a.metalness,h.roughness=a.roughness,s(e,h,a.metalnessMap,o,(e=>{h.metalness=1,h.roughness=1,h.metalnessMap=e,h.roughnessMap=e}))));let d=lf(a.emissive);return h.emissive=d,s(e,h,a.diffuseMap,o,(e=>{a.multiplyDiffuseMap||h.color.setRGB(1,1,1),h.map=e})),s(e,h,a.bumpMap,o,(e=>{h.bumpMap=e})),s(e,h,a.normalMap,o,(e=>{h.normalMap=e})),s(e,h,a.emissiveMap,o,(e=>{h.emissiveMap=e})),a.isDefault&&(o.defaultMaterial=h),h}function o(e,t,n){if(ip(t.mesh)===rp.TriangleMesh){let r=function(e,t){let n=e.mesh,r=n.TriangleCount(),i=[];for(let e=0;e<r;e++)i.push(e);i.sort(((e,t)=>{let r=n.GetTriangle(e),i=n.GetTriangle(t);return r.mat-i.mat}));let o=new On,s=[],a=[],l=new Map,c=[],u=[],h=[],d=[],p=[];p.push({start:0,end:-1});let f=n.VertexColorCount()>0,m=n.TextureUVCount()>0;for(let e=0;e<i.length;e++){let r=i[e],o=n.GetTriangle(r),g=n.GetVertex(o.v0),v=n.GetVertex(o.v1),y=n.GetVertex(o.v2);if(c.push(g.x,g.y,g.z,v.x,v.y,v.z,y.x,y.y,y.z),o.HasVertexColors()){let e=lf(n.GetVertexColor(o.c0)),t=lf(n.GetVertexColor(o.c1)),r=lf(n.GetVertexColor(o.c2));u.push(e.r,e.g,e.b,t.r,t.g,t.b,r.r,r.g,r.b)}else f&&u.push(0,0,0,0,0,0,0,0,0);let x=n.GetNormal(o.n0),_=n.GetNormal(o.n1),T=n.GetNormal(o.n2);if(h.push(x.x,x.y,x.z,_.x,_.y,_.z,T.x,T.y,T.z),o.HasTextureUVs()){let e=n.GetTextureUV(o.u0),t=n.GetTextureUV(o.u1),r=n.GetTextureUV(o.u2);d.push(e.x,e.y,t.x,t.y,r.x,r.y)}else m&&d.push(0,0,0,0,0,0);let E=o.mat;l.has(E)||(l.set(E,s.length),s.push(t[E]),a.push(E),e>0&&(p[p.length-1].end=e-1,p.push({start:p[p.length-1].end+1,end:-1})))}p[p.length-1].end=r-1,o.setAttribute("position",new wn(c,3)),0!==u.length&&o.setAttribute("color",new wn(u,3)),o.setAttribute("normal",new wn(h,3)),0!==d.length&&o.setAttribute("uv",new wn(d,2));for(let e=0;e<p.length;e++){let t=p[e];o.addGroup(3*t.start,3*(t.end-t.start+1),e)}let g=new $n(o,s);return g.name=n.GetName(),g.userData={originalMeshInstance:e,originalMaterials:a,threeMaterials:null},g}(t,n);e.add(r)}}let s=new Hg(r),a=nf(e),c=[];for(let r=0;r<e.MaterialCount();r++){let o=i(s,e,r,a,t,n);c.push(o)}!function(e,t,n,r){let i=new Wg(t,e).GetNodeItems();fh(i.length,100,{runTask:(e,t,r)=>{for(let r=e;r<=t;r++){let e=i[r];o(e.threeNode,e.meshInstance,n)}r()},onReady:()=>{r.OnModelLoaded(e)}})}(new $t,e,c,s)}class Xg{constructor(){this.importer=new pg,this.inProgress=!1,this.defaultMaterial=null,this.objectUrls=null,this.hasHighpDriverIssue=ef()}InProgress(){return this.inProgress}LoadModel(e,t,n){this.inProgress||(this.inProgress=!0,this.RevokeObjectUrls(),this.importer.ImportFiles(e,t,{onLoadStart:()=>{n.onLoadStart()},onFileListProgress:(e,t)=>{n.onFileListProgress(e,t)},onFileLoadProgress:(e,t)=>{n.onFileLoadProgress(e,t)},onImportStart:()=>{n.onImportStart()},onSelectMainFile:(e,t)=>{n.onSelectMainFile?n.onSelectMainFile(e,t):t(0)},onImportSuccess:e=>{n.onVisualizationStart();let t=new Vg;t.forceMediumpForMaterials=this.hasHighpDriverIssue;let r=new zg;jg(e.model,t,r,{onTextureLoaded:()=>{n.onTextureLoaded()},onModelLoaded:t=>{if(this.defaultMaterial=r.defaultMaterial,this.objectUrls=r.objectUrls,e.upVector===zh.X){let e=(new Ze).setFromAxisAngle(new Je(0,0,1),Math.PI/2);t.quaternion.multiply(e)}else if(e.upVector===zh.Z){let e=(new Ze).setFromAxisAngle(new Je(1,0,0),-Math.PI/2);t.quaternion.multiply(e)}n.onModelFinished(e,t),this.inProgress=!1}})},onImportError:e=>{n.onLoadError(e),this.inProgress=!1}}))}GetImporter(){return this.importer}GetDefaultMaterial(){return this.defaultMaterial}ReplaceDefaultMaterialColor(e){null===this.defaultMaterial||this.defaultMaterial.vertexColors||(this.defaultMaterial.color=lf(e))}RevokeObjectUrls(){if(null!==this.objectUrls){for(let e of this.objectUrls)kd(e);this.objectUrls=null}}Destroy(){this.RevokeObjectUrls(),this.importer=null}}function qg(e){return Math.round(parseFloat(e))}function Yg(e){return qg(e.paddingLeft)+qg(e.paddingRight)+(qg(e.borderLeftWidth)+qg(e.borderRightWidth))+(qg(e.marginLeft)+qg(e.marginRight))}function Kg(e){return qg(e.paddingTop)+qg(e.paddingBottom)+(qg(e.borderTopWidth)+qg(e.borderBottomWidth))+(qg(e.marginTop)+qg(e.marginBottom))}function Zg(e,t,n){let r=getComputedStyle(e);return{width:t-Yg(r),height:n-Kg(r)}}function Jg(e,t,n){if(e.getBoundingClientRect){let r=e.getBoundingClientRect();t-=r.left,n-=r.top}return window.pageXOffset&&window.pageYOffset&&(t+=window.pageXOffset,n+=window.pageYOffset),new Hh(t,n)}function $g(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n&&(r.innerHTML=n),r}function Qg(e,t,n,r){let i=$g(t,n,r);return e.appendChild(i),i}function ev(e,t,n){return Qg(e,"div",t,n)}function tv(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function nv(e,t){t.parentNode.insertBefore(e,t)}function rv(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function iv(e,t){e.style.display=t?"block":"none"}function ov(e){return null!==e.offsetParent}function sv(e,t){e.style.width=t.toString()+"px"}function av(e,t){e.style.height=t.toString()+"px"}function lv(e){let t=getComputedStyle(e);return e.offsetWidth+qg(t.marginLeft)+qg(t.marginRight)}function cv(e){let t=getComputedStyle(e);return e.offsetHeight+qg(t.marginTop)+qg(t.marginBottom)}function uv(e,t){sv(e,t-Yg(getComputedStyle(e)))}function hv(e,t){av(e,t-Kg(getComputedStyle(e)))}function dv(e,t){return $g("div",e,t)}class pv{constructor(){this.prev=new Hh(0,0),this.curr=new Hh(0,0),this.diff=new Hh(0,0),this.buttons=[]}Down(e,t){this.buttons.push(t.which),this.curr=this.GetPositionFromEvent(e,t),this.prev=this.curr.Clone()}Move(e,t){this.curr=this.GetPositionFromEvent(e,t),this.diff=Xh(this.curr,this.prev),this.prev=this.curr.Clone()}Up(e,t){let n=this.buttons.indexOf(t.which);-1!==n&&this.buttons.splice(n,1),this.curr=this.GetPositionFromEvent(e,t)}Leave(e,t){this.buttons=[],this.curr=this.GetPositionFromEvent(e,t)}IsButtonDown(){return this.buttons.length>0}GetButton(){let e=this.buttons.length;return 0===e?0:this.buttons[e-1]}GetPosition(){return this.curr}GetMoveDiff(){return this.diff}GetPositionFromEvent(e,t){return Jg(e,t.clientX,t.clientY)}}class fv{constructor(){this.prevPos=new Hh(0,0),this.currPos=new Hh(0,0),this.diffPos=new Hh(0,0),this.prevDist=0,this.currDist=0,this.diffDist=0,this.fingers=0}Start(e,t){0!==t.touches.length&&(this.fingers=t.touches.length,this.currPos=this.GetPositionFromEvent(e,t),this.prevPos=this.currPos.Clone(),this.currDist=this.GetTouchDistanceFromEvent(e,t),this.prevDist=this.currDist)}Move(e,t){0!==t.touches.length&&(this.currPos=this.GetPositionFromEvent(e,t),this.diffPos=Xh(this.currPos,this.prevPos),this.prevPos=this.currPos.Clone(),this.currDist=this.GetTouchDistanceFromEvent(e,t),this.diffDist=this.currDist-this.prevDist,this.prevDist=this.currDist)}End(e,t){0!==t.touches.length&&(this.fingers=0,this.currPos=this.GetPositionFromEvent(e,t),this.currDist=this.GetTouchDistanceFromEvent(e,t))}IsFingerDown(){return 0!==this.fingers}GetFingerCount(){return this.fingers}GetPosition(){return this.currPos}GetMoveDiff(){return this.diffPos}GetDistanceDiff(){return this.diffDist}GetPositionFromEvent(e,t){let n=null;if(0!==t.touches.length){let r=t.touches[0];n=Jg(e,r.pageX,r.pageY)}return n}GetTouchDistanceFromEvent(e,t){if(2!==t.touches.length)return 0;let n=t.touches[0],r=t.touches[1];return qh(Jg(e,n.pageX,n.pageY),Jg(e,r.pageX,r.pageY))}}class mv{constructor(){this.isClick=!1,this.startPosition=null}Start(e){this.isClick=!0,this.startPosition=e}Move(e){if(this.isClick)if(null!==this.startPosition){const t=3;qh(this.startPosition,e)>t&&this.Cancel()}else this.Cancel()}End(){this.startPosition=null}Cancel(){this.isClick=!1,this.startPosition=null}IsClick(){return this.isClick}}const gv={None:0,Orbit:1,Pan:2,Zoom:3};class vv{constructor(e,t,n){this.canvas=e,this.camera=t,this.callbacks=n,this.fixUpVector=!0,this.mouse=new pv,this.touch=new fv,this.clickDetector=new mv,this.onMouseClick=null,this.onMouseMove=null,this.onContext=null,this.canvas.addEventListener&&(this.canvas.addEventListener("mousedown",this.OnMouseDown.bind(this)),this.canvas.addEventListener("wheel",this.OnMouseWheel.bind(this)),this.canvas.addEventListener("touchstart",this.OnTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.OnTouchMove.bind(this)),this.canvas.addEventListener("touchcancel",this.OnTouchEnd.bind(this)),this.canvas.addEventListener("touchend",this.OnTouchEnd.bind(this)),this.canvas.addEventListener("contextmenu",this.OnContextMenu.bind(this))),document.addEventListener&&(document.addEventListener("mousemove",this.OnMouseMove.bind(this)),document.addEventListener("mouseup",this.OnMouseUp.bind(this)),document.addEventListener("mouseleave",this.OnMouseLeave.bind(this)))}SetMouseClickHandler(e){this.onMouseClick=e}SetMouseMoveHandler(e){this.onMouseMove=e}SetContextMenuHandler(e){this.onContext=e}IsFixUpVector(){return this.fixUpVector}SetFixUpVector(e){this.fixUpVector=e}GetCamera(){return this.camera}SetCamera(e){this.camera=e}MoveCamera(e,t){function n(e,t,r,i){e.camera.eye=t.eye[i],e.camera.center=t.center[i],e.camera.up=t.up[i],e.Update(),i<r-1&&requestAnimationFrame((()=>{n(e,t,r,i+1)}))}if(null!==e){if(0===t||Ig(this.camera,e))this.camera=e;else{let r=Pp,i={eye:Lp(this.camera.eye,e.eye,t,r),center:Lp(this.camera.center,e.center,t,r),up:Lp(this.camera.up,e.up,t,r)};requestAnimationFrame((()=>{n(this,i,t,0)}))}this.Update()}}GetFitToSphereCamera(e,t){if(Nh(t))return null;let n=this.camera.Clone(),r=xd(n.center,e);n.eye=xd(n.eye,r),n.center=e.Clone();let i=xd(n.eye,n.center).Normalize(),o=this.camera.fov/2;this.canvas.width<this.canvas.height&&(o=o*this.canvas.width/this.canvas.height);let s=t/Math.sin(o*Lh);return n.eye=n.center.Clone().Offset(i,s),n}OnMouseDown(e){e.preventDefault(),this.mouse.Down(this.canvas,e),this.clickDetector.Start(this.mouse.GetPosition())}OnMouseMove(e){if(this.mouse.Move(this.canvas,e),this.clickDetector.Move(this.mouse.GetPosition()),this.onMouseMove){let t=Jg(this.canvas,e.clientX,e.clientY);this.onMouseMove(t)}if(!this.mouse.IsButtonDown())return;let t=this.mouse.GetMoveDiff(),n=this.mouse.GetButton(),r=gv.None;if(1===n?r=e.ctrlKey?gv.Zoom:e.shiftKey?gv.Pan:gv.Orbit:2!==n&&3!==n||(r=gv.Pan),r===gv.Orbit){let e=.5;this.Orbit(t.x*e,t.y*e)}else if(r===gv.Pan){let e=.001*_d(this.camera.eye,this.camera.center);this.Pan(t.x*e,t.y*e)}else if(r===gv.Zoom){let e=.005;this.Zoom(-t.y*e)}this.Update()}OnMouseUp(e){if(this.mouse.Up(this.canvas,e),this.clickDetector.End(),this.clickDetector.IsClick()){let t=this.mouse.GetPosition();this.Click(e.which,t)}}OnMouseLeave(e){this.mouse.Leave(this.canvas,e),this.clickDetector.Cancel()}OnTouchStart(e){e.preventDefault(),this.touch.Start(this.canvas,e),this.clickDetector.Start(this.touch.GetPosition())}OnTouchMove(e){if(e.preventDefault(),this.touch.Move(this.canvas,e),this.clickDetector.Move(this.touch.GetPosition()),!this.touch.IsFingerDown())return;let t=this.touch.GetMoveDiff(),n=this.touch.GetDistanceDiff(),r=this.touch.GetFingerCount(),i=gv.None;if(1===r?i=gv.Orbit:2===r&&(i=gv.Pan),i===gv.Orbit){let e=.5;this.Orbit(t.x*e,t.y*e)}else if(i===gv.Pan){let e=.005;this.Zoom(n*e);let r=.001*_d(this.camera.eye,this.camera.center);this.Pan(t.x*r,t.y*r)}this.Update()}OnTouchEnd(e){if(e.preventDefault(),this.touch.End(this.canvas,e),this.clickDetector.End(),this.clickDetector.IsClick()){let e=this.touch.GetPosition();1===this.touch.GetFingerCount()&&this.Click(1,e)}}OnMouseWheel(e){let t=e||window.event;t.preventDefault();let n=.1;-t.deltaY/40<0&&(n*=-1),this.Zoom(n),this.Update()}OnContextMenu(e){e.preventDefault(),this.clickDetector.IsClick()&&(this.Context(e.clientX,e.clientY),this.clickDetector.Cancel())}Orbit(e,t){let n=e*Lh,r=t*Lh,i=xd(this.camera.center,this.camera.eye).Normalize(),o=Md(i,this.camera.up).Normalize();if(this.fixUpVector){let e=Ed(i,this.camera.up)+r;Uh(e,0)&&Oh(e,Math.PI)&&this.camera.eye.Rotate(o,-r,this.camera.center),this.camera.eye.Rotate(this.camera.up,-n,this.camera.center)}else{let e=Md(o,i).Normalize();this.camera.eye.Rotate(o,-r,this.camera.center),this.camera.eye.Rotate(e,-n,this.camera.center),this.camera.up=e}}Pan(e,t){let n=xd(this.camera.center,this.camera.eye).Normalize(),r=Md(n,this.camera.up).Normalize(),i=Md(r,n).Normalize();this.camera.eye.Offset(r,-e),this.camera.center.Offset(r,-e),this.camera.eye.Offset(i,t),this.camera.center.Offset(i,t)}Zoom(e){let t=xd(this.camera.center,this.camera.eye),n=t.Length()*e;this.camera.eye.Offset(t,n)}Update(){this.callbacks.onUpdate()}Click(e,t){this.onMouseClick&&this.onMouseClick(e,t)}Context(e,t){if(this.onContext){let n={x:e,y:t},r=Jg(this.canvas,e,t);this.onContext(n,r)}}}class yv{constructor(e,t){this.textureNames=e,this.backgroundIsEnvMap=t}Clone(){let e=null;if(null!==this.textureNames){e=[];for(let t of this.textureNames)e.push(t)}return new yv(e,this.backgroundIsEnvMap)}}class xv{constructor(e){this.scene=e,this.type=tf.Phong,this.cameraMode=Cg.Perspective,this.ambientLight=new Il(8947848),this.directionalLight=new Rl(8947848),this.environmentSettings=new yv(null,!1),this.environment=null,this.scene.add(this.ambientLight),this.scene.add(this.directionalLight)}SetShadingType(e){this.type=e,this.UpdateShading()}SetCameraMode(e){this.cameraMode=e,this.UpdateShading()}UpdateShading(){this.type===tf.Phong?(this.ambientLight.color.set(8947848),this.directionalLight.color.set(8947848),this.scene.environment=null):this.type===tf.Physical&&(this.ambientLight.color.set(0),this.directionalLight.color.set(5592405),this.scene.environment=this.environment),this.environmentSettings.backgroundIsEnvMap&&this.cameraMode===Cg.Perspective?this.scene.background=this.environment:this.scene.background=null}SetEnvironmentMapSettings(e,t){let n=new pl;this.environment=n.load(e.textureNames,(e=>{e.colorSpace=ne,t()})),this.environmentSettings=e}UpdateByCamera(e){const t=xd(e.eye,e.center);this.directionalLight.position.set(t.x,t.y,t.z)}CreateHighlightMaterial(e,t){let n=null;return this.type===tf.Phong?n=new ka({color:lf(e),side:l}):this.type===tf.Physical&&(n=new Da({color:lf(e),side:l})),null!==n&&t&&(n.polygonOffset=!0,n.polygonOffsetUnit=1,n.polygonOffsetFactor=1),n}}function _v(e){return e===zh.X?new Rg(new gd(2,-3,1.5),new gd(0,0,0),new gd(1,0,0),45):e===zh.Y?new Rg(new gd(-1.5,2,3),new gd(0,0,0),new gd(0,1,0),45):e===zh.Z?new Rg(new gd(-1.5,-3,2),new gd(0,0,0),new gd(0,0,1),45):null}function Tv(e,t){if(!t(e))return!1;for(let n of e.children)if(!Tv(n,t))return!1;return!0}function Ev(e){let t=null;return Tv(e,(e=>{if(e.isMesh)for(const n of e.material)return"MeshPhongMaterial"===n.type?t=tf.Phong:"MeshStandardMaterial"===n.type&&(t=tf.Physical),!1;return!0})),t}class Mv{constructor(){this.eyeCenterDistance=0,this.forceUpdate=!0}ForceUpdate(){this.forceUpdate=!0}ValidatePerspective(){return!this.forceUpdate||(this.forceUpdate=!1,!1)}ValidateOrthographic(e){return!(this.forceUpdate||!Fh(this.eyeCenterDistance,e))||(this.eyeCenterDistance=e,this.forceUpdate=!1,!1)}}class bv{constructor(){this.direction=zh.Y,this.isFixed=!0,this.isFlipped=!1}SetDirection(e,t){this.direction=e,this.isFlipped=!1;let n=_v(this.direction),r=xd(n.eye,n.center),i=_d(t.center,t.eye),o=t.center.Clone().Offset(r,i),s=t.Clone();return this.direction===zh.X?(s.up=new gd(1,0,0),s.eye=o):this.direction===zh.Y?(s.up=new gd(0,1,0),s.eye=o):this.direction===zh.Z&&(s.up=new gd(0,0,1),s.eye=o),s}SetFixed(e,t){return this.isFixed=e,this.isFixed?this.SetDirection(this.direction,t):null}Flip(e){this.isFlipped=!this.isFlipped;let t=e.Clone();return t.up.MultiplyScalar(-1),t}}class Sv{constructor(){Fe.enabled=!1,this.canvas=null,this.renderer=null,this.scene=null,this.mainModel=null,this.extraModel=null,this.camera=null,this.cameraMode=null,this.cameraValidator=null,this.shadingModel=null,this.navigation=null,this.upVector=null,this.settings={animationSteps:40}}Init(e){this.canvas=e,this.canvas.id="viewer";let t={canvas:this.canvas,antialias:!0};this.renderer=new Qo(t),this.renderer.outputColorSpace=ne,window.devicePixelRatio&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setClearColor("#ffffff",1),this.renderer.setSize(this.canvas.width,this.canvas.height),this.scene=new es,this.mainModel=new Og(this.scene),this.extraModel=new Lg(this.scene),this.InitNavigation(),this.InitShading(),this.Render()}SetMouseClickHandler(e){this.navigation.SetMouseClickHandler(e)}SetMouseMoveHandler(e){this.navigation.SetMouseMoveHandler(e)}SetContextMenuHandler(e){this.navigation.SetContextMenuHandler(e)}SetEdgeSettings(e){let t=e.Clone();this.mainModel.SetEdgeSettings(t),this.Render()}SetEnvironmentMapSettings(e){let t=e.Clone();this.shadingModel.SetEnvironmentMapSettings(t,(()=>{this.Render()})),this.shadingModel.UpdateShading(),this.Render()}SetBackgroundColor(e){let t=new yn(Jh(e.r),Jh(e.g),Jh(e.b)),n=Jh(e.a);this.renderer.setClearColor(t,n),this.Render()}GetCanvas(){return this.canvas}GetCamera(){return this.navigation.GetCamera()}GetCameraMode(){return this.cameraMode}SetCamera(e){this.navigation.SetCamera(e),this.cameraValidator.ForceUpdate(),this.Render()}SetCameraMode(e){this.cameraMode!==e&&(this.scene.remove(this.camera),e===Cg.Perspective?this.camera=new ar(45,1,.1,1e3):e===Cg.Orthographic&&(this.camera=new Lr(-1,1,1,-1,.1,1e3)),this.scene.add(this.camera),this.cameraMode=e,this.shadingModel.SetCameraMode(e),this.cameraValidator.ForceUpdate(),this.AdjustClippingPlanes(),this.Render())}Resize(e,t){let n=Zg(this.canvas,e,t);this.ResizeRenderer(n.width,n.height)}ResizeRenderer(e,t){window.devicePixelRatio&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t),this.cameraValidator.ForceUpdate(),this.Render()}FitSphereToWindow(e,t){if(null===e)return;let n=new gd(e.center.x,e.center.y,e.center.z),r=e.radius,i=this.navigation.GetFitToSphereCamera(n,r);this.navigation.MoveCamera(i,t?this.settings.animationSteps:0)}AdjustClippingPlanes(){let e=this.GetBoundingSphere((e=>!0));this.AdjustClippingPlanesToSphere(e)}AdjustClippingPlanesToSphere(e){null!==e&&(e.radius<10?(this.camera.near=.01,this.camera.far=100):e.radius<100?(this.camera.near=.1,this.camera.far=1e3):e.radius<1e3?(this.camera.near=10,this.camera.far=1e4):(this.camera.near=100,this.camera.far=1e6),this.cameraValidator.ForceUpdate(),this.Render())}IsFixUpVector(){return this.navigation.IsFixUpVector()}SetFixUpVector(e){let t=this.navigation.GetCamera(),n=this.upVector.SetFixed(e,t);this.navigation.SetFixUpVector(e),null!==n&&this.navigation.MoveCamera(n,this.settings.animationSteps),this.Render()}SetUpVector(e,t){let n=this.navigation.GetCamera(),r=this.upVector.SetDirection(e,n),i=t?this.settings.animationSteps:0;this.navigation.MoveCamera(r,i),this.Render()}FlipUpVector(){let e=this.navigation.GetCamera(),t=this.upVector.Flip(e);this.navigation.MoveCamera(t,0),this.Render()}Render(){let e=this.navigation.GetCamera();if(this.camera.position.set(e.eye.x,e.eye.y,e.eye.z),this.camera.up.set(e.up.x,e.up.y,e.up.z),this.camera.lookAt(new Je(e.center.x,e.center.y,e.center.z)),this.cameraMode===Cg.Perspective)this.cameraValidator.ValidatePerspective()||(this.camera.aspect=this.canvas.width/this.canvas.height,this.camera.fov=e.fov,this.camera.updateProjectionMatrix());else if(this.cameraMode===Cg.Orthographic){let t=_d(e.eye,e.center);if(!this.cameraValidator.ValidateOrthographic(t)){let t=this.canvas.width/this.canvas.height,n=_d(e.eye,e.center)*Math.tan(.5*e.fov*Lh);this.camera.left=-n*t,this.camera.right=n*t,this.camera.top=n,this.camera.bottom=-n,this.camera.updateProjectionMatrix()}}this.shadingModel.UpdateByCamera(e),this.renderer.render(this.scene,this.camera)}SetMainObject(e){const t=Ev(e);this.mainModel.SetMainObject(e),this.shadingModel.SetShadingType(t),this.Render()}AddExtraObject(e){this.extraModel.AddObject(e),this.Render()}Clear(){this.mainModel.Clear(),this.extraModel.Clear(),this.Render()}ClearExtra(){this.extraModel.Clear(),this.Render()}SetMeshesVisibility(e){this.mainModel.EnumerateMeshes((t=>{let n=e(t.userData);t.visible!==n&&(t.visible=n)})),this.mainModel.EnumerateEdges((t=>{let n=e(t.userData);t.visible!==n&&(t.visible=n)})),this.Render()}SetMeshesHighlight(e,t){const n=this.CreateHighlightMaterial(e);this.mainModel.EnumerateMeshes((e=>{t(e.userData)?null===e.userData.threeMaterials&&(e.userData.threeMaterials=e.material,e.material=function(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(t);return n}(e.material,n)):null!==e.userData.threeMaterials&&(e.material=e.userData.threeMaterials,e.userData.threeMaterials=null)})),this.Render()}CreateHighlightMaterial(e){const t=this.mainModel.edgeSettings.showEdges;return this.shadingModel.CreateHighlightMaterial(e,t)}GetMeshUserDataUnderMouse(e){let t=this.GetMeshIntersectionUnderMouse(e);return null===t?null:t.object.userData}GetMeshIntersectionUnderMouse(e){let t=this.GetCanvasSize(),n=this.mainModel.GetMeshIntersectionUnderMouse(e,this.camera,t.width,t.height);return null===n?null:n}GetBoundingBox(e){return this.mainModel.GetBoundingBox(e)}GetBoundingSphere(e){return this.mainModel.GetBoundingSphere(e)}EnumerateMeshesUserData(e){this.mainModel.EnumerateMeshes((t=>{e(t.userData)}))}InitNavigation(){let e=_v(zh.Y);this.camera=new ar(45,1,.1,1e3),this.cameraMode=Cg.Perspective,this.cameraValidator=new Mv,this.scene.add(this.camera);let t=this.renderer.domElement;this.navigation=new vv(t,e,{onUpdate:()=>{this.Render()}}),this.upVector=new bv}InitShading(){this.shadingModel=new xv(this.scene)}GetShadingType(){return this.shadingModel.type}GetImageSize(){let e=new Se;return this.renderer.getSize(e),{width:parseInt(e.x,10),height:parseInt(e.y,10)}}GetCanvasSize(){let e=this.canvas.width,t=this.canvas.height;return window.devicePixelRatio&&(e/=window.devicePixelRatio,t/=window.devicePixelRatio),{width:e,height:t}}GetImageAsDataUrl(e,t){let n=this.GetImageSize(),r=e,i=t;window.devicePixelRatio&&(r/=window.devicePixelRatio,i/=window.devicePixelRatio),this.ResizeRenderer(r,i),this.Render();let o=this.renderer.domElement.toDataURL();return this.ResizeRenderer(n.width,n.height),o}Destroy(){this.Clear(),this.renderer.dispose()}}class wv{constructor(e,t){this.parentElement=e,this.parameters={},oh(t)&&(this.parameters=t),this.canvas=document.createElement("canvas"),this.parentElement.appendChild(this.canvas),this.viewer=new Sv,this.viewer.Init(this.canvas);let n=this.parentElement.clientWidth,r=this.parentElement.clientHeight;this.viewer.Resize(n,r),this.parameters.cameraMode&&this.viewer.SetCameraMode(this.parameters.cameraMode),this.parameters.backgroundColor&&this.viewer.SetBackgroundColor(this.parameters.backgroundColor),this.parameters.edgeSettings&&this.viewer.SetEdgeSettings(this.parameters.edgeSettings),this.parameters.environmentSettings&&this.viewer.SetEnvironmentMapSettings(this.parameters.environmentSettings),this.model=null,this.modelLoader=new Xg,window.addEventListener("resize",(()=>{this.Resize()}))}LoadModelFromUrlList(e){Ah(e);let t=Op(e);this.LoadModelFromInputFiles(t)}LoadModelFromFileList(e){let t=Up(e);this.LoadModelFromInputFiles(t)}LoadModelFromInputFiles(e){if(null===e||0===e.length)return;this.viewer.Clear();let t=new lg;this.parameters.defaultColor&&(t.defaultColor=this.parameters.defaultColor),this.model=null;let n=null;this.modelLoader.LoadModel(e,t,{onLoadStart:()=>{this.canvas.style.display="none",n=document.createElement("div"),n.innerHTML="Loading model...",this.parentElement.appendChild(n)},onFileListProgress:(e,t)=>{},onFileLoadProgress:(e,t)=>{},onImportStart:()=>{n.innerHTML="Importing model..."},onVisualizationStart:()=>{n.innerHTML="Visualizing model..."},onModelFinished:(e,t)=>{this.parentElement.removeChild(n),this.canvas.style.display="inherit",this.viewer.SetMainObject(t);let r=this.viewer.GetBoundingSphere((e=>!0));this.viewer.AdjustClippingPlanesToSphere(r),this.parameters.camera?this.viewer.SetCamera(this.parameters.camera):(this.viewer.SetUpVector(zh.Y,!1),this.viewer.FitSphereToWindow(r,!1)),this.model=e.model,this.parameters.onModelLoaded&&this.parameters.onModelLoaded()},onTextureLoaded:()=>{this.viewer.Render()},onLoadError:e=>{let t="Unknown error.";e.code===cg.NoImportableFile?t="No importable file found.":e.code===cg.FailedToLoadFile?t="Failed to load file for import.":e.code===cg.ImportFailed&&(t="Failed to import model."),null!==e.message&&(t+=" ("+e.message+")"),n.innerHTML=t}})}GetViewer(){return this.viewer}GetModel(){return this.model}Resize(){let e=this.parentElement.clientWidth,t=this.parentElement.clientHeight;this.viewer.Resize(e,t)}Destroy(){this.modelLoader.Destroy(),this.viewer.Destroy(),this.model=null}}function Av(e,t,n){let r=new wv(e,n);return r.LoadModelFromUrlList(t),r}function Cv(e,t,n){let r=new wv(e,n);return r.LoadModelFromFileList(t),r}function Rv(e){function t(e){let t=null,n=e.getAttribute("camera");n&&(t=Ug.StringToCamera(n));let r=null,i=e.getAttribute("cameramode");i&&(r=Ug.StringToCameraMode(i));let o=null,s=e.getAttribute("backgroundcolor");s&&(o=Ug.StringToRGBAColor(s));let a=null,l=e.getAttribute("defaultcolor");l&&(a=Ug.StringToRGBColor(l));let c=null,u=e.getAttribute("edgesettings");u&&(c=Ug.StringToEdgeSettings(u));let h=null,d=e.getAttribute("environmentmap");if(d){let t=d.split(",");if(6===t.length){let n=!1,r=e.getAttribute("environmentmapbg");r&&"true"===r&&(n=!0),h=new yv(t,n)}}let p=null,f=e.getAttribute("model");return f&&(p=Ug.StringToModelUrls(f)),Av(e,p,{camera:t,cameraMode:r,backgroundColor:o,defaultColor:a,edgeSettings:c,environmentSettings:h})}let n=[],r=document.getElementsByClassName("online_3d_viewer");for(let e=0;e<r.length;e++){let i=t(r[e]);n.push(i)}return n}window.OV=e})()})();
Back to Directory File Manager