/*! For license information please see threed.min.js.LICENSE.txt */
!function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=12)}([,,function(t,e){t.exports="#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_fragment>\n#endif\n\nvarying vec4 vColor;\nuniform bool pickingMode;\nvoid main() {\n    #include <logdepthbuf_fragment>\n    // circular point rendering\n    if(length(gl_PointCoord - 0.5) > 0.5){\n        discard;\n    }\n\n#if defined(USE_TEXTURES_PROJECTIVE)\n    vec4 color = vColor;\n    if (!pickingMode) {\n        #pragma unroll_loop\n        for (int i = 0; i < ORIENTED_IMAGES_COUNT; i++) {\n            color = projectiveTextureColor(projectiveTextureCoords[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTextureDistortion[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTexture[ ORIENTED_IMAGES_COUNT - 1 - i ], mask[ORIENTED_IMAGES_COUNT - 1 - i], color);\n        }\n        gl_FragColor = vec4(color.rgb, color.a * opacity);\n    } else {\n        gl_FragColor = color;\n    }\n#else\n    gl_FragColor = vColor;\n#endif\n}\n"},function(t,e){t.exports="#include <itowns/precision_qualifier>\n#include <common>\n#include <itowns/project_pars_vertex>\n#include <itowns/elevation_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nattribute vec2      uv_0;\n#if NUM_CRS > 1\nattribute float     uv_1;\n#endif\nattribute vec3      normal;\n\nuniform mat4 modelMatrix;\nuniform bool lightingEnabled;\n\n#if MODE == MODE_FINAL\n#include <fog_pars_vertex>\nvarying vec3        vUv;\nvarying vec3        vNormal;\n#endif\nvoid main() {\n        vec2 uv = vec2(uv_0.x, 1.0 - uv_0.y);\n\n        #include <begin_vertex>\n        #include <itowns/elevation_vertex>\n        #include <project_vertex>\n        #include <logdepthbuf_vertex>\n#if MODE == MODE_FINAL\n        #include <fog_vertex>\n        #if NUM_CRS > 1\n        vUv = vec3(uv_0, (uv_1 > 0.) ? uv_1 : uv_0.y); // set uv_1 = uv_0 if uv_1 is undefined\n        #else\n        vUv = vec3(uv_0, 0.0);\n        #endif\n        vNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );\n#endif\n}\n"},function(t,e){t.exports="#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#include <itowns/pitUV>\n#include <itowns/color_layers_pars_fragment>\n#if MODE == MODE_FINAL\n#include <itowns/fog_pars_fragment>\n#include <itowns/overlay_pars_fragment>\n#include <itowns/lighting_pars_fragment>\n#endif\n#include <itowns/mode_pars_fragment>\n\nuniform vec3        diffuse;\nuniform float       opacity;\nvarying vec3        vUv; // uv_0.x/uv_1.x, uv_0.y, uv_1.y\n\nvoid main() {\n    #include <logdepthbuf_fragment>\n\n#if MODE == MODE_ID\n\n    #include <itowns/mode_id_fragment>\n\n#elif MODE == MODE_DEPTH\n\n    #include <itowns/mode_depth_fragment>\n\n#else\n\n    gl_FragColor = vec4(diffuse, opacity);\n\n    uvs[0] = vec3(vUv.xy, 0.);\n\n#if NUM_CRS > 1\n    uvs[1] = vec3(vUv.x, fract(vUv.z), floor(vUv.z));\n#endif\n\n    vec4 color;\n    #pragma unroll_loop\n    for ( int i = 0; i < NUM_FS_TEXTURES; i ++ ) {\n        color = getLayerColor( i , colorTextures[ i ], colorOffsetScales[ i ], colorLayers[ i ]);\n        gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n    }\n\n  #if defined(DEBUG)\n    if (showOutline) {\n        #pragma unroll_loop\n        for ( int i = 0; i < NUM_CRS; i ++) {\n            color = getOutlineColor( outlineColors[ i ], uvs[ i ].xy);\n            gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n        }\n    }\n  #endif\n\n    #include <itowns/fog_fragment>\n    #include <itowns/lighting_fragment>\n    #include <itowns/overlay_fragment>\n\n#endif\n}\n"},function(t,e){t.exports="uniform sampler2D uni[SAMPLE];\nvoid main() {\n    gl_FragColor += texture2D(uni[SAMPLE-1], vec2(0));\n}"},function(t,e){t.exports="void main() {\n    gl_Position = vec4( 0.0, 0.0, 0.0, 1.0 );\n}"},function(t,e,i){"use strict";function n(t,e,i){return e<=t&&t<=i}function r(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function s(t){this.tokens=[].slice.call(t)}s.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var o=-1;function a(t,e){if(t)throw TypeError("Decoder error");return e||65533}var h="utf-8";function c(t,e){if(!(this instanceof c))return new c(t,e);if((t=void 0!==t?String(t).toLowerCase():h)!==h)throw new Error("Encoding not supported. Only utf-8 is supported");e=r(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(e.fatal),this._ignoreBOM=Boolean(e.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function l(t,e){if(!(this instanceof l))return new l(t,e);if((t=void 0!==t?String(t).toLowerCase():h)!==h)throw new Error("Encoding not supported. Only utf-8 is supported");e=r(e),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(e.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function u(t){var e=t.fatal,i=0,r=0,s=0,h=128,c=191;this.handler=function(t,l){if(-1===l&&0!==s)return s=0,a(e);if(-1===l)return o;if(0===s){if(n(l,0,127))return l;if(n(l,194,223))s=1,i=l-192;else if(n(l,224,239))224===l&&(h=160),237===l&&(c=159),s=2,i=l-224;else{if(!n(l,240,244))return a(e);240===l&&(h=144),244===l&&(c=143),s=3,i=l-240}return i<<=6*s,null}if(!n(l,h,c))return i=s=r=0,h=128,c=191,t.prepend(l),a(e);if(h=128,c=191,i+=l-128<<6*(s-(r+=1)),r!==s)return null;var u=i;return i=s=r=0,u}}function d(t){t.fatal;this.handler=function(t,e){if(-1===e)return o;if(n(e,0,127))return e;var i,r;n(e,128,2047)?(i=1,r=192):n(e,2048,65535)?(i=2,r=224):n(e,65536,1114111)&&(i=3,r=240);for(var s=[(e>>6*i)+r];i>0;){var a=e>>6*(i-1);s.push(128|63&a),i-=1}return s}}c.prototype={decode:function(t,e){var i;i="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=r(e),this._streaming||(this._decoder=new u({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,a=new s(i),h=[];!a.endOfStream()&&(n=this._decoder.handler(a,a.read()))!==o;)null!==n&&(Array.isArray(n)?h.push.apply(h,n):h.push(n));if(!this._streaming){do{if((n=this._decoder.handler(a,a.read()))===o)break;null!==n&&(Array.isArray(n)?h.push.apply(h,n):h.push(n))}while(!a.endOfStream());this._decoder=null}return h.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===h[0]?(this._BOMseen=!0,h.shift()):this._BOMseen=!0)),function(t){for(var e="",i=0;i<t.length;++i){var n=t[i];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return e}(h)}},l.prototype={encode:function(t,e){t=t?String(t):"",e=r(e),this._streaming||(this._encoder=new d(this._options)),this._streaming=Boolean(e.stream);for(var i,n=[],a=new s(function(t){for(var e=String(t),i=e.length,n=0,r=[];n<i;){var s=e.charCodeAt(n);if(s<55296||s>57343)r.push(s);else if(56320<=s&&s<=57343)r.push(65533);else if(55296<=s&&s<=56319)if(n===i-1)r.push(65533);else{var o=t.charCodeAt(n+1);if(56320<=o&&o<=57343){var a=1023&s,h=1023&o;r.push(65536+(a<<10)+h),n+=1}else r.push(65533)}n+=1}return r}(t));!a.endOfStream()&&(i=this._encoder.handler(a,a.read()))!==o;)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;(i=this._encoder.handler(a,a.read()))!==o;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}},e.TextEncoder=l,e.TextDecoder=c},function(t,e){t.exports="#include <itowns/precision_qualifier>\n#include <itowns/project_pars_vertex>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_vertex>\n#endif\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\nuniform float size;\n\nuniform bool pickingMode;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\nattribute vec3 color;\nattribute vec4 unique_id;\nattribute float intensity;\n\n#if defined(NORMAL_OCT16)\nattribute vec2 oct16Normal;\n#elif defined(NORMAL_SPHEREMAPPED)\nattribute vec2 sphereMappedNormal;\n#else\nattribute vec3 normal;\n#endif\n\nvarying vec4 vColor;\n\n// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602\n// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)\n#if defined(NORMAL_OCT16)\nvec3 decodeOct16Normal(vec2 encodedNormal) {\n    vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;\n    vec3 n;\n    n.z = 1. - abs(nNorm.x) - abs(nNorm.y);\n    if (n.z >= 0.) {\n        n.x = nNorm.x;\n        n.y = nNorm.y;\n    } else {\n        n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;\n        n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;\n    }\n    return normalize(n);\n}\n#elif defined(NORMAL_SPHEREMAPPED)\n// see http://aras-p.info/texts/CompactNormalStorage.html method #4\n// or see potree's implementation in BINPointReader.cpp\nvec3 decodeSphereMappedNormal(vec2 encodedNormal) {\n    vec2 fenc = 2. * encodedNormal / 255. - 1.;\n    float f = dot(fenc,fenc);\n    float g = 2. * sqrt(1. - f);\n    vec3 n;\n    n.xy = fenc * g;\n    n.z = 1. - 2. * f;\n    return n;\n}\n#endif\n\nvoid main() {\n\n#if defined(NORMAL_OCT16)\n    vec3  normal = decodeOct16Normal(oct16Normal);\n#elif defined(NORMAL_SPHEREMAPPED)\n    vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);\n#elif defined(NORMAL)\n    // nothing to do\n#else\n    // default to color\n    vec3 normal = color;\n#endif\n\n    if (pickingMode) {\n        vColor = unique_id;\n    } else if (mode == MODE_INTENSITY) {\n        vColor = vec4(intensity, intensity, intensity, opacity);\n    } else if (mode == MODE_NORMAL) {\n        vColor = vec4(abs(normal), opacity);\n    } else {\n        // default to color mode\n        vColor = vec4(mix(color, overlayColor.rgb, overlayColor.a), opacity);\n    }\n\n    #include <begin_vertex>\n    #include <project_vertex>\n\n    if (size > 0.) {\n        gl_PointSize = size;\n    } else {\n        gl_PointSize = clamp(-size / gl_Position.w, 3.0, 10.0);\n    }\n\n#if defined(USE_TEXTURES_PROJECTIVE)\n    #include <itowns/projective_texturing_vertex>\n#endif\n    #include <logdepthbuf_vertex>\n}\n"},function(t,e,i){"use strict";window.BinaryHeap=function(t){this.content=[],this.scoreFunction=t},BinaryHeap.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},remove:function(t){for(var e=this.content.length,i=0;i<e;i++)if(this.content[i]==t){var n=this.content.pop();if(i==e-1)break;this.content[i]=n,this.bubbleUp(i),this.sinkDown(i);break}},size:function(){return this.content.length},bubbleUp:function(t){for(var e=this.content[t],i=this.scoreFunction(e);t>0;){var n=Math.floor((t+1)/2)-1,r=this.content[n];if(i>=this.scoreFunction(r))break;this.content[n]=e,this.content[t]=r,t=n}},sinkDown:function(t){for(var e=this.content.length,i=this.content[t],n=this.scoreFunction(i);;){var r=2*(t+1),s=r-1,o=null;if(s<e){var a=this.content[s],h=this.scoreFunction(a);h<n&&(o=s)}if(r<e){var c=this.content[r];this.scoreFunction(c)<(null==o?n:h)&&(o=r)}if(null==o)break;this.content[t]=this.content[o],this.content[o]=i,t=o}}}},function(t,e,i){"use strict";!function(t){var e={0:function(t){return{position:[t.getInt32(0,!0),t.getInt32(4,!0),t.getInt32(8,!0)],intensity:t.getUint16(12,!0),classification:t.getUint8(16,!0)}},1:function(t){return{position:[t.getInt32(0,!0),t.getInt32(4,!0),t.getInt32(8,!0)],intensity:t.getUint16(12,!0),classification:t.getUint8(16,!0)}},2:function(t){return{position:[t.getInt32(0,!0),t.getInt32(4,!0),t.getInt32(8,!0)],intensity:t.getUint16(12,!0),classification:t.getUint8(16,!0),color:[t.getUint16(20,!0),t.getUint16(22,!0),t.getUint16(24,!0)]}},3:function(t){return{position:[t.getInt32(0,!0),t.getInt32(4,!0),t.getInt32(8,!0)],intensity:t.getUint16(12,!0),classification:t.getUint8(16,!0),color:[t.getUint16(28,!0),t.getUint16(30,!0),t.getUint16(32,!0)]}}};function i(t,e,i,n){n=void 0===n||0===n?1:n;var r=new e(t.slice(i,i+e.BYTES_PER_ELEMENT*n));if(void 0===n||1===n)return r[0];for(var s=[],o=0;o<n;o++)s.push(r[o]);return s}var n={};t.handleMessage=function(t){var e=t.data,i=n[e.id];delete n[e.id],setTimeout((function(){return e.error?i.reject(new Error(e.message||"Unknown Error")):e.hasOwnProperty("count")&&e.hasOwnProperty("hasMoreData")?i.resolve({buffer:e.result,count:e.count,hasMoreData:e.hasMoreData}):void i.resolve(e.result)}),0)};var r=function(t){this.arraybuffer=t};r.prototype.open=function(){return this.readOffset=0,new Promise((function(t,e){setTimeout(t,0)}))},r.prototype.getHeader=function(){var t=this;return new Promise((function(e,n){setTimeout((function(){t.header=function(t){var e={};e.pointsOffset=i(t,Uint32Array,96),e.pointsFormatId=i(t,Uint8Array,104),e.pointsStructSize=i(t,Uint16Array,105),e.pointsCount=i(t,Uint32Array,107);var n=131;e.scale=i(t,Float64Array,n,3),n+=24,e.offset=i(t,Float64Array,n,3),n+=24;var r=i(t,Float64Array,n,6);return n+=48,e.maxs=[r[0],r[2],r[4]],e.mins=[r[1],r[3],r[5]],e}(t.arraybuffer),e(t.header)}),0)}))},r.prototype.readData=function(t,e,i){var n=this;return new Promise((function(e,r){setTimeout((function(){if(!n.header)return r(new Error("Cannot start reading data till a header request is issued"));var s;if(i<=1){t=Math.min(t,n.header.pointsCount-n.readOffset);var o=(s=n.header.pointsOffset+n.readOffset*n.header.pointsStructSize)+t*n.header.pointsStructSize;e({buffer:n.arraybuffer.slice(s,o),count:t,hasMoreData:n.readOffset+t<n.header.pointsCount}),n.readOffset+=t}else{for(var a=Math.min(t*i,n.header.pointsCount-n.readOffset),h=Math.ceil(a/i),c=0,l=new Uint8Array(h*n.header.pointsStructSize),u=0;u<a;u++){if(u%i==0){s=n.header.pointsOffset+n.readOffset*n.header.pointsStructSize;var d=new Uint8Array(n.arraybuffer,s,n.header.pointsStructSize);l.set(d,c*n.header.pointsStructSize),c++}n.readOffset++}e({buffer:l.buffer,count:c,hasMoreData:n.readOffset<n.header.pointsCount})}}),0)}))},r.prototype.close=function(){var t=this;return new Promise((function(e,i){t.arraybuffer=null,setTimeout(e,0)}))};var s=function(t){this.arraybuffer=t;let e=Potree.scriptPath+"/workers/LASLAZWorker.js";this.ww=Potree.workerPool.getWorker(e),this.nextCB=null;var i=this;this.ww.onmessage=function(t){null!==i.nextCB&&(i.nextCB(t.data),i.nextCB=null)},this.dorr=function(t,e){i.nextCB=e,i.ww.postMessage(t)}};s.prototype.open=function(){var t=this;return new Promise((function(e,i){t.dorr({type:"open",arraybuffer:t.arraybuffer},(function(t){if(1!==t.status)return i(new Error("Failed to open file"));e(!0)}))}))},s.prototype.getHeader=function(){var t=this;return new Promise((function(e,i){t.dorr({type:"header"},(function(t){if(1!==t.status)return i(new Error("Failed to get header"));e(t.header)}))}))},s.prototype.readData=function(t,e,i){var n=this;return new Promise((function(r,s){n.dorr({type:"read",count:t,offset:e,skip:i},(function(t){if(1!==t.status)return s(new Error("Failed to read data"));r({buffer:t.buffer,count:t.count,hasMoreData:t.hasMoreData})}))}))},s.prototype.close=function(){var t=this;return new Promise((function(e,i){t.dorr({type:"close"},(function(n){let r=Potree.scriptPath+"/workers/LASLAZWorker.js";if(Potree.workerPool.returnWorker(r,t.ww),1!==n.status)return i(new Error("Failed to close file"));e(!0)}))}))};var o=function(t){if(this.arraybuffer=t,this.determineVersion(),this.version>12)throw new Error("Only file versions <= 1.2 are supported at this time");if(this.determineFormat(),void 0===e[this.formatId])throw new Error("The point format ID is not supported");this.loader=this.isCompressed?new s(this.arraybuffer):new r(this.arraybuffer)};o.prototype.determineFormat=function(){var t=i(this.arraybuffer,Uint8Array,104),e=(128&t)>>7,n=(64&t)>>6;if(1===e&&1===n)throw new Error("Old style compression not supported");this.formatId=63&t,this.isCompressed=1===e||1===n},o.prototype.determineVersion=function(){var t=new Int8Array(this.arraybuffer,24,2);this.version=10*t[0]+t[1],this.versionAsString=t[0]+"."+t[1]},o.prototype.open=function(){return this.loader.open()},o.prototype.getHeader=function(){return this.loader.getHeader()},o.prototype.readData=function(t,e,i){return this.loader.readData(t,e,i)},o.prototype.close=function(){return this.loader.close()};var a=function(t,i,n,r,s,o,a,h){this.arrayb=t,this.decoder=e[i],this.pointsCount=r,this.pointSize=n,this.scale=s,this.offset=o,this.mins=a,this.maxs=h};a.prototype.getPoint=function(t){if(t<0||t>=this.pointsCount)throw new Error("Point index out of range");var e=new DataView(this.arrayb,t*this.pointSize,this.pointSize);return this.decoder(e)},t.LAZLoader=s,t.LASLoader=r,t.LASFile=o,t.LASDecoder=a,t.LASModuleWasLoaded=!1}(window)},function(t,e){},function(t,e,i){"use strict";i.r(e);const n=new WeakMap,r=t=>"function"==typeof t&&n.has(t),s=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,o=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},a={},h={},c=`{{lit-${String(Math.random()).slice(2)}}}`,l=`\x3c!--${c}--\x3e`,u=new RegExp(`${c}|${l}`),d="$lit$";class p{constructor(t,e){this.parts=[],this.element=e;const i=[],n=[],r=document.createTreeWalker(e.content,133,null,!1);let s=0,o=-1,a=0;const{strings:h,values:{length:l}}=t;for(;a<l;){const t=r.nextNode();if(null!==t){if(o++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:i}=e;let n=0;for(let t=0;t<i;t++)f(e[t].name,d)&&n++;for(;n-- >0;){const e=h[a],i=v.exec(e)[2],n=i.toLowerCase()+d,r=t.getAttribute(n);t.removeAttribute(n);const s=r.split(u);this.parts.push({type:"attribute",index:o,name:i,strings:s}),a+=s.length-1}}"TEMPLATE"===t.tagName&&(n.push(t),r.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(c)>=0){const n=t.parentNode,r=e.split(u),s=r.length-1;for(let e=0;e<s;e++){let i,s=r[e];if(""===s)i=g();else{const t=v.exec(s);null!==t&&f(t[2],d)&&(s=s.slice(0,t.index)+t[1]+t[2].slice(0,-d.length)+t[3]),i=document.createTextNode(s)}n.insertBefore(i,t),this.parts.push({type:"node",index:++o})}""===r[s]?(n.insertBefore(g(),t),i.push(t)):t.data=r[s],a+=s}}else if(8===t.nodeType)if(t.data===c){const e=t.parentNode;null!==t.previousSibling&&o!==s||(o++,e.insertBefore(g(),t)),s=o,this.parts.push({type:"node",index:o}),null===t.nextSibling?t.data="":(i.push(t),o--),a++}else{let e=-1;for(;-1!==(e=t.data.indexOf(c,e+1));)this.parts.push({type:"node",index:-1}),a++}}else r.currentNode=n.pop()}for(const t of i)t.parentNode.removeChild(t)}}const f=(t,e)=>{const i=t.length-e.length;return i>=0&&t.slice(i)===e},m=t=>-1!==t.index,g=()=>document.createComment(""),v=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class b{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=s?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],i=this.template.parts,n=document.createTreeWalker(t,133,null,!1);let r,o=0,a=0,h=n.nextNode();for(;o<i.length;)if(r=i[o],m(r)){for(;a<r.index;)a++,"TEMPLATE"===h.nodeName&&(e.push(h),n.currentNode=h.content),null===(h=n.nextNode())&&(n.currentNode=e.pop(),h=n.nextNode());if("node"===r.type){const t=this.processor.handleTextExpression(this.options);t.insertAfterNode(h.previousSibling),this.__parts.push(t)}else this.__parts.push(...this.processor.handleAttributeExpressions(h,r.name,r.strings,this.options));o++}else this.__parts.push(void 0),o++;return s&&(document.adoptNode(t),customElements.upgrade(t)),t}}const y=` ${c} `;class _{constructor(t,e,i,n){this.strings=t,this.values=e,this.type=i,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let n=0;n<t;n++){const t=this.strings[n],r=t.lastIndexOf("\x3c!--");i=(r>-1||i)&&-1===t.indexOf("--\x3e",r+1);const s=v.exec(t);e+=null===s?t+(i?y:l):t.substr(0,s.index)+s[1]+s[2]+d+s[3]+c}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}}const x=t=>null===t||!("object"==typeof t||"function"==typeof t),w=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class M{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t<i.length-1;t++)this.parts[t]=this._createPart()}_createPart(){return new T(this)}_getValue(){const t=this.strings,e=t.length-1;let i="";for(let n=0;n<e;n++){i+=t[n];const e=this.parts[n];if(void 0!==e){const t=e.value;if(x(t)||!w(t))i+="string"==typeof t?t:String(t);else for(const e of t)i+="string"==typeof e?e:String(e)}}return i+=t[e],i}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class T{constructor(t){this.value=void 0,this.committer=t}setValue(t){t===a||x(t)&&t===this.value||(this.value=t,r(t)||(this.committer.dirty=!0))}commit(){for(;r(this.value);){const t=this.value;this.value=a,t(this)}this.value!==a&&this.committer.commit()}}class S{constructor(t){this.value=void 0,this.__pendingValue=void 0,this.options=t}appendInto(t){this.startNode=t.appendChild(g()),this.endNode=t.appendChild(g())}insertAfterNode(t){this.startNode=t,this.endNode=t.nextSibling}appendIntoPart(t){t.__insert(this.startNode=g()),t.__insert(this.endNode=g())}insertAfterPart(t){t.__insert(this.startNode=g()),this.endNode=t.endNode,t.endNode=this.startNode}setValue(t){this.__pendingValue=t}commit(){for(;r(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=a,t(this)}const t=this.__pendingValue;t!==a&&(x(t)?t!==this.value&&this.__commitText(t):t instanceof _?this.__commitTemplateResult(t):t instanceof Node?this.__commitNode(t):w(t)?this.__commitIterable(t):t===h?(this.value=h,this.clear()):this.__commitText(t))}__insert(t){this.endNode.parentNode.insertBefore(t,this.endNode)}__commitNode(t){this.value!==t&&(this.clear(),this.__insert(t),this.value=t)}__commitText(t){const e=this.startNode.nextSibling,i="string"==typeof(t=null==t?"":t)?t:String(t);e===this.endNode.previousSibling&&3===e.nodeType?e.data=i:this.__commitNode(document.createTextNode(i)),this.value=t}__commitTemplateResult(t){const e=this.options.templateFactory(t);if(this.value instanceof b&&this.value.template===e)this.value.update(t.values);else{const i=new b(e,t.processor,this.options),n=i._clone();i.update(t.values),this.__commitNode(n),this.value=i}}__commitIterable(t){Array.isArray(this.value)||(this.value=[],this.clear());const e=this.value;let i,n=0;for(const r of t)i=e[n],void 0===i&&(i=new S(this.options),e.push(i),0===n?i.appendIntoPart(this):i.insertAfterPart(e[n-1])),i.setValue(r),i.commit(),n++;n<e.length&&(e.length=n,this.clear(i&&i.endNode))}clear(t=this.startNode){o(this.startNode.parentNode,t.nextSibling,this.endNode)}}class E{constructor(t,e,i){if(this.value=void 0,this.__pendingValue=void 0,2!==i.length||""!==i[0]||""!==i[1])throw new Error("Boolean attributes can only contain a single expression");this.element=t,this.name=e,this.strings=i}setValue(t){this.__pendingValue=t}commit(){for(;r(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=a,t(this)}if(this.__pendingValue===a)return;const t=!!this.__pendingValue;this.value!==t&&(t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=t),this.__pendingValue=a}}class P extends M{constructor(t,e,i){super(t,e,i),this.single=2===i.length&&""===i[0]&&""===i[1]}_createPart(){return new A(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class A extends T{}let C=!1;try{const t={get capture(){return C=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}class L{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;r(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=a,t(this)}if(this.__pendingValue===a)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),n=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=R(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=a}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const R=t=>t&&(C?{capture:t.capture,passive:t.passive,once:t.once}:t.capture);const I=new class{handleAttributeExpressions(t,e,i,n){const r=e[0];if("."===r){return new P(t,e.slice(1),i).parts}if("@"===r)return[new L(t,e.slice(1),n.eventContext)];if("?"===r)return[new E(t,e.slice(1),i)];return new M(t,e,i).parts}handleTextExpression(t){return new S(t)}};function O(t){let e=F.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},F.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(c);return i=e.keyString.get(n),void 0===i&&(i=new p(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const F=new Map,B=new WeakMap;(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.1.2");const D=(t,...e)=>new _(t,e,"html",I);function z(t,e){const{element:{content:i},parts:n}=t,r=document.createTreeWalker(i,133,null,!1);let s=U(n),o=n[s],a=-1,h=0;const c=[];let l=null;for(;r.nextNode();){a++;const t=r.currentNode;for(t.previousSibling===l&&(l=null),e.has(t)&&(c.push(t),null===l&&(l=t)),null!==l&&h++;void 0!==o&&o.index===a;)o.index=null!==l?-1:o.index-h,s=U(n,s),o=n[s]}c.forEach((t=>t.parentNode.removeChild(t)))}const N=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},U=(t,e=-1)=>{for(let i=e+1;i<t.length;i++){const e=t[i];if(m(e))return i}return-1};const V=(t,e)=>`${t}--${e}`;let k=!0;void 0===window.ShadyCSS?k=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),k=!1);const j=t=>e=>{const i=V(e.type,t);let n=F.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},F.set(i,n));let r=n.stringsArray.get(e.strings);if(void 0!==r)return r;const s=e.strings.join(c);if(r=n.keyString.get(s),void 0===r){const i=e.getTemplateElement();k&&window.ShadyCSS.prepareTemplateDom(i,t),r=new p(e,i),n.keyString.set(s,r)}return n.stringsArray.set(e.strings,r),r},H=["html","svg"],G=new Set,W=(t,e,i)=>{G.add(t);const n=i?i.element:document.createElement("template"),r=e.querySelectorAll("style"),{length:s}=r;if(0===s)return void window.ShadyCSS.prepareTemplateStyles(n,t);const o=document.createElement("style");for(let t=0;t<s;t++){const e=r[t];e.parentNode.removeChild(e),o.textContent+=e.textContent}(t=>{H.forEach((e=>{const i=F.get(V(e,t));void 0!==i&&i.keyString.forEach((t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach((t=>{i.add(t)})),z(t,i)}))}))})(t);const a=n.content;i?function(t,e,i=null){const{element:{content:n},parts:r}=t;if(null==i)return void n.appendChild(e);const s=document.createTreeWalker(n,133,null,!1);let o=U(r),a=0,h=-1;for(;s.nextNode();)for(h++,s.currentNode===i&&(a=N(e),i.parentNode.insertBefore(e,i));-1!==o&&r[o].index===h;){if(a>0){for(;-1!==o;)r[o].index+=a,o=U(r,o);return}o=U(r,o)}}(i,o,a.firstChild):a.insertBefore(o,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const h=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==h)e.insertBefore(h.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(o,a.firstChild);const t=new Set;t.add(o),z(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const q={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},X=(t,e)=>e!==t&&(e==e||t==t),Y={attribute:!0,type:String,converter:q,reflect:!1,hasChanged:X},Z=Promise.resolve(!0),J="finalized";class Q extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=Z,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach(((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))})),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach(((t,e)=>this._classProperties.set(e,t)))}}static createProperty(t,e=Y){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():`__${t}`;Object.defineProperty(this.prototype,t,{get(){return this[i]},set(e){const n=this[t];this[i]=e,this._requestUpdate(t,n)},configurable:!0,enumerable:!0})}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty(J)||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=X){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||q,r="function"==typeof n?n:n.fromAttribute;return r?r(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,n=e.converter;return(n&&n.toAttribute||q.toAttribute)(t,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach(((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}}))}_applyInstanceProperties(){this._instanceProperties.forEach(((t,e)=>this[e]=t)),this._instanceProperties=void 0}connectedCallback(){this._updateState=32|this._updateState,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=Y){const n=this.constructor,r=n._attributeNameForProperty(t,i);if(void 0!==r){const t=n._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(r):this.setAttribute(r,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(t);if(void 0!==n){const t=i._classProperties.get(n)||Y;this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}_requestUpdate(t,e){let i=!0;if(void 0!==t){const n=this.constructor,r=n._classProperties.get(t)||Y;n._valueHasChanged(this[t],e,r.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==r.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,r))):i=!1}!this._hasRequestedUpdate&&i&&this._enqueueUpdate()}requestUpdate(t,e){return this._requestUpdate(t,e),this.updateComplete}async _enqueueUpdate(){let t,e;this._updateState=4|this._updateState;const i=this._updatePromise;this._updatePromise=new Promise(((i,n)=>{t=i,e=n}));try{await i}catch(t){}this._hasConnected||await new Promise((t=>this._hasConnectedResolver=t));try{const t=this.performUpdate();null!=t&&await t}catch(t){e(t)}t(!this._hasRequestedUpdate)}get _hasConnected(){return 32&this._updateState}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t&&this.update(e)}catch(e){throw t=!1,e}finally{this._markUpdated()}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach(((t,e)=>this._propertyToAttribute(e,this[e],t))),this._reflectingProperties=void 0)}updated(t){}firstUpdated(t){}}Q.finalized=!0;const K="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype;Symbol();function tt(t,e=[]){for(let i=0,n=t.length;i<n;i++){const n=t[i];Array.isArray(n)?tt(n,e):e.push(n)}return e}(window.litElementVersions||(window.litElementVersions=[])).push("2.2.1");const et=t=>t.flat?t.flat(1/0):tt(t);class it extends Q{static finalize(){super.finalize.call(this),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const t=this.styles,e=[];if(Array.isArray(t)){et(t).reduceRight(((t,e)=>(t.add(e),t)),new Set).forEach((t=>e.unshift(t)))}else t&&e.push(t);return e}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?K?this.renderRoot.adoptedStyleSheets=t.map((t=>t.styleSheet)):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map((t=>t.cssText)),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){super.update(t);const e=this.render();e instanceof _&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach((t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)})))}render(){}}it.finalized=!0,it.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,r=B.has(e),s=k&&11===e.nodeType&&!!e.host,a=s&&!G.has(n),h=a?document.createDocumentFragment():e;if(((t,e,i)=>{let n=B.get(e);void 0===n&&(o(e,e.firstChild),B.set(e,n=new S(Object.assign({templateFactory:O},i))),n.appendInto(e)),n.setValue(t),n.commit()})(t,h,Object.assign({templateFactory:j(n)},i)),a){const t=B.get(h);B.delete(h);const i=t.value instanceof b?t.value.template:void 0;W(n,h,i),o(e,e.firstChild),e.appendChild(h),B.set(e,t)}!r&&s&&window.ShadyCSS.styleElement(e.host)},void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),i=1;i<arguments.length;i++){var n=arguments[i];if(null!=n)for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e});var nt=100,rt=103,st=104,ot=200,at=201,ht=204,ct=205,lt=306,ut=1e3,dt=1001,pt=1002,ft=1003,mt=1004,gt=1004,vt=1005,bt=1005,yt=1006,_t=1007,xt=1008,wt=1008,Mt=1009,Tt=1012,St=1014,Et=1015,Pt=1016,At=1017,Ct=1018,Lt=1019,Rt=1020,It=1021,Ot=1022,Ft=1023,Bt=1024,Dt=1025,zt=1026,Nt=1027,Ut=33776,Vt=33777,kt=33778,jt=33779,Ht=35840,Gt=35841,Wt=35842,qt=35843,Xt=2300,Yt=2301,Zt=2302,$t=2400,Jt=2401,Qt=2402,Kt=3e3,te=3001,ee=3002,ie=7680,ne=35044,re=35048;function se(){}Object.assign(se.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var i=this._listeners[t];if(void 0!==i){var n=i.indexOf(e);-1!==n&&i.splice(n,1)}}},dispatchEvent:function(t){if(void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var i=e.slice(0),n=0,r=i.length;n<r;n++)i[n].call(this,t)}}}});for(var oe=[],ae=0;ae<256;ae++)oe[ae]=(ae<16?"0":"")+ae.toString(16);var he={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(oe[255&t]+oe[t>>8&255]+oe[t>>16&255]+oe[t>>24&255]+"-"+oe[255&e]+oe[e>>8&255]+"-"+oe[e>>16&15|64]+oe[e>>24&255]+"-"+oe[63&i|128]+oe[i>>8&255]+"-"+oe[i>>16&255]+oe[i>>24&255]+oe[255&n]+oe[n>>8&255]+oe[n>>16&255]+oe[n>>24&255]).toUpperCase()},clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*he.DEG2RAD},radToDeg:function(t){return t*he.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}};function ce(t,e){this.x=t||0,this.y=e||0}function le(t,e,i,n){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==n?n:1}Object.defineProperties(ce.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(ce.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){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:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}}),Object.assign(le,{slerp:function(t,e,i,n){return i.copy(t).slerp(e,n)},slerpFlat:function(t,e,i,n,r,s,o){var a=i[n+0],h=i[n+1],c=i[n+2],l=i[n+3],u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(l!==f||a!==u||h!==d||c!==p){var m=1-o,g=a*u+h*d+c*p+l*f,v=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){var y=Math.sqrt(b),_=Math.atan2(y,g*v);m=Math.sin(m*_)/y,o=Math.sin(o*_)/y}var x=o*v;if(a=a*m+u*x,h=h*m+d*x,c=c*m+p*x,l=l*m+f*x,m===1-o){var w=1/Math.sqrt(a*a+h*h+c*c+l*l);a*=w,h*=w,c*=w,l*=w}}t[e]=a,t[e+1]=h,t[e+2]=c,t[e+3]=l}}),Object.defineProperties(le.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()}}}),Object.assign(le.prototype,{isQuaternion:!0,set:function(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=t._x,n=t._y,r=t._z,s=t.order,o=Math.cos,a=Math.sin,h=o(i/2),c=o(n/2),l=o(r/2),u=a(i/2),d=a(n/2),p=a(r/2);return"XYZ"===s?(this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p):"YXZ"===s?(this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p):"ZXY"===s?(this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p):"ZYX"===s?(this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p):"YZX"===s?(this._x=u*c*l+h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l-u*d*p):"XZY"===s&&(this._x=u*c*l-h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l+u*d*p),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,i=t.elements,n=i[0],r=i[4],s=i[8],o=i[1],a=i[5],h=i[9],c=i[2],l=i[6],u=i[10],d=n+a+u;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(l-h)*e,this._y=(s-c)*e,this._z=(o-r)*e):n>a&&n>u?(e=2*Math.sqrt(1+n-a-u),this._w=(l-h)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(s+c)/e):a>u?(e=2*Math.sqrt(1+a-n-u),this._w=(s-c)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(h+l)/e):(e=2*Math.sqrt(1+u-n-a),this._w=(o-r)/e,this._x=(s+c)/e,this._y=(h+l)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var i=t.dot(e)+1;return i<1e-6?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(he.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var i=this.angleTo(t);if(0===i)return this;var n=Math.min(1,e/i);return this.slerp(t,n),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var i=t._x,n=t._y,r=t._z,s=t._w,o=e._x,a=e._y,h=e._z,c=e._w;return this._x=i*c+s*o+n*h-r*a,this._y=n*c+s*a+r*o-i*h,this._z=r*c+s*h+i*a-n*o,this._w=s*c-i*o-n*a-r*h,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,n=this._y,r=this._z,s=this._w,o=s*t._w+i*t._x+n*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;var a=1-o*o;if(a<=Number.EPSILON){var h=1-e;return this._w=h*s+e*this._w,this._x=h*i+e*this._x,this._y=h*n+e*this._y,this._z=h*r+e*this._z,this.normalize(),this._onChangeCallback(),this}var c=Math.sqrt(a),l=Math.atan2(c,o),u=Math.sin((1-e)*l)/c,d=Math.sin(e*l)/c;return this._w=s*u+this._w*d,this._x=i*u+this._x*d,this._y=n*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},_onChange:function(t){return this._onChangeCallback=t,this},_onChangeCallback:function(){}});var ue=new pe,de=new le;function pe(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}Object.assign(pe.prototype,{isVector3:!0,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(de.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(de.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this},applyNormalMatrix:function(t){return this.applyMatrix3(t).normalize()},applyMatrix4:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this},applyQuaternion:function(t){var e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,o=t.z,a=t.w,h=a*e+s*n-o*i,c=a*i+o*e-r*n,l=a*n+r*i-s*e,u=-r*e-s*i-o*n;return this.x=h*a+u*-r+c*-o-l*-s,this.y=c*a+u*-s+l*-r-h*-o,this.z=l*a+u*-o+h*-s-c*-r,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){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:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var i=t.x,n=t.y,r=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return ue.copy(this).projectOnVector(t),this.sub(ue)},reflect:function(t){return this.sub(ue.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());0===e&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var i=this.dot(t)/e;return Math.acos(he.clamp(i,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,i){var n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var fe,me=new pe;function ge(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.assign(ge.prototype,{isMatrix3:!0,set:function(t,e,i,n,r,s,o,a,h){var c=this.elements;return c[0]=t,c[1]=n,c[2]=o,c[3]=e,c[4]=r,c[5]=a,c[6]=i,c[7]=s,c[8]=h,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(t){for(var e=0,i=t.count;e<i;e++)me.x=t.getX(e),me.y=t.getY(e),me.z=t.getZ(e),me.applyMatrix3(this),t.setXYZ(e,me.x,me.y,me.z);return t},multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[3],a=i[6],h=i[1],c=i[4],l=i[7],u=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],v=n[1],b=n[4],y=n[7],_=n[2],x=n[5],w=n[8];return r[0]=s*f+o*v+a*_,r[3]=s*m+o*b+a*x,r[6]=s*g+o*y+a*w,r[1]=h*f+c*v+l*_,r[4]=h*m+c*b+l*x,r[7]=h*g+c*y+l*w,r[2]=u*f+d*v+p*_,r[5]=u*m+d*b+p*x,r[8]=u*g+d*y+p*w,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],h=t[7],c=t[8];return e*s*c-e*o*h-i*r*c+i*o*a+n*r*h-n*s*a},getInverse:function(t,e){t&&t.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=t.elements,n=this.elements,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],c=i[5],l=i[6],u=i[7],d=i[8],p=d*h-c*u,f=c*l-d*a,m=u*a-h*l,g=r*p+s*f+o*m;if(0===g){var v="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(v);return console.warn(v),this.identity()}var b=1/g;return n[0]=p*b,n[1]=(o*u-d*s)*b,n[2]=(c*s-o*h)*b,n[3]=f*b,n[4]=(d*r-o*l)*b,n[5]=(o*a-c*r)*b,n[6]=m*b,n[7]=(s*l-u*r)*b,n[8]=(h*r-s*a)*b,this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},setUvTransform:function(t,e,i,n,r,s,o){var a=Math.cos(r),h=Math.sin(r);this.set(i*a,i*h,-i*(a*s+h*o)+s+t,-n*h,n*a,-n*(-h*s+a*o)+o+e,0,0,1)},scale:function(t,e){var i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),n=this.elements,r=n[0],s=n[3],o=n[6],a=n[1],h=n[4],c=n[7];return n[0]=e*r+i*a,n[3]=e*s+i*h,n[6]=e*o+i*c,n[1]=-i*r+e*a,n[4]=-i*s+e*h,n[7]=-i*o+e*c,this},translate:function(t,e){var i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this},equals:function(t){for(var e=this.elements,i=t.elements,n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}});var ve={getDataURL:function(t){var e;if("undefined"==typeof HTMLCanvasElement)return t.src;if(t instanceof HTMLCanvasElement)e=t;else{void 0===fe&&(fe=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),fe.width=t.width,fe.height=t.height;var i=fe.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=fe}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},be=0;function ye(t,e,i,n,r,s,o,a,h,c){Object.defineProperty(this,"id",{value:be++}),this.uuid=he.generateUUID(),this.name="",this.image=void 0!==t?t:ye.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:ye.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:dt,this.wrapT=void 0!==n?n:dt,this.magFilter=void 0!==r?r:yt,this.minFilter=void 0!==s?s:xt,this.anisotropy=void 0!==h?h:1,this.format=void 0!==o?o:Ft,this.internalFormat=null,this.type=void 0!==a?a:Mt,this.offset=new ce(0,0),this.repeat=new ce(1,1),this.center=new ce(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ge,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==c?c:Kt,this.version=0,this.onUpdate=null}function _e(t,e,i,n){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==n?n:1}function xe(t,e,i){this.width=t,this.height=e,this.scissor=new _e(0,0,t,e),this.scissorTest=!1,this.viewport=new _e(0,0,t,e),i=i||{},this.texture=new ye(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:yt,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function we(t,e,i){xe.call(this,t,e,i),this.samples=4}ye.DEFAULT_IMAGE=void 0,ye.DEFAULT_MAPPING=300,ye.prototype=Object.assign(Object.create(se.prototype),{constructor:ye,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){var e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var n=this.image;if(void 0===n.uuid&&(n.uuid=he.generateUUID()),!e&&void 0===t.images[n.uuid]){var r;if(Array.isArray(n)){r=[];for(var s=0,o=n.length;s<o;s++)r.push(ve.getDataURL(n[s]))}else r=ve.getDataURL(n);t.images[n.uuid]={uuid:n.uuid,url:r}}i.image=n.uuid}return e||(t.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ut:t.x=t.x-Math.floor(t.x);break;case dt:t.x=t.x<0?0:1;break;case pt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case ut:t.y=t.y-Math.floor(t.y);break;case dt:t.y=t.y<0?0:1;break;case pt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(ye.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.defineProperties(_e.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(_e.prototype,{isVector4:!0,set:function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){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: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,i,n,r,s=.01,o=.1,a=t.elements,h=a[0],c=a[4],l=a[8],u=a[1],d=a[5],p=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(c-u)<s&&Math.abs(l-f)<s&&Math.abs(p-m)<s){if(Math.abs(c+u)<o&&Math.abs(l+f)<o&&Math.abs(p+m)<o&&Math.abs(h+d+g-3)<o)return this.set(1,0,0,0),this;e=Math.PI;var v=(h+1)/2,b=(d+1)/2,y=(g+1)/2,_=(c+u)/4,x=(l+f)/4,w=(p+m)/4;return v>b&&v>y?v<s?(i=0,n=.707106781,r=.707106781):(n=_/(i=Math.sqrt(v)),r=x/i):b>y?b<s?(i=.707106781,n=0,r=.707106781):(i=_/(n=Math.sqrt(b)),r=w/n):y<s?(i=.707106781,n=.707106781,r=0):(i=x/(r=Math.sqrt(y)),n=w/r),this.set(i,n,r,e),this}var M=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-c)*(u-c));return Math.abs(M)<.001&&(M=1),this.x=(m-p)/M,this.y=(l-f)/M,this.z=(u-c)/M,this.w=Math.acos((h+d+g-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){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:function(){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:function(){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:function(){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:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),xe.prototype=Object.assign(Object.create(se.prototype),{constructor:xe,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),we.prototype=Object.assign(Object.create(xe.prototype),{constructor:we,isWebGLMultisampleRenderTarget:!0,copy:function(t){return xe.prototype.copy.call(this,t),this.samples=t.samples,this}});var Me=new pe,Te=new Le,Se=new pe(0,0,0),Ee=new pe(1,1,1),Pe=new pe,Ae=new pe,Ce=new pe;function Le(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(Le.prototype,{isMatrix4:!0,set:function(t,e,i,n,r,s,o,a,h,c,l,u,d,p,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=o,g[13]=a,g[2]=h,g[6]=c,g[10]=l,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new Le).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},copyPosition:function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},extractBasis:function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,i=t.elements,n=1/Me.setFromMatrixColumn(t,0).length(),r=1/Me.setFromMatrixColumn(t,1).length(),s=1/Me.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),o=Math.sin(i),a=Math.cos(n),h=Math.sin(n),c=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){var u=s*c,d=s*l,p=o*c,f=o*l;e[0]=a*c,e[4]=-a*l,e[8]=h,e[1]=d+p*h,e[5]=u-f*h,e[9]=-o*a,e[2]=f-u*h,e[6]=p+d*h,e[10]=s*a}else if("YXZ"===t.order){var m=a*c,g=a*l,v=h*c,b=h*l;e[0]=m+b*o,e[4]=v*o-g,e[8]=s*h,e[1]=s*l,e[5]=s*c,e[9]=-o,e[2]=g*o-v,e[6]=b+m*o,e[10]=s*a}else if("ZXY"===t.order){m=a*c,g=a*l,v=h*c,b=h*l;e[0]=m-b*o,e[4]=-s*l,e[8]=v+g*o,e[1]=g+v*o,e[5]=s*c,e[9]=b-m*o,e[2]=-s*h,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){u=s*c,d=s*l,p=o*c,f=o*l;e[0]=a*c,e[4]=p*h-d,e[8]=u*h+f,e[1]=a*l,e[5]=f*h+u,e[9]=d*h-p,e[2]=-h,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){var y=s*a,_=s*h,x=o*a,w=o*h;e[0]=a*c,e[4]=w-y*l,e[8]=x*l+_,e[1]=l,e[5]=s*c,e[9]=-o*c,e[2]=-h*c,e[6]=_*l+x,e[10]=y-w*l}else if("XZY"===t.order){y=s*a,_=s*h,x=o*a,w=o*h;e[0]=a*c,e[4]=-l,e[8]=h*c,e[1]=y*l+w,e[5]=s*c,e[9]=_*l-x,e[2]=x*l-_,e[6]=o*c,e[10]=w*l+y}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){return this.compose(Se,t,Ee)},lookAt:function(t,e,i){var n=this.elements;return Ce.subVectors(t,e),0===Ce.lengthSq()&&(Ce.z=1),Ce.normalize(),Pe.crossVectors(i,Ce),0===Pe.lengthSq()&&(1===Math.abs(i.z)?Ce.x+=1e-4:Ce.z+=1e-4,Ce.normalize(),Pe.crossVectors(i,Ce)),Pe.normalize(),Ae.crossVectors(Ce,Pe),n[0]=Pe.x,n[4]=Ae.x,n[8]=Ce.x,n[1]=Pe.y,n[5]=Ae.y,n[9]=Ce.y,n[2]=Pe.z,n[6]=Ae.z,n[10]=Ce.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[4],a=i[8],h=i[12],c=i[1],l=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],v=i[3],b=i[7],y=i[11],_=i[15],x=n[0],w=n[4],M=n[8],T=n[12],S=n[1],E=n[5],P=n[9],A=n[13],C=n[2],L=n[6],R=n[10],I=n[14],O=n[3],F=n[7],B=n[11],D=n[15];return r[0]=s*x+o*S+a*C+h*O,r[4]=s*w+o*E+a*L+h*F,r[8]=s*M+o*P+a*R+h*B,r[12]=s*T+o*A+a*I+h*D,r[1]=c*x+l*S+u*C+d*O,r[5]=c*w+l*E+u*L+d*F,r[9]=c*M+l*P+u*R+d*B,r[13]=c*T+l*A+u*I+d*D,r[2]=p*x+f*S+m*C+g*O,r[6]=p*w+f*E+m*L+g*F,r[10]=p*M+f*P+m*R+g*B,r[14]=p*T+f*A+m*I+g*D,r[3]=v*x+b*S+y*C+_*O,r[7]=v*w+b*E+y*L+_*F,r[11]=v*M+b*P+y*R+_*B,r[15]=v*T+b*A+y*I+_*D,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(t){for(var e=0,i=t.count;e<i;e++)Me.x=t.getX(e),Me.y=t.getY(e),Me.z=t.getZ(e),Me.applyMatrix4(this),t.setXYZ(e,Me.x,Me.y,Me.z);return t},determinant:function(){var t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],o=t[5],a=t[9],h=t[13],c=t[2],l=t[6],u=t[10],d=t[14];return t[3]*(+r*a*l-n*h*l-r*o*u+i*h*u+n*o*d-i*a*d)+t[7]*(+e*a*d-e*h*u+r*s*u-n*s*d+n*h*c-r*a*c)+t[11]*(+e*h*l-e*o*d-r*s*l+i*s*d+r*o*c-i*h*c)+t[15]*(-n*o*c-e*a*l+e*o*u+n*s*l-i*s*u+i*a*c)},transpose:function(){var t,e=this.elements;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:function(t,e,i){var n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this},getInverse:function(t,e){var i=this.elements,n=t.elements,r=n[0],s=n[1],o=n[2],a=n[3],h=n[4],c=n[5],l=n[6],u=n[7],d=n[8],p=n[9],f=n[10],m=n[11],g=n[12],v=n[13],b=n[14],y=n[15],_=p*b*u-v*f*u+v*l*m-c*b*m-p*l*y+c*f*y,x=g*f*u-d*b*u-g*l*m+h*b*m+d*l*y-h*f*y,w=d*v*u-g*p*u+g*c*m-h*v*m-d*c*y+h*p*y,M=g*p*l-d*v*l-g*c*f+h*v*f+d*c*b-h*p*b,T=r*_+s*x+o*w+a*M;if(0===T){var S="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(S);return console.warn(S),this.identity()}var E=1/T;return i[0]=_*E,i[1]=(v*f*a-p*b*a-v*o*m+s*b*m+p*o*y-s*f*y)*E,i[2]=(c*b*a-v*l*a+v*o*u-s*b*u-c*o*y+s*l*y)*E,i[3]=(p*l*a-c*f*a-p*o*u+s*f*u+c*o*m-s*l*m)*E,i[4]=x*E,i[5]=(d*b*a-g*f*a+g*o*m-r*b*m-d*o*y+r*f*y)*E,i[6]=(g*l*a-h*b*a-g*o*u+r*b*u+h*o*y-r*l*y)*E,i[7]=(h*f*a-d*l*a+d*o*u-r*f*u-h*o*m+r*l*m)*E,i[8]=w*E,i[9]=(g*p*a-d*v*a-g*s*m+r*v*m+d*s*y-r*p*y)*E,i[10]=(h*v*a-g*c*a+g*s*u-r*v*u-h*s*y+r*c*y)*E,i[11]=(d*c*a-h*p*a-d*s*u+r*p*u+h*s*m-r*c*m)*E,i[12]=M*E,i[13]=(d*v*o-g*p*o+g*s*f-r*v*f-d*s*b+r*p*b)*E,i[14]=(g*c*o-h*v*o-g*s*l+r*v*l+h*s*b-r*c*b)*E,i[15]=(h*p*o-d*c*o+d*s*l-r*p*l-h*s*f+r*c*f)*E,this},scale:function(t){var e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))},makeTranslation:function(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,o=t.y,a=t.z,h=r*s,c=r*o;return this.set(h*s+i,h*o-n*a,h*a+n*o,0,h*o+n*a,c*o+i,c*a-n*s,0,h*a-n*o,c*a+n*s,r*a*a+i,0,0,0,0,1),this},makeScale:function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this},compose:function(t,e,i){var n=this.elements,r=e._x,s=e._y,o=e._z,a=e._w,h=r+r,c=s+s,l=o+o,u=r*h,d=r*c,p=r*l,f=s*c,m=s*l,g=o*l,v=a*h,b=a*c,y=a*l,_=i.x,x=i.y,w=i.z;return n[0]=(1-(f+g))*_,n[1]=(d+y)*_,n[2]=(p-b)*_,n[3]=0,n[4]=(d-y)*x,n[5]=(1-(u+g))*x,n[6]=(m+v)*x,n[7]=0,n[8]=(p+b)*w,n[9]=(m-v)*w,n[10]=(1-(u+f))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this},decompose:function(t,e,i){var n=this.elements,r=Me.set(n[0],n[1],n[2]).length(),s=Me.set(n[4],n[5],n[6]).length(),o=Me.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],Te.copy(this);var a=1/r,h=1/s,c=1/o;return Te.elements[0]*=a,Te.elements[1]*=a,Te.elements[2]*=a,Te.elements[4]*=h,Te.elements[5]*=h,Te.elements[6]*=h,Te.elements[8]*=c,Te.elements[9]*=c,Te.elements[10]*=c,e.setFromRotationMatrix(Te),i.x=r,i.y=s,i.z=o,this},makePerspective:function(t,e,i,n,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var o=this.elements,a=2*r/(e-t),h=2*r/(i-n),c=(e+t)/(e-t),l=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return o[0]=a,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=h,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makeOrthographic:function(t,e,i,n,r,s){var o=this.elements,a=1/(e-t),h=1/(i-n),c=1/(s-r),l=(e+t)*a,u=(i+n)*h,d=(s+r)*c;return o[0]=2*a,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(t){for(var e=this.elements,i=t.elements,n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}});var Re=new Le,Ie=new le;function Oe(t,e,i,n){this._x=t||0,this._y=e||0,this._z=i||0,this._order=n||Oe.DefaultOrder}function Fe(){this.mask=1}Oe.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Oe.DefaultOrder="XYZ",Object.defineProperties(Oe.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this._onChangeCallback()}}}),Object.assign(Oe.prototype,{isEuler:!0,set:function(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._order=n||this._order,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this},setFromRotationMatrix:function(t,e,i){var n=he.clamp,r=t.elements,s=r[0],o=r[4],a=r[8],h=r[1],c=r[5],l=r[9],u=r[2],d=r[6],p=r[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(h,c)):(this._y=Math.atan2(-u,s),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(h,s))):"ZYX"===e?(this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(h,s)):(this._x=0,this._z=Math.atan2(-o,c))):"YZX"===e?(this._z=Math.asin(n(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,p))):"XZY"===e?(this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-l,p),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==i&&this._onChangeCallback(),this},setFromQuaternion:function(t,e,i){return Re.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Re,e,i)},setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(t){return Ie.setFromEuler(this),this.setFromQuaternion(Ie,t)},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new pe(this._x,this._y,this._z)},_onChange:function(t){return this._onChangeCallback=t,this},_onChangeCallback:function(){}}),Object.assign(Fe.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},enableAll:function(){this.mask=-1},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},disableAll:function(){this.mask=0},test:function(t){return 0!=(this.mask&t.mask)}});var Be=0,De=new pe,ze=new le,Ne=new Le,Ue=new pe,Ve=new pe,ke=new pe,je=new le,He=new pe(1,0,0),Ge=new pe(0,1,0),We=new pe(0,0,1),qe={type:"added"},Xe={type:"removed"};function Ye(){Object.defineProperty(this,"id",{value:Be++}),this.uuid=he.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ye.DefaultUp.clone();var t=new pe,e=new Oe,i=new le,n=new pe(1,1,1);e._onChange((function(){i.setFromEuler(e,!1)})),i._onChange((function(){e.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Le},normalMatrix:{value:new ge}}),this.matrix=new Le,this.matrixWorld=new Le,this.matrixAutoUpdate=Ye.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Fe,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function Ze(){Ye.call(this),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Ye.DefaultUp=new pe(0,1,0),Ye.DefaultMatrixAutoUpdate=!0,Ye.prototype=Object.assign(Object.create(se.prototype),{constructor:Ye,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return ze.setFromAxisAngle(t,e),this.quaternion.multiply(ze),this},rotateOnWorldAxis:function(t,e){return ze.setFromAxisAngle(t,e),this.quaternion.premultiply(ze),this},rotateX:function(t){return this.rotateOnAxis(He,t)},rotateY:function(t){return this.rotateOnAxis(Ge,t)},rotateZ:function(t){return this.rotateOnAxis(We,t)},translateOnAxis:function(t,e){return De.copy(t).applyQuaternion(this.quaternion),this.position.add(De.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(He,t)},translateY:function(t){return this.translateOnAxis(Ge,t)},translateZ:function(t){return this.translateOnAxis(We,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(Ne.getInverse(this.matrixWorld))},lookAt:function(t,e,i){t.isVector3?Ue.copy(t):Ue.set(t,e,i);var n=this.parent;this.updateWorldMatrix(!0,!1),Ve.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ne.lookAt(Ve,Ue,this.up):Ne.lookAt(Ue,Ve,this.up),this.quaternion.setFromRotationMatrix(Ne),n&&(Ne.extractRotation(n.matrixWorld),ze.setFromRotationMatrix(Ne),this.quaternion.premultiply(ze.inverse()))},add:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(qe)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}var i=this.children.indexOf(t);return-1!==i&&(t.parent=null,this.children.splice(i,1),t.dispatchEvent(Xe)),this},attach:function(t){return this.updateWorldMatrix(!0,!1),Ne.getInverse(this.matrixWorld),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Ne.multiply(t.parent.matrixWorld)),t.applyMatrix(Ne),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(var i=0,n=this.children.length;i<n;i++){var r=this.children[i].getObjectByProperty(t,e);if(void 0!==r)return r}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new pe),this.updateMatrixWorld(!0),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new le),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Ve,t,ke),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new pe),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Ve,je,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new pe),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);for(var e=this.children,i=0,n=e.length;i<n;i++)e[i].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=this.children,i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}},traverseAncestors:function(t){var e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(var e=this.children,i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){var i=this.parent;if(!0===t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e)for(var n=this.children,r=0,s=n.length;r<s;r++)n[r].updateWorldMatrix(!1,!0)},toJSON:function(t){var e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);var s=this.geometry.parameters;if(void 0!==s&&void 0!==s.shapes){var o=s.shapes;if(Array.isArray(o))for(var a=0,h=o.length;a<h;a++){var c=o[a];r(t.shapes,c)}else r(t.shapes,o)}}if(void 0!==this.material)if(Array.isArray(this.material)){var l=[];for(a=0,h=this.material.length;a<h;a++)l.push(r(t.materials,this.material[a]));n.material=l}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(t).object)}if(e){var u=m(t.geometries),d=m(t.materials),p=m(t.textures),f=m(t.images);o=m(t.shapes);u.length>0&&(i.geometries=u),d.length>0&&(i.materials=d),p.length>0&&(i.textures=p),f.length>0&&(i.images=f),o.length>0&&(i.shapes=o)}return i.object=n,i;function m(t){var e=[];for(var i in t){var n=t[i];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var i=0;i<t.children.length;i++){var n=t.children[i];this.add(n.clone())}return this}}),Ze.prototype=Object.assign(Object.create(Ye.prototype),{constructor:Ze,isScene:!0,copy:function(t,e){return Ye.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},toJSON:function(t){var e=Ye.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.environment&&(e.object.environment=this.environment.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e},dispose:function(){this.dispatchEvent({type:"dispose"})}});var $e=[new pe,new pe,new pe,new pe,new pe,new pe,new pe,new pe],Je=new pe,Qe=new ci,Ke=new pe,ti=new pe,ei=new pe,ii=new pe,ni=new pe,ri=new pe,si=new pe,oi=new pe,ai=new pe,hi=new pe;function ci(t,e){this.min=void 0!==t?t:new pe(1/0,1/0,1/0),this.max=void 0!==e?e:new pe(-1/0,-1/0,-1/0)}function li(t,e,i,n,r){var s,o;for(s=0,o=t.length-3;s<=o;s+=3){hi.fromArray(t,s);var a=r.x*Math.abs(hi.x)+r.y*Math.abs(hi.y)+r.z*Math.abs(hi.z),h=e.dot(hi),c=i.dot(hi),l=n.dot(hi);if(Math.max(-Math.max(h,c,l),Math.min(h,c,l))>a)return!1}return!0}Object.assign(ci.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0,a=0,h=t.length;a<h;a+=3){var c=t[a],l=t[a+1],u=t[a+2];c<e&&(e=c),l<i&&(i=l),u<n&&(n=u),c>r&&(r=c),l>s&&(s=l),u>o&&(o=u)}return this.min.set(e,i,n),this.max.set(r,s,o),this},setFromBufferAttribute:function(t){for(var e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0,a=0,h=t.count;a<h;a++){var c=t.getX(a),l=t.getY(a),u=t.getZ(a);c<e&&(e=c),l<i&&(i=l),u<n&&(n=u),c>r&&(r=c),l>s&&(s=l),u>o&&(o=u)}return this.min.set(e,i,n),this.max.set(r,s,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(t,e){var i=Je.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){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:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new pe),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new pe),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(t){t.updateWorldMatrix(!1,!1);var e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),Qe.copy(e.boundingBox),Qe.applyMatrix4(t.matrixWorld),this.expandByPoint(Qe.min),this.expandByPoint(Qe.max));for(var i=t.children,n=0,r=i.length;n<r;n++)this.expandByObject(i[n]);return this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new pe),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,Je),Je.distanceToSquared(t.center)<=t.radius*t.radius},intersectsPlane:function(t){var e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant},intersectsTriangle:function(t){if(this.isEmpty())return!1;this.getCenter(si),oi.subVectors(this.max,si),Ke.subVectors(t.a,si),ti.subVectors(t.b,si),ei.subVectors(t.c,si),ii.subVectors(ti,Ke),ni.subVectors(ei,ti),ri.subVectors(Ke,ei);var e=[0,-ii.z,ii.y,0,-ni.z,ni.y,0,-ri.z,ri.y,ii.z,0,-ii.x,ni.z,0,-ni.x,ri.z,0,-ri.x,-ii.y,ii.x,0,-ni.y,ni.x,0,-ri.y,ri.x,0];return!!li(e,Ke,ti,ei,oi)&&(!!li(e=[1,0,0,0,1,0,0,0,1],Ke,ti,ei,oi)&&(ai.crossVectors(ii,ni),li(e=[ai.x,ai.y,ai.z],Ke,ti,ei,oi)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new pe),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return Je.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(Je).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()||($e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),$e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),$e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),$e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),$e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),$e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),$e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),$e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints($e)),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var ui=new ci;function di(t,e){this.center=void 0!==t?t:new pe,this.radius=void 0!==e?e:0}Object.assign(di.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var i=this.center;void 0!==e?i.copy(e):ui.setFromPoints(t).getCenter(i);for(var n=0,r=0,s=t.length;r<s;r++)n=Math.max(n,i.distanceToSquared(t[r]));return this.radius=Math.sqrt(n),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius},clampPoint:function(t,e){var i=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new pe),e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new ci),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var pi=new pe,fi=new pe,mi=new pe,gi=new pe,vi=new pe,bi=new pe,yi=new pe;function _i(t,e){this.origin=void 0!==t?t:new pe,this.direction=void 0!==e?e:new pe(0,0,-1)}Object.assign(_i.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new pe),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,pi)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new pe),e.subVectors(t,this.origin);var i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=pi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(pi.copy(this.direction).multiplyScalar(e).add(this.origin),pi.distanceToSquared(t))},distanceSqToSegment:function(t,e,i,n){fi.copy(t).add(e).multiplyScalar(.5),mi.copy(e).sub(t).normalize(),gi.copy(this.origin).sub(fi);var r,s,o,a,h=.5*t.distanceTo(e),c=-this.direction.dot(mi),l=gi.dot(this.direction),u=-gi.dot(mi),d=gi.lengthSq(),p=Math.abs(1-c*c);if(p>0)if(s=c*l-u,a=h*p,(r=c*u-l)>=0)if(s>=-a)if(s<=a){var f=1/p;o=(r*=f)*(r+c*(s*=f)+2*l)+s*(c*r+s+2*u)+d}else s=h,o=-(r=Math.max(0,-(c*s+l)))*r+s*(s+2*u)+d;else s=-h,o=-(r=Math.max(0,-(c*s+l)))*r+s*(s+2*u)+d;else s<=-a?o=-(r=Math.max(0,-(-c*h+l)))*r+(s=r>0?-h:Math.min(Math.max(-h,-u),h))*(s+2*u)+d:s<=a?(r=0,o=(s=Math.min(Math.max(-h,-u),h))*(s+2*u)+d):o=-(r=Math.max(0,-(c*h+l)))*r+(s=r>0?h:Math.min(Math.max(-h,-u),h))*(s+2*u)+d;else s=c>0?-h:h,o=-(r=Math.max(0,-(c*s+l)))*r+s*(s+2*u)+d;return i&&i.copy(this.direction).multiplyScalar(r).add(this.origin),n&&n.copy(mi).multiplyScalar(s).add(fi),o},intersectSphere:function(t,e){pi.subVectors(t.center,this.origin);var i=pi.dot(this.direction),n=pi.dot(pi)-i*i,r=t.radius*t.radius;if(n>r)return null;var s=Math.sqrt(r-n),o=i-s,a=i+s;return o<0&&a<0?null:o<0?this.at(a,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null},intersectPlane:function(t,e){var i=this.distanceToPlane(t);return null===i?null:this.at(i,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var i,n,r,s,o,a,h=1/this.direction.x,c=1/this.direction.y,l=1/this.direction.z,u=this.origin;return h>=0?(i=(t.min.x-u.x)*h,n=(t.max.x-u.x)*h):(i=(t.max.x-u.x)*h,n=(t.min.x-u.x)*h),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),i>s||r>n?null:((r>i||i!=i)&&(i=r),(s<n||n!=n)&&(n=s),l>=0?(o=(t.min.z-u.z)*l,a=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,a=(t.min.z-u.z)*l),i>a||o>n?null:((o>i||i!=i)&&(i=o),(a<n||n!=n)&&(n=a),n<0?null:this.at(i>=0?i:n,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,pi)},intersectTriangle:function(t,e,i,n,r){vi.subVectors(e,t),bi.subVectors(i,t),yi.crossVectors(vi,bi);var s,o=this.direction.dot(yi);if(o>0){if(n)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}gi.subVectors(this.origin,t);var a=s*this.direction.dot(bi.crossVectors(gi,bi));if(a<0)return null;var h=s*this.direction.dot(vi.cross(gi));if(h<0)return null;if(a+h>o)return null;var c=-s*gi.dot(yi);return c<0?null:this.at(c/o,r)},applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}});var xi=new pe,wi=new pe,Mi=new ge;function Ti(t,e){this.normal=void 0!==t?t:new pe(1,0,0),this.constant=void 0!==e?e:0}Object.assign(Ti.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,i){var n=xi.subVectors(i,e).cross(wi.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new pe),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new pe);var i=t.delta(xi),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?void 0:e.copy(i).multiplyScalar(r).add(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new pe),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var i=e||Mi.getNormalMatrix(t),n=this.coplanarPoint(xi).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this},translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}});var Si=new pe,Ei=new pe,Pi=new pe,Ai=new pe,Ci=new pe,Li=new pe,Ri=new pe,Ii=new pe,Oi=new pe,Fi=new pe;function Bi(t,e,i){this.a=void 0!==t?t:new pe,this.b=void 0!==e?e:new pe,this.c=void 0!==i?i:new pe}Object.assign(Bi,{getNormal:function(t,e,i,n){void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new pe),n.subVectors(i,e),Si.subVectors(t,e),n.cross(Si);var r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)},getBarycoord:function(t,e,i,n,r){Si.subVectors(n,e),Ei.subVectors(i,e),Pi.subVectors(t,e);var s=Si.dot(Si),o=Si.dot(Ei),a=Si.dot(Pi),h=Ei.dot(Ei),c=Ei.dot(Pi),l=s*h-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new pe),0===l)return r.set(-2,-1,-1);var u=1/l,d=(h*a-o*c)*u,p=(s*c-o*a)*u;return r.set(1-d-p,p,d)},containsPoint:function(t,e,i,n){return Bi.getBarycoord(t,e,i,n,Ai),Ai.x>=0&&Ai.y>=0&&Ai.x+Ai.y<=1},getUV:function(t,e,i,n,r,s,o,a){return this.getBarycoord(t,e,i,n,Ai),a.set(0,0),a.addScaledVector(r,Ai.x),a.addScaledVector(s,Ai.y),a.addScaledVector(o,Ai.z),a},isFrontFacing:function(t,e,i,n){return Si.subVectors(i,e),Ei.subVectors(t,e),Si.cross(Ei).dot(n)<0}}),Object.assign(Bi.prototype,{set:function(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this},setFromPointsAndIndices:function(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return Si.subVectors(this.c,this.b),Ei.subVectors(this.a,this.b),.5*Si.cross(Ei).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new pe),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Bi.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ti),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Bi.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,i,n,r){return Bi.getUV(t,this.a,this.b,this.c,e,i,n,r)},containsPoint:function(t){return Bi.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Bi.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new pe);var i,n,r=this.a,s=this.b,o=this.c;Ci.subVectors(s,r),Li.subVectors(o,r),Ii.subVectors(t,r);var a=Ci.dot(Ii),h=Li.dot(Ii);if(a<=0&&h<=0)return e.copy(r);Oi.subVectors(t,s);var c=Ci.dot(Oi),l=Li.dot(Oi);if(c>=0&&l<=c)return e.copy(s);var u=a*l-c*h;if(u<=0&&a>=0&&c<=0)return i=a/(a-c),e.copy(r).addScaledVector(Ci,i);Fi.subVectors(t,o);var d=Ci.dot(Fi),p=Li.dot(Fi);if(p>=0&&d<=p)return e.copy(o);var f=d*h-a*p;if(f<=0&&h>=0&&p<=0)return n=h/(h-p),e.copy(r).addScaledVector(Li,n);var m=c*p-d*l;if(m<=0&&l-c>=0&&d-p>=0)return Ri.subVectors(o,s),n=(l-c)/(l-c+(d-p)),e.copy(s).addScaledVector(Ri,n);var g=1/(m+f+u);return i=f*g,n=u*g,e.copy(r).addScaledVector(Ci,i).addScaledVector(Li,n)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var Di={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},zi={h:0,s:0,l:0},Ni={h:0,s:0,l:0};function Ui(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}function Vi(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function ki(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function ji(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function Hi(t,e,i,n,r,s){this.a=t,this.b=e,this.c=i,this.normal=n&&n.isVector3?n:new pe,this.vertexNormals=Array.isArray(n)?n:[],this.color=r&&r.isColor?r:new Ui,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==s?s:0}Object.assign(Ui.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this},setHSL:function(t,e,i){if(t=he.euclideanModulo(t,1),e=he.clamp(e,0,1),i=he.clamp(i,0,1),0===e)this.r=this.g=this.b=i;else{var n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=Vi(r,n,t+1/3),this.g=Vi(r,n,t),this.b=Vi(r,n,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,r=i[1],s=i[2];switch(r){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s)){var o=parseFloat(n[1])/360,a=parseInt(n[2],10)/100,h=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(o,a,h)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c=i[1],l=c.length;if(3===l)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},setColorName:function(t){var e=Di[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this},convertGammaToLinear:function(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=ki(t.r),this.g=ki(t.g),this.b=ki(t.b),this},copyLinearToSRGB:function(t){return this.r=ji(t.r),this.g=ji(t.g),this.b=ji(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,i,n=this.r,r=this.g,s=this.b,o=Math.max(n,r,s),a=Math.min(n,r,s),h=(a+o)/2;if(a===o)e=0,i=0;else{var c=o-a;switch(i=h<=.5?c/(o+a):c/(2-o-a),o){case n:e=(r-s)/c+(r<s?6:0);break;case r:e=(s-n)/c+2;break;case s:e=(n-r)/c+4}e/=6}return t.h=e,t.s=i,t.l=h,t},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,i){return this.getHSL(zi),zi.h+=t,zi.s+=e,zi.l+=i,this.setHSL(zi.h,zi.s,zi.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},lerpHSL:function(t,e){this.getHSL(zi),t.getHSL(Ni);var i=he.lerp(zi.h,Ni.h,e),n=he.lerp(zi.s,Ni.s,e),r=he.lerp(zi.l,Ni.l,e);return this.setHSL(i,n,r),this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},toJSON:function(){return this.getHex()}}),Ui.NAMES=Di,Object.assign(Hi.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var e=0,i=t.vertexNormals.length;e<i;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(e=0,i=t.vertexColors.length;e<i;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}});var Gi=0;function Wi(){Object.defineProperty(this,"id",{value:Gi++}),this.uuid=he.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexTangents=!1,this.vertexColors=0,this.opacity=1,this.transparent=!1,this.blendSrc=ht,this.blendDst=ct,this.blendEquation=nt,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.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}function qi(t){Wi.call(this),this.type="MeshBasicMaterial",this.color=new Ui(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}Wi.prototype=Object.assign(Object.create(se.prototype),{constructor:Wi,isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var e in t){var i=t[e];if(void 0!==i)if("shading"!==e){var n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){var e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){var e=[];for(var i in t){var n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,void 0!==this.combine&&(i.combine=this.combine),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),0!==this.side&&(i.side=this.side),0!==this.vertexColors&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.morphNormals&&(i.morphNormals=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),e){var r=n(t.textures),s=n(t.images);r.length>0&&(i.textures=r),s.length>0&&(i.images=s)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var e=t.clippingPlanes,i=null;if(null!==e){var n=e.length;i=new Array(n);for(var r=0;r!==n;++r)i[r]=e[r].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Wi.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),qi.prototype=Object.create(Wi.prototype),qi.prototype.constructor=qi,qi.prototype.isMeshBasicMaterial=!0,qi.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this};var Xi=new pe;function Yi(t,e,i){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===i,this.usage=ne,this.updateRange={offset:0,count:-1},this.version=0}function Zi(t,e,i){Yi.call(this,new Int8Array(t),e,i)}function $i(t,e,i){Yi.call(this,new Uint8Array(t),e,i)}function Ji(t,e,i){Yi.call(this,new Uint8ClampedArray(t),e,i)}function Qi(t,e,i){Yi.call(this,new Int16Array(t),e,i)}function Ki(t,e,i){Yi.call(this,new Uint16Array(t),e,i)}function tn(t,e,i){Yi.call(this,new Int32Array(t),e,i)}function en(t,e,i){Yi.call(this,new Uint32Array(t),e,i)}function nn(t,e,i){Yi.call(this,new Float32Array(t),e,i)}function rn(t,e,i){Yi.call(this,new Float64Array(t),e,i)}function sn(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function on(t){if(0===t.length)return-1/0;for(var e=t[0],i=1,n=t.length;i<n;++i)t[i]>e&&(e=t[i]);return e}Object.defineProperty(Yi.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Yi.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.itemSize,i*=e.itemSize;for(var n=0,r=this.itemSize;n<r;n++)this.array[t+n]=e.array[i+n];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var e=this.array,i=0,n=0,r=t.length;n<r;n++){var s=t[n];void 0===s&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Ui),e[i++]=s.r,e[i++]=s.g,e[i++]=s.b}return this},copyVector2sArray:function(t){for(var e=this.array,i=0,n=0,r=t.length;n<r;n++){var s=t[n];void 0===s&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new ce),e[i++]=s.x,e[i++]=s.y}return this},copyVector3sArray:function(t){for(var e=this.array,i=0,n=0,r=t.length;n<r;n++){var s=t[n];void 0===s&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new pe),e[i++]=s.x,e[i++]=s.y,e[i++]=s.z}return this},copyVector4sArray:function(t){for(var e=this.array,i=0,n=0,r=t.length;n<r;n++){var s=t[n];void 0===s&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new _e),e[i++]=s.x,e[i++]=s.y,e[i++]=s.z,e[i++]=s.w}return this},applyMatrix3:function(t){for(var e=0,i=this.count;e<i;e++)Xi.x=this.getX(e),Xi.y=this.getY(e),Xi.z=this.getZ(e),Xi.applyMatrix3(t),this.setXYZ(e,Xi.x,Xi.y,Xi.z);return this},applyMatrix4:function(t){for(var e=0,i=this.count;e<i;e++)Xi.x=this.getX(e),Xi.y=this.getY(e),Xi.z=this.getZ(e),Xi.applyMatrix4(t),this.setXYZ(e,Xi.x,Xi.y,Xi.z);return this},applyNormalMatrix:function(t){for(var e=0,i=this.count;e<i;e++)Xi.x=this.getX(e),Xi.y=this.getY(e),Xi.z=this.getZ(e),Xi.applyNormalMatrix(t),this.setXYZ(e,Xi.x,Xi.y,Xi.z);return this},transformDirection:function(t){for(var e=0,i=this.count;e<i;e++)Xi.x=this.getX(e),Xi.y=this.getY(e),Xi.z=this.getZ(e),Xi.transformDirection(t),this.setXYZ(e,Xi.x,Xi.y,Xi.z);return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),Zi.prototype=Object.create(Yi.prototype),Zi.prototype.constructor=Zi,$i.prototype=Object.create(Yi.prototype),$i.prototype.constructor=$i,Ji.prototype=Object.create(Yi.prototype),Ji.prototype.constructor=Ji,Qi.prototype=Object.create(Yi.prototype),Qi.prototype.constructor=Qi,Ki.prototype=Object.create(Yi.prototype),Ki.prototype.constructor=Ki,tn.prototype=Object.create(Yi.prototype),tn.prototype.constructor=tn,en.prototype=Object.create(Yi.prototype),en.prototype.constructor=en,nn.prototype=Object.create(Yi.prototype),nn.prototype.constructor=nn,rn.prototype=Object.create(Yi.prototype),rn.prototype.constructor=rn,Object.assign(sn.prototype,{computeGroups:function(t){for(var e,i=[],n=void 0,r=t.faces,s=0;s<r.length;s++){var o=r[s];o.materialIndex!==n&&(n=o.materialIndex,void 0!==e&&(e.count=3*s-e.start,i.push(e)),e={start:3*s,materialIndex:n})}void 0!==e&&(e.count=3*s-e.start,i.push(e)),this.groups=i},fromGeometry:function(t){var e,i=t.faces,n=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[1].length>0,a=t.morphTargets,h=a.length;if(h>0){e=[];for(var c=0;c<h;c++)e[c]={name:a[c].name,data:[]};this.morphTargets.position=e}var l,u=t.morphNormals,d=u.length;if(d>0){l=[];for(c=0;c<d;c++)l[c]={name:u[c].name,data:[]};this.morphTargets.normal=l}var p=t.skinIndices,f=t.skinWeights,m=p.length===n.length,g=f.length===n.length;n.length>0&&0===i.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(c=0;c<i.length;c++){var v=i[c];this.vertices.push(n[v.a],n[v.b],n[v.c]);var b=v.vertexNormals;if(3===b.length)this.normals.push(b[0],b[1],b[2]);else{var y=v.normal;this.normals.push(y,y,y)}var _,x=v.vertexColors;if(3===x.length)this.colors.push(x[0],x[1],x[2]);else{var w=v.color;this.colors.push(w,w,w)}if(!0===s)void 0!==(_=r[0][c])?this.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",c),this.uvs.push(new ce,new ce,new ce));if(!0===o)void 0!==(_=r[1][c])?this.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",c),this.uvs2.push(new ce,new ce,new ce));for(var M=0;M<h;M++){var T=a[M].vertices;e[M].data.push(T[v.a],T[v.b],T[v.c])}for(M=0;M<d;M++){var S=u[M].vertexNormals[c];l[M].data.push(S.a,S.b,S.c)}m&&this.skinIndices.push(p[v.a],p[v.b],p[v.c]),g&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this}});var an=1,hn=new Le,cn=new Ye,ln=new pe,un=new ci,dn=new ci,pn=new pe;function fn(){Object.defineProperty(this,"id",{value:an+=2}),this.uuid=he.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}fn.prototype=Object.assign(Object.create(se.prototype),{constructor:fn,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(on(t)>65535?en:Ki)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,i){this.groups.push({start:t,count:e,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);var i=this.attributes.normal;if(void 0!==i){var n=(new ge).getNormalMatrix(t);i.applyNormalMatrix(n),i.needsUpdate=!0}var r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(t),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return hn.makeRotationX(t),this.applyMatrix(hn),this},rotateY:function(t){return hn.makeRotationY(t),this.applyMatrix(hn),this},rotateZ:function(t){return hn.makeRotationZ(t),this.applyMatrix(hn),this},translate:function(t,e,i){return hn.makeTranslation(t,e,i),this.applyMatrix(hn),this},scale:function(t,e,i){return hn.makeScale(t,e,i),this.applyMatrix(hn),this},lookAt:function(t){return cn.lookAt(t),cn.updateMatrix(),this.applyMatrix(cn.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(ln).negate(),this.translate(ln.x,ln.y,ln.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var i=new nn(3*e.vertices.length,3),n=new nn(3*e.colors.length,3);if(this.setAttribute("position",i.copyVector3sArray(e.vertices)),this.setAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var r=new nn(e.lineDistances.length,1);this.setAttribute("lineDistance",r.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],i=0,n=t.length;i<n;i++){var r=t[i];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new nn(e,3)),this},updateFromObject:function(t){var e,i=t.geometry;if(t.isMesh){var n=i.__directGeometry;if(!0===i.elementsNeedUpdate&&(n=void 0,i.elementsNeedUpdate=!1),void 0===n)return this.fromGeometry(i);n.verticesNeedUpdate=i.verticesNeedUpdate,n.normalsNeedUpdate=i.normalsNeedUpdate,n.colorsNeedUpdate=i.colorsNeedUpdate,n.uvsNeedUpdate=i.uvsNeedUpdate,n.groupsNeedUpdate=i.groupsNeedUpdate,i.verticesNeedUpdate=!1,i.normalsNeedUpdate=!1,i.colorsNeedUpdate=!1,i.uvsNeedUpdate=!1,i.groupsNeedUpdate=!1,i=n}return!0===i.verticesNeedUpdate&&(void 0!==(e=this.attributes.position)&&(e.copyVector3sArray(i.vertices),e.needsUpdate=!0),i.verticesNeedUpdate=!1),!0===i.normalsNeedUpdate&&(void 0!==(e=this.attributes.normal)&&(e.copyVector3sArray(i.normals),e.needsUpdate=!0),i.normalsNeedUpdate=!1),!0===i.colorsNeedUpdate&&(void 0!==(e=this.attributes.color)&&(e.copyColorsArray(i.colors),e.needsUpdate=!0),i.colorsNeedUpdate=!1),i.uvsNeedUpdate&&(void 0!==(e=this.attributes.uv)&&(e.copyVector2sArray(i.uvs),e.needsUpdate=!0),i.uvsNeedUpdate=!1),i.lineDistancesNeedUpdate&&(void 0!==(e=this.attributes.lineDistance)&&(e.copyArray(i.lineDistances),e.needsUpdate=!0),i.lineDistancesNeedUpdate=!1),i.groupsNeedUpdate&&(i.computeGroups(t.geometry),this.groups=i.groups,i.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new sn).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.setAttribute("position",new Yi(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var i=new Float32Array(3*t.normals.length);this.setAttribute("normal",new Yi(i,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.setAttribute("color",new Yi(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var r=new Float32Array(2*t.uvs.length);this.setAttribute("uv",new Yi(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var s=new Float32Array(2*t.uvs2.length);this.setAttribute("uv2",new Yi(s,2).copyVector2sArray(t.uvs2))}for(var o in this.groups=t.groups,t.morphTargets){for(var a=[],h=t.morphTargets[o],c=0,l=h.length;c<l;c++){var u=h[c],d=new nn(3*u.data.length,3);d.name=u.name,a.push(d.copyVector3sArray(u.data))}this.morphAttributes[o]=a}if(t.skinIndices.length>0){var p=new nn(4*t.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new nn(4*t.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new ci);var t=this.attributes.position,e=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var i=0,n=e.length;i<n;i++){var r=e[i];un.setFromBufferAttribute(r),this.morphTargetsRelative?(pn.addVectors(this.boundingBox.min,un.min),this.boundingBox.expandByPoint(pn),pn.addVectors(this.boundingBox.max,un.max),this.boundingBox.expandByPoint(pn)):(this.boundingBox.expandByPoint(un.min),this.boundingBox.expandByPoint(un.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new di);var t=this.attributes.position,e=this.morphAttributes.position;if(t){var i=this.boundingSphere.center;if(un.setFromBufferAttribute(t),e)for(var n=0,r=e.length;n<r;n++){var s=e[n];dn.setFromBufferAttribute(s),this.morphTargetsRelative?(pn.addVectors(un.min,dn.min),un.expandByPoint(pn),pn.addVectors(un.max,dn.max),un.expandByPoint(pn)):(un.expandByPoint(dn.min),un.expandByPoint(dn.max))}un.getCenter(i);var o=0;for(n=0,r=t.count;n<r;n++)pn.fromBufferAttribute(t,n),o=Math.max(o,i.distanceToSquared(pn));if(e)for(n=0,r=e.length;n<r;n++){s=e[n];for(var a=this.morphTargetsRelative,h=0,c=s.count;h<c;h++)pn.fromBufferAttribute(s,h),a&&(ln.fromBufferAttribute(t,h),pn.add(ln)),o=Math.max(o,i.distanceToSquared(pn))}this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,e=this.attributes;if(e.position){var i=e.position.array;if(void 0===e.normal)this.setAttribute("normal",new Yi(new Float32Array(i.length),3));else for(var n=e.normal.array,r=0,s=n.length;r<s;r++)n[r]=0;var o,a,h,c=e.normal.array,l=new pe,u=new pe,d=new pe,p=new pe,f=new pe;if(t){var m=t.array;for(r=0,s=t.count;r<s;r+=3)o=3*m[r+0],a=3*m[r+1],h=3*m[r+2],l.fromArray(i,o),u.fromArray(i,a),d.fromArray(i,h),p.subVectors(d,u),f.subVectors(l,u),p.cross(f),c[o]+=p.x,c[o+1]+=p.y,c[o+2]+=p.z,c[a]+=p.x,c[a+1]+=p.y,c[a+2]+=p.z,c[h]+=p.x,c[h+1]+=p.y,c[h+2]+=p.z}else for(r=0,s=i.length;r<s;r+=9)l.fromArray(i,r),u.fromArray(i,r+3),d.fromArray(i,r+6),p.subVectors(d,u),f.subVectors(l,u),p.cross(f),c[r]=p.x,c[r+1]=p.y,c[r+2]=p.z,c[r+3]=p.x,c[r+4]=p.y,c[r+5]=p.z,c[r+6]=p.x,c[r+7]=p.y,c[r+8]=p.z;this.normalizeNormals(),e.normal.needsUpdate=!0}},merge:function(t,e){if(t&&t.isBufferGeometry){void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var i=this.attributes;for(var n in i)if(void 0!==t.attributes[n])for(var r=i[n].array,s=t.attributes[n],o=s.array,a=s.itemSize*e,h=Math.min(o.length,r.length-a),c=0,l=a;c<h;c++,l++)r[l]=o[c];return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t)},normalizeNormals:function(){for(var t=this.attributes.normal,e=0,i=t.count;e<i;e++)pn.x=t.getX(e),pn.y=t.getY(e),pn.z=t.getZ(e),pn.normalize(),t.setXYZ(e,pn.x,pn.y,pn.z)},toNonIndexed:function(){function t(t,e){for(var i=t.array,n=t.itemSize,r=new i.constructor(e.length*n),s=0,o=0,a=0,h=e.length;a<h;a++){s=e[a]*n;for(var c=0;c<n;c++)r[o++]=i[s++]}return new Yi(r,n)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var e=new fn,i=this.index.array,n=this.attributes;for(var r in n){var s=t(n[r],i);e.setAttribute(r,s)}var o=this.morphAttributes;for(r in o){for(var a=[],h=o[r],c=0,l=h.length;c<l;c++){s=t(h[c],i);a.push(s)}e.morphAttributes[r]=a}e.morphTargetsRelative=this.morphTargetsRelative;for(var u=this.groups,d=(c=0,u.length);c<d;c++){var p=u[c];e.addGroup(p.start,p.count,p.materialIndex)}return e},toJSON:function(){var t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){var e=this.parameters;for(var i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};var n=this.index;null!==n&&(t.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});var r=this.attributes;for(var i in r){var s=(d=r[i]).toJSON();""!==d.name&&(s.name=d.name),t.data.attributes[i]=s}var o={},a=!1;for(var i in this.morphAttributes){for(var h=this.morphAttributes[i],c=[],l=0,u=h.length;l<u;l++){var d;s=(d=h[l]).toJSON();""!==d.name&&(s.name=d.name),c.push(s)}c.length>0&&(o[i]=c,a=!0)}a&&(t.data.morphAttributes=o,t.data.morphTargetsRelative=this.morphTargetsRelative);var p=this.groups;p.length>0&&(t.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(t.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),t},clone:function(){return(new fn).copy(this)},copy:function(t){var e,i,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var r=t.index;null!==r&&this.setIndex(r.clone());var s=t.attributes;for(e in s){var o=s[e];this.setAttribute(e,o.clone())}var a=t.morphAttributes;for(e in a){var h=[],c=a[e];for(i=0,n=c.length;i<n;i++)h.push(c[i].clone());this.morphAttributes[e]=h}this.morphTargetsRelative=t.morphTargetsRelative;var l=t.groups;for(i=0,n=l.length;i<n;i++){var u=l[i];this.addGroup(u.start,u.count,u.materialIndex)}var d=t.boundingBox;null!==d&&(this.boundingBox=d.clone());var p=t.boundingSphere;return null!==p&&(this.boundingSphere=p.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var mn=new Le,gn=new _i,vn=new di,bn=new pe,yn=new pe,_n=new pe,xn=new pe,wn=new pe,Mn=new pe,Tn=new pe,Sn=new pe,En=new pe,Pn=new ce,An=new ce,Cn=new ce,Ln=new pe,Rn=new pe;function In(t,e){Ye.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new fn,this.material=void 0!==e?e:new qi({color:16777215*Math.random()}),this.updateMorphTargets()}function On(t,e,i,n,r,s,o,a){if(null===(1===e.side?n.intersectTriangle(o,s,r,!0,a):n.intersectTriangle(r,s,o,2!==e.side,a)))return null;Rn.copy(a),Rn.applyMatrix4(t.matrixWorld);var h=i.ray.origin.distanceTo(Rn);return h<i.near||h>i.far?null:{distance:h,point:Rn.clone(),object:t}}function Fn(t,e,i,n,r,s,o,a,h,c,l,u){bn.fromBufferAttribute(r,c),yn.fromBufferAttribute(r,l),_n.fromBufferAttribute(r,u);var d=t.morphTargetInfluences;if(e.morphTargets&&s&&d){Tn.set(0,0,0),Sn.set(0,0,0),En.set(0,0,0);for(var p=0,f=s.length;p<f;p++){var m=d[p],g=s[p];0!==m&&(xn.fromBufferAttribute(g,c),wn.fromBufferAttribute(g,l),Mn.fromBufferAttribute(g,u),o?(Tn.addScaledVector(xn,m),Sn.addScaledVector(wn,m),En.addScaledVector(Mn,m)):(Tn.addScaledVector(xn.sub(bn),m),Sn.addScaledVector(wn.sub(yn),m),En.addScaledVector(Mn.sub(_n),m)))}bn.add(Tn),yn.add(Sn),_n.add(En)}var v=On(t,e,i,n,bn,yn,_n,Ln);if(v){a&&(Pn.fromBufferAttribute(a,c),An.fromBufferAttribute(a,l),Cn.fromBufferAttribute(a,u),v.uv=Bi.getUV(Ln,bn,yn,_n,Pn,An,Cn,new ce)),h&&(Pn.fromBufferAttribute(h,c),An.fromBufferAttribute(h,l),Cn.fromBufferAttribute(h,u),v.uv2=Bi.getUV(Ln,bn,yn,_n,Pn,An,Cn,new ce));var b=new Hi(c,l,u);Bi.getNormal(bn,yn,_n,b.normal),v.face=b}return v}In.prototype=Object.assign(Object.create(Ye.prototype),{constructor:In,isMesh:!0,copy:function(t){return Ye.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this},updateMorphTargets:function(){var t,e,i,n=this.geometry;if(n.isBufferGeometry){var r=n.morphAttributes,s=Object.keys(r);if(s.length>0){var o=r[s[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t<e;t++)i=o[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}else{var a=n.morphTargets;void 0!==a&&a.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var i,n=this.geometry,r=this.material,s=this.matrixWorld;if(void 0!==r&&(null===n.boundingSphere&&n.computeBoundingSphere(),vn.copy(n.boundingSphere),vn.applyMatrix4(s),!1!==t.ray.intersectsSphere(vn)&&(mn.getInverse(s),gn.copy(t.ray).applyMatrix4(mn),null===n.boundingBox||!1!==gn.intersectsBox(n.boundingBox))))if(n.isBufferGeometry){var o,a,h,c,l,u,d,p,f,m=n.index,g=n.attributes.position,v=n.morphAttributes.position,b=n.morphTargetsRelative,y=n.attributes.uv,_=n.attributes.uv2,x=n.groups,w=n.drawRange;if(null!==m)if(Array.isArray(r))for(c=0,u=x.length;c<u;c++)for(f=r[(p=x[c]).materialIndex],l=Math.max(p.start,w.start),d=Math.min(p.start+p.count,w.start+w.count);l<d;l+=3)o=m.getX(l),a=m.getX(l+1),h=m.getX(l+2),(i=Fn(this,f,t,gn,g,v,b,y,_,o,a,h))&&(i.faceIndex=Math.floor(l/3),i.face.materialIndex=p.materialIndex,e.push(i));else for(c=Math.max(0,w.start),u=Math.min(m.count,w.start+w.count);c<u;c+=3)o=m.getX(c),a=m.getX(c+1),h=m.getX(c+2),(i=Fn(this,r,t,gn,g,v,b,y,_,o,a,h))&&(i.faceIndex=Math.floor(c/3),e.push(i));else if(void 0!==g)if(Array.isArray(r))for(c=0,u=x.length;c<u;c++)for(f=r[(p=x[c]).materialIndex],l=Math.max(p.start,w.start),d=Math.min(p.start+p.count,w.start+w.count);l<d;l+=3)(i=Fn(this,f,t,gn,g,v,b,y,_,o=l,a=l+1,h=l+2))&&(i.faceIndex=Math.floor(l/3),i.face.materialIndex=p.materialIndex,e.push(i));else for(c=Math.max(0,w.start),u=Math.min(g.count,w.start+w.count);c<u;c+=3)(i=Fn(this,r,t,gn,g,v,b,y,_,o=c,a=c+1,h=c+2))&&(i.faceIndex=Math.floor(c/3),e.push(i))}else if(n.isGeometry){var M,T,S,E,P=Array.isArray(r),A=n.vertices,C=n.faces,L=n.faceVertexUvs[0];L.length>0&&(E=L);for(var R=0,I=C.length;R<I;R++){var O=C[R],F=P?r[O.materialIndex]:r;if(void 0!==F&&(M=A[O.a],T=A[O.b],S=A[O.c],i=On(this,F,t,gn,M,T,S,Ln))){if(E&&E[R]){var B=E[R];Pn.copy(B[0]),An.copy(B[1]),Cn.copy(B[2]),i.uv=Bi.getUV(Ln,M,T,S,Pn,An,Cn,new ce)}i.face=O,i.faceIndex=R,e.push(i)}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Bn=0,Dn=new Le,zn=new Ye,Nn=new pe;function Un(){Object.defineProperty(this,"id",{value:Bn+=2}),this.uuid=he.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}Un.prototype=Object.assign(Object.create(se.prototype),{constructor:Un,isGeometry:!0,applyMatrix:function(t){for(var e=(new ge).getNormalMatrix(t),i=0,n=this.vertices.length;i<n;i++){this.vertices[i].applyMatrix4(t)}for(i=0,n=this.faces.length;i<n;i++){var r=this.faces[i];r.normal.applyMatrix3(e).normalize();for(var s=0,o=r.vertexNormals.length;s<o;s++)r.vertexNormals[s].applyMatrix3(e).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(t){return Dn.makeRotationX(t),this.applyMatrix(Dn),this},rotateY:function(t){return Dn.makeRotationY(t),this.applyMatrix(Dn),this},rotateZ:function(t){return Dn.makeRotationZ(t),this.applyMatrix(Dn),this},translate:function(t,e,i){return Dn.makeTranslation(t,e,i),this.applyMatrix(Dn),this},scale:function(t,e,i){return Dn.makeScale(t,e,i),this.applyMatrix(Dn),this},lookAt:function(t){return zn.lookAt(t),zn.updateMatrix(),this.applyMatrix(zn.matrix),this},fromBufferGeometry:function(t){var e=this,i=null!==t.index?t.index.array:void 0,n=t.attributes;if(void 0===n.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var r=n.position.array,s=void 0!==n.normal?n.normal.array:void 0,o=void 0!==n.color?n.color.array:void 0,a=void 0!==n.uv?n.uv.array:void 0,h=void 0!==n.uv2?n.uv2.array:void 0;void 0!==h&&(this.faceVertexUvs[1]=[]);for(var c=0;c<r.length;c+=3)e.vertices.push((new pe).fromArray(r,c)),void 0!==o&&e.colors.push((new Ui).fromArray(o,c));function l(t,i,n,r){var c=void 0===o?[]:[e.colors[t].clone(),e.colors[i].clone(),e.colors[n].clone()],l=new Hi(t,i,n,void 0===s?[]:[(new pe).fromArray(s,3*t),(new pe).fromArray(s,3*i),(new pe).fromArray(s,3*n)],c,r);e.faces.push(l),void 0!==a&&e.faceVertexUvs[0].push([(new ce).fromArray(a,2*t),(new ce).fromArray(a,2*i),(new ce).fromArray(a,2*n)]),void 0!==h&&e.faceVertexUvs[1].push([(new ce).fromArray(h,2*t),(new ce).fromArray(h,2*i),(new ce).fromArray(h,2*n)])}var u=t.groups;if(u.length>0)for(c=0;c<u.length;c++)for(var d=u[c],p=d.start,f=p,m=p+d.count;f<m;f+=3)void 0!==i?l(i[f],i[f+1],i[f+2],d.materialIndex):l(f,f+1,f+2,d.materialIndex);else if(void 0!==i)for(c=0;c<i.length;c+=3)l(i[c],i[c+1],i[c+2]);else for(c=0;c<r.length/3;c+=3)l(c,c+1,c+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Nn).negate(),this.translate(Nn.x,Nn.y,Nn.z),this},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,e=this.boundingSphere.radius,i=0===e?1:1/e,n=new Le;return n.set(i,0,0,-i*t.x,0,i,0,-i*t.y,0,0,i,-i*t.z,0,0,0,1),this.applyMatrix(n),this},computeFaceNormals:function(){for(var t=new pe,e=new pe,i=0,n=this.faces.length;i<n;i++){var r=this.faces[i],s=this.vertices[r.a],o=this.vertices[r.b],a=this.vertices[r.c];t.subVectors(a,o),e.subVectors(s,o),t.cross(e),t.normalize(),r.normal.copy(t)}},computeVertexNormals:function(t){var e,i,n,r,s,o;for(void 0===t&&(t=!0),o=new Array(this.vertices.length),e=0,i=this.vertices.length;e<i;e++)o[e]=new pe;if(t){var a,h,c,l=new pe,u=new pe;for(n=0,r=this.faces.length;n<r;n++)s=this.faces[n],a=this.vertices[s.a],h=this.vertices[s.b],c=this.vertices[s.c],l.subVectors(c,h),u.subVectors(a,h),l.cross(u),o[s.a].add(l),o[s.b].add(l),o[s.c].add(l)}else for(this.computeFaceNormals(),n=0,r=this.faces.length;n<r;n++)o[(s=this.faces[n]).a].add(s.normal),o[s.b].add(s.normal),o[s.c].add(s.normal);for(e=0,i=this.vertices.length;e<i;e++)o[e].normalize();for(n=0,r=this.faces.length;n<r;n++){var d=(s=this.faces[n]).vertexNormals;3===d.length?(d[0].copy(o[s.a]),d[1].copy(o[s.b]),d[2].copy(o[s.c])):(d[0]=o[s.a].clone(),d[1]=o[s.b].clone(),d[2]=o[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,i;for(this.computeFaceNormals(),t=0,e=this.faces.length;t<e;t++){var n=(i=this.faces[t]).vertexNormals;3===n.length?(n[0].copy(i.normal),n[1].copy(i.normal),n[2].copy(i.normal)):(n[0]=i.normal.clone(),n[1]=i.normal.clone(),n[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,i,n,r;for(i=0,n=this.faces.length;i<n;i++)for((r=this.faces[i]).__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]),t=0,e=r.vertexNormals.length;t<e;t++)r.__originalVertexNormals[t]?r.__originalVertexNormals[t].copy(r.vertexNormals[t]):r.__originalVertexNormals[t]=r.vertexNormals[t].clone();var s=new Un;for(s.faces=this.faces,t=0,e=this.morphTargets.length;t<e;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];var o=this.morphNormals[t].faceNormals,a=this.morphNormals[t].vertexNormals;for(i=0,n=this.faces.length;i<n;i++)h=new pe,c={a:new pe,b:new pe,c:new pe},o.push(h),a.push(c)}var h,c,l=this.morphNormals[t];for(s.vertices=this.morphTargets[t].vertices,s.computeFaceNormals(),s.computeVertexNormals(),i=0,n=this.faces.length;i<n;i++)r=this.faces[i],h=l.faceNormals[i],c=l.vertexNormals[i],h.copy(r.normal),c.a.copy(r.vertexNormals[0]),c.b.copy(r.vertexNormals[1]),c.c.copy(r.vertexNormals[2])}for(i=0,n=this.faces.length;i<n;i++)(r=this.faces[i]).normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new ci),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new di),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,i){if(t&&t.isGeometry){var n,r=this.vertices.length,s=this.vertices,o=t.vertices,a=this.faces,h=t.faces,c=this.colors,l=t.colors;void 0===i&&(i=0),void 0!==e&&(n=(new ge).getNormalMatrix(e));for(var u=0,d=o.length;u<d;u++){var p=o[u].clone();void 0!==e&&p.applyMatrix4(e),s.push(p)}for(u=0,d=l.length;u<d;u++)c.push(l[u].clone());for(u=0,d=h.length;u<d;u++){var f,m,g,v=h[u],b=v.vertexNormals,y=v.vertexColors;(f=new Hi(v.a+r,v.b+r,v.c+r)).normal.copy(v.normal),void 0!==n&&f.normal.applyMatrix3(n).normalize();for(var _=0,x=b.length;_<x;_++)m=b[_].clone(),void 0!==n&&m.applyMatrix3(n).normalize(),f.vertexNormals.push(m);f.color.copy(v.color);for(_=0,x=y.length;_<x;_++)g=y[_],f.vertexColors.push(g.clone());f.materialIndex=v.materialIndex+i,a.push(f)}for(u=0,d=t.faceVertexUvs.length;u<d;u++){var w=t.faceVertexUvs[u];void 0===this.faceVertexUvs[u]&&(this.faceVertexUvs[u]=[]);for(_=0,x=w.length;_<x;_++){for(var M=w[_],T=[],S=0,E=M.length;S<E;S++)T.push(M[S].clone());this.faceVertexUvs[u].push(T)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t)},mergeMesh:function(t){t&&t.isMesh?(t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t)},mergeVertices:function(){var t,e,i,n,r,s,o,a,h={},c=[],l=[],u=Math.pow(10,4);for(i=0,n=this.vertices.length;i<n;i++)t=this.vertices[i],void 0===h[e=Math.round(t.x*u)+"_"+Math.round(t.y*u)+"_"+Math.round(t.z*u)]?(h[e]=i,c.push(this.vertices[i]),l[i]=c.length-1):l[i]=l[h[e]];var d=[];for(i=0,n=this.faces.length;i<n;i++){(r=this.faces[i]).a=l[r.a],r.b=l[r.b],r.c=l[r.c],s=[r.a,r.b,r.c];for(var p=0;p<3;p++)if(s[p]===s[(p+1)%3]){d.push(i);break}}for(i=d.length-1;i>=0;i--){var f=d[i];for(this.faces.splice(f,1),o=0,a=this.faceVertexUvs.length;o<a;o++)this.faceVertexUvs[o].splice(f,1)}var m=this.vertices.length-c.length;return this.vertices=c,m},setFromPoints:function(t){this.vertices=[];for(var e=0,i=t.length;e<i;e++){var n=t[e];this.vertices.push(new pe(n.x,n.y,n.z||0))}return this},sortFacesByMaterialIndex:function(){for(var t=this.faces,e=t.length,i=0;i<e;i++)t[i]._id=i;t.sort((function(t,e){return t.materialIndex-e.materialIndex}));var n,r,s=this.faceVertexUvs[0],o=this.faceVertexUvs[1];s&&s.length===e&&(n=[]),o&&o.length===e&&(r=[]);for(i=0;i<e;i++){var a=t[i]._id;n&&n.push(s[a]),r&&r.push(o[a])}n&&(this.faceVertexUvs[0]=n),r&&(this.faceVertexUvs[1]=r)},toJSON:function(){var t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var i in e)void 0!==e[i]&&(t[i]=e[i]);return t}for(var n=[],r=0;r<this.vertices.length;r++){var s=this.vertices[r];n.push(s.x,s.y,s.z)}var o=[],a=[],h={},c=[],l={},u=[],d={};for(r=0;r<this.faces.length;r++){var p=this.faces[r],f=void 0!==this.faceVertexUvs[0][r],m=p.normal.length()>0,g=p.vertexNormals.length>0,v=1!==p.color.r||1!==p.color.g||1!==p.color.b,b=p.vertexColors.length>0,y=0;if(y=M(y,0,0),y=M(y,1,!0),y=M(y,2,!1),y=M(y,3,f),y=M(y,4,m),y=M(y,5,g),y=M(y,6,v),y=M(y,7,b),o.push(y),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var _=this.faceVertexUvs[0][r];o.push(E(_[0]),E(_[1]),E(_[2]))}if(m&&o.push(T(p.normal)),g){var x=p.vertexNormals;o.push(T(x[0]),T(x[1]),T(x[2]))}if(v&&o.push(S(p.color)),b){var w=p.vertexColors;o.push(S(w[0]),S(w[1]),S(w[2]))}}function M(t,e,i){return i?t|1<<e:t&~(1<<e)}function T(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==h[e]||(h[e]=a.length/3,a.push(t.x,t.y,t.z)),h[e]}function S(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==l[e]||(l[e]=c.length,c.push(t.getHex())),l[e]}function E(t){var e=t.x.toString()+t.y.toString();return void 0!==d[e]||(d[e]=u.length/2,u.push(t.x,t.y)),d[e]}return t.data={},t.data.vertices=n,t.data.normals=a,c.length>0&&(t.data.colors=c),u.length>0&&(t.data.uvs=[u]),t.data.faces=o,t},clone:function(){return(new Un).copy(this)},copy:function(t){var e,i,n,r,s,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var a=t.vertices;for(e=0,i=a.length;e<i;e++)this.vertices.push(a[e].clone());var h=t.colors;for(e=0,i=h.length;e<i;e++)this.colors.push(h[e].clone());var c=t.faces;for(e=0,i=c.length;e<i;e++)this.faces.push(c[e].clone());for(e=0,i=t.faceVertexUvs.length;e<i;e++){var l=t.faceVertexUvs[e];for(void 0===this.faceVertexUvs[e]&&(this.faceVertexUvs[e]=[]),n=0,r=l.length;n<r;n++){var u=l[n],d=[];for(s=0,o=u.length;s<o;s++){var p=u[s];d.push(p.clone())}this.faceVertexUvs[e].push(d)}}var f=t.morphTargets;for(e=0,i=f.length;e<i;e++){var m={};if(m.name=f[e].name,void 0!==f[e].vertices)for(m.vertices=[],n=0,r=f[e].vertices.length;n<r;n++)m.vertices.push(f[e].vertices[n].clone());if(void 0!==f[e].normals)for(m.normals=[],n=0,r=f[e].normals.length;n<r;n++)m.normals.push(f[e].normals[n].clone());this.morphTargets.push(m)}var g=t.morphNormals;for(e=0,i=g.length;e<i;e++){var v={};if(void 0!==g[e].vertexNormals)for(v.vertexNormals=[],n=0,r=g[e].vertexNormals.length;n<r;n++){var b=g[e].vertexNormals[n],y={};y.a=b.a.clone(),y.b=b.b.clone(),y.c=b.c.clone(),v.vertexNormals.push(y)}if(void 0!==g[e].faceNormals)for(v.faceNormals=[],n=0,r=g[e].faceNormals.length;n<r;n++)v.faceNormals.push(g[e].faceNormals[n].clone());this.morphNormals.push(v)}var _=t.skinWeights;for(e=0,i=_.length;e<i;e++)this.skinWeights.push(_[e].clone());var x=t.skinIndices;for(e=0,i=x.length;e<i;e++)this.skinIndices.push(x[e].clone());var w=t.lineDistances;for(e=0,i=w.length;e<i;e++)this.lineDistances.push(w[e]);var M=t.boundingBox;null!==M&&(this.boundingBox=M.clone());var T=t.boundingSphere;return null!==T&&(this.boundingSphere=T.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});class Vn extends Un{constructor(t,e,i,n,r,s){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s},this.fromBufferGeometry(new kn(t,e,i,n,r,s)),this.mergeVertices()}}class kn extends fn{constructor(t,e,i,n,r,s){super(),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};var o=this;t=t||1,e=e||1,i=i||1,n=Math.floor(n)||1,r=Math.floor(r)||1,s=Math.floor(s)||1;var a=[],h=[],c=[],l=[],u=0,d=0;function p(t,e,i,n,r,s,p,f,m,g,v){var b,y,_=s/m,x=p/g,w=s/2,M=p/2,T=f/2,S=m+1,E=g+1,P=0,A=0,C=new pe;for(y=0;y<E;y++){var L=y*x-M;for(b=0;b<S;b++){var R=b*_-w;C[t]=R*n,C[e]=L*r,C[i]=T,h.push(C.x,C.y,C.z),C[t]=0,C[e]=0,C[i]=f>0?1:-1,c.push(C.x,C.y,C.z),l.push(b/m),l.push(1-y/g),P+=1}}for(y=0;y<g;y++)for(b=0;b<m;b++){var I=u+b+S*y,O=u+b+S*(y+1),F=u+(b+1)+S*(y+1),B=u+(b+1)+S*y;a.push(I,O,B),a.push(O,F,B),A+=6}o.addGroup(d,A,v),d+=A,u+=P}p("z","y","x",-1,-1,i,e,t,s,r,0),p("z","y","x",1,-1,i,e,-t,s,r,1),p("x","z","y",1,1,t,i,e,n,s,2),p("x","z","y",1,-1,t,i,-e,n,s,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(a),this.setAttribute("position",new nn(h,3)),this.setAttribute("normal",new nn(c,3)),this.setAttribute("uv",new nn(l,2))}}function jn(t){var e={};for(var i in t)for(var n in e[i]={},t[i]){var r=t[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?e[i][n]=r.clone():Array.isArray(r)?e[i][n]=r.slice():e[i][n]=r}return e}function Hn(t){for(var e={},i=0;i<t.length;i++){var n=jn(t[i]);for(var r in n)e[r]=n[r]}return e}var Gn={clone:jn,merge:Hn};function Wn(t){Wi.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},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.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function qn(){Ye.call(this),this.type="Camera",this.matrixWorldInverse=new Le,this.projectionMatrix=new Le,this.projectionMatrixInverse=new Le}function Xn(t,e,i,n){qn.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==n?n:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Wn.prototype=Object.create(Wi.prototype),Wn.prototype.constructor=Wn,Wn.prototype.isShaderMaterial=!0,Wn.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=jn(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},Wn.prototype.toJSON=function(t){var e=Wi.prototype.toJSON.call(this,t);for(var i in e.uniforms={},this.uniforms){var n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var r={};for(var s in this.extensions)!0===this.extensions[s]&&(r[s]=!0);return Object.keys(r).length>0&&(e.extensions=r),e},qn.prototype=Object.assign(Object.create(Ye.prototype),{constructor:qn,isCamera:!0,copy:function(t,e){return Ye.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new pe),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){Ye.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),Xn.prototype=Object.assign(Object.create(qn.prototype),{constructor:Xn,isPerspectiveCamera:!0,copy:function(t,e){return qn.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*he.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*he.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*he.RAD2DEG*Math.atan(Math.tan(.5*he.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,i,n,r,s){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*he.DEG2RAD*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n,s=this.view;if(null!==this.view&&this.view.enabled){var o=s.fullWidth,a=s.fullHeight;r+=s.offsetX*n/o,e-=s.offsetY*i/a,n*=s.width/o,i*=s.height/a}var h=this.filmOffset;0!==h&&(r+=t*h/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=Ye.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});var Yn=90;function Zn(t,e,i,n){Ye.call(this),this.type="CubeCamera";var r=new Xn(Yn,1,t,e);r.up.set(0,-1,0),r.lookAt(new pe(1,0,0)),this.add(r);var s=new Xn(Yn,1,t,e);s.up.set(0,-1,0),s.lookAt(new pe(-1,0,0)),this.add(s);var o=new Xn(Yn,1,t,e);o.up.set(0,0,1),o.lookAt(new pe(0,1,0)),this.add(o);var a=new Xn(Yn,1,t,e);a.up.set(0,0,-1),a.lookAt(new pe(0,-1,0)),this.add(a);var h=new Xn(Yn,1,t,e);h.up.set(0,-1,0),h.lookAt(new pe(0,0,1)),this.add(h);var c=new Xn(Yn,1,t,e);c.up.set(0,-1,0),c.lookAt(new pe(0,0,-1)),this.add(c),n=n||{format:Ot,magFilter:yt,minFilter:yt},this.renderTarget=new $n(i,i,n),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var i=t.getRenderTarget(),n=this.renderTarget,l=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,r),t.setRenderTarget(n,1),t.render(e,s),t.setRenderTarget(n,2),t.render(e,o),t.setRenderTarget(n,3),t.render(e,a),t.setRenderTarget(n,4),t.render(e,h),n.texture.generateMipmaps=l,t.setRenderTarget(n,5),t.render(e,c),t.setRenderTarget(i)},this.clear=function(t,e,i,n){for(var r=t.getRenderTarget(),s=this.renderTarget,o=0;o<6;o++)t.setRenderTarget(s,o),t.clear(e,i,n);t.setRenderTarget(r)}}function $n(t,e,i){xe.call(this,t,e,i)}function Jn(t,e,i,n,r,s,o,a,h,c,l,u){ye.call(this,null,s,o,a,h,c,n,r,l,u),this.image={data:t||null,width:e||1,height:i||1},this.magFilter=void 0!==h?h:ft,this.minFilter=void 0!==c?c:ft,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Zn.prototype=Object.create(Ye.prototype),Zn.prototype.constructor=Zn,$n.prototype=Object.create(xe.prototype),$n.prototype.constructor=$n,$n.prototype.isWebGLRenderTargetCube=!0,$n.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=e.format,this.texture.encoding=e.encoding;var i=new Ze,n={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include <begin_vertex>","\t#include <project_vertex>","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},r=new Wn({type:"CubemapFromEquirect",uniforms:jn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;var s=new In(new kn(5,5,5),r);i.add(s);var o=new Zn(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(t,i),s.geometry.dispose(),s.material.dispose(),this},Jn.prototype=Object.create(ye.prototype),Jn.prototype.constructor=Jn,Jn.prototype.isDataTexture=!0;var Qn=new di,Kn=new pe;function tr(t,e,i,n,r,s){this.planes=[void 0!==t?t:new Ti,void 0!==e?e:new Ti,void 0!==i?i:new Ti,void 0!==n?n:new Ti,void 0!==r?r:new Ti,void 0!==s?s:new Ti]}Object.assign(tr.prototype,{set:function(t,e,i,n,r,s){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(s),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,i=0;i<6;i++)e[i].copy(t.planes[i]);return this},setFromMatrix:function(t){var e=this.planes,i=t.elements,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],h=i[5],c=i[6],l=i[7],u=i[8],d=i[9],p=i[10],f=i[11],m=i[12],g=i[13],v=i[14],b=i[15];return e[0].setComponents(o-n,l-a,f-u,b-m).normalize(),e[1].setComponents(o+n,l+a,f+u,b+m).normalize(),e[2].setComponents(o+r,l+h,f+d,b+g).normalize(),e[3].setComponents(o-r,l-h,f-d,b-g).normalize(),e[4].setComponents(o-s,l-c,f-p,b-v).normalize(),e[5].setComponents(o+s,l+c,f+p,b+v).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),Qn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Qn)},intersectsSprite:function(t){return Qn.center.set(0,0,0),Qn.radius=.7071067811865476,Qn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Qn)},intersectsSphere:function(t){for(var e=this.planes,i=t.center,n=-t.radius,r=0;r<6;r++){if(e[r].distanceToPoint(i)<n)return!1}return!0},intersectsBox:function(t){for(var e=this.planes,i=0;i<6;i++){var n=e[i];if(Kn.x=n.normal.x>0?t.max.x:t.min.x,Kn.y=n.normal.y>0?t.max.y:t.min.y,Kn.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Kn)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}});var er={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).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.specularRoughness );\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:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\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\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_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}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * 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}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat 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_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha  = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\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( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\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\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\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; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\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 max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\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 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}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\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 linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n  return m[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n    vec3 absDirection = abs(direction);\n    float face = -1.0;\n    if (absDirection.x > absDirection.z) {\n      if (absDirection.x > absDirection.y)\n        face = direction.x > 0.0 ? 0.0 : 3.0;\n      else\n        face = direction.y > 0.0 ? 1.0 : 4.0;\n    } else {\n      if (absDirection.z > absDirection.y)\n        face = direction.z > 0.0 ? 2.0 : 5.0;\n      else\n        face = direction.y > 0.0 ? 1.0 : 4.0;\n    }\n    return face;\n}\nvec2 getUV(vec3 direction, float face) {\n    vec2 uv;\n    if (face == 0.0) {\n      uv = vec2(-direction.z, direction.y) / abs(direction.x);\n    } else if (face == 1.0) {\n      uv = vec2(direction.x, -direction.z) / abs(direction.y);\n    } else if (face == 2.0) {\n      uv = direction.xy / abs(direction.z);\n    } else if (face == 3.0) {\n      uv = vec2(direction.z, direction.y) / abs(direction.x);\n    } else if (face == 4.0) {\n      uv = direction.xz / abs(direction.y);\n    } else {\n      uv = vec2(-direction.x, direction.y) / abs(direction.z);\n    }\n    return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n  float face = getFace(direction);\n  float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n  mipInt = max(mipInt, cubeUV_minMipLevel);\n  float faceSize = exp2(mipInt);\n  float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n  vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n  vec2 f = fract(uv);\n  uv += 0.5 - f;\n  if (face > 2.0) {\n    uv.y += faceSize;\n    face -= 3.0;\n  }\n  uv.x += face * faceSize;\n  if(mipInt < cubeUV_maxMipLevel){\n    uv.y += 2.0 * cubeUV_maxTileSize;\n  }\n  uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n  uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n  uv *= texelSize;\n  vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  uv.x += texelSize;\n  vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  uv.y += texelSize;\n  vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  uv.x -= texelSize;\n  vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  vec3 tm = mix(tl, tr, f.x);\n  vec3 bm = mix(bl, br, f.x);\n  return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n  float mip = 0.0;\n  if (roughness >= r1) {\n    mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n  } else if (roughness >= r4) {\n    mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n  } else if (roughness >= r5) {\n    mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n  } else if (roughness >= r6) {\n    mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n  } else {\n    mip = -2.0 * log2(1.16 * roughness);  }\n  return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n  float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n  float mipF = fract(mip);\n  float mipInt = floor(mip);\n  vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n  if (mipF == 0.0) {\n    return vec4(color0, 1.0);\n  } else {\n    vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n    return vec4(mix(color0, color1, mipF), 1.0);\n  }\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * 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, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\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:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\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}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value )  {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\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#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ), 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\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\tuniform int maxMipLevel;\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 )\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 )\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:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t  vec3 reflectVec = reflect( -viewDir, normal );\n\t\t  reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t  vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\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\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\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 fogDepth;\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 texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",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 GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.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\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.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 GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\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\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\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_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",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;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\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\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, 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_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",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.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\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.specularRoughness;\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#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_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_Diffuse_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 CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * 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 CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\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#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\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, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\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\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\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, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).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 * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",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}\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 linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - 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, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#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#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ 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#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 texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\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\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\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 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\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\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:"#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#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ 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#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\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\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\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\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\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, vUv );\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;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\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 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\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_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",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}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\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}",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 <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\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\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\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>\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}",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 <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}",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}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\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}",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 <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 <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_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 <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_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 <cube_uv_reflection_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\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_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 <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\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 <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_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 <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_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 <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\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 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_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 <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_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 <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\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_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 <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\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\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\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 <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_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 <lights_toon_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_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 + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\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#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_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 <uv2_vertex>\n\t#include <color_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#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#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\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_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 <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_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 <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\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}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_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 <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_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#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#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\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#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\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\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 <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_normalmap_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 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\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#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\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_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 <uv2_vertex>\n\t#include <color_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#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\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}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#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\n#include <packing>\n#include <uv_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}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#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\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 <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#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\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( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\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 <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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_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>\nvoid main() {\n\t#include <color_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}",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 <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_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 <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\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\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}"},ir={common:{diffuse:{value:new Ui(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new ge},uv2Transform:{value:new ge},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ui(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new Ui(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new ge}},sprite:{diffuse:{value:new Ui(15658734)},opacity:{value:1},center:{value:new ce(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new ge}}},nr={basic:{uniforms:Hn([ir.common,ir.specularmap,ir.envmap,ir.aomap,ir.lightmap,ir.fog]),vertexShader:er.meshbasic_vert,fragmentShader:er.meshbasic_frag},lambert:{uniforms:Hn([ir.common,ir.specularmap,ir.envmap,ir.aomap,ir.lightmap,ir.emissivemap,ir.fog,ir.lights,{emissive:{value:new Ui(0)}}]),vertexShader:er.meshlambert_vert,fragmentShader:er.meshlambert_frag},phong:{uniforms:Hn([ir.common,ir.specularmap,ir.envmap,ir.aomap,ir.lightmap,ir.emissivemap,ir.bumpmap,ir.normalmap,ir.displacementmap,ir.fog,ir.lights,{emissive:{value:new Ui(0)},specular:{value:new Ui(1118481)},shininess:{value:30}}]),vertexShader:er.meshphong_vert,fragmentShader:er.meshphong_frag},standard:{uniforms:Hn([ir.common,ir.envmap,ir.aomap,ir.lightmap,ir.emissivemap,ir.bumpmap,ir.normalmap,ir.displacementmap,ir.roughnessmap,ir.metalnessmap,ir.fog,ir.lights,{emissive:{value:new Ui(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:er.meshphysical_vert,fragmentShader:er.meshphysical_frag},toon:{uniforms:Hn([ir.common,ir.specularmap,ir.aomap,ir.lightmap,ir.emissivemap,ir.bumpmap,ir.normalmap,ir.displacementmap,ir.gradientmap,ir.fog,ir.lights,{emissive:{value:new Ui(0)},specular:{value:new Ui(1118481)},shininess:{value:30}}]),vertexShader:er.meshtoon_vert,fragmentShader:er.meshtoon_frag},matcap:{uniforms:Hn([ir.common,ir.bumpmap,ir.normalmap,ir.displacementmap,ir.fog,{matcap:{value:null}}]),vertexShader:er.meshmatcap_vert,fragmentShader:er.meshmatcap_frag},points:{uniforms:Hn([ir.points,ir.fog]),vertexShader:er.points_vert,fragmentShader:er.points_frag},dashed:{uniforms:Hn([ir.common,ir.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:er.linedashed_vert,fragmentShader:er.linedashed_frag},depth:{uniforms:Hn([ir.common,ir.displacementmap]),vertexShader:er.depth_vert,fragmentShader:er.depth_frag},normal:{uniforms:Hn([ir.common,ir.bumpmap,ir.normalmap,ir.displacementmap,{opacity:{value:1}}]),vertexShader:er.normal_vert,fragmentShader:er.normal_frag},sprite:{uniforms:Hn([ir.sprite,ir.fog]),vertexShader:er.sprite_vert,fragmentShader:er.sprite_frag},background:{uniforms:{uvTransform:{value:new ge},t2D:{value:null}},vertexShader:er.background_vert,fragmentShader:er.background_frag},cube:{uniforms:Hn([ir.envmap,{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:Hn([ir.common,ir.displacementmap,{referencePosition:{value:new pe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:er.distanceRGBA_vert,fragmentShader:er.distanceRGBA_frag},shadow:{uniforms:Hn([ir.lights,ir.fog,{color:{value:new Ui(0)},opacity:{value:1}}]),vertexShader:er.shadow_vert,fragmentShader:er.shadow_frag}};function rr(){var t=null,e=!1,i=null;function n(r,s){!1!==e&&(i(r,s),t.requestAnimationFrame(n))}return{start:function(){!0!==e&&null!==i&&(t.requestAnimationFrame(n),e=!0)},stop:function(){e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function sr(t){var e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);var n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){i.isInterleavedBufferAttribute&&(i=i.data);var r=e.get(i);void 0===r?e.set(i,function(e,i){var n=e.array,r=e.usage,s=t.createBuffer();t.bindBuffer(i,s),t.bufferData(i,n,r),e.onUploadCallback();var o=5126;return n instanceof Float32Array?o=5126:n instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):n instanceof Uint16Array?o=5123:n instanceof Int16Array?o=5122:n instanceof Uint32Array?o=5125:n instanceof Int32Array?o=5124:n instanceof Int8Array?o=5120:n instanceof Uint8Array&&(o=5121),{buffer:s,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version}}(i,n)):r.version<i.version&&(!function(e,i,n){var r=i.array,s=i.updateRange;t.bindBuffer(n,e),-1===s.count?t.bufferSubData(n,0,r):(t.bufferSubData(n,s.offset*r.BYTES_PER_ELEMENT,r.subarray(s.offset,s.offset+s.count)),s.count=-1)}(r.buffer,i,n),r.version=i.version)}}}function or(t,e,i,n){Un.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n},this.fromBufferGeometry(new ar(t,e,i,n)),this.mergeVertices()}function ar(t,e,i,n){fn.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};var r,s,o=(t=t||1)/2,a=(e=e||1)/2,h=Math.floor(i)||1,c=Math.floor(n)||1,l=h+1,u=c+1,d=t/h,p=e/c,f=[],m=[],g=[],v=[];for(s=0;s<u;s++){var b=s*p-a;for(r=0;r<l;r++){var y=r*d-o;m.push(y,-b,0),g.push(0,0,1),v.push(r/h),v.push(1-s/c)}}for(s=0;s<c;s++)for(r=0;r<h;r++){var _=r+l*s,x=r+l*(s+1),w=r+1+l*(s+1),M=r+1+l*s;f.push(_,x,M),f.push(x,w,M)}this.setIndex(f),this.setAttribute("position",new nn(m,3)),this.setAttribute("normal",new nn(g,3)),this.setAttribute("uv",new nn(v,2))}function hr(t,e,i,n){var r,s,o=new Ui(0),a=0,h=null,c=0;function l(t,i){e.buffers.color.setClear(t.r,t.g,t.b,i,n)}return{getClearColor:function(){return o},setClearColor:function(t,e){o.set(t),l(o,a=void 0!==e?e:1)},getClearAlpha:function(){return a},setClearAlpha:function(t){l(o,a=t)},render:function(e,n,u,d){var p=n.background,f=t.xr,m=f.getSession&&f.getSession();if(m&&"additive"===m.environmentBlendMode&&(p=null),null===p?(l(o,a),h=null,c=0):p&&p.isColor&&(l(p,1),d=!0,h=null,c=0),(t.autoClear||d)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),p&&(p.isCubeTexture||p.isWebGLRenderTargetCube||p.mapping===lt)){void 0===s&&((s=new In(new kn(1,1,1),new Wn({type:"BackgroundCubeMaterial",uniforms:jn(nr.cube.uniforms),vertexShader:nr.cube.vertexShader,fragmentShader:nr.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s));var g=p.isWebGLRenderTargetCube?p.texture:p;s.material.uniforms.envMap.value=g,s.material.uniforms.flipEnvMap.value=g.isCubeTexture?-1:1,h===p&&c===g.version||(s.material.needsUpdate=!0,h=p,c=g.version),e.unshift(s,s.geometry,s.material,0,0,null)}else p&&p.isTexture&&(void 0===r&&((r=new In(new ar(2,2),new Wn({type:"BackgroundMaterial",uniforms:jn(nr.background.uniforms),vertexShader:nr.background.vertexShader,fragmentShader:nr.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(r.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(r)),r.material.uniforms.t2D.value=p,!0===p.matrixAutoUpdate&&p.updateMatrix(),r.material.uniforms.uvTransform.value.copy(p.matrix),h===p&&c===p.version||(r.material.needsUpdate=!0,h=p,c=p.version),e.unshift(r,r.geometry,r.material,0,0,null))}}}function cr(t,e,i,n){var r,s=n.isWebGL2;this.setMode=function(t){r=t},this.render=function(e,n){t.drawArrays(r,e,n),i.update(n,r)},this.renderInstances=function(n,o,a,h){if(0!==h){var c,l;if(s)c=t,l="drawArraysInstanced";else if(l="drawArraysInstancedANGLE",null===(c=e.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[l](r,o,a,h),i.update(a,r,h)}}}function lr(t,e,i){var n;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var s="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==i.precision?i.precision:"highp",a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var h=!0===i.logarithmicDepthBuffer,c=t.getParameter(34930),l=t.getParameter(35660),u=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),g=t.getParameter(36349),v=l>0,b=s||!!e.get("OES_texture_float");return{isWebGL2:s,getMaxAnisotropy:function(){if(void 0!==n)return n;var i=e.get("EXT_texture_filter_anisotropic");return n=null!==i?t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:b,floatVertexTextures:v&&b,maxSamples:s?t.getParameter(36183):0}}function ur(){var t=this,e=null,i=0,n=!1,r=!1,s=new Ti,o=new ge,a={value:null,needsUpdate:!1};function h(){a.value!==e&&(a.value=e,a.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function c(e,i,n,r){var h=null!==e?e.length:0,c=null;if(0!==h){if(c=a.value,!0!==r||null===c){var l=n+4*h,u=i.matrixWorldInverse;o.getNormalMatrix(u),(null===c||c.length<l)&&(c=new Float32Array(l));for(var d=0,p=n;d!==h;++d,p+=4)s.copy(e[d]).applyMatrix4(u,o),s.normal.toArray(c,p),c[p+3]=s.constant}a.value=c,a.needsUpdate=!0}return t.numPlanes=h,c}this.uniform=a,this.numPlanes=0,this.numIntersection=0,this.init=function(t,r,s){var o=0!==t.length||r||0!==i||n;return n=r,e=c(t,s,0),i=t.length,o},this.beginShadows=function(){r=!0,c(null)},this.endShadows=function(){r=!1,h()},this.setState=function(t,s,o,l,u,d){if(!n||null===t||0===t.length||r&&!o)r?c(null):h();else{var p=r?0:i,f=4*p,m=u.clippingState||null;a.value=m,m=c(t,l,f,d);for(var g=0;g!==f;++g)m[g]=e[g];u.clippingState=m,this.numIntersection=s?this.numPlanes:0,this.numPlanes+=p}}}function dr(t){var e={};return{get:function(i){if(void 0!==e[i])return e[i];var n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return null===n&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),e[i]=n,n}}}function pr(t,e,i){var n=new WeakMap,r=new WeakMap;function s(t){var o=t.target,a=n.get(o);for(var h in null!==a.index&&e.remove(a.index),a.attributes)e.remove(a.attributes[h]);o.removeEventListener("dispose",s),n.delete(o);var c=r.get(a);c&&(e.remove(c),r.delete(a)),i.memory.geometries--}function o(t){var i=[],n=t.index,s=t.attributes.position,o=0;if(null!==n){var a=n.array;o=n.version;for(var h=0,c=a.length;h<c;h+=3){var l=a[h+0],u=a[h+1],d=a[h+2];i.push(l,u,u,d,d,l)}}else{a=s.array;o=s.version;for(h=0,c=a.length/3-1;h<c;h+=3){l=h+0,u=h+1,d=h+2;i.push(l,u,u,d,d,l)}}var p=new(on(i)>65535?en:Ki)(i,1);p.version=o,e.update(p,34963);var f=r.get(t);f&&e.remove(f),r.set(t,p)}return{get:function(t,e){var r=n.get(e);return r||(e.addEventListener("dispose",s),e.isBufferGeometry?r=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new fn).setFromObject(t)),r=e._bufferGeometry),n.set(e,r),i.memory.geometries++,r)},update:function(t){var i=t.index,n=t.attributes;for(var r in null!==i&&e.update(i,34963),n)e.update(n[r],34962);var s=t.morphAttributes;for(var r in s)for(var o=s[r],a=0,h=o.length;a<h;a++)e.update(o[a],34962)},getWireframeAttribute:function(t){var e=r.get(t);if(e){var i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return r.get(t)}}}function fr(t,e,i,n){var r,s,o,a=n.isWebGL2;this.setMode=function(t){r=t},this.setIndex=function(t){s=t.type,o=t.bytesPerElement},this.render=function(e,n){t.drawElements(r,n,s,e*o),i.update(n,r)},this.renderInstances=function(n,h,c,l){if(0!==l){var u,d;if(a)u=t,d="drawElementsInstanced";else if(d="drawElementsInstancedANGLE",null===(u=e.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[d](r,c,s,h*o,l),i.update(c,r,l)}}}function mr(t){var e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,i,n){switch(n=n||1,e.calls++,i){case 4:e.triangles+=n*(t/3);break;case 1:e.lines+=n*(t/2);break;case 3:e.lines+=n*(t-1);break;case 2:e.lines+=n*t;break;case 0:e.points+=n*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function gr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function vr(t){var e={},i=new Float32Array(8);return{update:function(n,r,s,o){var a=n.morphTargetInfluences,h=void 0===a?0:a.length,c=e[r.id];if(void 0===c){c=[];for(var l=0;l<h;l++)c[l]=[l,0];e[r.id]=c}var u=s.morphTargets&&r.morphAttributes.position,d=s.morphNormals&&r.morphAttributes.normal;for(l=0;l<h;l++){0!==(f=c[l])[1]&&(u&&r.deleteAttribute("morphTarget"+l),d&&r.deleteAttribute("morphNormal"+l))}for(l=0;l<h;l++){(f=c[l])[0]=l,f[1]=a[l]}c.sort(gr);var p=0;for(l=0;l<8;l++){var f;if(f=c[l]){var m=f[0],g=f[1];if(g){u&&r.setAttribute("morphTarget"+l,u[m]),d&&r.setAttribute("morphNormal"+l,d[m]),i[l]=g,p+=g;continue}}i[l]=0}var v=r.morphTargetsRelative?1:1-p;o.getUniforms().setValue(t,"morphTargetBaseInfluence",v),o.getUniforms().setValue(t,"morphTargetInfluences",i)}}}function br(t,e,i,n){var r={};return{update:function(t){var s=n.render.frame,o=t.geometry,a=e.get(t,o);return r[a.id]!==s&&(o.isGeometry&&a.updateFromObject(t),e.update(a),r[a.id]=s),t.isInstancedMesh&&i.update(t.instanceMatrix,34962),a},dispose:function(){r={}}}}function yr(t,e,i,n,r,s,o,a,h,c){t=void 0!==t?t:[],e=void 0!==e?e:301,o=void 0!==o?o:Ot,ye.call(this,t,e,i,n,r,s,o,a,h,c),this.flipY=!1}function _r(t,e,i,n){ye.call(this,null),this.image={data:t||null,width:e||1,height:i||1,depth:n||1},this.magFilter=ft,this.minFilter=ft,this.wrapR=dt,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function xr(t,e,i,n){ye.call(this,null),this.image={data:t||null,width:e||1,height:i||1,depth:n||1},this.magFilter=ft,this.minFilter=ft,this.wrapR=dt,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}nr.physical={uniforms:Hn([nr.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new Ui(0)},clearcoatNormalScale:{value:new ce(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:er.meshphysical_vert,fragmentShader:er.meshphysical_frag},or.prototype=Object.create(Un.prototype),or.prototype.constructor=or,ar.prototype=Object.create(fn.prototype),ar.prototype.constructor=ar,yr.prototype=Object.create(ye.prototype),yr.prototype.constructor=yr,yr.prototype.isCubeTexture=!0,Object.defineProperty(yr.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}}),_r.prototype=Object.create(ye.prototype),_r.prototype.constructor=_r,_r.prototype.isDataTexture2DArray=!0,xr.prototype=Object.create(ye.prototype),xr.prototype.constructor=xr,xr.prototype.isDataTexture3D=!0;var wr=new ye,Mr=new _r,Tr=new xr,Sr=new yr,Er=[],Pr=[],Ar=new Float32Array(16),Cr=new Float32Array(9),Lr=new Float32Array(4);function Rr(t,e,i){var n=t[0];if(n<=0||n>0)return t;var r=e*i,s=Er[r];if(void 0===s&&(s=new Float32Array(r),Er[r]=s),0!==e){n.toArray(s,0);for(var o=1,a=0;o!==e;++o)a+=i,t[o].toArray(s,a)}return s}function Ir(t,e){if(t.length!==e.length)return!1;for(var i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Or(t,e){for(var i=0,n=e.length;i<n;i++)t[i]=e[i]}function Fr(t,e){var i=Pr[e];void 0===i&&(i=new Int32Array(e),Pr[e]=i);for(var n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Br(t,e){var i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Dr(t,e){var i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Ir(i,e))return;t.uniform2fv(this.addr,e),Or(i,e)}}function zr(t,e){var i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Ir(i,e))return;t.uniform3fv(this.addr,e),Or(i,e)}}function Nr(t,e){var i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Ir(i,e))return;t.uniform4fv(this.addr,e),Or(i,e)}}function Ur(t,e){var i=this.cache,n=e.elements;if(void 0===n){if(Ir(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Or(i,e)}else{if(Ir(i,n))return;Lr.set(n),t.uniformMatrix2fv(this.addr,!1,Lr),Or(i,n)}}function Vr(t,e){var i=this.cache,n=e.elements;if(void 0===n){if(Ir(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Or(i,e)}else{if(Ir(i,n))return;Cr.set(n),t.uniformMatrix3fv(this.addr,!1,Cr),Or(i,n)}}function kr(t,e){var i=this.cache,n=e.elements;if(void 0===n){if(Ir(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Or(i,e)}else{if(Ir(i,n))return;Ar.set(n),t.uniformMatrix4fv(this.addr,!1,Ar),Or(i,n)}}function jr(t,e,i){var n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(e||wr,r)}function Hr(t,e,i){var n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||Mr,r)}function Gr(t,e,i){var n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||Tr,r)}function Wr(t,e,i){var n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(e||Sr,r)}function qr(t,e){var i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function Xr(t,e){var i=this.cache;Ir(i,e)||(t.uniform2iv(this.addr,e),Or(i,e))}function Yr(t,e){var i=this.cache;Ir(i,e)||(t.uniform3iv(this.addr,e),Or(i,e))}function Zr(t,e){var i=this.cache;Ir(i,e)||(t.uniform4iv(this.addr,e),Or(i,e))}function $r(t,e){t.uniform1fv(this.addr,e)}function Jr(t,e){t.uniform1iv(this.addr,e)}function Qr(t,e){t.uniform2iv(this.addr,e)}function Kr(t,e){t.uniform3iv(this.addr,e)}function ts(t,e){t.uniform4iv(this.addr,e)}function es(t,e){var i=Rr(e,this.size,2);t.uniform2fv(this.addr,i)}function is(t,e){var i=Rr(e,this.size,3);t.uniform3fv(this.addr,i)}function ns(t,e){var i=Rr(e,this.size,4);t.uniform4fv(this.addr,i)}function rs(t,e){var i=Rr(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function ss(t,e){var i=Rr(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function os(t,e){var i=Rr(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function as(t,e,i){var n=e.length,r=Fr(i,n);t.uniform1iv(this.addr,r);for(var s=0;s!==n;++s)i.safeSetTexture2D(e[s]||wr,r[s])}function hs(t,e,i){var n=e.length,r=Fr(i,n);t.uniform1iv(this.addr,r);for(var s=0;s!==n;++s)i.safeSetTextureCube(e[s]||Sr,r[s])}function cs(t,e,i){this.id=t,this.addr=i,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Br;case 35664:return Dr;case 35665:return zr;case 35666:return Nr;case 35674:return Ur;case 35675:return Vr;case 35676:return kr;case 35678:case 36198:return jr;case 35679:return Gr;case 35680:return Wr;case 36289:return Hr;case 5124:case 35670:return qr;case 35667:case 35671:return Xr;case 35668:case 35672:return Yr;case 35669:case 35673:return Zr}}(e.type)}function ls(t,e,i){this.id=t,this.addr=i,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return $r;case 35664:return es;case 35665:return is;case 35666:return ns;case 35674:return rs;case 35675:return ss;case 35676:return os;case 35678:case 36198:case 36298:case 36306:return as;case 35680:case 36300:case 36308:return hs;case 5124:case 35670:return Jr;case 35667:case 35671:return Qr;case 35668:case 35672:return Kr;case 35669:case 35673:return ts}}(e.type)}function us(t){this.id=t,this.seq=[],this.map={}}ls.prototype.updateCache=function(t){var e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),Or(e,t)},us.prototype.setValue=function(t,e,i){for(var n=this.seq,r=0,s=n.length;r!==s;++r){var o=n[r];o.setValue(t,e[o.id],i)}};var ds=/([\w\d_]+)(\])?(\[|\.)?/g;function ps(t,e){t.seq.push(e),t.map[e.id]=e}function fs(t,e,i){var n=t.name,r=n.length;for(ds.lastIndex=0;;){var s=ds.exec(n),o=ds.lastIndex,a=s[1],h="]"===s[2],c=s[3];if(h&&(a|=0),void 0===c||"["===c&&o+2===r){ps(i,void 0===c?new cs(a,t,e):new ls(a,t,e));break}var l=i.map[a];void 0===l&&ps(i,l=new us(a)),i=l}}function ms(t,e){this.seq=[],this.map={};for(var i=t.getProgramParameter(e,35718),n=0;n<i;++n){var r=t.getActiveUniform(e,n);fs(r,t.getUniformLocation(e,r.name),this)}}function gs(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}ms.prototype.setValue=function(t,e,i,n){var r=this.map[e];void 0!==r&&r.setValue(t,i,n)},ms.prototype.setOptional=function(t,e,i){var n=e[i];void 0!==n&&this.setValue(t,i,n)},ms.upload=function(t,e,i,n){for(var r=0,s=e.length;r!==s;++r){var o=e[r],a=i[o.id];!1!==a.needsUpdate&&o.setValue(t,a.value,n)}},ms.seqWithValue=function(t,e){for(var i=[],n=0,r=t.length;n!==r;++n){var s=t[n];s.id in e&&i.push(s)}return i};var vs=0;function bs(t){switch(t){case Kt:return["Linear","( value )"];case te:return["sRGB","( value )"];case ee:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:throw new Error("unsupported encoding: "+t)}}function ys(t,e,i){var n=t.getShaderParameter(e,35713),r=t.getShaderInfoLog(e).trim();return n&&""===r?"":"THREE.WebGLShader: gl.getShaderInfoLog() "+i+"\n"+r+function(t){for(var e=t.split("\n"),i=0;i<e.length;i++)e[i]=i+1+": "+e[i];return e.join("\n")}(t.getShaderSource(e))}function _s(t,e){var i=bs(e);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function xs(t,e){var i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="Uncharted2";break;case 4:i="OptimizedCineon";break;case 5:i="ACESFilmic";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function ws(t){return""!==t}function Ms(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ts(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Ss=/^[ \t]*#include +<([\w\d./]+)>/gm;function Es(t){return t.replace(Ss,Ps)}function Ps(t,e){var i=er[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return Es(i)}var As=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Cs(t){return t.replace(As,Ls)}function Ls(t,e,i,n){for(var r="",s=parseInt(e);s<parseInt(i);s++)r+=n.replace(/\[ i \]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Rs(t){var e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Is(t,e,i,n,r,s){var o,a,h,c,l,u=t.getContext(),d=n.defines,p=r.vertexShader,f=r.fragmentShader,m=function(t){var e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(s),g=function(t){var e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case 301:case 302:e="ENVMAP_TYPE_CUBE";break;case lt:case 307:e="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:e="ENVMAP_TYPE_EQUIREC";break;case 305:e="ENVMAP_TYPE_SPHERE"}return e}(s),v=function(t){var e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case 302:case 304:e="ENVMAP_MODE_REFRACTION"}return e}(s),b=function(t){var e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(s),y=t.gammaFactor>0?t.gammaFactor:1,_=s.isWebGL2?"":function(t,e,i){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ws).join("\n")}(n.extensions,s,e),x=function(t){var e=[];for(var i in t){var n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(d),w=u.createProgram(),M=s.numMultiviewViews;if(n.isRawShaderMaterial?((o=[x].filter(ws).join("\n")).length>0&&(o+="\n"),(a=[_,x].filter(ws).join("\n")).length>0&&(a+="\n")):(o=[Rs(s),"#define SHADER_NAME "+r.name,x,s.instancing?"#define USE_INSTANCING":"",s.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+y,"#define MAX_BONES "+s.maxBones,s.useFog&&s.fog?"#define USE_FOG":"",s.useFog&&s.fogExp2?"#define FOG_EXP2":"",s.map?"#define USE_MAP":"",s.envMap?"#define USE_ENVMAP":"",s.envMap?"#define "+v:"",s.lightMap?"#define USE_LIGHTMAP":"",s.aoMap?"#define USE_AOMAP":"",s.emissiveMap?"#define USE_EMISSIVEMAP":"",s.bumpMap?"#define USE_BUMPMAP":"",s.normalMap?"#define USE_NORMALMAP":"",s.normalMap&&s.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",s.normalMap&&s.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",s.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",s.displacementMap&&s.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",s.specularMap?"#define USE_SPECULARMAP":"",s.roughnessMap?"#define USE_ROUGHNESSMAP":"",s.metalnessMap?"#define USE_METALNESSMAP":"",s.alphaMap?"#define USE_ALPHAMAP":"",s.vertexTangents?"#define USE_TANGENT":"",s.vertexColors?"#define USE_COLOR":"",s.vertexUvs?"#define USE_UV":"",s.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",s.flatShading?"#define FLAT_SHADED":"",s.skinning?"#define USE_SKINNING":"",s.useVertexTexture?"#define BONE_TEXTURE":"",s.morphTargets?"#define USE_MORPHTARGETS":"",s.morphNormals&&!1===s.flatShading?"#define USE_MORPHNORMALS":"",s.doubleSided?"#define DOUBLE_SIDED":"",s.flipSided?"#define FLIP_SIDED":"",s.shadowMapEnabled?"#define USE_SHADOWMAP":"",s.shadowMapEnabled?"#define "+m:"",s.sizeAttenuation?"#define USE_SIZEATTENUATION":"",s.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",s.logarithmicDepthBuffer&&(s.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\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(ws).join("\n"),a=[_,Rs(s),"#define SHADER_NAME "+r.name,x,s.alphaTest?"#define ALPHATEST "+s.alphaTest+(s.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+y,s.useFog&&s.fog?"#define USE_FOG":"",s.useFog&&s.fogExp2?"#define FOG_EXP2":"",s.map?"#define USE_MAP":"",s.matcap?"#define USE_MATCAP":"",s.envMap?"#define USE_ENVMAP":"",s.envMap?"#define "+g:"",s.envMap?"#define "+v:"",s.envMap?"#define "+b:"",s.lightMap?"#define USE_LIGHTMAP":"",s.aoMap?"#define USE_AOMAP":"",s.emissiveMap?"#define USE_EMISSIVEMAP":"",s.bumpMap?"#define USE_BUMPMAP":"",s.normalMap?"#define USE_NORMALMAP":"",s.normalMap&&s.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",s.normalMap&&s.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",s.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",s.specularMap?"#define USE_SPECULARMAP":"",s.roughnessMap?"#define USE_ROUGHNESSMAP":"",s.metalnessMap?"#define USE_METALNESSMAP":"",s.alphaMap?"#define USE_ALPHAMAP":"",s.sheen?"#define USE_SHEEN":"",s.vertexTangents?"#define USE_TANGENT":"",s.vertexColors?"#define USE_COLOR":"",s.vertexUvs?"#define USE_UV":"",s.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",s.gradientMap?"#define USE_GRADIENTMAP":"",s.flatShading?"#define FLAT_SHADED":"",s.doubleSided?"#define DOUBLE_SIDED":"",s.flipSided?"#define FLIP_SIDED":"",s.shadowMapEnabled?"#define USE_SHADOWMAP":"",s.shadowMapEnabled?"#define "+m:"",s.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",s.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",s.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",s.logarithmicDepthBuffer&&(s.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensions&&n.extensions.shaderTextureLOD||s.envMap)&&(s.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==s.toneMapping?"#define TONE_MAPPING":"",0!==s.toneMapping?er.tonemapping_pars_fragment:"",0!==s.toneMapping?xs("toneMapping",s.toneMapping):"",s.dithering?"#define DITHERING":"",s.outputEncoding||s.mapEncoding||s.matcapEncoding||s.envMapEncoding||s.emissiveMapEncoding||s.lightMapEncoding?er.encodings_pars_fragment:"",s.mapEncoding?_s("mapTexelToLinear",s.mapEncoding):"",s.matcapEncoding?_s("matcapTexelToLinear",s.matcapEncoding):"",s.envMapEncoding?_s("envMapTexelToLinear",s.envMapEncoding):"",s.emissiveMapEncoding?_s("emissiveMapTexelToLinear",s.emissiveMapEncoding):"",s.lightMapEncoding?_s("lightMapTexelToLinear",s.lightMapEncoding):"",s.outputEncoding?(h="linearToOutputTexel",c=s.outputEncoding,l=bs(c),"vec4 "+h+"( vec4 value ) { return LinearTo"+l[0]+l[1]+"; }"):"",s.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ws).join("\n")),p=Ts(p=Ms(p=Es(p),s),s),f=Ts(f=Ms(f=Es(f),s),s),p=Cs(p),f=Cs(f),s.isWebGL2&&!n.isRawShaderMaterial){var T=!1,S=/^\s*#version\s+300\s+es\s*\n/;n.isShaderMaterial&&null!==p.match(S)&&null!==f.match(S)&&(T=!0,p=p.replace(S,""),f=f.replace(S,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,a=["#version 300 es\n","#define varying in",T?"":"out highp vec4 pc_fragColor;",T?"":"#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,M>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+M+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+M+"];","uniform mat4 projectionMatrices["+M+"];","uniform mat4 viewMatrices["+M+"];","uniform mat3 normalMatrices["+M+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),a=(a=a.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+M+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var E,P,A=a+f,C=gs(u,35633,o+p),L=gs(u,35632,A);if(u.attachShader(w,C),u.attachShader(w,L),void 0!==n.index0AttributeName?u.bindAttribLocation(w,0,n.index0AttributeName):!0===s.morphTargets&&u.bindAttribLocation(w,0,"position"),u.linkProgram(w),t.debug.checkShaderErrors){var R=u.getProgramInfoLog(w).trim(),I=u.getShaderInfoLog(C).trim(),O=u.getShaderInfoLog(L).trim(),F=!0,B=!0;if(!1===u.getProgramParameter(w,35714)){F=!1;var D=ys(u,C,"vertex"),z=ys(u,L,"fragment");console.error("THREE.WebGLProgram: shader error: ",u.getError(),"35715",u.getProgramParameter(w,35715),"gl.getProgramInfoLog",R,D,z)}else""!==R?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",R):""!==I&&""!==O||(B=!1);B&&(this.diagnostics={runnable:F,material:n,programLog:R,vertexShader:{log:I,prefix:o},fragmentShader:{log:O,prefix:a}})}return u.deleteShader(C),u.deleteShader(L),this.getUniforms=function(){return void 0===E&&(E=new ms(u,w)),E},this.getAttributes=function(){return void 0===P&&(P=function(t,e){for(var i={},n=t.getProgramParameter(e,35721),r=0;r<n;r++){var s=t.getActiveAttrib(e,r).name;i[s]=t.getAttribLocation(e,s)}return i}(u,w)),P},this.destroy=function(){u.deleteProgram(w),this.program=void 0},this.name=r.name,this.id=vs++,this.cacheKey=i,this.usedTimes=1,this.program=w,this.vertexShader=C,this.fragmentShader=L,this.numMultiviewViews=M,this}function Os(t,e,i){var n=[],r=i.isWebGL2,s=i.logarithmicDepthBuffer,o=i.floatVertexTextures,a=i.precision,h=i.maxVertexUniforms,c=i.vertexTextures,l={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"},u=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","numMultiviewViews","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen"];function d(t){var e;return t?t.isTexture?e=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e=t.texture.encoding):e=Kt,e}this.getParameters=function(e,n,u,p,f,m,g){var v=p.fog,b=e.isMeshStandardMaterial?p.environment:null,y=e.envMap||b,_=l[e.type],x=g.isSkinnedMesh?function(t){var e=t.skeleton.bones;if(o)return 1024;var i=h,n=Math.floor((i-20)/4),r=Math.min(n,e.length);return r<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+r+"."),0):r}(g):0;null!==e.precision&&(a=i.getMaxPrecision(e.precision))!==e.precision&&console.warn("THREE.WebGLProgram.getParameters:",e.precision,"not supported, using",a,"instead.");var w=t.getRenderTarget(),M=w&&w.isWebGLMultiviewRenderTarget?w.numViews:0;return{isWebGL2:r,shaderID:_,precision:a,instancing:!0===g.isInstancedMesh,supportsVertexTextures:c,numMultiviewViews:M,outputEncoding:null!==w?d(w.texture):t.outputEncoding,map:!!e.map,mapEncoding:d(e.map),matcap:!!e.matcap,matcapEncoding:d(e.matcap),envMap:!!y,envMapMode:y&&y.mapping,envMapEncoding:d(y),envMapCubeUV:!!y&&(y.mapping===lt||307===y.mapping),lightMap:!!e.lightMap,lightMapEncoding:d(e.lightMap),aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:d(e.emissiveMap),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,objectSpaceNormalMap:1===e.normalMapType,tangentSpaceNormalMap:0===e.normalMapType,clearcoatNormalMap:!!e.clearcoatNormalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,alphaMap:!!e.alphaMap,gradientMap:!!e.gradientMap,sheen:!!e.sheen,combine:e.combine,vertexTangents:e.normalMap&&e.vertexTangents,vertexColors:e.vertexColors,vertexUvs:!!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap||e.displacementMap),uvsVertexOnly:!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap||!e.displacementMap),fog:!!v,useFog:e.fog,fogExp2:v&&v.isFogExp2,flatShading:e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:s,skinning:e.skinning&&x>0,maxBones:x,useVertexTexture:o,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:n.directional.length,numPointLights:n.point.length,numSpotLights:n.spot.length,numRectAreaLights:n.rectArea.length,numHemiLights:n.hemi.length,numDirLightShadows:n.directionalShadowMap.length,numPointLightShadows:n.pointShadowMap.length,numSpotLightShadows:n.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:m,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.length>0,shadowMapType:t.shadowMap.type,toneMapping:e.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:2===e.side,flipSided:1===e.side,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCacheKey=function(e,i){var n=[];if(i.shaderID?n.push(i.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var r in e.defines)n.push(r),n.push(e.defines[r]);if(void 0===e.isRawShaderMaterial){for(var s=0;s<u.length;s++)n.push(i[u[s]]);n.push(t.outputEncoding),n.push(t.gammaFactor)}return n.push(e.onBeforeCompile.toString()),n.join()},this.acquireProgram=function(i,r,s,o){for(var a,h=0,c=n.length;h<c;h++){var l=n[h];if(l.cacheKey===o){++(a=l).usedTimes;break}}return void 0===a&&(a=new Is(t,e,o,i,r,s),n.push(a)),a},this.releaseProgram=function(t){if(0==--t.usedTimes){var e=n.indexOf(t);n[e]=n[n.length-1],n.pop(),t.destroy()}},this.programs=n}function Fs(){var t=new WeakMap;return{get:function(e){var i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Bs(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ds(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function zs(){var t=[],e=0,i=[],n=[],r={id:-1};function s(i,n,s,o,a,h){var c=t[e];return void 0===c?(c={id:i.id,object:i,geometry:n,material:s,program:s.program||r,groupOrder:o,renderOrder:i.renderOrder,z:a,group:h},t[e]=c):(c.id=i.id,c.object=i,c.geometry=n,c.material=s,c.program=s.program||r,c.groupOrder=o,c.renderOrder=i.renderOrder,c.z=a,c.group=h),e++,c}return{opaque:i,transparent:n,init:function(){e=0,i.length=0,n.length=0},push:function(t,e,r,o,a,h){var c=s(t,e,r,o,a,h);(!0===r.transparent?n:i).push(c)},unshift:function(t,e,r,o,a,h){var c=s(t,e,r,o,a,h);(!0===r.transparent?n:i).unshift(c)},sort:function(t,e){i.length>1&&i.sort(t||Bs),n.length>1&&n.sort(e||Ds)}}}function Ns(){var t=new WeakMap;function e(i){var n=i.target;n.removeEventListener("dispose",e),t.delete(n)}return{get:function(i,n){var r,s=t.get(i);return void 0===s?(r=new zs,t.set(i,new WeakMap),t.get(i).set(n,r),i.addEventListener("dispose",e)):void 0===(r=s.get(n))&&(r=new zs,s.set(n,r)),r},dispose:function(){t=new WeakMap}}}function Us(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var i;switch(e.type){case"DirectionalLight":i={direction:new pe,color:new Ui,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ce};break;case"SpotLight":i={position:new pe,direction:new pe,color:new Ui,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ce};break;case"PointLight":i={position:new pe,color:new Ui,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ce,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new pe,skyColor:new Ui,groundColor:new Ui};break;case"RectAreaLight":i={color:new Ui,position:new pe,halfWidth:new pe,halfHeight:new pe}}return t[e.id]=i,i}}}var Vs=0;function ks(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function js(){for(var t=new Us,e={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},i=0;i<9;i++)e.probe.push(new pe);var n=new pe,r=new Le,s=new Le;return{setup:function(i,o,a){for(var h=0,c=0,l=0,u=0;u<9;u++)e.probe[u].set(0,0,0);var d=0,p=0,f=0,m=0,g=0,v=0,b=0,y=0,_=a.matrixWorldInverse;i.sort(ks),u=0;for(var x=i.length;u<x;u++){var w=i[u],M=w.color,T=w.intensity,S=w.distance,E=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)h+=M.r*T,c+=M.g*T,l+=M.b*T;else if(w.isLightProbe)for(var P=0;P<9;P++)e.probe[P].addScaledVector(w.sh.coefficients[P],T);else if(w.isDirectionalLight){if((C=t.get(w)).color.copy(w.color).multiplyScalar(w.intensity),C.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),C.direction.sub(n),C.direction.transformDirection(_),C.shadow=w.castShadow,w.castShadow){var A=w.shadow;C.shadowBias=A.bias,C.shadowRadius=A.radius,C.shadowMapSize=A.mapSize,e.directionalShadowMap[d]=E,e.directionalShadowMatrix[d]=w.shadow.matrix,v++}e.directional[d]=C,d++}else if(w.isSpotLight){if((C=t.get(w)).position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(_),C.color.copy(M).multiplyScalar(T),C.distance=S,C.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),C.direction.sub(n),C.direction.transformDirection(_),C.coneCos=Math.cos(w.angle),C.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),C.decay=w.decay,C.shadow=w.castShadow,w.castShadow){A=w.shadow;C.shadowBias=A.bias,C.shadowRadius=A.radius,C.shadowMapSize=A.mapSize,e.spotShadowMap[f]=E,e.spotShadowMatrix[f]=w.shadow.matrix,y++}e.spot[f]=C,f++}else if(w.isRectAreaLight){(C=t.get(w)).color.copy(M).multiplyScalar(T),C.position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(_),s.identity(),r.copy(w.matrixWorld),r.premultiply(_),s.extractRotation(r),C.halfWidth.set(.5*w.width,0,0),C.halfHeight.set(0,.5*w.height,0),C.halfWidth.applyMatrix4(s),C.halfHeight.applyMatrix4(s),e.rectArea[m]=C,m++}else if(w.isPointLight){if((C=t.get(w)).position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(_),C.color.copy(w.color).multiplyScalar(w.intensity),C.distance=w.distance,C.decay=w.decay,C.shadow=w.castShadow,w.castShadow){A=w.shadow;C.shadowBias=A.bias,C.shadowRadius=A.radius,C.shadowMapSize=A.mapSize,C.shadowCameraNear=A.camera.near,C.shadowCameraFar=A.camera.far,e.pointShadowMap[p]=E,e.pointShadowMatrix[p]=w.shadow.matrix,b++}e.point[p]=C,p++}else if(w.isHemisphereLight){var C;(C=t.get(w)).direction.setFromMatrixPosition(w.matrixWorld),C.direction.transformDirection(_),C.direction.normalize(),C.skyColor.copy(w.color).multiplyScalar(T),C.groundColor.copy(w.groundColor).multiplyScalar(T),e.hemi[g]=C,g++}}e.ambient[0]=h,e.ambient[1]=c,e.ambient[2]=l;var L=e.hash;L.directionalLength===d&&L.pointLength===p&&L.spotLength===f&&L.rectAreaLength===m&&L.hemiLength===g&&L.numDirectionalShadows===v&&L.numPointShadows===b&&L.numSpotShadows===y||(e.directional.length=d,e.spot.length=f,e.rectArea.length=m,e.point.length=p,e.hemi.length=g,e.directionalShadowMap.length=v,e.pointShadowMap.length=b,e.spotShadowMap.length=y,e.directionalShadowMatrix.length=v,e.pointShadowMatrix.length=b,e.spotShadowMatrix.length=y,L.directionalLength=d,L.pointLength=p,L.spotLength=f,L.rectAreaLength=m,L.hemiLength=g,L.numDirectionalShadows=v,L.numPointShadows=b,L.numSpotShadows=y,e.version=Vs++)},state:e}}function Hs(){var t=new js,e=[],i=[];return{init:function(){e.length=0,i.length=0},state:{lightsArray:e,shadowsArray:i,lights:t},setupLights:function(n){t.setup(e,i,n)},pushLight:function(t){e.push(t)},pushShadow:function(t){i.push(t)}}}function Gs(){var t=new WeakMap;function e(i){var n=i.target;n.removeEventListener("dispose",e),t.delete(n)}return{get:function(i,n){var r;return!1===t.has(i)?(r=new Hs,t.set(i,new WeakMap),t.get(i).set(n,r),i.addEventListener("dispose",e)):!1===t.get(i).has(n)?(r=new Hs,t.get(i).set(n,r)):r=t.get(i).get(n),r},dispose:function(){t=new WeakMap}}}function Ws(t){Wi.call(this),this.type="MeshDepthMaterial",this.depthPacking=3200,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}function qs(t){Wi.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new pe,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}Ws.prototype=Object.create(Wi.prototype),Ws.prototype.constructor=Ws,Ws.prototype.isMeshDepthMaterial=!0,Ws.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},qs.prototype=Object.create(Wi.prototype),qs.prototype.constructor=qs,qs.prototype.isMeshDistanceMaterial=!0,qs.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this};function Xs(t,e,i){var n=new tr,r=new ce,s=new ce,o=new _e,a=[],h=[],c={},l={0:1,1:0,2:2},u=new Wn({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new ce},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  float mean = 0.0;\n  float squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy  ) / resolution ) );\n  for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n    #ifdef HORIZONAL_PASS\n      vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n      mean += distribution.x;\n      squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n    #else\n      float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0,  i )  * radius ) / resolution ) );\n      mean += depth;\n      squared_mean += depth * depth;\n    #endif\n  }\n  mean = mean * HALF_SAMPLE_RATE;\n  squared_mean = squared_mean * HALF_SAMPLE_RATE;\n  float std_dev = sqrt( squared_mean - mean * mean );\n  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),d=u.clone();d.defines.HORIZONAL_PASS=1;var p=new fn;p.setAttribute("position",new Yi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var f=new In(p,u),m=this;function g(i,n){var r=e.update(f);u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,u,f,null),d.uniforms.shadow_pass.value=i.mapPass.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,d,f,null)}function v(t,e,i){var n=t<<0|e<<1|i<<2,r=a[n];return void 0===r&&(r=new Ws({depthPacking:3201,morphTargets:t,skinning:e}),a[n]=r),r}function b(t,e,i){var n=t<<0|e<<1|i<<2,r=h[n];return void 0===r&&(r=new qs({morphTargets:t,skinning:e}),h[n]=r),r}function y(e,i,n,r,s,o){var a=e.geometry,h=null,u=v,d=e.customDepthMaterial;if(!0===n.isPointLight&&(u=b,d=e.customDistanceMaterial),void 0===d){var p=!1;!0===i.morphTargets&&(!0===a.isBufferGeometry?p=a.morphAttributes&&a.morphAttributes.position&&a.morphAttributes.position.length>0:!0===a.isGeometry&&(p=a.morphTargets&&a.morphTargets.length>0));var f=!1;!0===e.isSkinnedMesh&&(!0===i.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e)),h=u(p,f,!0===e.isInstancedMesh)}else h=d;if(t.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var m=h.uuid,g=i.uuid,y=c[m];void 0===y&&(y={},c[m]=y);var _=y[g];void 0===_&&(_=h.clone(),y[g]=_),h=_}return h.visible=i.visible,h.wireframe=i.wireframe,h.side=3===o?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:l[i.side],h.clipShadows=i.clipShadows,h.clippingPlanes=i.clippingPlanes,h.clipIntersection=i.clipIntersection,h.wireframeLinewidth=i.wireframeLinewidth,h.linewidth=i.linewidth,!0===n.isPointLight&&!0===h.isMeshDistanceMaterial&&(h.referencePosition.setFromMatrixPosition(n.matrixWorld),h.nearDistance=r,h.farDistance=s),h}function _(i,r,s,o,a){if(!1!==i.visible){if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);var h=e.update(i),c=i.material;if(Array.isArray(c))for(var l=h.groups,u=0,d=l.length;u<d;u++){var p=l[u],f=c[p.materialIndex];if(f&&f.visible){var m=y(i,f,o,s.near,s.far,a);t.renderBufferDirect(s,null,h,m,i,p)}}else if(c.visible){m=y(i,c,o,s.near,s.far,a);t.renderBufferDirect(s,null,h,m,i,null)}}for(var g=i.children,v=0,b=g.length;v<b;v++)_(g[v],r,s,o,a)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,a,h){if(!1!==m.enabled&&(!1!==m.autoUpdate||!1!==m.needsUpdate)&&0!==e.length){var c=t.getRenderTarget(),l=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(var p=0,f=e.length;p<f;p++){var v=e[p],b=v.shadow;if(void 0!==b){r.copy(b.mapSize);var y=b.getFrameExtents();if(r.multiply(y),s.copy(b.mapSize),(r.x>i||r.y>i)&&(console.warn("THREE.WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),r.x>i&&(s.x=Math.floor(i/y.x),r.x=s.x*y.x,b.mapSize.x=s.x),r.y>i&&(s.y=Math.floor(i/y.y),r.y=s.y*y.y,b.mapSize.y=s.y)),null===b.map&&!b.isPointLightShadow&&3===this.type){var x={minFilter:yt,magFilter:yt,format:Ft};b.map=new xe(r.x,r.y,x),b.map.texture.name=v.name+".shadowMap",b.mapPass=new xe(r.x,r.y,x),b.camera.updateProjectionMatrix()}if(null===b.map){x={minFilter:ft,magFilter:ft,format:Ft};b.map=new xe(r.x,r.y,x),b.map.texture.name=v.name+".shadowMap",b.camera.updateProjectionMatrix()}t.setRenderTarget(b.map),t.clear();for(var w=b.getViewportCount(),M=0;M<w;M++){var T=b.getViewport(M);o.set(s.x*T.x,s.y*T.y,s.x*T.z,s.y*T.w),d.viewport(o),b.updateMatrices(v,M),n=b.getFrustum(),_(a,h,b.camera,v,this.type)}b.isPointLightShadow||3!==this.type||g(b,h)}else console.warn("THREE.WebGLShadowMap:",v,"has no shadow.")}m.needsUpdate=!1,t.setRenderTarget(c,l,u)}}}function Ys(t,e,i){var n=i.isWebGL2;var r=new function(){var e=!1,i=new _e,n=null,r=new _e(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,o,a){!0===a&&(e*=o,n*=o,s*=o),i.set(e,n,s,o),!1===r.equals(i)&&(t.clearColor(e,n,s,o),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},s=new function(){var e=!1,i=null,n=null,r=null;return{setTest:function(t){t?N(2929):U(2929)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);n=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,n=null,r=null}}},o=new function(){var e=!1,i=null,n=null,r=null,s=null,o=null,a=null,h=null,c=null;return{setTest:function(t){e||(t?N(2960):U(2960))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,o){n===e&&r===i&&s===o||(t.stencilFunc(e,i,o),n=e,r=i,s=o)},setOp:function(e,i,n){o===e&&a===i&&h===n||(t.stencilOp(e,i,n),o=e,a=i,h=n)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,o=null,a=null,h=null,c=null}}},a=t.getParameter(34921),h=new Uint8Array(a),c=new Uint8Array(a),l=new Uint8Array(a),u={},d=null,p=null,f=null,m=null,g=null,v=null,b=null,y=null,_=null,x=!1,w=null,M=null,T=null,S=null,E=null,P=t.getParameter(35661),A=!1,C=0,L=t.getParameter(7938);-1!==L.indexOf("WebGL")?(C=parseFloat(/^WebGL\ ([0-9])/.exec(L)[1]),A=C>=1):-1!==L.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(L)[1]),A=C>=2);var R=null,I={},O=new _e,F=new _e;function B(e,i,n){var r=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;o<n;o++)t.texImage2D(i+o,0,6408,1,1,0,6408,5121,r);return s}var D={};function z(i,r){(h[i]=1,0===c[i]&&(t.enableVertexAttribArray(i),c[i]=1),l[i]!==r)&&((n?t:e.get("ANGLE_instanced_arrays"))[n?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),l[i]=r)}function N(e){!0!==u[e]&&(t.enable(e),u[e]=!0)}function U(e){!1!==u[e]&&(t.disable(e),u[e]=!1)}D[3553]=B(3553,3553,1),D[34067]=B(34067,34069,6),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),N(2929),s.setFunc(3),G(!1),W(1),N(2884),H(0);var V={[nt]:32774,101:32778,102:32779};if(n)V[103]=32775,V[104]=32776;else{var k=e.get("EXT_blend_minmax");null!==k&&(V[103]=k.MIN_EXT,V[104]=k.MAX_EXT)}var j={[ot]:0,[at]:1,202:768,[ht]:770,210:776,208:774,206:772,203:769,[ct]:771,209:775,207:773};function H(e,i,n,r,s,o,a,h){if(0!==e){if(p||(N(3042),p=!0),5===e)s=s||i,o=o||n,a=a||r,i===m&&s===b||(t.blendEquationSeparate(V[i],V[s]),m=i,b=s),n===g&&r===v&&o===y&&a===_||(t.blendFuncSeparate(j[n],j[r],j[o],j[a]),g=n,v=r,y=o,_=a),f=e,x=null;else if(e!==f||h!==x){if(m===nt&&b===nt||(t.blendEquation(32774),m=nt,b=nt),h)switch(e){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,0,769,771);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFunc(0,769);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}g=null,v=null,y=null,_=null,f=e,x=h}}else p&&(U(3042),p=!1)}function G(e){w!==e&&(e?t.frontFace(2304):t.frontFace(2305),w=e)}function W(e){0!==e?(N(2884),e!==M&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):U(2884),M=e}function q(e,i,n){e?(N(32823),S===i&&E===n||(t.polygonOffset(i,n),S=i,E=n)):U(32823)}function X(e){void 0===e&&(e=33984+P-1),R!==e&&(t.activeTexture(e),R=e)}return{buffers:{color:r,depth:s,stencil:o},initAttributes:function(){for(var t=0,e=h.length;t<e;t++)h[t]=0},enableAttribute:function(t){z(t,0)},enableAttributeAndDivisor:z,disableUnusedAttributes:function(){for(var e=0,i=c.length;e!==i;++e)c[e]!==h[e]&&(t.disableVertexAttribArray(e),c[e]=0)},enable:N,disable:U,useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:H,setMaterial:function(t,e){2===t.side?U(2884):N(2884);var i=1===t.side;e&&(i=!i),G(i),1===t.blending&&!1===t.transparent?H(0):H(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),s.setFunc(t.depthFunc),s.setTest(t.depthTest),s.setMask(t.depthWrite),r.setMask(t.colorWrite);var n=t.stencilWrite;o.setTest(n),n&&(o.setMask(t.stencilWriteMask),o.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),o.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)},setFlipSided:G,setCullFace:W,setLineWidth:function(e){e!==T&&(A&&t.lineWidth(e),T=e)},setPolygonOffset:q,setScissorTest:function(t){t?N(3089):U(3089)},activeTexture:X,bindTexture:function(e,i){null===R&&X();var n=I[R];void 0===n&&(n={type:void 0,texture:void 0},I[R]=n),n.type===e&&n.texture===i||(t.bindTexture(e,i||D[e]),n.type=e,n.texture=i)},unbindTexture:function(){var e=I[R];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===O.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),O.copy(e))},viewport:function(e){!1===F.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),F.copy(e))},reset:function(){for(var e=0;e<c.length;e++)1===c[e]&&(t.disableVertexAttribArray(e),c[e]=0);u={},R=null,I={},d=null,f=null,w=null,M=null,r.reset(),s.reset(),o.reset()}}}function Zs(t,e,i,n,r,s,o){var a,h=r.isWebGL2,c=r.maxTextures,l=r.maxCubemapSize,u=r.maxTextureSize,d=r.maxSamples,p=new WeakMap,f=!1;try{f="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return f?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function g(t,e,i,n){var r=1;if((t.width>n||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var s=e?he.floorPowerOfTwo:Math.floor,o=s(r*t.width),h=s(r*t.height);void 0===a&&(a=m(o,h));var c=i?m(o,h):a;return c.width=o,c.height=h,c.getContext("2d").drawImage(t,0,0,o,h),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+h+")."),c}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function v(t){return he.isPowerOfTwo(t.width)&&he.isPowerOfTwo(t.height)}function b(t,e){return t.generateMipmaps&&e&&t.minFilter!==ft&&t.minFilter!==yt}function y(e,i,r,s){t.generateMipmap(e),n.get(i).__maxMipLevel=Math.log(Math.max(r,s))*Math.LOG2E}function _(i,n,r){if(!1===h)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}var s=n;return 6403===n&&(5126===r&&(s=33326),5131===r&&(s=33325),5121===r&&(s=33321)),6407===n&&(5126===r&&(s=34837),5131===r&&(s=34843),5121===r&&(s=32849)),6408===n&&(5126===r&&(s=34836),5131===r&&(s=34842),5121===r&&(s=32856)),33325===s||33326===s||34842===s||34836===s?e.get("EXT_color_buffer_float"):34843!==s&&34837!==s||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),s}function x(t){return t===ft||t===mt||t===vt?9728:9729}function w(e){var i=e.target;i.removeEventListener("dispose",w),function(e){var i=n.get(e);if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture),n.remove(e)}(i),i.isVideoTexture&&p.delete(i),o.memory.textures--}function M(e){var i=e.target;i.removeEventListener("dispose",M),function(e){var i=n.get(e),r=n.get(e.texture);if(!e)return;void 0!==r.__webglTexture&&t.deleteTexture(r.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var s=0;s<6;s++)t.deleteFramebuffer(i.__webglFramebuffer[s]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[s]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){t.deleteTexture(i.__webglColorTexture),t.deleteTexture(i.__webglDepthStencilTexture),o.memory.textures-=2;s=0;for(var a=i.__webglViewFramebuffers.length;s<a;s++)t.deleteFramebuffer(i.__webglViewFramebuffers[s])}n.remove(e.texture),n.remove(e)}(i),o.memory.textures--}var T=0;function S(t,e){var r=n.get(t);if(t.isVideoTexture&&function(t){var e=o.render.frame;p.get(t)!==e&&(p.set(t,e),t.update())}(t),t.version>0&&r.__version!==t.version){var s=t.image;if(void 0===s)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==s.complete)return void I(r,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+e),i.bindTexture(3553,r.__webglTexture)}function E(e,r){if(6===e.image.length){var o=n.get(e);if(e.version>0&&o.__version!==e.version){R(o,e),i.activeTexture(33984+r),i.bindTexture(34067,o.__webglTexture),t.pixelStorei(37440,e.flipY);for(var a=e&&e.isCompressedTexture,c=e.image[0]&&e.image[0].isDataTexture,u=[],d=0;d<6;d++)u[d]=a||c?c?e.image[d].image:e.image[d]:g(e.image[d],!1,!0,l);var p,f=u[0],m=v(f)||h,x=s.convert(e.format),w=s.convert(e.type),M=_(e.internalFormat,x,w);if(L(34067,e,m),a){for(d=0;d<6;d++){p=u[d].mipmaps;for(var T=0;T<p.length;T++){var S=p[T];e.format!==Ft&&e.format!==Ot?null!==x?i.compressedTexImage2D(34069+d,T,M,S.width,S.height,0,S.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+d,T,M,S.width,S.height,0,x,w,S.data)}}o.__maxMipLevel=p.length-1}else{p=e.mipmaps;for(d=0;d<6;d++)if(c){i.texImage2D(34069+d,0,M,u[d].width,u[d].height,0,x,w,u[d].data);for(T=0;T<p.length;T++){var E=(S=p[T]).image[d].image;i.texImage2D(34069+d,T+1,M,E.width,E.height,0,x,w,E.data)}}else{i.texImage2D(34069+d,0,M,x,w,u[d]);for(T=0;T<p.length;T++){S=p[T];i.texImage2D(34069+d,T+1,M,x,w,S.image[d])}}o.__maxMipLevel=p.length}b(e,m)&&y(34067,e,f.width,f.height),o.__version=e.version,e.onUpdate&&e.onUpdate(e)}else i.activeTexture(33984+r),i.bindTexture(34067,o.__webglTexture)}}function P(t,e){i.activeTexture(33984+e),i.bindTexture(34067,n.get(t).__webglTexture)}var A={[ut]:10497,[dt]:33071,[pt]:33648},C={[ft]:9728,[mt]:9984,[vt]:9986,[yt]:9729,1007:9985,[xt]:9987};function L(i,s,o){o?(t.texParameteri(i,10242,A[s.wrapS]),t.texParameteri(i,10243,A[s.wrapT]),32879!==i&&35866!==i||t.texParameteri(i,32882,A[s.wrapR]),t.texParameteri(i,10240,C[s.magFilter]),t.texParameteri(i,10241,C[s.minFilter])):(t.texParameteri(i,10242,33071),t.texParameteri(i,10243,33071),32879!==i&&35866!==i||t.texParameteri(i,32882,33071),s.wrapS===dt&&s.wrapT===dt||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,10240,x(s.magFilter)),t.texParameteri(i,10241,x(s.minFilter)),s.minFilter!==ft&&s.minFilter!==yt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));var a=e.get("EXT_texture_filter_anisotropic");if(a){if(s.type===Et&&null===e.get("OES_texture_float_linear"))return;if(s.type===Pt&&null===(h||e.get("OES_texture_half_float_linear")))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function R(e,i){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",w),e.__webglTexture=t.createTexture(),o.memory.textures++)}function I(e,n,r){var o=3553;n.isDataTexture2DArray&&(o=35866),n.isDataTexture3D&&(o=32879),R(e,n),i.activeTexture(33984+r),i.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment);var a=function(t){return!h&&(t.wrapS!==dt||t.wrapT!==dt||t.minFilter!==ft&&t.minFilter!==yt)}(n)&&!1===v(n.image),c=g(n.image,a,!1,u),l=v(c)||h,d=s.convert(n.format),p=s.convert(n.type),f=_(n.internalFormat,d,p);L(o,n,l);var m,x=n.mipmaps;if(n.isDepthTexture){if(f=6402,n.type===Et){if(!1===h)throw new Error("Float Depth Texture only supported in WebGL2.0");f=36012}else h&&(f=33189);n.format===zt&&6402===f&&n.type!==Tt&&n.type!==St&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=Tt,p=s.convert(n.type)),n.format===Nt&&(f=34041,n.type!==Rt&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=Rt,p=s.convert(n.type))),i.texImage2D(3553,0,f,c.width,c.height,0,d,p,null)}else if(n.isDataTexture)if(x.length>0&&l){for(var w=0,M=x.length;w<M;w++)m=x[w],i.texImage2D(3553,w,f,m.width,m.height,0,d,p,m.data);n.generateMipmaps=!1,e.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,f,c.width,c.height,0,d,p,c.data),e.__maxMipLevel=0;else if(n.isCompressedTexture){for(w=0,M=x.length;w<M;w++)m=x[w],n.format!==Ft&&n.format!==Ot?null!==d?i.compressedTexImage2D(3553,w,f,m.width,m.height,0,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,w,f,m.width,m.height,0,d,p,m.data);e.__maxMipLevel=x.length-1}else if(n.isDataTexture2DArray)i.texImage3D(35866,0,f,c.width,c.height,c.depth,0,d,p,c.data),e.__maxMipLevel=0;else if(n.isDataTexture3D)i.texImage3D(32879,0,f,c.width,c.height,c.depth,0,d,p,c.data),e.__maxMipLevel=0;else if(x.length>0&&l){for(w=0,M=x.length;w<M;w++)m=x[w],i.texImage2D(3553,w,f,d,p,m);n.generateMipmaps=!1,e.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,f,d,p,c),e.__maxMipLevel=0;b(n,l)&&y(o,n,c.width,c.height),e.__version=n.version,n.onUpdate&&n.onUpdate(n)}function O(e,r,o,a){var h=s.convert(r.texture.format),c=s.convert(r.texture.type),l=_(r.texture.internalFormat,h,c);i.texImage2D(a,0,l,r.width,r.height,0,h,c,null),t.bindFramebuffer(36160,e),t.framebufferTexture2D(36160,o,a,n.get(r.texture).__webglTexture,0),t.bindFramebuffer(36160,null)}function F(e,i,n){if(t.bindRenderbuffer(36161,e),i.depthBuffer&&!i.stencilBuffer){if(n){var r=D(i);t.renderbufferStorageMultisample(36161,r,33189,i.width,i.height)}else t.renderbufferStorage(36161,33189,i.width,i.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(i.depthBuffer&&i.stencilBuffer){if(n){r=D(i);t.renderbufferStorageMultisample(36161,r,35056,i.width,i.height)}else t.renderbufferStorage(36161,34041,i.width,i.height);t.framebufferRenderbuffer(36160,33306,36161,e)}else{var o=s.convert(i.texture.format),a=s.convert(i.texture.type),h=_(i.texture.internalFormat,o,a);if(n){r=D(i);t.renderbufferStorageMultisample(36161,r,h,i.width,i.height)}else t.renderbufferStorage(36161,h,i.width,i.height)}t.bindRenderbuffer(36161,null)}function B(e){var i=n.get(e),r=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,i){if(i&&i.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,e),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.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),S(i.depthTexture,0);var r=n.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===zt)t.framebufferTexture2D(36160,36096,3553,r,0);else{if(i.depthTexture.format!==Nt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(36160,33306,3553,r,0)}}(i.__webglFramebuffer,e)}else if(r){i.__webglDepthbuffer=[];for(var s=0;s<6;s++)t.bindFramebuffer(36160,i.__webglFramebuffer[s]),i.__webglDepthbuffer[s]=t.createRenderbuffer(),F(i.__webglDepthbuffer[s],e)}else t.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),F(i.__webglDepthbuffer,e);t.bindFramebuffer(36160,null)}function D(t){return h&&t.isWebGLMultisampleRenderTarget?Math.min(d,t.samples):0}var z=!1,N=!1;this.allocateTextureUnit=function(){var t=T;return t>=c&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+c),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=S,this.setTexture2DArray=function(t,e){var r=n.get(t);t.version>0&&r.__version!==t.version?I(r,t,e):(i.activeTexture(33984+e),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(t,e){var r=n.get(t);t.version>0&&r.__version!==t.version?I(r,t,e):(i.activeTexture(33984+e),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=E,this.setTextureCubeDynamic=P,this.setupRenderTarget=function(r){var a=n.get(r),c=n.get(r.texture);r.addEventListener("dispose",M),c.__webglTexture=t.createTexture(),o.memory.textures++;var l=!0===r.isWebGLRenderTargetCube,u=!0===r.isWebGLMultisampleRenderTarget,d=!0===r.isWebGLMultiviewRenderTarget,p=v(r)||h;if(l){a.__webglFramebuffer=[];for(var f=0;f<6;f++)a.__webglFramebuffer[f]=t.createFramebuffer()}else if(a.__webglFramebuffer=t.createFramebuffer(),u)if(h){a.__webglMultisampledFramebuffer=t.createFramebuffer(),a.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,a.__webglColorRenderbuffer);var m=s.convert(r.texture.format),g=s.convert(r.texture.type),x=_(r.texture.internalFormat,m,g),w=D(r);t.renderbufferStorageMultisample(36161,w,x,r.width,r.height),t.bindFramebuffer(36160,a.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,a.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),r.depthBuffer&&(a.__webglDepthRenderbuffer=t.createRenderbuffer(),F(a.__webglDepthRenderbuffer,r,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(d){var T=r.width,S=r.height,E=r.numViews;t.bindFramebuffer(36160,a.__webglFramebuffer);var P=e.get("OVR_multiview2");o.memory.textures+=2;var A=t.createTexture();t.bindTexture(35866,A),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,32856,T,S,E,0,6408,5121,null),P.framebufferTextureMultiviewOVR(36160,36064,A,0,0,E);var C=t.createTexture();t.bindTexture(35866,C),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,35056,T,S,E,0,34041,34042,null),P.framebufferTextureMultiviewOVR(36160,33306,C,0,0,E);var R=new Array(E);for(f=0;f<E;++f)R[f]=t.createFramebuffer(),t.bindFramebuffer(36160,R[f]),t.framebufferTextureLayer(36160,36064,A,0,f);a.__webglColorTexture=A,a.__webglDepthStencilTexture=C,a.__webglViewFramebuffers=R,t.bindFramebuffer(36160,null),t.bindTexture(35866,null)}if(l){i.bindTexture(34067,c.__webglTexture),L(34067,r.texture,p);for(f=0;f<6;f++)O(a.__webglFramebuffer[f],r,36064,34069+f);b(r.texture,p)&&y(34067,r.texture,r.width,r.height),i.bindTexture(34067,null)}else d||(i.bindTexture(3553,c.__webglTexture),L(3553,r.texture,p),O(a.__webglFramebuffer,r,36064,3553),b(r.texture,p)&&y(3553,r.texture,r.width,r.height),i.bindTexture(3553,null));r.depthBuffer&&B(r)},this.updateRenderTargetMipmap=function(t){var e=t.texture;if(b(e,v(t)||h)){var r=t.isWebGLRenderTargetCube?34067:3553,s=n.get(e).__webglTexture;i.bindTexture(r,s),y(r,e,t.width,t.height),i.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(e){if(e.isWebGLMultisampleRenderTarget)if(h){var i=n.get(e);t.bindFramebuffer(36008,i.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,i.__webglFramebuffer);var r=e.width,s=e.height,o=16384;e.depthBuffer&&(o|=256),e.stencilBuffer&&(o|=1024),t.blitFramebuffer(0,0,r,s,0,0,r,s,o,9728)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(t,e){t&&t.isWebGLRenderTarget&&(!1===z&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),z=!0),t=t.texture),S(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLRenderTargetCube&&(!1===N&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),N=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?E(t,e):P(t,e)}}function $s(t,e,i){var n=i.isWebGL2;return{convert:function(t){var i;if(t===Mt)return 5121;if(t===At)return 32819;if(t===Ct)return 32820;if(t===Lt)return 33635;if(1010===t)return 5120;if(1011===t)return 5122;if(t===Tt)return 5123;if(1013===t)return 5124;if(t===St)return 5125;if(t===Et)return 5126;if(t===Pt)return n?5131:null!==(i=e.get("OES_texture_half_float"))?i.HALF_FLOAT_OES:null;if(t===It)return 6406;if(t===Ot)return 6407;if(t===Ft)return 6408;if(t===Bt)return 6409;if(t===Dt)return 6410;if(t===zt)return 6402;if(t===Nt)return 34041;if(1028===t)return 6403;if(1029===t)return 36244;if(1030===t)return 33319;if(1031===t)return 33320;if(1032===t)return 36248;if(1033===t)return 36249;if(t===Ut||t===Vt||t===kt||t===jt){if(null===(i=e.get("WEBGL_compressed_texture_s3tc")))return null;if(t===Ut)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===Vt)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===kt)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===jt)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t===Ht||t===Gt||t===Wt||t===qt){if(null===(i=e.get("WEBGL_compressed_texture_pvrtc")))return null;if(t===Ht)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===Gt)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===Wt)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===qt)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}return 36196===t?null!==(i=e.get("WEBGL_compressed_texture_etc1"))?i.COMPRESSED_RGB_ETC1_WEBGL:null:37808===t||37809===t||37810===t||37811===t||37812===t||37813===t||37814===t||37815===t||37816===t||37817===t||37818===t||37819===t||37820===t||37821===t?null!==(i=e.get("WEBGL_compressed_texture_astc"))?t:null:t===Rt?n?34042:null!==(i=e.get("WEBGL_depth_texture"))?i.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}function Js(t,e,i,n){xe.call(this,t,e,n),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=i}function Qs(t,e){var i,n,r,s,o,a,h,c=t.extensions,l=t.properties,u=0;function d(t){return t.isArrayCamera?t.cameras:(o[0]=t,o)}this.isAvailable=function(){if(void 0===h){var t=c.get("OVR_multiview2");if(h=null!==t&&!1===e.getContextAttributes().antialias){u=e.getParameter(t.MAX_VIEWS_OVR),i=new Js(0,0,2),a=new ce,s=[],r=[],o=[];for(var n=0;n<u;n++)s[n]=new Le,r[n]=new ge}}return h},this.attachCamera=function(e){!1!==function(t){if(void 0===t.isArrayCamera)return!0;var e=t.cameras;if(e.length>u)return!1;for(var i=1,n=e.length;i<n;i++)if(e[0].viewport.z!==e[i].viewport.z||e[0].viewport.w!==e[i].viewport.w)return!1;return!0}(e)&&(n=t.getRenderTarget(),function(e){if(n?a.set(n.width,n.height):t.getDrawingBufferSize(a),e.isArrayCamera){var r=e.cameras[0].viewport;i.setSize(r.z,r.w),i.setNumViews(e.cameras.length)}else i.setSize(a.x,a.y),i.setNumViews(2)}(e),t.setRenderTarget(i))},this.detachCamera=function(r){i===t.getRenderTarget()&&(t.setRenderTarget(n),function(t){var n=i,r=n.numViews,s=l.get(n).__webglViewFramebuffers,o=n.width,h=n.height;if(t.isArrayCamera)for(var c=0;c<r;c++){var u=t.cameras[c].viewport,d=u.x,p=u.y,f=d+u.z,m=p+u.w;e.bindFramebuffer(36008,s[c]),e.blitFramebuffer(0,0,o,h,d,p,f,m,16384,9728)}else e.bindFramebuffer(36008,s[0]),e.blitFramebuffer(0,0,o,h,0,0,a.x,a.y,16384,9728)}(r))},this.updateCameraProjectionMatricesUniform=function(t,i){for(var n=d(t),r=0;r<n.length;r++)s[r].copy(n[r].projectionMatrix);i.setValue(e,"projectionMatrices",s)},this.updateCameraViewMatricesUniform=function(t,i){for(var n=d(t),r=0;r<n.length;r++)s[r].copy(n[r].matrixWorldInverse);i.setValue(e,"viewMatrices",s)},this.updateObjectMatricesUniforms=function(t,i,n){for(var o=d(i),a=0;a<o.length;a++)s[a].multiplyMatrices(o[a].matrixWorldInverse,t.matrixWorld),r[a].getNormalMatrix(s[a]);n.setValue(e,"modelViewMatrices",s),n.setValue(e,"normalMatrices",r)}}function Ks(t){Xn.call(this),this.cameras=t||[]}function to(){Ye.call(this),this.type="Group"}function eo(t,e){var i=this,n=null,r=null,s="local-floor",o=null,a=[],h=new Map,c=new Xn;c.layers.enable(1),c.viewport=new _e;var l=new Xn;l.layers.enable(2),l.viewport=new _e;var u=new Ks([c,l]);function d(t){var e=h.get(t.inputSource);e&&e.dispatchEvent({type:t.type})}function p(){h.forEach((function(t,e){t.dispatchEvent({type:"disconnected",data:e}),t.visible=!1})),h.clear(),t.setFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),_.stop(),i.dispatchEvent({type:"sessionend"}),i.isPresenting=!1}function f(t){r=t,_.setContext(n),_.start(),i.dispatchEvent({type:"sessionstart"}),i.isPresenting=!0}function m(t){for(var e=n.inputSources,i=0;i<a.length;i++)h.set(e[i],a[i]);for(i=0;i<t.removed.length;i++){var r=t.removed[i];(s=h.get(r))&&(s.dispatchEvent({type:"disconnected",data:r}),h.delete(r))}for(i=0;i<t.added.length;i++){var s;r=t.added[i];(s=h.get(r))&&s.dispatchEvent({type:"connected",data:r})}}u.layers.enable(1),u.layers.enable(2),this.enabled=!1,this.isPresenting=!1,this.getController=function(t){var e=a[t];return void 0===e&&((e=new to).matrixAutoUpdate=!1,e.visible=!1,a[t]=e),e},this.setFramebufferScaleFactor=function(){},this.setReferenceSpaceType=function(t){s=t},this.getReferenceSpace=function(){return r},this.getSession=function(){return n},this.setSession=function(t){if(null!==(n=t)){n.addEventListener("select",d),n.addEventListener("selectstart",d),n.addEventListener("selectend",d),n.addEventListener("squeeze",d),n.addEventListener("squeezestart",d),n.addEventListener("squeezeend",d),n.addEventListener("end",p);var i=e.getContextAttributes(),r={antialias:i.antialias,alpha:i.alpha,depth:i.depth,stencil:i.stencil},o=new XRWebGLLayer(n,e,r);n.updateRenderState({baseLayer:o}),n.requestReferenceSpace(s).then(f),n.addEventListener("inputsourceschange",m)}};var g=new pe,v=new pe;function b(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.getInverse(t.matrixWorld)}this.getCamera=function(t){var e=t.parent,i=u.cameras;b(u,e);for(var n=0;n<i.length;n++)b(i[n],e);t.matrixWorld.copy(u.matrixWorld);for(var r=t.children,s=(n=0,r.length);n<s;n++)r[n].updateMatrixWorld(!0);return function(t,e,i){g.setFromMatrixPosition(e.matrixWorld),v.setFromMatrixPosition(i.matrixWorld);var n=g.distanceTo(v),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,o=r[14]/(r[10]-1),a=r[14]/(r[10]+1),h=(r[9]+1)/r[5],c=(r[9]-1)/r[5],l=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=o*l,p=o*u,f=n/(-l+u),m=f*-l;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.getInverse(t.matrixWorld);var b=o+f,y=a+f,_=d-m,x=p+(n-m),w=h*a/y*b,M=c*a/y*b;t.projectionMatrix.makePerspective(_,x,w,M,b,y)}(u,c,l),u};var y=null;var _=new rr;_.setAnimationLoop((function(e,i){if(null!==(o=i.getViewerPose(r))){var s=o.views,h=n.renderState.baseLayer;t.setFramebuffer(h.framebuffer);for(var c=0;c<s.length;c++){var l=s[c],d=h.getViewport(l),p=l.transform.inverse.matrix,f=u.cameras[c];f.matrix.fromArray(p).getInverse(f.matrix),f.projectionMatrix.fromArray(l.projectionMatrix),f.viewport.set(d.x,d.y,d.width,d.height),0===c&&u.matrix.copy(f.matrix)}}var m=n.inputSources;for(c=0;c<a.length;c++){var g=a[c],v=m[c];if(v){var b=i.getPose(v.targetRaySpace,r);if(null!==b){g.matrix.fromArray(b.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.visible=!0;continue}}g.visible=!1}y&&y(e,i)})),this.setAnimationLoop=function(t){y=t},this.dispose=function(){}}function io(t){var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),i=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,r=void 0===t.depth||t.depth,s=void 0===t.stencil||t.stencil,o=void 0!==t.antialias&&t.antialias,a=void 0===t.premultipliedAlpha||t.premultipliedAlpha,h=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,c=void 0!==t.powerPreference?t.powerPreference:"default",l=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat,u=null,d=null;this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=Kt,this.physicallyCorrectLights=!1,this.toneMapping=1,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var p,f,m,g,v,b,y,_,x,w,M,T,S,E,P,A,C,L,R=this,I=!1,O=null,F=0,B=0,D=null,z=null,N=-1,U={geometry:null,program:null,wireframe:!1},V=null,k=null,j=new _e,H=new _e,G=null,W=e.width,q=e.height,X=1,Y=null,Z=null,$=new _e(0,0,W,q),J=new _e(0,0,W,q),Q=!1,K=new tr,tt=new ur,et=!1,it=!1,nt=new Le,rt=new pe;function st(){return null===D?X:1}try{var ot={alpha:n,depth:r,stencil:s,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:l,xrCompatible:!0};if(e.addEventListener("webglcontextlost",ut,!1),e.addEventListener("webglcontextrestored",dt,!1),null===(p=i||e.getContext("webgl",ot)||e.getContext("experimental-webgl",ot)))throw null!==e.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===p.getShaderPrecisionFormat&&(p.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function at(){f=new dr(p),!1===(m=new lr(p,f,t)).isWebGL2&&(f.get("WEBGL_depth_texture"),f.get("OES_texture_float"),f.get("OES_texture_half_float"),f.get("OES_texture_half_float_linear"),f.get("OES_standard_derivatives"),f.get("OES_element_index_uint"),f.get("ANGLE_instanced_arrays")),f.get("OES_texture_float_linear"),L=new $s(p,f,m),(g=new Ys(p,f,m)).scissor(H.copy(J).multiplyScalar(X).floor()),g.viewport(j.copy($).multiplyScalar(X).floor()),v=new mr(p),b=new Fs,y=new Zs(p,f,g,b,m,L,v),_=new sr(p),x=new pr(p,_,v),w=new br(p,x,_,v),P=new vr(p),M=new Os(R,f,m),T=new Ns,S=new Gs,E=new hr(R,g,w,a),A=new cr(p,f,v,m),C=new fr(p,f,v,m),v.programs=M.programs,R.capabilities=m,R.extensions=f,R.properties=b,R.renderLists=T,R.state=g,R.info=v}at();var ht=new eo(R,p);this.xr=ht;var ct=new Qs(R,p),lt=new Xs(R,w,m.maxTextureSize);function ut(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),I=!0}function dt(){console.log("THREE.WebGLRenderer: Context Restored."),I=!1,at()}function pt(t){var e=t.target;e.removeEventListener("dispose",pt),function(t){ft(t),b.remove(t)}(e)}function ft(t){var e=b.get(t).program;t.program=void 0,void 0!==e&&M.releaseProgram(e)}this.shadowMap=lt,this.getContext=function(){return p},this.getContextAttributes=function(){return p.getContextAttributes()},this.forceContextLoss=function(){var t=f.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=f.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(t){void 0!==t&&(X=t,this.setSize(W,q,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new ce),t.set(W,q)},this.setSize=function(t,i,n){ht.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(W=t,q=i,e.width=Math.floor(t*X),e.height=Math.floor(i*X),!1!==n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),t=new ce),t.set(W*X,q*X).floor()},this.setDrawingBufferSize=function(t,i,n){W=t,q=i,X=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),t=new _e),t.copy(j)},this.getViewport=function(t){return t.copy($)},this.setViewport=function(t,e,i,n){t.isVector4?$.set(t.x,t.y,t.z,t.w):$.set(t,e,i,n),g.viewport(j.copy($).multiplyScalar(X).floor())},this.getScissor=function(t){return t.copy(J)},this.setScissor=function(t,e,i,n){t.isVector4?J.set(t.x,t.y,t.z,t.w):J.set(t,e,i,n),g.scissor(H.copy(J).multiplyScalar(X).floor())},this.getScissorTest=function(){return Q},this.setScissorTest=function(t){g.setScissorTest(Q=t)},this.setOpaqueSort=function(t){Y=t},this.setTransparentSort=function(t){Z=t},this.getClearColor=function(){return E.getClearColor()},this.setClearColor=function(){E.setClearColor.apply(E,arguments)},this.getClearAlpha=function(){return E.getClearAlpha()},this.setClearAlpha=function(){E.setClearAlpha.apply(E,arguments)},this.clear=function(t,e,i){var n=0;(void 0===t||t)&&(n|=16384),(void 0===e||e)&&(n|=256),(void 0===i||i)&&(n|=1024),p.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ut,!1),e.removeEventListener("webglcontextrestored",dt,!1),T.dispose(),S.dispose(),b.dispose(),w.dispose(),ht.dispose(),vt.stop()},this.renderBufferImmediate=function(t,e){g.initAttributes();var i=b.get(t);t.hasPositions&&!i.position&&(i.position=p.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=p.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=p.createBuffer()),t.hasColors&&!i.color&&(i.color=p.createBuffer());var n=e.getAttributes();t.hasPositions&&(p.bindBuffer(34962,i.position),p.bufferData(34962,t.positionArray,35048),g.enableAttribute(n.position),p.vertexAttribPointer(n.position,3,5126,!1,0,0)),t.hasNormals&&(p.bindBuffer(34962,i.normal),p.bufferData(34962,t.normalArray,35048),g.enableAttribute(n.normal),p.vertexAttribPointer(n.normal,3,5126,!1,0,0)),t.hasUvs&&(p.bindBuffer(34962,i.uv),p.bufferData(34962,t.uvArray,35048),g.enableAttribute(n.uv),p.vertexAttribPointer(n.uv,2,5126,!1,0,0)),t.hasColors&&(p.bindBuffer(34962,i.color),p.bufferData(34962,t.colorArray,35048),g.enableAttribute(n.color),p.vertexAttribPointer(n.color,3,5126,!1,0,0)),g.disableUnusedAttributes(),p.drawArrays(4,0,t.count),t.count=0};var mt=new Ze;this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=mt);var o=r.isMesh&&r.matrixWorld.determinant()<0,a=wt(t,e,n,r);g.setMaterial(n,o);var h=!1;U.geometry===i.id&&U.program===a.id&&U.wireframe===(!0===n.wireframe)||(U.geometry=i.id,U.program=a.id,U.wireframe=!0===n.wireframe,h=!0),(n.morphTargets||n.morphNormals)&&(P.update(r,i,n,a),h=!0);var c=i.index,l=i.attributes.position;if(null===c){if(void 0===l||0===l.count)return}else if(0===c.count)return;var u,d=1;!0===n.wireframe&&(c=x.getWireframeAttribute(i),d=2);var v=A;null!==c&&(u=_.get(c),(v=C).setIndex(u)),h&&(!function(t,e,i,n){if(!1===m.isWebGL2&&(t.isInstancedMesh||e.isInstancedBufferGeometry)&&null===f.get("ANGLE_instanced_arrays"))return;g.initAttributes();var r=e.attributes,s=n.getAttributes(),o=i.defaultAttributeValues;for(var a in s){var h=s[a];if(h>=0){var c=r[a];if(void 0!==c){var l=c.normalized,u=c.itemSize;if(void 0===(M=_.get(c)))continue;var d=M.buffer,v=M.type,b=M.bytesPerElement;if(c.isInterleavedBufferAttribute){var y=c.data,x=y.stride,w=c.offset;y&&y.isInstancedInterleavedBuffer?(g.enableAttributeAndDivisor(h,y.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=y.meshPerAttribute*y.count)):g.enableAttribute(h),p.bindBuffer(34962,d),p.vertexAttribPointer(h,u,v,l,x*b,w*b)}else c.isInstancedBufferAttribute?(g.enableAttributeAndDivisor(h,c.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=c.meshPerAttribute*c.count)):g.enableAttribute(h),p.bindBuffer(34962,d),p.vertexAttribPointer(h,u,v,l,0,0)}else if("instanceMatrix"===a){var M;if(void 0===(M=_.get(t.instanceMatrix)))continue;d=M.buffer,v=M.type;g.enableAttributeAndDivisor(h+0,1),g.enableAttributeAndDivisor(h+1,1),g.enableAttributeAndDivisor(h+2,1),g.enableAttributeAndDivisor(h+3,1),p.bindBuffer(34962,d),p.vertexAttribPointer(h+0,4,v,!1,64,0),p.vertexAttribPointer(h+1,4,v,!1,64,16),p.vertexAttribPointer(h+2,4,v,!1,64,32),p.vertexAttribPointer(h+3,4,v,!1,64,48)}else if(void 0!==o){var T=o[a];if(void 0!==T)switch(T.length){case 2:p.vertexAttrib2fv(h,T);break;case 3:p.vertexAttrib3fv(h,T);break;case 4:p.vertexAttrib4fv(h,T);break;default:p.vertexAttrib1fv(h,T)}}}}g.disableUnusedAttributes()}(r,i,n,a),null!==c&&p.bindBuffer(34963,u.buffer));var b=null!==c?c.count:l.count,y=i.drawRange.start*d,w=i.drawRange.count*d,M=null!==s?s.start*d:0,T=null!==s?s.count*d:1/0,S=Math.max(y,M),E=Math.min(b,y+w,M+T)-1,L=Math.max(0,E-S+1);if(0!==L){if(r.isMesh)!0===n.wireframe?(g.setLineWidth(n.wireframeLinewidth*st()),v.setMode(1)):v.setMode(4);else if(r.isLine){var R=n.linewidth;void 0===R&&(R=1),g.setLineWidth(R*st()),r.isLineSegments?v.setMode(1):r.isLineLoop?v.setMode(2):v.setMode(3)}else r.isPoints?v.setMode(0):r.isSprite&&v.setMode(4);r.isInstancedMesh?v.renderInstances(i,S,L,r.count):i.isInstancedBufferGeometry?v.renderInstances(i,S,L,i.maxInstancedCount):v.render(S,L)}},this.compile=function(t,e){(d=S.get(t,e)).init(),t.traverse((function(t){t.isLight&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(e),t.traverse((function(e){if(e.material)if(Array.isArray(e.material))for(var i=0;i<e.material.length;i++)xt(e.material[i],t,e);else xt(e.material,t,e)}))};var gt=null;var vt=new rr;function bt(t,e,i,n){if(!1!==t.visible){if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)d.pushLight(t),t.castShadow&&d.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||K.intersectsSprite(t)){n&&rt.setFromMatrixPosition(t.matrixWorld).applyMatrix4(nt);var r=w.update(t);(s=t.material).visible&&u.push(t,r,s,i,rt.z,null)}}else if(t.isImmediateRenderObject)n&&rt.setFromMatrixPosition(t.matrixWorld).applyMatrix4(nt),u.push(t,null,t.material,i,rt.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==v.render.frame&&(t.skeleton.update(),t.skeleton.frame=v.render.frame),!t.frustumCulled||K.intersectsObject(t))){n&&rt.setFromMatrixPosition(t.matrixWorld).applyMatrix4(nt);r=w.update(t);var s=t.material;if(Array.isArray(s))for(var o=r.groups,a=0,h=o.length;a<h;a++){var c=o[a],l=s[c.materialIndex];l&&l.visible&&u.push(t,r,l,i,rt.z,c)}else s.visible&&u.push(t,r,s,i,rt.z,null)}var p=t.children;for(a=0,h=p.length;a<h;a++)bt(p[a],e,i,n)}}function yt(t,e,i,n){for(var r=0,s=t.length;r<s;r++){var o=t[r],a=o.object,h=o.geometry,c=void 0===n?o.material:n,l=o.group;if(i.isArrayCamera)if(k=i,ht.enabled&&ct.isAvailable())_t(a,e,i,h,c,l);else for(var u=i.cameras,p=0,f=u.length;p<f;p++){var m=u[p];a.layers.test(m.layers)&&(g.viewport(j.copy(m.viewport)),d.setupLights(m),_t(a,e,m,h,c,l))}else k=null,_t(a,e,i,h,c,l)}}function _t(t,e,i,n,r,s){if(t.onBeforeRender(R,e,i,n,r,s),d=S.get(e,k||i),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){var o=wt(i,e,r,t);g.setMaterial(r),U.geometry=null,U.program=null,U.wireframe=!1,function(t,e){t.render((function(t){R.renderBufferImmediate(t,e)}))}(t,o)}else R.renderBufferDirect(i,e,n,r,t,s);t.onAfterRender(R,e,i,n,r,s),d=S.get(e,k||i)}function xt(t,e,i){var n=b.get(t),r=d.state.lights,s=d.state.shadowsArray,o=r.state.version,a=M.getParameters(t,r.state,s,e,tt.numPlanes,tt.numIntersection,i),h=M.getProgramCacheKey(t,a),c=n.program,l=!0;if(void 0===c)t.addEventListener("dispose",pt);else if(c.cacheKey!==h)ft(t);else if(n.lightsStateVersion!==o)n.lightsStateVersion=o,l=!1;else{if(void 0!==a.shaderID)return;l=!1}if(l){if(a.shaderID){var u=nr[a.shaderID];n.shader={name:t.type,uniforms:jn(u.uniforms),vertexShader:u.vertexShader,fragmentShader:u.fragmentShader}}else n.shader={name:t.type,uniforms:t.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader};t.onBeforeCompile(n.shader,R),h=M.getProgramCacheKey(t,a),c=M.acquireProgram(t,n.shader,a,h),n.program=c,n.environment=t.isMeshStandardMaterial?e.environment:null,n.outputEncoding=R.outputEncoding,t.program=c}var p=c.getAttributes();if(t.morphTargets){t.numSupportedMorphTargets=0;for(var f=0;f<R.maxMorphTargets;f++)p["morphTarget"+f]>=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(f=0;f<R.maxMorphNormals;f++)p["morphNormal"+f]>=0&&t.numSupportedMorphNormals++}var m=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=tt.numPlanes,n.numIntersection=tt.numIntersection,m.clippingPlanes=tt.uniform),n.fog=e.fog,n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=o,n.needsLights&&(m.ambientLightColor.value=r.state.ambient,m.lightProbe.value=r.state.probe,m.directionalLights.value=r.state.directional,m.spotLights.value=r.state.spot,m.rectAreaLights.value=r.state.rectArea,m.pointLights.value=r.state.point,m.hemisphereLights.value=r.state.hemi,m.directionalShadowMap.value=r.state.directionalShadowMap,m.directionalShadowMatrix.value=r.state.directionalShadowMatrix,m.spotShadowMap.value=r.state.spotShadowMap,m.spotShadowMatrix.value=r.state.spotShadowMatrix,m.pointShadowMap.value=r.state.pointShadowMap,m.pointShadowMatrix.value=r.state.pointShadowMatrix);var g=n.program.getUniforms(),v=ms.seqWithValue(g.seq,m);n.uniformsList=v}function wt(t,e,i,n){y.resetTextureUnits();var r=e.fog,s=i.isMeshStandardMaterial?e.environment:null,o=b.get(i),a=d.state.lights;if(et&&(it||t!==V)){var h=t===V&&i.id===N;tt.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,t,o,h)}i.version===o.__version&&(void 0===o.program||i.fog&&o.fog!==r||o.environment!==s||o.needsLights&&o.lightsStateVersion!==a.state.version?i.needsUpdate=!0:void 0===o.numClippingPlanes||o.numClippingPlanes===tt.numPlanes&&o.numIntersection===tt.numIntersection?o.outputEncoding!==R.outputEncoding&&(i.needsUpdate=!0):i.needsUpdate=!0),i.version!==o.__version&&(xt(i,e,n),o.__version=i.version);var c,l,u=!1,f=!1,v=!1,_=o.program,x=_.getUniforms(),w=o.shader.uniforms;if(g.useProgram(_.program)&&(u=!0,f=!0,v=!0),i.id!==N&&(N=i.id,f=!0),u||V!==t){if(_.numMultiviewViews>0?ct.updateCameraProjectionMatricesUniform(t,x):x.setValue(p,"projectionMatrix",t.projectionMatrix),m.logarithmicDepthBuffer&&x.setValue(p,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),V!==t&&(V=t,f=!0,v=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){var M=x.map.cameraPosition;void 0!==M&&M.setValue(p,rt.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&x.setValue(p,"isOrthographic",!0===t.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&(_.numMultiviewViews>0?ct.updateCameraViewMatricesUniform(t,x):x.setValue(p,"viewMatrix",t.matrixWorldInverse))}if(i.skinning){x.setOptional(p,n,"bindMatrix"),x.setOptional(p,n,"bindMatrixInverse");var T=n.skeleton;if(T){var S=T.bones;if(m.floatVertexTextures){if(void 0===T.boneTexture){var E=Math.sqrt(4*S.length);E=he.ceilPowerOfTwo(E),E=Math.max(E,4);var P=new Float32Array(E*E*4);P.set(T.boneMatrices);var A=new Jn(P,E,E,Ft,Et);T.boneMatrices=P,T.boneTexture=A,T.boneTextureSize=E}x.setValue(p,"boneTexture",T.boneTexture,y),x.setValue(p,"boneTextureSize",T.boneTextureSize)}else x.setOptional(p,T,"boneMatrices")}}return(f||o.receiveShadow!==n.receiveShadow)&&(o.receiveShadow=n.receiveShadow,x.setValue(p,"receiveShadow",n.receiveShadow)),f&&(x.setValue(p,"toneMappingExposure",R.toneMappingExposure),x.setValue(p,"toneMappingWhitePoint",R.toneMappingWhitePoint),o.needsLights&&(l=v,(c=w).ambientLightColor.needsUpdate=l,c.lightProbe.needsUpdate=l,c.directionalLights.needsUpdate=l,c.pointLights.needsUpdate=l,c.spotLights.needsUpdate=l,c.rectAreaLights.needsUpdate=l,c.hemisphereLights.needsUpdate=l),r&&i.fog&&function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(w,r),i.isMeshBasicMaterial?Tt(w,i):i.isMeshLambertMaterial?(Tt(w,i),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(w,i)):i.isMeshToonMaterial?(Tt(w,i),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,i)):i.isMeshPhongMaterial?(Tt(w,i),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,i)):i.isMeshStandardMaterial?(Tt(w,i,s),i.isMeshPhysicalMaterial?function(t,e,i){St(t,e,i),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate());t.transparency.value=e.transparency}(w,i,s):St(w,i,s)):i.isMeshMatcapMaterial?(Tt(w,i),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,i)):i.isMeshDepthMaterial?(Tt(w,i),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,i)):i.isMeshDistanceMaterial?(Tt(w,i),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(w,i)):i.isMeshNormalMaterial?(Tt(w,i),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,i)):i.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(w,i),i.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(w,i)):i.isPointsMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*X,t.scale.value=.5*q,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(w,i):i.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(w,i):i.isShadowMaterial&&(w.color.value.copy(i.color),w.opacity.value=i.opacity),void 0!==w.ltc_1&&(w.ltc_1.value=ir.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=ir.LTC_2),ms.upload(p,o.uniformsList,w,y),i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ms.upload(p,o.uniformsList,w,y),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&x.setValue(p,"center",n.center),_.numMultiviewViews>0?ct.updateObjectMatricesUniforms(n,t,x):(x.setValue(p,"modelViewMatrix",n.modelViewMatrix),x.setValue(p,"normalMatrix",n.normalMatrix)),x.setValue(p,"modelMatrix",n.matrixWorld),_}function Tt(t,e,i){t.opacity.value=e.opacity,e.color&&t.diffuse.value.copy(e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap);var n,r,s=e.envMap||i;s&&(t.envMap.value=s,t.flipEnvMap.value=s.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=b.get(s).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix)),e.aoMap?r=e.aoMap:e.lightMap&&(r=e.lightMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uv2Transform.value.copy(r.matrix))}function St(t,e,i){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),(e.envMap||i)&&(t.envMapIntensity.value=e.envMapIntensity)}vt.setAnimationLoop((function(t){ht.isPresenting||gt&&gt(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){gt=t,ht.setAnimationLoop(t),vt.start()},this.render=function(t,e){var i,n;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),i=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),n=arguments[3]),e&&e.isCamera){if(!I){U.geometry=null,U.program=null,U.wireframe=!1,N=-1,V=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),ht.enabled&&ht.isPresenting&&(e=ht.getCamera(e)),(d=S.get(t,e)).init(),t.onBeforeRender(R,t,e,i||D),nt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),K.setFromMatrix(nt),it=this.localClippingEnabled,et=tt.init(this.clippingPlanes,it,e),(u=T.get(t,e)).init(),bt(t,e,0,R.sortObjects),!0===R.sortObjects&&u.sort(Y,Z),et&&tt.beginShadows();var r=d.state.shadowsArray;lt.render(r,t,e),d.setupLights(e),et&&tt.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==i&&this.setRenderTarget(i),ht.enabled&&ct.isAvailable()&&ct.attachCamera(e),E.render(u,t,e,n);var s=u.opaque,o=u.transparent;if(t.overrideMaterial){var a=t.overrideMaterial;s.length&&yt(s,t,e,a),o.length&&yt(o,t,e,a)}else s.length&&yt(s,t,e),o.length&&yt(o,t,e);t.onAfterRender(R,t,e),null!==D&&(y.updateRenderTargetMipmap(D),y.updateMultisampleRenderTarget(D)),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1),ht.enabled&&ct.isAvailable()&&ct.detachCamera(e),u=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(t){O!==t&&null===D&&p.bindFramebuffer(36160,t),O=t},this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return D},this.setRenderTarget=function(t,e,i){D=t,F=e,B=i,t&&void 0===b.get(t).__webglFramebuffer&&y.setupRenderTarget(t);var n=O,r=!1;if(t){var s=b.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(n=s[e||0],r=!0):n=t.isWebGLMultisampleRenderTarget?b.get(t).__webglMultisampledFramebuffer:s,j.copy(t.viewport),H.copy(t.scissor),G=t.scissorTest}else j.copy($).multiplyScalar(X).floor(),H.copy(J).multiplyScalar(X).floor(),G=Q;if(z!==n&&(p.bindFramebuffer(36160,n),z=n),g.viewport(j),g.scissor(H),g.setScissorTest(G),r){var o=b.get(t.texture);p.framebufferTexture2D(36160,36064,34069+(e||0),o.__webglTexture,i||0)}},this.readRenderTargetPixels=function(t,e,i,n,r,s,o){if(t&&t.isWebGLRenderTarget){var a=b.get(t).__webglFramebuffer;if(t.isWebGLRenderTargetCube&&void 0!==o&&(a=a[o]),a){var h=!1;a!==z&&(p.bindFramebuffer(36160,a),h=!0);try{var c=t.texture,l=c.format,u=c.type;if(l!==Ft&&L.convert(l)!==p.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(u===Mt||L.convert(u)===p.getParameter(35738)||u===Et&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||u===Pt&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===p.checkFramebufferStatus(36160)?e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&p.readPixels(e,i,n,r,L.convert(l),L.convert(u),s):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{h&&p.bindFramebuffer(36160,z)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,i){void 0===i&&(i=0);var n=Math.pow(2,-i),r=Math.floor(e.image.width*n),s=Math.floor(e.image.height*n),o=L.convert(e.format);y.setTexture2D(e,0),p.copyTexImage2D(3553,i,o,t.x,t.y,r,s,0),g.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n){var r=e.image.width,s=e.image.height,o=L.convert(i.format),a=L.convert(i.type);y.setTexture2D(i,0),e.isDataTexture?p.texSubImage2D(3553,n||0,t.x,t.y,r,s,o,a,e.image.data):p.texSubImage2D(3553,n||0,t.x,t.y,o,a,e.image),g.unbindTexture()},this.initTexture=function(t){y.setTexture2D(t,0),g.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function no(t,e){this.name="",this.color=new Ui(t),this.density=void 0!==e?e:25e-5}function ro(t,e,i){this.name="",this.color=new Ui(t),this.near=void 0!==e?e:1,this.far=void 0!==i?i:1e3}function so(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=ne,this.updateRange={offset:0,count:-1},this.version=0}Js.prototype=Object.assign(Object.create(xe.prototype),{constructor:Js,isWebGLMultiviewRenderTarget:!0,copy:function(t){return xe.prototype.copy.call(this,t),this.numViews=t.numViews,this},setNumViews:function(t){return this.numViews!==t&&(this.numViews=t,this.dispose()),this}}),Ks.prototype=Object.assign(Object.create(Xn.prototype),{constructor:Ks,isArrayCamera:!0}),to.prototype=Object.assign(Object.create(Ye.prototype),{constructor:to,isGroup:!0}),Object.assign(eo.prototype,se.prototype),Object.assign(no.prototype,{isFogExp2:!0,clone:function(){return new no(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(ro.prototype,{isFog:!0,clone:function(){return new ro(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(so.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(so.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.stride,i*=e.stride;for(var n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}});var oo,ao=new pe;function ho(t,e,i,n){this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===n}function co(t){Wi.call(this),this.type="SpriteMaterial",this.color=new Ui(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.defineProperties(ho.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(ho.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(var e=0,i=this.data.count;e<i;e++)ao.x=this.getX(e),ao.y=this.getY(e),ao.z=this.getZ(e),ao.applyMatrix4(t),this.setXYZ(e,ao.x,ao.y,ao.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this}}),co.prototype=Object.create(Wi.prototype),co.prototype.constructor=co,co.prototype.isSpriteMaterial=!0,co.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};var lo=new pe,uo=new pe,po=new pe,fo=new ce,mo=new ce,go=new Le,vo=new pe,bo=new pe,yo=new pe,_o=new ce,xo=new ce,wo=new ce;function Mo(t){if(Ye.call(this),this.type="Sprite",void 0===oo){oo=new fn;var e=new so(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);oo.setIndex([0,1,2,0,2,3]),oo.setAttribute("position",new ho(e,3,0,!1)),oo.setAttribute("uv",new ho(e,2,3,!1))}this.geometry=oo,this.material=void 0!==t?t:new co,this.center=new ce(.5,.5)}function To(t,e,i,n,r,s){fo.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(mo.x=s*fo.x-r*fo.y,mo.y=r*fo.x+s*fo.y):mo.copy(fo),t.copy(e),t.x+=mo.x,t.y+=mo.y,t.applyMatrix4(go)}Mo.prototype=Object.assign(Object.create(Ye.prototype),{constructor:Mo,isSprite:!0,raycast:function(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),uo.setFromMatrixScale(this.matrixWorld),go.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),po.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&uo.multiplyScalar(-po.z);var i,n,r=this.material.rotation;0!==r&&(n=Math.cos(r),i=Math.sin(r));var s=this.center;To(vo.set(-.5,-.5,0),po,s,uo,i,n),To(bo.set(.5,-.5,0),po,s,uo,i,n),To(yo.set(.5,.5,0),po,s,uo,i,n),_o.set(0,0),xo.set(1,0),wo.set(1,1);var o=t.ray.intersectTriangle(vo,bo,yo,!1,lo);if(null!==o||(To(bo.set(-.5,.5,0),po,s,uo,i,n),xo.set(0,1),null!==(o=t.ray.intersectTriangle(vo,yo,bo,!1,lo)))){var a=t.ray.origin.distanceTo(lo);a<t.near||a>t.far||e.push({distance:a,point:lo.clone(),uv:Bi.getUV(lo,vo,bo,yo,_o,xo,wo,new ce),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return Ye.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}});var So=new pe,Eo=new pe;function Po(){Ye.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function Ao(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),In.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Le,this.bindMatrixInverse=new Le}Po.prototype=Object.assign(Object.create(Ye.prototype),{constructor:Po,isLOD:!0,copy:function(t){Ye.prototype.copy.call(this,t,!1);for(var e=t.levels,i=0,n=e.length;i<n;i++){var r=e[i];this.addLevel(r.object.clone(),r.distance)}return this.autoUpdate=t.autoUpdate,this},addLevel:function(t,e){void 0===e&&(e=0),e=Math.abs(e);for(var i=this.levels,n=0;n<i.length&&!(e<i[n].distance);n++);return i.splice(n,0,{distance:e,object:t}),this.add(t),this},getObjectForDistance:function(t){var e=this.levels;if(e.length>0){for(var i=1,n=e.length;i<n&&!(t<e[i].distance);i++);return e[i-1].object}return null},raycast:function(t,e){if(this.levels.length>0){So.setFromMatrixPosition(this.matrixWorld);var i=t.ray.origin.distanceTo(So);this.getObjectForDistance(i).raycast(t,e)}},update:function(t){var e=this.levels;if(e.length>1){So.setFromMatrixPosition(t.matrixWorld),Eo.setFromMatrixPosition(this.matrixWorld);var i=So.distanceTo(Eo);e[0].object.visible=!0;for(var n=1,r=e.length;n<r&&i>=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(;n<r;n++)e[n].object.visible=!1}},toJSON:function(t){var e=Ye.prototype.toJSON.call(this,t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];for(var i=this.levels,n=0,r=i.length;n<r;n++){var s=i[n];e.object.levels.push({object:s.object.uuid,distance:s.distance})}return e}}),Ao.prototype=Object.assign(Object.create(In.prototype),{constructor:Ao,isSkinnedMesh:!0,bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var t=new _e,e=this.geometry.attributes.skinWeight,i=0,n=e.count;i<n;i++){t.x=e.getX(i),t.y=e.getY(i),t.z=e.getZ(i),t.w=e.getW(i);var r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){In.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Co=new Le,Lo=new Le;function Ro(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),this.frame=-1,void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Le)}}function Io(){Ye.call(this),this.type="Bone"}Object.assign(Ro.prototype,{calculateInverses:function(){this.boneInverses=[];for(var t=0,e=this.bones.length;t<e;t++){var i=new Le;this.bones[t]&&i.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(i)}},pose:function(){var t,e,i;for(e=0,i=this.bones.length;e<i;e++)(t=this.bones[e])&&t.matrixWorld.getInverse(this.boneInverses[e]);for(e=0,i=this.bones.length;e<i;e++)(t=this.bones[e])&&(t.parent&&t.parent.isBone?(t.matrix.getInverse(t.parent.matrixWorld),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))},update:function(){for(var t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture,r=0,s=t.length;r<s;r++){var o=t[r]?t[r].matrixWorld:Lo;Co.multiplyMatrices(o,e[r]),Co.toArray(i,16*r)}void 0!==n&&(n.needsUpdate=!0)},clone:function(){return new Ro(this.bones,this.boneInverses)},getBoneByName:function(t){for(var e=0,i=this.bones.length;e<i;e++){var n=this.bones[e];if(n.name===t)return n}}}),Io.prototype=Object.assign(Object.create(Ye.prototype),{constructor:Io,isBone:!0});var Oo=new Le,Fo=new Le,Bo=[],Do=new In;function zo(t,e,i){In.call(this,t,e),this.instanceMatrix=new Yi(new Float32Array(16*i),16),this.count=i}function No(t){Wi.call(this),this.type="LineBasicMaterial",this.color=new Ui(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(t)}zo.prototype=Object.assign(Object.create(In.prototype),{constructor:zo,isInstancedMesh:!0,getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,16*t)},raycast:function(t,e){var i=this.matrixWorld,n=this.count;if(Do.geometry=this.geometry,Do.material=this.material,void 0!==Do.material)for(var r=0;r<n;r++)this.getMatrixAt(r,Oo),Fo.multiplyMatrices(i,Oo),Do.matrixWorld=Fo,Do.raycast(t,Bo),Bo.length>0&&(Bo[0].instanceId=r,Bo[0].object=this,e.push(Bo[0]),Bo.length=0)},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,16*t)},updateMorphTargets:function(){}}),No.prototype=Object.create(Wi.prototype),No.prototype.constructor=No,No.prototype.isLineBasicMaterial=!0,No.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this};var Uo=new pe,Vo=new pe,ko=new Le,jo=new _i,Ho=new di;function Go(t,e,i){1===i&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),Ye.call(this),this.type="Line",this.geometry=void 0!==t?t:new fn,this.material=void 0!==e?e:new No({color:16777215*Math.random()})}Go.prototype=Object.assign(Object.create(Ye.prototype),{constructor:Go,isLine:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,i=[0],n=1,r=e.count;n<r;n++)Uo.fromBufferAttribute(e,n-1),Vo.fromBufferAttribute(e,n),i[n]=i[n-1],i[n]+=Uo.distanceTo(Vo);t.setAttribute("lineDistance",new nn(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){var s=t.vertices;(i=t.lineDistances)[0]=0;for(n=1,r=s.length;n<r;n++)i[n]=i[n-1],i[n]+=s[n-1].distanceTo(s[n])}return this},raycast:function(t,e){var i=t.linePrecision,n=this.geometry,r=this.matrixWorld;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ho.copy(n.boundingSphere),Ho.applyMatrix4(r),Ho.radius+=i,!1!==t.ray.intersectsSphere(Ho)){ko.getInverse(r),jo.copy(t.ray).applyMatrix4(ko);var s=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,a=new pe,h=new pe,c=new pe,l=new pe,u=this&&this.isLineSegments?2:1;if(n.isBufferGeometry){var d=n.index,p=n.attributes.position.array;if(null!==d)for(var f=d.array,m=0,g=f.length-1;m<g;m+=u){var v=f[m],b=f[m+1];if(a.fromArray(p,3*v),h.fromArray(p,3*b),!(jo.distanceSqToSegment(a,h,l,c)>o))l.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(l))<t.near||x>t.far||e.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,g=p.length/3-1;m<g;m+=u){if(a.fromArray(p,3*m),h.fromArray(p,3*m+3),!(jo.distanceSqToSegment(a,h,l,c)>o))l.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(l))<t.near||x>t.far||e.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(n.isGeometry){var y=n.vertices,_=y.length;for(m=0;m<_-1;m+=u){var x;if(!(jo.distanceSqToSegment(y[m],y[m+1],l,c)>o))l.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(l))<t.near||x>t.far||e.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Wo=new pe,qo=new pe;function Xo(t,e){Go.call(this,t,e),this.type="LineSegments"}function Yo(t,e){Go.call(this,t,e),this.type="LineLoop"}function Zo(t){Wi.call(this),this.type="PointsMaterial",this.color=new Ui(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}Xo.prototype=Object.assign(Object.create(Go.prototype),{constructor:Xo,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,i=[],n=0,r=e.count;n<r;n+=2)Wo.fromBufferAttribute(e,n),qo.fromBufferAttribute(e,n+1),i[n]=0===n?0:i[n-1],i[n+1]=i[n]+Wo.distanceTo(qo);t.setAttribute("lineDistance",new nn(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){var s=t.vertices;for(i=t.lineDistances,n=0,r=s.length;n<r;n+=2)Wo.copy(s[n]),qo.copy(s[n+1]),i[n]=0===n?0:i[n-1],i[n+1]=i[n]+Wo.distanceTo(qo)}return this}}),Yo.prototype=Object.assign(Object.create(Go.prototype),{constructor:Yo,isLineLoop:!0}),Zo.prototype=Object.create(Wi.prototype),Zo.prototype.constructor=Zo,Zo.prototype.isPointsMaterial=!0,Zo.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this};var $o=new Le,Jo=new _i,Qo=new di,Ko=new pe;function ta(t,e){Ye.call(this),this.type="Points",this.geometry=void 0!==t?t:new fn,this.material=void 0!==e?e:new Zo({color:16777215*Math.random()}),this.updateMorphTargets()}function ea(t,e,i,n,r,s,o){var a=Jo.distanceSqToPoint(t);if(a<i){var h=new pe;Jo.closestPointToPoint(t,h),h.applyMatrix4(n);var c=r.ray.origin.distanceTo(h);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:h,index:e,face:null,object:o})}}function ia(t,e,i,n,r,s,o,a,h){ye.call(this,t,e,i,n,r,s,o,a,h),this.format=void 0!==o?o:Ot,this.minFilter=void 0!==s?s:yt,this.magFilter=void 0!==r?r:yt,this.generateMipmaps=!1}function na(t,e,i,n,r,s,o,a,h,c,l,u){ye.call(this,null,s,o,a,h,c,n,r,l,u),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function ra(t,e,i,n,r,s,o,a,h){ye.call(this,t,e,i,n,r,s,o,a,h),this.needsUpdate=!0}function sa(t,e,i,n,r,s,o,a,h,c){if((c=void 0!==c?c:zt)!==zt&&c!==Nt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===zt&&(i=Tt),void 0===i&&c===Nt&&(i=Rt),ye.call(this,null,n,r,s,o,a,c,i,h),this.image={width:t,height:e},this.magFilter=void 0!==o?o:ft,this.minFilter=void 0!==a?a:ft,this.flipY=!1,this.generateMipmaps=!1}function oa(t){fn.call(this),this.type="WireframeGeometry";var e,i,n,r,s,o,a,h,c,l,u=[],d=[0,0],p={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,n=m.length;e<n;e++){var g=m[e];for(i=0;i<3;i++)a=g[f[i]],h=g[f[(i+1)%3]],d[0]=Math.min(a,h),d[1]=Math.max(a,h),void 0===p[c=d[0]+","+d[1]]&&(p[c]={index1:d[0],index2:d[1]})}for(c in p)o=p[c],l=t.vertices[o.index1],u.push(l.x,l.y,l.z),l=t.vertices[o.index2],u.push(l.x,l.y,l.z)}else if(t&&t.isBufferGeometry){var v,b,y,_,x,w,M;if(l=new pe,null!==t.index){for(v=t.attributes.position,b=t.index,0===(y=t.groups).length&&(y=[{start:0,count:b.count,materialIndex:0}]),r=0,s=y.length;r<s;++r)for(e=x=(_=y[r]).start,n=x+_.count;e<n;e+=3)for(i=0;i<3;i++)a=b.getX(e+i),h=b.getX(e+(i+1)%3),d[0]=Math.min(a,h),d[1]=Math.max(a,h),void 0===p[c=d[0]+","+d[1]]&&(p[c]={index1:d[0],index2:d[1]});for(c in p)o=p[c],l.fromBufferAttribute(v,o.index1),u.push(l.x,l.y,l.z),l.fromBufferAttribute(v,o.index2),u.push(l.x,l.y,l.z)}else for(e=0,n=(v=t.attributes.position).count/3;e<n;e++)for(i=0;i<3;i++)w=3*e+i,l.fromBufferAttribute(v,w),u.push(l.x,l.y,l.z),M=3*e+(i+1)%3,l.fromBufferAttribute(v,M),u.push(l.x,l.y,l.z)}this.setAttribute("position",new nn(u,3))}function aa(t,e,i){Un.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i},this.fromBufferGeometry(new ha(t,e,i)),this.mergeVertices()}function ha(t,e,i){fn.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:i};var n,r,s=[],o=[],a=[],h=[],c=1e-5,l=new pe,u=new pe,d=new pe,p=new pe,f=new pe;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var m=e+1;for(n=0;n<=i;n++){var g=n/i;for(r=0;r<=e;r++){var v=r/e;t(v,g,u),o.push(u.x,u.y,u.z),v-c>=0?(t(v-c,g,d),p.subVectors(u,d)):(t(v+c,g,d),p.subVectors(d,u)),g-c>=0?(t(v,g-c,d),f.subVectors(u,d)):(t(v,g+c,d),f.subVectors(d,u)),l.crossVectors(p,f).normalize(),a.push(l.x,l.y,l.z),h.push(v,g)}}for(n=0;n<i;n++)for(r=0;r<e;r++){var b=n*m+r,y=n*m+r+1,_=(n+1)*m+r+1,x=(n+1)*m+r;s.push(b,y,x),s.push(y,_,x)}this.setIndex(s),this.setAttribute("position",new nn(o,3)),this.setAttribute("normal",new nn(a,3)),this.setAttribute("uv",new nn(h,2))}function ca(t,e,i,n){Un.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n},this.fromBufferGeometry(new la(t,e,i,n)),this.mergeVertices()}function la(t,e,i,n){fn.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n},i=i||1;var r=[],s=[];function o(t,e,i,n){var r,s,o=Math.pow(2,n),h=[];for(r=0;r<=o;r++){h[r]=[];var c=t.clone().lerp(i,r/o),l=e.clone().lerp(i,r/o),u=o-r;for(s=0;s<=u;s++)h[r][s]=0===s&&r===o?c:c.clone().lerp(l,s/u)}for(r=0;r<o;r++)for(s=0;s<2*(o-r)-1;s++){var d=Math.floor(s/2);s%2==0?(a(h[r][d+1]),a(h[r+1][d]),a(h[r][d])):(a(h[r][d+1]),a(h[r+1][d+1]),a(h[r+1][d]))}}function a(t){r.push(t.x,t.y,t.z)}function h(e,i){var n=3*e;i.x=t[n+0],i.y=t[n+1],i.z=t[n+2]}function c(t,e,i,n){n<0&&1===t.x&&(s[e]=t.x-1),0===i.x&&0===i.z&&(s[e]=n/2/Math.PI+.5)}function l(t){return Math.atan2(t.z,-t.x)}!function(t){for(var i=new pe,n=new pe,r=new pe,s=0;s<e.length;s+=3)h(e[s+0],i),h(e[s+1],n),h(e[s+2],r),o(i,n,r,t)}(n=n||0),function(t){for(var e=new pe,i=0;i<r.length;i+=3)e.x=r[i+0],e.y=r[i+1],e.z=r[i+2],e.normalize().multiplyScalar(t),r[i+0]=e.x,r[i+1]=e.y,r[i+2]=e.z}(i),function(){for(var t=new pe,e=0;e<r.length;e+=3){t.x=r[e+0],t.y=r[e+1],t.z=r[e+2];var i=l(t)/2/Math.PI+.5,n=(o=t,Math.atan2(-o.y,Math.sqrt(o.x*o.x+o.z*o.z))/Math.PI+.5);s.push(i,1-n)}var o;(function(){for(var t=new pe,e=new pe,i=new pe,n=new pe,o=new ce,a=new ce,h=new ce,u=0,d=0;u<r.length;u+=9,d+=6){t.set(r[u+0],r[u+1],r[u+2]),e.set(r[u+3],r[u+4],r[u+5]),i.set(r[u+6],r[u+7],r[u+8]),o.set(s[d+0],s[d+1]),a.set(s[d+2],s[d+3]),h.set(s[d+4],s[d+5]),n.copy(t).add(e).add(i).divideScalar(3);var p=l(n);c(o,d+0,t,p),c(a,d+2,e,p),c(h,d+4,i,p)}})(),function(){for(var t=0;t<s.length;t+=6){var e=s[t+0],i=s[t+2],n=s[t+4],r=Math.max(e,i,n),o=Math.min(e,i,n);r>.9&&o<.1&&(e<.2&&(s[t+0]+=1),i<.2&&(s[t+2]+=1),n<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new nn(r,3)),this.setAttribute("normal",new nn(r.slice(),3)),this.setAttribute("uv",new nn(s,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}function ua(t,e){Un.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new da(t,e)),this.mergeVertices()}function da(t,e){la.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function pa(t,e){Un.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new fa(t,e)),this.mergeVertices()}function fa(t,e){la.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ma(t,e){Un.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ga(t,e)),this.mergeVertices()}function ga(t,e){var i=(1+Math.sqrt(5))/2,n=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];la.call(this,n,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function va(t,e){Un.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ba(t,e)),this.mergeVertices()}function ba(t,e){var i=(1+Math.sqrt(5))/2,n=1/i,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n];la.call(this,r,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ya(t,e,i,n,r,s){Un.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:r},void 0!==s&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new _a(t,e,i,n,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function _a(t,e,i,n,r){fn.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:r},e=e||64,i=i||1,n=n||8,r=r||!1;var s=t.computeFrenetFrames(e,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;var o,a,h=new pe,c=new pe,l=new ce,u=new pe,d=[],p=[],f=[],m=[];function g(r){u=t.getPointAt(r/e,u);var o=s.normals[r],l=s.binormals[r];for(a=0;a<=n;a++){var f=a/n*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);c.x=g*o.x+m*l.x,c.y=g*o.y+m*l.y,c.z=g*o.z+m*l.z,c.normalize(),p.push(c.x,c.y,c.z),h.x=u.x+i*c.x,h.y=u.y+i*c.y,h.z=u.z+i*c.z,d.push(h.x,h.y,h.z)}}!function(){for(o=0;o<e;o++)g(o);g(!1===r?e:0),function(){for(o=0;o<=e;o++)for(a=0;a<=n;a++)l.x=o/e,l.y=a/n,f.push(l.x,l.y)}(),function(){for(a=1;a<=e;a++)for(o=1;o<=n;o++){var t=(n+1)*(a-1)+(o-1),i=(n+1)*a+(o-1),r=(n+1)*a+o,s=(n+1)*(a-1)+o;m.push(t,i,s),m.push(i,r,s)}}()}(),this.setIndex(m),this.setAttribute("position",new nn(d,3)),this.setAttribute("normal",new nn(p,3)),this.setAttribute("uv",new nn(f,2))}function xa(t,e,i,n,r,s,o){Un.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:r,q:s},void 0!==o&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new wa(t,e,i,n,r,s)),this.mergeVertices()}function wa(t,e,i,n,r,s){fn.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:r,q:s},t=t||1,e=e||.4,i=Math.floor(i)||64,n=Math.floor(n)||8,r=r||2,s=s||3;var o,a,h=[],c=[],l=[],u=[],d=new pe,p=new pe,f=new pe,m=new pe,g=new pe,v=new pe,b=new pe;for(o=0;o<=i;++o){var y=o/i*r*Math.PI*2;for(P(y,r,s,t,f),P(y+.01,r,s,t,m),v.subVectors(m,f),b.addVectors(m,f),g.crossVectors(v,b),b.crossVectors(g,v),g.normalize(),b.normalize(),a=0;a<=n;++a){var _=a/n*Math.PI*2,x=-e*Math.cos(_),w=e*Math.sin(_);d.x=f.x+(x*b.x+w*g.x),d.y=f.y+(x*b.y+w*g.y),d.z=f.z+(x*b.z+w*g.z),c.push(d.x,d.y,d.z),p.subVectors(d,f).normalize(),l.push(p.x,p.y,p.z),u.push(o/i),u.push(a/n)}}for(a=1;a<=i;a++)for(o=1;o<=n;o++){var M=(n+1)*(a-1)+(o-1),T=(n+1)*a+(o-1),S=(n+1)*a+o,E=(n+1)*(a-1)+o;h.push(M,T,E),h.push(T,S,E)}function P(t,e,i,n,r){var s=Math.cos(t),o=Math.sin(t),a=i/e*t,h=Math.cos(a);r.x=n*(2+h)*.5*s,r.y=n*(2+h)*o*.5,r.z=n*Math.sin(a)*.5}this.setIndex(h),this.setAttribute("position",new nn(c,3)),this.setAttribute("normal",new nn(l,3)),this.setAttribute("uv",new nn(u,2))}function Ma(t,e,i,n,r){Un.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r},this.fromBufferGeometry(new Ta(t,e,i,n,r)),this.mergeVertices()}function Ta(t,e,i,n,r){fn.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r},t=t||1,e=e||.4,i=Math.floor(i)||8,n=Math.floor(n)||6,r=r||2*Math.PI;var s,o,a=[],h=[],c=[],l=[],u=new pe,d=new pe,p=new pe;for(s=0;s<=i;s++)for(o=0;o<=n;o++){var f=o/n*r,m=s/i*Math.PI*2;d.x=(t+e*Math.cos(m))*Math.cos(f),d.y=(t+e*Math.cos(m))*Math.sin(f),d.z=e*Math.sin(m),h.push(d.x,d.y,d.z),u.x=t*Math.cos(f),u.y=t*Math.sin(f),p.subVectors(d,u).normalize(),c.push(p.x,p.y,p.z),l.push(o/n),l.push(s/i)}for(s=1;s<=i;s++)for(o=1;o<=n;o++){var g=(n+1)*s+o-1,v=(n+1)*(s-1)+o-1,b=(n+1)*(s-1)+o,y=(n+1)*s+o;a.push(g,v,y),a.push(v,b,y)}this.setIndex(a),this.setAttribute("position",new nn(h,3)),this.setAttribute("normal",new nn(c,3)),this.setAttribute("uv",new nn(l,2))}ta.prototype=Object.assign(Object.create(Ye.prototype),{constructor:ta,isPoints:!0,raycast:function(t,e){var i=this.geometry,n=this.matrixWorld,r=t.params.Points.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Qo.copy(i.boundingSphere),Qo.applyMatrix4(n),Qo.radius+=r,!1!==t.ray.intersectsSphere(Qo)){$o.getInverse(n),Jo.copy(t.ray).applyMatrix4($o);var s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s;if(i.isBufferGeometry){var a=i.index,h=i.attributes.position.array;if(null!==a)for(var c=a.array,l=0,u=c.length;l<u;l++){var d=c[l];Ko.fromArray(h,3*d),ea(Ko,d,o,n,t,e,this)}else{l=0;for(var p=h.length/3;l<p;l++)Ko.fromArray(h,3*l),ea(Ko,l,o,n,t,e,this)}}else{var f=i.vertices;for(l=0,p=f.length;l<p;l++)ea(f[l],l,o,n,t,e,this)}}},updateMorphTargets:function(){var t,e,i,n=this.geometry;if(n.isBufferGeometry){var r=n.morphAttributes,s=Object.keys(r);if(s.length>0){var o=r[s[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t<e;t++)i=o[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}else{var a=n.morphTargets;void 0!==a&&a.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ia.prototype=Object.assign(Object.create(ye.prototype),{constructor:ia,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),na.prototype=Object.create(ye.prototype),na.prototype.constructor=na,na.prototype.isCompressedTexture=!0,ra.prototype=Object.create(ye.prototype),ra.prototype.constructor=ra,ra.prototype.isCanvasTexture=!0,sa.prototype=Object.create(ye.prototype),sa.prototype.constructor=sa,sa.prototype.isDepthTexture=!0,oa.prototype=Object.create(fn.prototype),oa.prototype.constructor=oa,aa.prototype=Object.create(Un.prototype),aa.prototype.constructor=aa,ha.prototype=Object.create(fn.prototype),ha.prototype.constructor=ha,ca.prototype=Object.create(Un.prototype),ca.prototype.constructor=ca,la.prototype=Object.create(fn.prototype),la.prototype.constructor=la,ua.prototype=Object.create(Un.prototype),ua.prototype.constructor=ua,da.prototype=Object.create(la.prototype),da.prototype.constructor=da,pa.prototype=Object.create(Un.prototype),pa.prototype.constructor=pa,fa.prototype=Object.create(la.prototype),fa.prototype.constructor=fa,ma.prototype=Object.create(Un.prototype),ma.prototype.constructor=ma,ga.prototype=Object.create(la.prototype),ga.prototype.constructor=ga,va.prototype=Object.create(Un.prototype),va.prototype.constructor=va,ba.prototype=Object.create(la.prototype),ba.prototype.constructor=ba,ya.prototype=Object.create(Un.prototype),ya.prototype.constructor=ya,_a.prototype=Object.create(fn.prototype),_a.prototype.constructor=_a,_a.prototype.toJSON=function(){var t=fn.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},xa.prototype=Object.create(Un.prototype),xa.prototype.constructor=xa,wa.prototype=Object.create(fn.prototype),wa.prototype.constructor=wa,Ma.prototype=Object.create(Un.prototype),Ma.prototype.constructor=Ma,Ta.prototype=Object.create(fn.prototype),Ta.prototype.constructor=Ta;var Sa=function(t,e,i){i=i||2;var n,r,s,o,a,h,c,l=e&&e.length,u=l?e[0]*i:t.length,d=Ea(t,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(l&&(d=function(t,e,i,n){var r,s,o,a=[];for(r=0,s=e.length;r<s;r++)(o=Ea(t,e[r]*n,r<s-1?e[r+1]*n:t.length,n,!1))===o.next&&(o.steiner=!0),a.push(Da(o));for(a.sort(Oa),r=0;r<a.length;r++)Fa(a[r],i),i=Pa(i,i.next);return i}(t,e,d,i)),t.length>80*i){n=s=t[0],r=o=t[1];for(var f=i;f<u;f+=i)(a=t[f])<n&&(n=a),(h=t[f+1])<r&&(r=h),a>s&&(s=a),h>o&&(o=h);c=0!==(c=Math.max(s-n,o-r))?1/c:0}return Aa(d,p,i,n,r,c),p};function Ea(t,e,i,n,r){var s,o;if(r===function(t,e,i,n){for(var r=0,s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,i,n)>0)for(s=e;s<i;s+=n)o=Ga(s,t[s],t[s+1],o);else for(s=i-n;s>=e;s-=n)o=Ga(s,t[s],t[s+1],o);return o&&Va(o,o.next)&&(Wa(o),o=o.next),o}function Pa(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!Va(n,n.next)&&0!==Ua(n.prev,n,n.next))n=n.next;else{if(Wa(n),(n=e=n.prev)===n.next)break;i=!0}}while(i||n!==e);return e}function Aa(t,e,i,n,r,s,o){if(t){!o&&s&&function(t,e,i,n){var r=t;do{null===r.z&&(r.z=Ba(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,i,n,r,s,o,a,h,c=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e<c&&(a++,n=n.nextZ);e++);for(h=c;a>0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,h--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,c*=2}while(o>1)}(r)}(t,n,r,s);for(var a,h,c=t;t.prev!==t.next;)if(a=t.prev,h=t.next,s?La(t,n,r,s):Ca(t))e.push(a.i/i),e.push(t.i/i),e.push(h.i/i),Wa(t),t=h.next,c=h.next;else if((t=h)===c){o?1===o?Aa(t=Ra(t,e,i),e,i,n,r,s,2):2===o&&Ia(t,e,i,n,r,s):Aa(Pa(t),e,i,n,r,s,1);break}}}function Ca(t){var e=t.prev,i=t,n=t.next;if(Ua(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(za(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Ua(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function La(t,e,i,n){var r=t.prev,s=t,o=t.next;if(Ua(r,s,o)>=0)return!1;for(var a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,h=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,c=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,u=Ba(a,h,e,i,n),d=Ba(c,l,e,i,n),p=t.prevZ,f=t.nextZ;p&&p.z>=u&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&za(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Ua(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&za(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Ua(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&za(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Ua(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&za(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Ua(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Ra(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!Va(r,s)&&ka(r,n,n.next,s)&&ja(r,s)&&ja(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),Wa(n),Wa(n.next),n=t=s),n=n.next}while(n!==t);return n}function Ia(t,e,i,n,r,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Na(o,a)){var h=Ha(o,a);return o=Pa(o,o.next),h=Pa(h,h.next),Aa(o,e,i,n,r,s),void Aa(h,e,i,n,r,s)}a=a.next}o=o.next}while(o!==t)}function Oa(t,e){return t.x-e.x}function Fa(t,e){if(e=function(t,e){var i,n=e,r=t.x,s=t.y,o=-1/0;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){var a=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>o){if(o=a,a===r){if(s===n.y)return n;if(s===n.next.y)return n.next}i=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!i)return null;if(r===o)return i.prev;var h,c=i,l=i.x,u=i.y,d=1/0;n=i.next;for(;n!==c;)r>=n.x&&n.x>=l&&r!==n.x&&za(s<u?r:o,s,l,u,s<u?o:r,s,n.x,n.y)&&((h=Math.abs(s-n.y)/(r-n.x))<d||h===d&&n.x>i.x)&&ja(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=Ha(e,t);Pa(i,i.next)}}function Ba(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Da(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function za(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function Na(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&ka(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&ja(t,e)&&ja(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function Ua(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Va(t,e){return t.x===e.x&&t.y===e.y}function ka(t,e,i,n){return!!(Va(t,i)&&Va(e,n)||Va(t,n)&&Va(i,e))||Ua(t,e,i)>0!=Ua(t,e,n)>0&&Ua(i,n,t)>0!=Ua(i,n,e)>0}function ja(t,e){return Ua(t.prev,t,t.next)<0?Ua(t,e,t.next)>=0&&Ua(t,t.prev,e)>=0:Ua(t,e,t.prev)<0||Ua(t,t.next,e)<0}function Ha(t,e){var i=new qa(t.i,t.x,t.y),n=new qa(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Ga(t,e,i,n){var r=new qa(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Wa(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function qa(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Xa={area:function(t){for(var e=t.length,i=0,n=e-1,r=0;r<e;n=r++)i+=t[n].x*t[r].y-t[r].x*t[n].y;return.5*i},isClockWise:function(t){return Xa.area(t)<0},triangulateShape:function(t,e){var i=[],n=[],r=[];Ya(t),Za(i,t);var s=t.length;e.forEach(Ya);for(var o=0;o<e.length;o++)n.push(s),s+=e[o].length,Za(i,e[o]);var a=Sa(i,n);for(o=0;o<a.length;o+=3)r.push(a.slice(o,o+3));return r}};function Ya(t){var e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Za(t,e){for(var i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}function $a(t,e){Un.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},this.fromBufferGeometry(new Ja(t,e)),this.mergeVertices()}function Ja(t,e){fn.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];for(var i=this,n=[],r=[],s=0,o=t.length;s<o;s++){a(t[s])}function a(t){var s=[],o=void 0!==e.curveSegments?e.curveSegments:12,a=void 0!==e.steps?e.steps:1,h=void 0!==e.depth?e.depth:100,c=void 0===e.bevelEnabled||e.bevelEnabled,l=void 0!==e.bevelThickness?e.bevelThickness:6,u=void 0!==e.bevelSize?e.bevelSize:l-2,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3,f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:Qa;void 0!==e.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=e.amount);var g,v,b,y,_,x,w,M,T=!1;f&&(g=f.getSpacedPoints(a),T=!0,c=!1,v=f.computeFrenetFrames(a,!1),b=new pe,y=new pe,_=new pe),c||(p=0,l=0,u=0,d=0);var S=t.extractPoints(o),E=S.shape,P=S.holes;if(!Xa.isClockWise(E))for(E=E.reverse(),w=0,M=P.length;w<M;w++)x=P[w],Xa.isClockWise(x)&&(P[w]=x.reverse());var A=Xa.triangulateShape(E,P),C=E;for(w=0,M=P.length;w<M;w++)x=P[w],E=E.concat(x);function L(t,e,i){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(i).add(t)}var R,I,O,F,B,D,z=E.length,N=A.length;function U(t,e,i){var n,r,s,o=t.x-e.x,a=t.y-e.y,h=i.x-t.x,c=i.y-t.y,l=o*o+a*a,u=o*c-a*h;if(Math.abs(u)>Number.EPSILON){var d=Math.sqrt(l),p=Math.sqrt(h*h+c*c),f=e.x-a/d,m=e.y+o/d,g=((i.x-c/p-f)*c-(i.y+h/p-m)*h)/(o*c-a*h),v=(n=f+o*g-t.x)*n+(r=m+a*g-t.y)*r;if(v<=2)return new ce(n,r);s=Math.sqrt(v/2)}else{var b=!1;o>Number.EPSILON?h>Number.EPSILON&&(b=!0):o<-Number.EPSILON?h<-Number.EPSILON&&(b=!0):Math.sign(a)===Math.sign(c)&&(b=!0),b?(n=-a,r=o,s=Math.sqrt(l)):(n=o,r=a,s=Math.sqrt(l/2))}return new ce(n/s,r/s)}for(var V=[],k=0,j=C.length,H=j-1,G=k+1;k<j;k++,H++,G++)H===j&&(H=0),G===j&&(G=0),V[k]=U(C[k],C[H],C[G]);var W,q,X=[],Y=V.concat();for(w=0,M=P.length;w<M;w++){for(x=P[w],W=[],k=0,H=(j=x.length)-1,G=k+1;k<j;k++,H++,G++)H===j&&(H=0),G===j&&(G=0),W[k]=U(x[k],x[H],x[G]);X.push(W),Y=Y.concat(W)}for(R=0;R<p;R++){for(O=R/p,F=l*Math.cos(O*Math.PI/2),I=u*Math.sin(O*Math.PI/2)+d,k=0,j=C.length;k<j;k++)$((B=L(C[k],V[k],I)).x,B.y,-F);for(w=0,M=P.length;w<M;w++)for(x=P[w],W=X[w],k=0,j=x.length;k<j;k++)$((B=L(x[k],W[k],I)).x,B.y,-F)}for(I=u+d,k=0;k<z;k++)B=c?L(E[k],Y[k],I):E[k],T?(y.copy(v.normals[0]).multiplyScalar(B.x),b.copy(v.binormals[0]).multiplyScalar(B.y),_.copy(g[0]).add(y).add(b),$(_.x,_.y,_.z)):$(B.x,B.y,0);for(q=1;q<=a;q++)for(k=0;k<z;k++)B=c?L(E[k],Y[k],I):E[k],T?(y.copy(v.normals[q]).multiplyScalar(B.x),b.copy(v.binormals[q]).multiplyScalar(B.y),_.copy(g[q]).add(y).add(b),$(_.x,_.y,_.z)):$(B.x,B.y,h/a*q);for(R=p-1;R>=0;R--){for(O=R/p,F=l*Math.cos(O*Math.PI/2),I=u*Math.sin(O*Math.PI/2)+d,k=0,j=C.length;k<j;k++)$((B=L(C[k],V[k],I)).x,B.y,h+F);for(w=0,M=P.length;w<M;w++)for(x=P[w],W=X[w],k=0,j=x.length;k<j;k++)B=L(x[k],W[k],I),T?$(B.x,B.y+g[a-1].y,g[a-1].x+F):$(B.x,B.y,h+F)}function Z(t,e){var i,n;for(k=t.length;--k>=0;){i=k,(n=k-1)<0&&(n=t.length-1);var r=0,s=a+2*p;for(r=0;r<s;r++){var o=z*r,h=z*(r+1);Q(e+i+o,e+n+o,e+n+h,e+i+h)}}}function $(t,e,i){s.push(t),s.push(e),s.push(i)}function J(t,e,r){K(t),K(e),K(r);var s=n.length/3,o=m.generateTopUV(i,n,s-3,s-2,s-1);tt(o[0]),tt(o[1]),tt(o[2])}function Q(t,e,r,s){K(t),K(e),K(s),K(e),K(r),K(s);var o=n.length/3,a=m.generateSideWallUV(i,n,o-6,o-3,o-2,o-1);tt(a[0]),tt(a[1]),tt(a[3]),tt(a[1]),tt(a[2]),tt(a[3])}function K(t){n.push(s[3*t+0]),n.push(s[3*t+1]),n.push(s[3*t+2])}function tt(t){r.push(t.x),r.push(t.y)}!function(){var t=n.length/3;if(c){var e=0,r=z*e;for(k=0;k<N;k++)J((D=A[k])[2]+r,D[1]+r,D[0]+r);for(r=z*(e=a+2*p),k=0;k<N;k++)J((D=A[k])[0]+r,D[1]+r,D[2]+r)}else{for(k=0;k<N;k++)J((D=A[k])[2],D[1],D[0]);for(k=0;k<N;k++)J((D=A[k])[0]+z*a,D[1]+z*a,D[2]+z*a)}i.addGroup(t,n.length/3-t,0)}(),function(){var t=n.length/3,e=0;for(Z(C,e),e+=C.length,w=0,M=P.length;w<M;w++)Z(x=P[w],e),e+=x.length;i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new nn(n,3)),this.setAttribute("uv",new nn(r,2)),this.computeVertexNormals()}$a.prototype=Object.create(Un.prototype),$a.prototype.constructor=$a,$a.prototype.toJSON=function(){var t=Un.prototype.toJSON.call(this);return Ka(this.parameters.shapes,this.parameters.options,t)},Ja.prototype=Object.create(fn.prototype),Ja.prototype.constructor=Ja,Ja.prototype.toJSON=function(){var t=fn.prototype.toJSON.call(this);return Ka(this.parameters.shapes,this.parameters.options,t)};var Qa={generateTopUV:function(t,e,i,n,r){var s=e[3*i],o=e[3*i+1],a=e[3*n],h=e[3*n+1],c=e[3*r],l=e[3*r+1];return[new ce(s,o),new ce(a,h),new ce(c,l)]},generateSideWallUV:function(t,e,i,n,r,s){var o=e[3*i],a=e[3*i+1],h=e[3*i+2],c=e[3*n],l=e[3*n+1],u=e[3*n+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*s],g=e[3*s+1],v=e[3*s+2];return Math.abs(a-l)<.01?[new ce(o,1-h),new ce(c,1-u),new ce(d,1-f),new ce(m,1-v)]:[new ce(a,1-h),new ce(l,1-u),new ce(p,1-f),new ce(g,1-v)]}};function Ka(t,e,i){if(i.shapes=[],Array.isArray(t))for(var n=0,r=t.length;n<r;n++){var s=t[n];i.shapes.push(s.uuid)}else i.shapes.push(t.uuid);return void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON()),i}function th(t,e){Un.call(this),this.type="TextGeometry",this.parameters={text:t,parameters:e},this.fromBufferGeometry(new eh(t,e)),this.mergeVertices()}function eh(t,e){var i=(e=e||{}).font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Un;var n=i.generateShapes(t,e.size);e.depth=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),Ja.call(this,n,e),this.type="TextBufferGeometry"}function ih(t,e,i,n,r,s,o){Un.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:o},this.fromBufferGeometry(new nh(t,e,i,n,r,s,o)),this.mergeVertices()}function nh(t,e,i,n,r,s,o){fn.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:o},t=t||1,e=Math.max(3,Math.floor(e)||8),i=Math.max(2,Math.floor(i)||6),n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI,s=void 0!==s?s:0,o=void 0!==o?o:Math.PI;var a,h,c=Math.min(s+o,Math.PI),l=0,u=[],d=new pe,p=new pe,f=[],m=[],g=[],v=[];for(h=0;h<=i;h++){var b=[],y=h/i,_=0;for(0==h&&0==s?_=.5/e:h==i&&c==Math.PI&&(_=-.5/e),a=0;a<=e;a++){var x=a/e;d.x=-t*Math.cos(n+x*r)*Math.sin(s+y*o),d.y=t*Math.cos(s+y*o),d.z=t*Math.sin(n+x*r)*Math.sin(s+y*o),m.push(d.x,d.y,d.z),p.copy(d).normalize(),g.push(p.x,p.y,p.z),v.push(x+_,1-y),b.push(l++)}u.push(b)}for(h=0;h<i;h++)for(a=0;a<e;a++){var w=u[h][a+1],M=u[h][a],T=u[h+1][a],S=u[h+1][a+1];(0!==h||s>0)&&f.push(w,M,S),(h!==i-1||c<Math.PI)&&f.push(M,T,S)}this.setIndex(f),this.setAttribute("position",new nn(m,3)),this.setAttribute("normal",new nn(g,3)),this.setAttribute("uv",new nn(v,2))}function rh(t,e,i,n,r,s){Un.call(this),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:s},this.fromBufferGeometry(new sh(t,e,i,n,r,s)),this.mergeVertices()}function sh(t,e,i,n,r,s){fn.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:s},t=t||.5,e=e||1,r=void 0!==r?r:0,s=void 0!==s?s:2*Math.PI,i=void 0!==i?Math.max(3,i):8;var o,a,h,c=[],l=[],u=[],d=[],p=t,f=(e-t)/(n=void 0!==n?Math.max(1,n):1),m=new pe,g=new ce;for(a=0;a<=n;a++){for(h=0;h<=i;h++)o=r+h/i*s,m.x=p*Math.cos(o),m.y=p*Math.sin(o),l.push(m.x,m.y,m.z),u.push(0,0,1),g.x=(m.x/e+1)/2,g.y=(m.y/e+1)/2,d.push(g.x,g.y);p+=f}for(a=0;a<n;a++){var v=a*(i+1);for(h=0;h<i;h++){var b=o=h+v,y=o+i+1,_=o+i+2,x=o+1;c.push(b,y,x),c.push(y,_,x)}}this.setIndex(c),this.setAttribute("position",new nn(l,3)),this.setAttribute("normal",new nn(u,3)),this.setAttribute("uv",new nn(d,2))}function oh(t,e,i,n){Un.call(this),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},this.fromBufferGeometry(new ah(t,e,i,n)),this.mergeVertices()}function ah(t,e,i,n){fn.call(this),this.type="LatheBufferGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e)||12,i=i||0,n=n||2*Math.PI,n=he.clamp(n,0,2*Math.PI);var r,s,o,a=[],h=[],c=[],l=1/e,u=new pe,d=new ce;for(s=0;s<=e;s++){var p=i+s*l*n,f=Math.sin(p),m=Math.cos(p);for(o=0;o<=t.length-1;o++)u.x=t[o].x*f,u.y=t[o].y,u.z=t[o].x*m,h.push(u.x,u.y,u.z),d.x=s/e,d.y=o/(t.length-1),c.push(d.x,d.y)}for(s=0;s<e;s++)for(o=0;o<t.length-1;o++){var g=r=o+s*t.length,v=r+t.length,b=r+t.length+1,y=r+1;a.push(g,v,y),a.push(v,b,y)}if(this.setIndex(a),this.setAttribute("position",new nn(h,3)),this.setAttribute("uv",new nn(c,2)),this.computeVertexNormals(),n===2*Math.PI){var _=this.attributes.normal.array,x=new pe,w=new pe,M=new pe;for(r=e*t.length*3,s=0,o=0;s<t.length;s++,o+=3)x.x=_[o+0],x.y=_[o+1],x.z=_[o+2],w.x=_[r+o+0],w.y=_[r+o+1],w.z=_[r+o+2],M.addVectors(x,w).normalize(),_[o+0]=_[r+o+0]=M.x,_[o+1]=_[r+o+1]=M.y,_[o+2]=_[r+o+2]=M.z}}function hh(t,e){Un.call(this),this.type="ShapeGeometry","object"==typeof e&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),e=e.curveSegments),this.parameters={shapes:t,curveSegments:e},this.fromBufferGeometry(new ch(t,e)),this.mergeVertices()}function ch(t,e){fn.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:e},e=e||12;var i=[],n=[],r=[],s=[],o=0,a=0;if(!1===Array.isArray(t))c(t);else for(var h=0;h<t.length;h++)c(t[h]),this.addGroup(o,a,h),o+=a,a=0;function c(t){var o,h,c,l=n.length/3,u=t.extractPoints(e),d=u.shape,p=u.holes;for(!1===Xa.isClockWise(d)&&(d=d.reverse()),o=0,h=p.length;o<h;o++)c=p[o],!0===Xa.isClockWise(c)&&(p[o]=c.reverse());var f=Xa.triangulateShape(d,p);for(o=0,h=p.length;o<h;o++)c=p[o],d=d.concat(c);for(o=0,h=d.length;o<h;o++){var m=d[o];n.push(m.x,m.y,0),r.push(0,0,1),s.push(m.x,m.y)}for(o=0,h=f.length;o<h;o++){var g=f[o],v=g[0]+l,b=g[1]+l,y=g[2]+l;i.push(v,b,y),a+=3}}this.setIndex(i),this.setAttribute("position",new nn(n,3)),this.setAttribute("normal",new nn(r,3)),this.setAttribute("uv",new nn(s,2))}function lh(t,e){if(e.shapes=[],Array.isArray(t))for(var i=0,n=t.length;i<n;i++){var r=t[i];e.shapes.push(r.uuid)}else e.shapes.push(t.uuid);return e}function uh(t,e){fn.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1;var i,n,r,s,o=[],a=Math.cos(he.DEG2RAD*e),h=[0,0],c={},l=["a","b","c"];t.isBufferGeometry?(s=new Un).fromBufferGeometry(t):s=t.clone(),s.mergeVertices(),s.computeFaceNormals();for(var u=s.vertices,d=s.faces,p=0,f=d.length;p<f;p++)for(var m=d[p],g=0;g<3;g++)i=m[l[g]],n=m[l[(g+1)%3]],h[0]=Math.min(i,n),h[1]=Math.max(i,n),void 0===c[r=h[0]+","+h[1]]?c[r]={index1:h[0],index2:h[1],face1:p,face2:void 0}:c[r].face2=p;for(r in c){var v=c[r];if(void 0===v.face2||d[v.face1].normal.dot(d[v.face2].normal)<=a){var b=u[v.index1];o.push(b.x,b.y,b.z),b=u[v.index2],o.push(b.x,b.y,b.z)}}this.setAttribute("position",new nn(o,3))}function dh(t,e,i,n,r,s,o,a){Un.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new ph(t,e,i,n,r,s,o,a)),this.mergeVertices()}function ph(t,e,i,n,r,s,o,a){fn.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a};var h=this;t=void 0!==t?t:1,e=void 0!==e?e:1,i=i||1,n=Math.floor(n)||8,r=Math.floor(r)||1,s=void 0!==s&&s,o=void 0!==o?o:0,a=void 0!==a?a:2*Math.PI;var c=[],l=[],u=[],d=[],p=0,f=[],m=i/2,g=0;function v(i){var r,s,f,v=new ce,b=new pe,y=0,_=!0===i?t:e,x=!0===i?1:-1;for(s=p,r=1;r<=n;r++)l.push(0,m*x,0),u.push(0,x,0),d.push(.5,.5),p++;for(f=p,r=0;r<=n;r++){var w=r/n*a+o,M=Math.cos(w),T=Math.sin(w);b.x=_*T,b.y=m*x,b.z=_*M,l.push(b.x,b.y,b.z),u.push(0,x,0),v.x=.5*M+.5,v.y=.5*T*x+.5,d.push(v.x,v.y),p++}for(r=0;r<n;r++){var S=s+r,E=f+r;!0===i?c.push(E,E+1,S):c.push(E+1,E,S),y+=3}h.addGroup(g,y,!0===i?1:2),g+=y}!function(){var s,v,b=new pe,y=new pe,_=0,x=(e-t)/i;for(v=0;v<=r;v++){var w=[],M=v/r,T=M*(e-t)+t;for(s=0;s<=n;s++){var S=s/n,E=S*a+o,P=Math.sin(E),A=Math.cos(E);y.x=T*P,y.y=-M*i+m,y.z=T*A,l.push(y.x,y.y,y.z),b.set(P,x,A).normalize(),u.push(b.x,b.y,b.z),d.push(S,1-M),w.push(p++)}f.push(w)}for(s=0;s<n;s++)for(v=0;v<r;v++){var C=f[v][s],L=f[v+1][s],R=f[v+1][s+1],I=f[v][s+1];c.push(C,L,I),c.push(L,R,I),_+=6}h.addGroup(g,_,0),g+=_}(),!1===s&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new nn(l,3)),this.setAttribute("normal",new nn(u,3)),this.setAttribute("uv",new nn(d,2))}function fh(t,e,i,n,r,s,o){dh.call(this,0,t,e,i,n,r,s,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:s,thetaLength:o}}function mh(t,e,i,n,r,s,o){ph.call(this,0,t,e,i,n,r,s,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:s,thetaLength:o}}function gh(t,e,i,n){Un.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},this.fromBufferGeometry(new vh(t,e,i,n)),this.mergeVertices()}function vh(t,e,i,n){fn.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},t=t||1,e=void 0!==e?Math.max(3,e):8,i=void 0!==i?i:0,n=void 0!==n?n:2*Math.PI;var r,s,o=[],a=[],h=[],c=[],l=new pe,u=new ce;for(a.push(0,0,0),h.push(0,0,1),c.push(.5,.5),s=0,r=3;s<=e;s++,r+=3){var d=i+s/e*n;l.x=t*Math.cos(d),l.y=t*Math.sin(d),a.push(l.x,l.y,l.z),h.push(0,0,1),u.x=(a[r]/t+1)/2,u.y=(a[r+1]/t+1)/2,c.push(u.x,u.y)}for(r=1;r<=e;r++)o.push(r,r+1,0);this.setIndex(o),this.setAttribute("position",new nn(a,3)),this.setAttribute("normal",new nn(h,3)),this.setAttribute("uv",new nn(c,2))}th.prototype=Object.create(Un.prototype),th.prototype.constructor=th,eh.prototype=Object.create(Ja.prototype),eh.prototype.constructor=eh,ih.prototype=Object.create(Un.prototype),ih.prototype.constructor=ih,nh.prototype=Object.create(fn.prototype),nh.prototype.constructor=nh,rh.prototype=Object.create(Un.prototype),rh.prototype.constructor=rh,sh.prototype=Object.create(fn.prototype),sh.prototype.constructor=sh,oh.prototype=Object.create(Un.prototype),oh.prototype.constructor=oh,ah.prototype=Object.create(fn.prototype),ah.prototype.constructor=ah,hh.prototype=Object.create(Un.prototype),hh.prototype.constructor=hh,hh.prototype.toJSON=function(){var t=Un.prototype.toJSON.call(this);return lh(this.parameters.shapes,t)},ch.prototype=Object.create(fn.prototype),ch.prototype.constructor=ch,ch.prototype.toJSON=function(){var t=fn.prototype.toJSON.call(this);return lh(this.parameters.shapes,t)},uh.prototype=Object.create(fn.prototype),uh.prototype.constructor=uh,dh.prototype=Object.create(Un.prototype),dh.prototype.constructor=dh,ph.prototype=Object.create(fn.prototype),ph.prototype.constructor=ph,fh.prototype=Object.create(dh.prototype),fh.prototype.constructor=fh,mh.prototype=Object.create(ph.prototype),mh.prototype.constructor=mh,gh.prototype=Object.create(Un.prototype),gh.prototype.constructor=gh,vh.prototype=Object.create(fn.prototype),vh.prototype.constructor=vh;var bh=Object.freeze({__proto__:null,WireframeGeometry:oa,ParametricGeometry:aa,ParametricBufferGeometry:ha,TetrahedronGeometry:ua,TetrahedronBufferGeometry:da,OctahedronGeometry:pa,OctahedronBufferGeometry:fa,IcosahedronGeometry:ma,IcosahedronBufferGeometry:ga,DodecahedronGeometry:va,DodecahedronBufferGeometry:ba,PolyhedronGeometry:ca,PolyhedronBufferGeometry:la,TubeGeometry:ya,TubeBufferGeometry:_a,TorusKnotGeometry:xa,TorusKnotBufferGeometry:wa,TorusGeometry:Ma,TorusBufferGeometry:Ta,TextGeometry:th,TextBufferGeometry:eh,SphereGeometry:ih,SphereBufferGeometry:nh,RingGeometry:rh,RingBufferGeometry:sh,PlaneGeometry:or,PlaneBufferGeometry:ar,LatheGeometry:oh,LatheBufferGeometry:ah,ShapeGeometry:hh,ShapeBufferGeometry:ch,ExtrudeGeometry:$a,ExtrudeBufferGeometry:Ja,EdgesGeometry:uh,ConeGeometry:fh,ConeBufferGeometry:mh,CylinderGeometry:dh,CylinderBufferGeometry:ph,CircleGeometry:gh,CircleBufferGeometry:vh,BoxGeometry:Vn,BoxBufferGeometry:kn});function yh(t){Wi.call(this),this.type="ShadowMaterial",this.color=new Ui(0),this.transparent=!0,this.setValues(t)}function _h(t){Wn.call(this,t),this.type="RawShaderMaterial"}function xh(t){Wi.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ui(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 Ui(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function wh(t){xh.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new ce(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(t)}function Mh(t){Wi.call(this),this.type="MeshPhongMaterial",this.color=new Ui(16777215),this.specular=new Ui(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ui(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Th(t){Wi.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ui(16777215),this.specular=new Ui(1118481),this.shininess=30,this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ui(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Sh(t){Wi.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Eh(t){Wi.call(this),this.type="MeshLambertMaterial",this.color=new Ui(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ui(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ph(t){Wi.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ui(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ah(t){No.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}yh.prototype=Object.create(Wi.prototype),yh.prototype.constructor=yh,yh.prototype.isShadowMaterial=!0,yh.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this},_h.prototype=Object.create(Wn.prototype),_h.prototype.constructor=_h,_h.prototype.isRawShaderMaterial=!0,xh.prototype=Object.create(Wi.prototype),xh.prototype.constructor=xh,xh.prototype.isMeshStandardMaterial=!0,xh.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},wh.prototype=Object.create(xh.prototype),wh.prototype.constructor=wh,wh.prototype.isMeshPhysicalMaterial=!0,wh.prototype.copy=function(t){return xh.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearcoat=t.clearcoat,this.clearcoatRoughness=t.clearcoatRoughness,t.sheen?this.sheen=(this.sheen||new Ui).copy(t.sheen):this.sheen=null,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.transparency=t.transparency,this},Mh.prototype=Object.create(Wi.prototype),Mh.prototype.constructor=Mh,Mh.prototype.isMeshPhongMaterial=!0,Mh.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Th.prototype=Object.create(Wi.prototype),Th.prototype.constructor=Th,Th.prototype.isMeshToonMaterial=!0,Th.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Sh.prototype=Object.create(Wi.prototype),Sh.prototype.constructor=Sh,Sh.prototype.isMeshNormalMaterial=!0,Sh.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Eh.prototype=Object.create(Wi.prototype),Eh.prototype.constructor=Eh,Eh.prototype.isMeshLambertMaterial=!0,Eh.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ph.prototype=Object.create(Wi.prototype),Ph.prototype.constructor=Ph,Ph.prototype.isMeshMatcapMaterial=!0,Ph.prototype.copy=function(t){return Wi.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ah.prototype=Object.create(No.prototype),Ah.prototype.constructor=Ah,Ah.prototype.isLineDashedMaterial=!0,Ah.prototype.copy=function(t){return No.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Ch=Object.freeze({__proto__:null,ShadowMaterial:yh,SpriteMaterial:co,RawShaderMaterial:_h,ShaderMaterial:Wn,PointsMaterial:Zo,MeshPhysicalMaterial:wh,MeshStandardMaterial:xh,MeshPhongMaterial:Mh,MeshToonMaterial:Th,MeshNormalMaterial:Sh,MeshLambertMaterial:Eh,MeshDepthMaterial:Ws,MeshDistanceMaterial:qs,MeshBasicMaterial:qi,MeshMatcapMaterial:Ph,LineDashedMaterial:Ah,LineBasicMaterial:No,Material:Wi}),Lh={arraySlice:function(t,e,i){return Lh.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,i=new Array(e),n=0;n!==e;++n)i[n]=n;return i.sort((function(e,i){return t[e]-t[i]})),i},sortedArray:function(t,e,i){for(var n=t.length,r=new t.constructor(n),s=0,o=0;o!==n;++s)for(var a=i[s]*e,h=0;h!==e;++h)r[o++]=t[a+h];return r},flattenJSON:function(t,e,i,n){for(var r=1,s=t[0];void 0!==s&&void 0===s[n];)s=t[r++];if(void 0!==s){var o=s[n];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=s[n])&&(e.push(s.time),i.push.apply(i,o)),s=t[r++]}while(void 0!==s);else if(void 0!==o.toArray)do{void 0!==(o=s[n])&&(e.push(s.time),o.toArray(i,i.length)),s=t[r++]}while(void 0!==s);else do{void 0!==(o=s[n])&&(e.push(s.time),i.push(o)),s=t[r++]}while(void 0!==s)}},subclip:function(t,e,i,n,r){r=r||30;var s=t.clone();s.name=e;for(var o=[],a=0;a<s.tracks.length;++a){for(var h=s.tracks[a],c=h.getValueSize(),l=[],u=[],d=0;d<h.times.length;++d){var p=h.times[d]*r;if(!(p<i||p>=n)){l.push(h.times[d]);for(var f=0;f<c;++f)u.push(h.values[d*c+f])}}0!==l.length&&(h.times=Lh.convertArray(l,h.times.constructor),h.values=Lh.convertArray(u,h.values.constructor),o.push(h))}s.tracks=o;var m=1/0;for(a=0;a<s.tracks.length;++a)m>s.tracks[a].times[0]&&(m=s.tracks[a].times[0]);for(a=0;a<s.tracks.length;++a)s.tracks[a].shift(-1*m);return s.resetDuration(),s}};function Rh(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function Ih(t,e,i,n){Rh.call(this,t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Oh(t,e,i,n){Rh.call(this,t,e,i,n)}function Fh(t,e,i,n){Rh.call(this,t,e,i,n)}function Bh(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Lh.convertArray(e,this.TimeBufferType),this.values=Lh.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}function Dh(t,e,i){Bh.call(this,t,e,i)}function zh(t,e,i,n){Bh.call(this,t,e,i,n)}function Nh(t,e,i,n){Bh.call(this,t,e,i,n)}function Uh(t,e,i,n){Rh.call(this,t,e,i,n)}function Vh(t,e,i,n){Bh.call(this,t,e,i,n)}function kh(t,e,i,n){Bh.call(this,t,e,i,n)}function jh(t,e,i,n){Bh.call(this,t,e,i,n)}function Hh(t,e,i){this.name=t,this.tracks=i,this.duration=void 0!==e?e:-1,this.uuid=he.generateUUID(),this.duration<0&&this.resetDuration()}function Gh(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Nh;case"vector":case"vector2":case"vector3":case"vector4":return jh;case"color":return zh;case"quaternion":return Vh;case"bool":case"boolean":return Dh;case"string":return kh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){var i=[],n=[];Lh.flattenJSON(t.keys,i,n,"value"),t.times=i,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}Object.assign(Rh.prototype,{evaluate:function(t){var e=this.parameterPositions,i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{var s;i:{n:if(!(t<n)){for(var o=i+2;;){if(void 0===n){if(t<r)break n;return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,t,r)}if(i===o)break;if(r=n,t<(n=e[++i]))break e}s=e.length;break i}if(t>=r)break t;var a=e[1];t<a&&(i=2,r=a);for(o=i-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(i===o)break;if(n=r,t>=(r=e[--i-1]))break e}s=i,i=0}for(;i<s;){var h=i+s>>>1;t<e[h]?s=h:i=h+1}if(n=e[i],void 0===(r=e[i-1]))return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,r,t)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,t,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){for(var e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n,s=0;s!==n;++s)e[s]=i[r+s];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Rh.prototype,{beforeStart_:Rh.prototype.copySampleValue_,afterEnd_:Rh.prototype.copySampleValue_}),Ih.prototype=Object.assign(Object.create(Rh.prototype),{constructor:Ih,DefaultSettings_:{endingStart:$t,endingEnd:$t},intervalChanged_:function(t,e,i){var n=this.parameterPositions,r=t-2,s=t+1,o=n[r],a=n[s];if(void 0===o)switch(this.getSettings_().endingStart){case Jt:r=t,o=2*e-i;break;case Qt:o=e+n[r=n.length-2]-n[r+1];break;default:r=t,o=i}if(void 0===a)switch(this.getSettings_().endingEnd){case Jt:s=t,a=2*i-e;break;case Qt:s=1,a=i+n[1]-n[0];break;default:s=t-1,a=e}var h=.5*(i-e),c=this.valueSize;this._weightPrev=h/(e-o),this._weightNext=h/(a-i),this._offsetPrev=r*c,this._offsetNext=s*c},interpolate_:function(t,e,i,n){for(var r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,h=a-o,c=this._offsetPrev,l=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-e)/(n-e),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,b=(-1-d)*m+(1.5+d)*f+.5*p,y=d*m-d*f,_=0;_!==o;++_)r[_]=g*s[c+_]+v*s[h+_]+b*s[a+_]+y*s[l+_];return r}}),Oh.prototype=Object.assign(Object.create(Rh.prototype),{constructor:Oh,interpolate_:function(t,e,i,n){for(var r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,h=a-o,c=(i-e)/(n-e),l=1-c,u=0;u!==o;++u)r[u]=s[h+u]*l+s[a+u]*c;return r}}),Fh.prototype=Object.assign(Object.create(Rh.prototype),{constructor:Fh,interpolate_:function(t){return this.copySampleValue_(t-1)}}),Object.assign(Bh,{toJSON:function(t){var e,i=t.constructor;if(void 0!==i.toJSON)e=i.toJSON(t);else{e={name:t.name,times:Lh.convertArray(t.times,Array),values:Lh.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e}}),Object.assign(Bh.prototype,{constructor:Bh,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:Yt,InterpolantFactoryMethodDiscrete:function(t){return new Fh(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new Oh(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Ih(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){var e;switch(t){case Xt:e=this.InterpolantFactoryMethodDiscrete;break;case Yt:e=this.InterpolantFactoryMethodLinear;break;case Zt:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=e,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Xt;case this.InterpolantFactoryMethodLinear:return Yt;case this.InterpolantFactoryMethodSmooth:return Zt}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t)for(var e=this.times,i=0,n=e.length;i!==n;++i)e[i]+=t;return this},scale:function(t){if(1!==t)for(var e=this.times,i=0,n=e.length;i!==n;++i)e[i]*=t;return this},trim:function(t,e){for(var i=this.times,n=i.length,r=0,s=n-1;r!==n&&i[r]<t;)++r;for(;-1!==s&&i[s]>e;)--s;if(++s,0!==r||s!==n){r>=s&&(r=(s=Math.max(s,1))-1);var o=this.getValueSize();this.times=Lh.arraySlice(i,r,s),this.values=Lh.arraySlice(this.values,r*o,s*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var s=null,o=0;o!==r;o++){var a=i[o];if("number"==typeof a&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,a),t=!1;break}if(null!==s&&s>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,a,s),t=!1;break}s=a}if(void 0!==n&&Lh.isTypedArray(n)){o=0;for(var h=n.length;o!==h;++o){var c=n[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,i=this.getValueSize(),n=this.getInterpolation()===Zt,r=1,s=t.length-1,o=1;o<s;++o){var a=!1,h=t[o];if(h!==t[o+1]&&(1!==o||h!==h[0]))if(n)a=!0;else for(var c=o*i,l=c-i,u=c+i,d=0;d!==i;++d){var p=e[c+d];if(p!==e[l+d]||p!==e[u+d]){a=!0;break}}if(a){if(o!==r){t[r]=t[o];var f=o*i,m=r*i;for(d=0;d!==i;++d)e[m+d]=e[f+d]}++r}}if(s>0){t[r]=t[s];for(f=s*i,m=r*i,d=0;d!==i;++d)e[m+d]=e[f+d];++r}return r!==t.length&&(this.times=Lh.arraySlice(t,0,r),this.values=Lh.arraySlice(e,0,r*i)),this},clone:function(){var t=Lh.arraySlice(this.times,0),e=Lh.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}),Dh.prototype=Object.assign(Object.create(Bh.prototype),{constructor:Dh,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Xt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),zh.prototype=Object.assign(Object.create(Bh.prototype),{constructor:zh,ValueTypeName:"color"}),Nh.prototype=Object.assign(Object.create(Bh.prototype),{constructor:Nh,ValueTypeName:"number"}),Uh.prototype=Object.assign(Object.create(Rh.prototype),{constructor:Uh,interpolate_:function(t,e,i,n){for(var r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,h=(i-e)/(n-e),c=a+o;a!==c;a+=4)le.slerpFlat(r,0,s,a-o,s,a,h);return r}}),Vh.prototype=Object.assign(Object.create(Bh.prototype),{constructor:Vh,ValueTypeName:"quaternion",DefaultInterpolation:Yt,InterpolantFactoryMethodLinear:function(t){return new Uh(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),kh.prototype=Object.assign(Object.create(Bh.prototype),{constructor:kh,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Xt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),jh.prototype=Object.assign(Object.create(Bh.prototype),{constructor:jh,ValueTypeName:"vector"}),Object.assign(Hh,{parse:function(t){for(var e=[],i=t.tracks,n=1/(t.fps||1),r=0,s=i.length;r!==s;++r)e.push(Gh(i[r]).scale(n));return new Hh(t.name,t.duration,e)},toJSON:function(t){for(var e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},r=0,s=i.length;r!==s;++r)e.push(Bh.toJSON(i[r]));return n},CreateFromMorphTargetSequence:function(t,e,i,n){for(var r=e.length,s=[],o=0;o<r;o++){var a=[],h=[];a.push((o+r-1)%r,o,(o+1)%r),h.push(0,1,0);var c=Lh.getKeyframeOrder(a);a=Lh.sortedArray(a,1,c),h=Lh.sortedArray(h,1,c),n||0!==a[0]||(a.push(r),h.push(h[0])),s.push(new Nh(".morphTargetInfluences["+e[o].name+"]",a,h).scale(1/i))}return new Hh(t,-1,s)},findByName:function(t,e){var i=t;if(!Array.isArray(t)){var n=t;i=n.geometry&&n.geometry.animations||n.animations}for(var r=0;r<i.length;r++)if(i[r].name===e)return i[r];return null},CreateClipsFromMorphTargetSequences:function(t,e,i){for(var n={},r=/^([\w-]*?)([\d]+)$/,s=0,o=t.length;s<o;s++){var a=t[s],h=a.name.match(r);if(h&&h.length>1){var c=n[u=h[1]];c||(n[u]=c=[]),c.push(a)}}var l=[];for(var u in n)l.push(Hh.CreateFromMorphTargetSequence(u,n[u],e,i));return l},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(t,e,i,n,r){if(0!==i.length){var s=[],o=[];Lh.flattenJSON(i,s,o,n),0!==s.length&&r.push(new t(e,s,o))}},n=[],r=t.name||"default",s=t.length||-1,o=t.fps||30,a=t.hierarchy||[],h=0;h<a.length;h++){var c=a[h].keys;if(c&&0!==c.length)if(c[0].morphTargets){for(var l={},u=0;u<c.length;u++)if(c[u].morphTargets)for(var d=0;d<c[u].morphTargets.length;d++)l[c[u].morphTargets[d]]=-1;for(var p in l){var f=[],m=[];for(d=0;d!==c[u].morphTargets.length;++d){var g=c[u];f.push(g.time),m.push(g.morphTarget===p?1:0)}n.push(new Nh(".morphTargetInfluence["+p+"]",f,m))}s=l.length*(o||1)}else{var v=".bones["+e[h].name+"]";i(jh,v+".position",c,"pos",n),i(Vh,v+".quaternion",c,"rot",n),i(jh,v+".scale",c,"scl",n)}}return 0===n.length?null:new Hh(r,s,n)}}),Object.assign(Hh.prototype,{resetDuration:function(){for(var t=0,e=0,i=this.tracks.length;e!==i;++e){var n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this},trim:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},validate:function(){for(var t=!0,e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t},optimize:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this},clone:function(){for(var t=[],e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new Hh(this.name,this.duration,t)}});var Wh={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function qh(t,e,i){var n=this,r=!1,s=0,o=0,a=void 0,h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){o++,!1===r&&void 0!==n.onStart&&n.onStart(t,s,o),r=!0},this.itemEnd=function(t){s++,void 0!==n.onProgress&&n.onProgress(t,s,o),s===o&&(r=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return a?a(t):t},this.setURLModifier=function(t){return a=t,this},this.addHandler=function(t,e){return h.push(t,e),this},this.removeHandler=function(t){var e=h.indexOf(t);return-1!==e&&h.splice(e,2),this},this.getHandler=function(t){for(var e=0,i=h.length;e<i;e+=2){var n=h[e],r=h[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return r}return null}}var Xh=new qh;function Yh(t){this.manager=void 0!==t?t:Xh,this.crossOrigin="anonymous",this.path="",this.resourcePath=""}Object.assign(Yh.prototype,{load:function(){},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this}});var Zh={};function $h(t){Yh.call(this,t)}function Jh(t){Yh.call(this,t)}function Qh(t){Yh.call(this,t)}function Kh(t){Yh.call(this,t)}function tc(t){Yh.call(this,t)}function ec(t){Yh.call(this,t)}function ic(t){Yh.call(this,t)}function nc(){this.type="Curve",this.arcLengthDivisions=200}function rc(t,e,i,n,r,s,o,a){nc.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=i||1,this.yRadius=n||1,this.aStartAngle=r||0,this.aEndAngle=s||2*Math.PI,this.aClockwise=o||!1,this.aRotation=a||0}function sc(t,e,i,n,r,s){rc.call(this,t,e,i,i,n,r,s),this.type="ArcCurve"}function oc(){var t=0,e=0,i=0,n=0;function r(r,s,o,a){t=r,e=o,i=-3*r+3*s-2*o-a,n=2*r-2*s+o+a}return{initCatmullRom:function(t,e,i,n,s){r(e,i,s*(i-t),s*(n-e))},initNonuniformCatmullRom:function(t,e,i,n,s,o,a){var h=(e-t)/s-(i-t)/(s+o)+(i-e)/o,c=(i-e)/o-(n-e)/(o+a)+(n-i)/a;r(e,i,h*=o,c*=o)},calc:function(r){var s=r*r;return t+e*r+i*s+n*(s*r)}}}$h.prototype=Object.assign(Object.create(Yh.prototype),{constructor:$h,load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var r=this,s=Wh.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;if(void 0===Zh[t]){var o=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(o){var a=o[1],h=!!o[2],c=o[3];c=decodeURIComponent(c),h&&(c=atob(c));try{var l,u=(this.responseType||"").toLowerCase();switch(u){case"arraybuffer":case"blob":for(var d=new Uint8Array(c.length),p=0;p<c.length;p++)d[p]=c.charCodeAt(p);l="blob"===u?new Blob([d.buffer],{type:a}):d.buffer;break;case"document":var f=new DOMParser;l=f.parseFromString(c,a);break;case"json":l=JSON.parse(c);break;default:l=c}setTimeout((function(){e&&e(l),r.manager.itemEnd(t)}),0)}catch(e){setTimeout((function(){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}),0)}}else{Zh[t]=[],Zh[t].push({onLoad:e,onProgress:i,onError:n});var m=new XMLHttpRequest;for(var g in m.open("GET",t,!0),m.addEventListener("load",(function(e){var i=this.response,n=Zh[t];if(delete Zh[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Wh.add(t,i);for(var s=0,o=n.length;s<o;s++){(a=n[s]).onLoad&&a.onLoad(i)}r.manager.itemEnd(t)}else{for(s=0,o=n.length;s<o;s++){var a;(a=n[s]).onError&&a.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}}),!1),m.addEventListener("progress",(function(e){for(var i=Zh[t],n=0,r=i.length;n<r;n++){var s=i[n];s.onProgress&&s.onProgress(e)}}),!1),m.addEventListener("error",(function(e){var i=Zh[t];delete Zh[t];for(var n=0,s=i.length;n<s;n++){var o=i[n];o.onError&&o.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),m.addEventListener("abort",(function(e){var i=Zh[t];delete Zh[t];for(var n=0,s=i.length;n<s;n++){var o=i[n];o.onError&&o.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),void 0!==this.responseType&&(m.responseType=this.responseType),void 0!==this.withCredentials&&(m.withCredentials=this.withCredentials),m.overrideMimeType&&m.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)m.setRequestHeader(g,this.requestHeader[g]);m.send(null)}return r.manager.itemStart(t),m}Zh[t].push({onLoad:e,onProgress:i,onError:n})},setResponseType:function(t){return this.responseType=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setMimeType:function(t){return this.mimeType=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}}),Jh.prototype=Object.assign(Object.create(Yh.prototype),{constructor:Jh,load:function(t,e,i,n){var r=this,s=new $h(r.manager);s.setPath(r.path),s.load(t,(function(t){e(r.parse(JSON.parse(t)))}),i,n)},parse:function(t){for(var e=[],i=0;i<t.length;i++){var n=Hh.parse(t[i]);e.push(n)}return e}}),Qh.prototype=Object.assign(Object.create(Yh.prototype),{constructor:Qh,load:function(t,e,i,n){var r=this,s=[],o=new na;o.image=s;var a=new $h(this.manager);function h(h){a.load(t[h],(function(t){var i=r.parse(t,!0);s[h]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},6===(c+=1)&&(1===i.mipmapCount&&(o.minFilter=yt),o.format=i.format,o.needsUpdate=!0,e&&e(o))}),i,n)}if(a.setPath(this.path),a.setResponseType("arraybuffer"),Array.isArray(t))for(var c=0,l=0,u=t.length;l<u;++l)h(l);else a.load(t,(function(t){var i=r.parse(t,!0);if(i.isCubemap)for(var n=i.mipmaps.length/i.mipmapCount,a=0;a<n;a++){s[a]={mipmaps:[]};for(var h=0;h<i.mipmapCount;h++)s[a].mipmaps.push(i.mipmaps[a*i.mipmapCount+h]),s[a].format=i.format,s[a].width=i.width,s[a].height=i.height}else o.image.width=i.width,o.image.height=i.height,o.mipmaps=i.mipmaps;1===i.mipmapCount&&(o.minFilter=yt),o.format=i.format,o.needsUpdate=!0,e&&e(o)}),i,n);return o}}),Kh.prototype=Object.assign(Object.create(Yh.prototype),{constructor:Kh,load:function(t,e,i,n){var r=this,s=new Jn,o=new $h(this.manager);return o.setResponseType("arraybuffer"),o.setPath(this.path),o.load(t,(function(t){var i=r.parse(t);i&&(void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:dt,s.wrapT=void 0!==i.wrapT?i.wrapT:dt,s.magFilter=void 0!==i.magFilter?i.magFilter:yt,s.minFilter=void 0!==i.minFilter?i.minFilter:yt,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=xt),1===i.mipmapCount&&(s.minFilter=yt),s.needsUpdate=!0,e&&e(s,i))}),i,n),s}}),tc.prototype=Object.assign(Object.create(Yh.prototype),{constructor:tc,load:function(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var r=this,s=Wh.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;var o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){o.removeEventListener("load",a,!1),o.removeEventListener("error",h,!1),Wh.add(t,this),e&&e(this),r.manager.itemEnd(t)}function h(e){o.removeEventListener("load",a,!1),o.removeEventListener("error",h,!1),n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}return o.addEventListener("load",a,!1),o.addEventListener("error",h,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(t),o.src=t,o}}),ec.prototype=Object.assign(Object.create(Yh.prototype),{constructor:ec,load:function(t,e,i,n){var r=new yr,s=new tc(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);var o=0;function a(i){s.load(t[i],(function(t){r.images[i]=t,6===++o&&(r.needsUpdate=!0,e&&e(r))}),void 0,n)}for(var h=0;h<t.length;++h)a(h);return r}}),ic.prototype=Object.assign(Object.create(Yh.prototype),{constructor:ic,load:function(t,e,i,n){var r=new ye,s=new tc(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(i){r.image=i;var n=t.search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/);r.format=n?Ot:Ft,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r}}),Object.assign(nc.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i,n=[],r=this.getPoint(0),s=0;for(n.push(0),i=1;i<=t;i++)s+=(e=this.getPoint(i/t)).distanceTo(r),n.push(s),r=e;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var i,n=this.getLengths(),r=0,s=n.length;i=e||t*n[s-1];for(var o,a=0,h=s-1;a<=h;)if((o=n[r=Math.floor(a+(h-a)/2)]-i)<0)a=r+1;else{if(!(o>0)){h=r;break}h=r-1}if(n[r=h]===i)return r/(s-1);var c=n[r];return(r+(i-c)/(n[r+1]-c))/(s-1)},getTangent:function(t){var e=1e-4,i=t-e,n=t+e;i<0&&(i=0),n>1&&(n=1);var r=this.getPoint(i);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var i,n,r,s=new pe,o=[],a=[],h=[],c=new pe,l=new Le;for(i=0;i<=t;i++)n=i/t,o[i]=this.getTangentAt(n),o[i].normalize();a[0]=new pe,h[0]=new pe;var u=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=u&&(u=d,s.set(1,0,0)),p<=u&&(u=p,s.set(0,1,0)),f<=u&&s.set(0,0,1),c.crossVectors(o[0],s).normalize(),a[0].crossVectors(o[0],c),h[0].crossVectors(o[0],a[0]),i=1;i<=t;i++)a[i]=a[i-1].clone(),h[i]=h[i-1].clone(),c.crossVectors(o[i-1],o[i]),c.length()>Number.EPSILON&&(c.normalize(),r=Math.acos(he.clamp(o[i-1].dot(o[i]),-1,1)),a[i].applyMatrix4(l.makeRotationAxis(c,r))),h[i].crossVectors(o[i],a[i]);if(!0===e)for(r=Math.acos(he.clamp(a[0].dot(a[t]),-1,1)),r/=t,o[0].dot(c.crossVectors(a[0],a[t]))>0&&(r=-r),i=1;i<=t;i++)a[i].applyMatrix4(l.makeRotationAxis(o[i],r*i)),h[i].crossVectors(o[i],a[i]);return{tangents:o,normals:a,binormals:h}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){var t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),rc.prototype=Object.create(nc.prototype),rc.prototype.constructor=rc,rc.prototype.isEllipseCurve=!0,rc.prototype.getPoint=function(t,e){for(var i=e||new ce,n=2*Math.PI,r=this.aEndAngle-this.aStartAngle,s=Math.abs(r)<Number.EPSILON;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);var o=this.aStartAngle+t*r,a=this.aX+this.xRadius*Math.cos(o),h=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){var c=Math.cos(this.aRotation),l=Math.sin(this.aRotation),u=a-this.aX,d=h-this.aY;a=u*c-d*l+this.aX,h=u*l+d*c+this.aY}return i.set(a,h)},rc.prototype.copy=function(t){return nc.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},rc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t},rc.prototype.fromJSON=function(t){return nc.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},sc.prototype=Object.create(rc.prototype),sc.prototype.constructor=sc,sc.prototype.isArcCurve=!0;var ac=new pe,hc=new oc,cc=new oc,lc=new oc;function uc(t,e,i,n){nc.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=e||!1,this.curveType=i||"centripetal",this.tension=n||.5}function dc(t,e,i,n,r){var s=.5*(n-e),o=.5*(r-i),a=t*t;return(2*i-2*n+s+o)*(t*a)+(-3*i+3*n-2*s-o)*a+s*t+i}function pc(t,e,i,n){return function(t,e){var i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function fc(t,e,i,n,r){return function(t,e){var i=1-t;return i*i*i*e}(t,e)+function(t,e){var i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,r)}function mc(t,e,i,n){nc.call(this),this.type="CubicBezierCurve",this.v0=t||new ce,this.v1=e||new ce,this.v2=i||new ce,this.v3=n||new ce}function gc(t,e,i,n){nc.call(this),this.type="CubicBezierCurve3",this.v0=t||new pe,this.v1=e||new pe,this.v2=i||new pe,this.v3=n||new pe}function vc(t,e){nc.call(this),this.type="LineCurve",this.v1=t||new ce,this.v2=e||new ce}function bc(t,e){nc.call(this),this.type="LineCurve3",this.v1=t||new pe,this.v2=e||new pe}function yc(t,e,i){nc.call(this),this.type="QuadraticBezierCurve",this.v0=t||new ce,this.v1=e||new ce,this.v2=i||new ce}function _c(t,e,i){nc.call(this),this.type="QuadraticBezierCurve3",this.v0=t||new pe,this.v1=e||new pe,this.v2=i||new pe}function xc(t){nc.call(this),this.type="SplineCurve",this.points=t||[]}uc.prototype=Object.create(nc.prototype),uc.prototype.constructor=uc,uc.prototype.isCatmullRomCurve3=!0,uc.prototype.getPoint=function(t,e){var i,n,r,s,o=e||new pe,a=this.points,h=a.length,c=(h-(this.closed?0:1))*t,l=Math.floor(c),u=c-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/h)+1)*h:0===u&&l===h-1&&(l=h-2,u=1),this.closed||l>0?i=a[(l-1)%h]:(ac.subVectors(a[0],a[1]).add(a[0]),i=ac),n=a[l%h],r=a[(l+1)%h],this.closed||l+2<h?s=a[(l+2)%h]:(ac.subVectors(a[h-1],a[h-2]).add(a[h-1]),s=ac),"centripetal"===this.curveType||"chordal"===this.curveType){var d="chordal"===this.curveType?.5:.25,p=Math.pow(i.distanceToSquared(n),d),f=Math.pow(n.distanceToSquared(r),d),m=Math.pow(r.distanceToSquared(s),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),hc.initNonuniformCatmullRom(i.x,n.x,r.x,s.x,p,f,m),cc.initNonuniformCatmullRom(i.y,n.y,r.y,s.y,p,f,m),lc.initNonuniformCatmullRom(i.z,n.z,r.z,s.z,p,f,m)}else"catmullrom"===this.curveType&&(hc.initCatmullRom(i.x,n.x,r.x,s.x,this.tension),cc.initCatmullRom(i.y,n.y,r.y,s.y,this.tension),lc.initCatmullRom(i.z,n.z,r.z,s.z,this.tension));return o.set(hc.calc(u),cc.calc(u),lc.calc(u)),o},uc.prototype.copy=function(t){nc.prototype.copy.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},uc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);t.points=[];for(var e=0,i=this.points.length;e<i;e++){var n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t},uc.prototype.fromJSON=function(t){nc.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var n=t.points[e];this.points.push((new pe).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},mc.prototype=Object.create(nc.prototype),mc.prototype.constructor=mc,mc.prototype.isCubicBezierCurve=!0,mc.prototype.getPoint=function(t,e){var i=e||new ce,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(fc(t,n.x,r.x,s.x,o.x),fc(t,n.y,r.y,s.y,o.y)),i},mc.prototype.copy=function(t){return nc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},mc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},mc.prototype.fromJSON=function(t){return nc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},gc.prototype=Object.create(nc.prototype),gc.prototype.constructor=gc,gc.prototype.isCubicBezierCurve3=!0,gc.prototype.getPoint=function(t,e){var i=e||new pe,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(fc(t,n.x,r.x,s.x,o.x),fc(t,n.y,r.y,s.y,o.y),fc(t,n.z,r.z,s.z,o.z)),i},gc.prototype.copy=function(t){return nc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},gc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},gc.prototype.fromJSON=function(t){return nc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},vc.prototype=Object.create(nc.prototype),vc.prototype.constructor=vc,vc.prototype.isLineCurve=!0,vc.prototype.getPoint=function(t,e){var i=e||new ce;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},vc.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},vc.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},vc.prototype.copy=function(t){return nc.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},vc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},vc.prototype.fromJSON=function(t){return nc.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},bc.prototype=Object.create(nc.prototype),bc.prototype.constructor=bc,bc.prototype.isLineCurve3=!0,bc.prototype.getPoint=function(t,e){var i=e||new pe;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},bc.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},bc.prototype.copy=function(t){return nc.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},bc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},bc.prototype.fromJSON=function(t){return nc.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},yc.prototype=Object.create(nc.prototype),yc.prototype.constructor=yc,yc.prototype.isQuadraticBezierCurve=!0,yc.prototype.getPoint=function(t,e){var i=e||new ce,n=this.v0,r=this.v1,s=this.v2;return i.set(pc(t,n.x,r.x,s.x),pc(t,n.y,r.y,s.y)),i},yc.prototype.copy=function(t){return nc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},yc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},yc.prototype.fromJSON=function(t){return nc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},_c.prototype=Object.create(nc.prototype),_c.prototype.constructor=_c,_c.prototype.isQuadraticBezierCurve3=!0,_c.prototype.getPoint=function(t,e){var i=e||new pe,n=this.v0,r=this.v1,s=this.v2;return i.set(pc(t,n.x,r.x,s.x),pc(t,n.y,r.y,s.y),pc(t,n.z,r.z,s.z)),i},_c.prototype.copy=function(t){return nc.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},_c.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},_c.prototype.fromJSON=function(t){return nc.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},xc.prototype=Object.create(nc.prototype),xc.prototype.constructor=xc,xc.prototype.isSplineCurve=!0,xc.prototype.getPoint=function(t,e){var i=e||new ce,n=this.points,r=(n.length-1)*t,s=Math.floor(r),o=r-s,a=n[0===s?s:s-1],h=n[s],c=n[s>n.length-2?n.length-1:s+1],l=n[s>n.length-3?n.length-1:s+2];return i.set(dc(o,a.x,h.x,c.x,l.x),dc(o,a.y,h.y,c.y,l.y)),i},xc.prototype.copy=function(t){nc.prototype.copy.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var n=t.points[e];this.points.push(n.clone())}return this},xc.prototype.toJSON=function(){var t=nc.prototype.toJSON.call(this);t.points=[];for(var e=0,i=this.points.length;e<i;e++){var n=this.points[e];t.points.push(n.toArray())}return t},xc.prototype.fromJSON=function(t){nc.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var n=t.points[e];this.points.push((new ce).fromArray(n))}return this};var wc=Object.freeze({__proto__:null,ArcCurve:sc,CatmullRomCurve3:uc,CubicBezierCurve:mc,CubicBezierCurve3:gc,EllipseCurve:rc,LineCurve:vc,LineCurve3:bc,QuadraticBezierCurve:yc,QuadraticBezierCurve3:_c,SplineCurve:xc});function Mc(){nc.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Tc(t){Mc.call(this),this.type="Path",this.currentPoint=new ce,t&&this.setFromPoints(t)}function Sc(t){Tc.call(this,t),this.uuid=he.generateUUID(),this.type="Shape",this.holes=[]}function Ec(t,e){Ye.call(this),this.type="Light",this.color=new Ui(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Pc(t,e,i){Ec.call(this,t,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(Ye.DefaultUp),this.updateMatrix(),this.groundColor=new Ui(e)}function Ac(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new ce(512,512),this.map=null,this.mapPass=null,this.matrix=new Le,this._frustum=new tr,this._frameExtents=new ce(1,1),this._viewportCount=1,this._viewports=[new _e(0,0,1,1)]}function Cc(){Ac.call(this,new Xn(50,1,.5,500))}function Lc(t,e,i,n,r,s){Ec.call(this,t,e),this.type="SpotLight",this.position.copy(Ye.DefaultUp),this.updateMatrix(),this.target=new Ye,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==s?s:1,this.shadow=new Cc}function Rc(){Ac.call(this,new Xn(90,1,.5,500)),this._frameExtents=new ce(4,2),this._viewportCount=6,this._viewports=[new _e(2,1,1,1),new _e(0,1,1,1),new _e(3,1,1,1),new _e(1,1,1,1),new _e(3,0,1,1),new _e(1,0,1,1)],this._cubeDirections=[new pe(1,0,0),new pe(-1,0,0),new pe(0,0,1),new pe(0,0,-1),new pe(0,1,0),new pe(0,-1,0)],this._cubeUps=[new pe(0,1,0),new pe(0,1,0),new pe(0,1,0),new pe(0,1,0),new pe(0,0,1),new pe(0,0,-1)]}function Ic(t,e,i,n){Ec.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==i?i:0,this.decay=void 0!==n?n:1,this.shadow=new Rc}function Oc(t,e,i,n,r,s){qn.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==t?t:-1,this.right=void 0!==e?e:1,this.top=void 0!==i?i:1,this.bottom=void 0!==n?n:-1,this.near=void 0!==r?r:.1,this.far=void 0!==s?s:2e3,this.updateProjectionMatrix()}function Fc(){Ac.call(this,new Oc(-5,5,5,-5,.5,500))}function Bc(t,e){Ec.call(this,t,e),this.type="DirectionalLight",this.position.copy(Ye.DefaultUp),this.updateMatrix(),this.target=new Ye,this.shadow=new Fc}function Dc(t,e){Ec.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function zc(t,e,i,n){Ec.call(this,t,e),this.type="RectAreaLight",this.width=void 0!==i?i:10,this.height=void 0!==n?n:10}function Nc(t){Yh.call(this,t),this.textures={}}Mc.prototype=Object.assign(Object.create(nc.prototype),{constructor:Mc,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new vc(e,t))},getPoint:function(t){for(var e=t*this.getLength(),i=this.getCurveLengths(),n=0;n<i.length;){if(i[n]>=e){var r=i[n]-e,s=this.curves[n],o=s.getLength(),a=0===o?0:1-r/o;return s.getPointAt(a)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,i=0,n=this.curves.length;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;for(var e,i=[],n=0,r=this.curves;n<r.length;n++)for(var s=r[n],o=s&&s.isEllipseCurve?2*t:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?t*s.points.length:t,a=s.getPoints(o),h=0;h<a.length;h++){var c=a[h];e&&e.equals(c)||(i.push(c),e=c)}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},copy:function(t){nc.prototype.copy.call(this,t),this.curves=[];for(var e=0,i=t.curves.length;e<i;e++){var n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){var t=nc.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(var e=0,i=this.curves.length;e<i;e++){var n=this.curves[e];t.curves.push(n.toJSON())}return t},fromJSON:function(t){nc.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(var e=0,i=t.curves.length;e<i;e++){var n=t.curves[e];this.curves.push((new wc[n.type]).fromJSON(n))}return this}}),Tc.prototype=Object.assign(Object.create(Mc.prototype),{constructor:Tc,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y);return this},moveTo:function(t,e){return this.currentPoint.set(t,e),this},lineTo:function(t,e){var i=new vc(this.currentPoint.clone(),new ce(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this},quadraticCurveTo:function(t,e,i,n){var r=new yc(this.currentPoint.clone(),new ce(t,e),new ce(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this},bezierCurveTo:function(t,e,i,n,r,s){var o=new mc(this.currentPoint.clone(),new ce(t,e),new ce(i,n),new ce(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this},splineThru:function(t){var e=new xc([this.currentPoint.clone()].concat(t));return this.curves.push(e),this.currentPoint.copy(t[t.length-1]),this},arc:function(t,e,i,n,r,s){var o=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(t+o,e+a,i,n,r,s),this},absarc:function(t,e,i,n,r,s){return this.absellipse(t,e,i,i,n,r,s),this},ellipse:function(t,e,i,n,r,s,o,a){var h=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+h,e+c,i,n,r,s,o,a),this},absellipse:function(t,e,i,n,r,s,o,a){var h=new rc(t,e,i,n,r,s,o,a);if(this.curves.length>0){var c=h.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(h);var l=h.getPoint(1);return this.currentPoint.copy(l),this},copy:function(t){return Mc.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Mc.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Mc.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Sc.prototype=Object.assign(Object.create(Tc.prototype),{constructor:Sc,getPointsHoles:function(t){for(var e=[],i=0,n=this.holes.length;i<n;i++)e[i]=this.holes[i].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){Tc.prototype.copy.call(this,t),this.holes=[];for(var e=0,i=t.holes.length;e<i;e++){var n=t.holes[e];this.holes.push(n.clone())}return this},toJSON:function(){var t=Tc.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(var e=0,i=this.holes.length;e<i;e++){var n=this.holes[e];t.holes.push(n.toJSON())}return t},fromJSON:function(t){Tc.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(var e=0,i=t.holes.length;e<i;e++){var n=t.holes[e];this.holes.push((new Tc).fromJSON(n))}return this}}),Ec.prototype=Object.assign(Object.create(Ye.prototype),{constructor:Ec,isLight:!0,copy:function(t){return Ye.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Ye.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Pc.prototype=Object.assign(Object.create(Ec.prototype),{constructor:Pc,isHemisphereLight:!0,copy:function(t){return Ec.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Ac.prototype,{_projScreenMatrix:new Le,_lightPositionWorld:new pe,_lookTarget:new pe,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(t){var e=this.camera,i=this.matrix,n=this._projScreenMatrix,r=this._lookTarget,s=this._lightPositionWorld;s.setFromMatrixPosition(t.matrixWorld),e.position.copy(s),r.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(r),e.updateMatrixWorld(),n.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromMatrix(n),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(e.projectionMatrix),i.multiply(e.matrixWorldInverse)},getViewport:function(t){return this._viewports[t]},getFrameExtents:function(){return this._frameExtents},copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),Cc.prototype=Object.assign(Object.create(Ac.prototype),{constructor:Cc,isSpotLightShadow:!0,updateMatrices:function(t){var e=this.camera,i=2*he.RAD2DEG*t.angle,n=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),Ac.prototype.updateMatrices.call(this,t)}}),Lc.prototype=Object.assign(Object.create(Ec.prototype),{constructor:Lc,isSpotLight:!0,copy:function(t){return Ec.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Rc.prototype=Object.assign(Object.create(Ac.prototype),{constructor:Rc,isPointLightShadow:!0,updateMatrices:function(t,e){void 0===e&&(e=0);var i=this.camera,n=this.matrix,r=this._lightPositionWorld,s=this._lookTarget,o=this._projScreenMatrix;r.setFromMatrixPosition(t.matrixWorld),i.position.copy(r),s.copy(i.position),s.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(s),i.updateMatrixWorld(),n.makeTranslation(-r.x,-r.y,-r.z),o.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromMatrix(o)}}),Ic.prototype=Object.assign(Object.create(Ec.prototype),{constructor:Ic,isPointLight:!0,copy:function(t){return Ec.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Oc.prototype=Object.assign(Object.create(qn.prototype),{constructor:Oc,isOrthographicCamera:!0,copy:function(t,e){return qn.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2,r=i-t,s=i+t,o=n+e,a=n-e;if(null!==this.view&&this.view.enabled){var h=this.zoom/(this.view.width/this.view.fullWidth),c=this.zoom/(this.view.height/this.view.fullHeight),l=(this.right-this.left)/this.view.width,u=(this.top-this.bottom)/this.view.height;s=(r+=l*(this.view.offsetX/h))+l*(this.view.width/h),a=(o-=u*(this.view.offsetY/c))-u*(this.view.height/c)}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=Ye.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),Fc.prototype=Object.assign(Object.create(Ac.prototype),{constructor:Fc,isDirectionalLightShadow:!0,updateMatrices:function(t){Ac.prototype.updateMatrices.call(this,t)}}),Bc.prototype=Object.assign(Object.create(Ec.prototype),{constructor:Bc,isDirectionalLight:!0,copy:function(t){return Ec.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Dc.prototype=Object.assign(Object.create(Ec.prototype),{constructor:Dc,isAmbientLight:!0}),zc.prototype=Object.assign(Object.create(Ec.prototype),{constructor:zc,isRectAreaLight:!0,copy:function(t){return Ec.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Ec.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}}),Nc.prototype=Object.assign(Object.create(Yh.prototype),{constructor:Nc,load:function(t,e,i,n){var r=this,s=new $h(r.manager);s.setPath(r.path),s.load(t,(function(t){e(r.parse(JSON.parse(t)))}),i,n)},parse:function(t){var e=this.textures;function i(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}var n=new Ch[t.type];if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=(new Ui).setHex(t.sheen)),void 0!==t.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&n.specular.setHex(t.specular),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.vertexColors&&(n.vertexColors=t.vertexColors),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),1!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.skinning&&(n.skinning=t.skinning),void 0!==t.morphTargets&&(n.morphTargets=t.morphTargets),void 0!==t.morphNormals&&(n.morphNormals=t.morphNormals),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.uniforms)for(var r in t.uniforms){var s=t.uniforms[r];switch(n.uniforms[r]={},s.type){case"t":n.uniforms[r].value=i(s.value);break;case"c":n.uniforms[r].value=(new Ui).setHex(s.value);break;case"v2":n.uniforms[r].value=(new ce).fromArray(s.value);break;case"v3":n.uniforms[r].value=(new pe).fromArray(s.value);break;case"v4":n.uniforms[r].value=(new _e).fromArray(s.value);break;case"m3":n.uniforms[r].value=(new ge).fromArray(s.value);case"m4":n.uniforms[r].value=(new Le).fromArray(s.value);break;default:n.uniforms[r].value=s.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(var o in t.extensions)n.extensions[o]=t.extensions[o];if(void 0!==t.shading&&(n.flatShading=1===t.shading),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap),n.transparent=!0),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){var a=t.normalScale;!1===Array.isArray(a)&&(a=[a,a]),n.normalScale=(new ce).fromArray(a)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new ce).fromArray(t.clearcoatNormalScale)),n},setTextures:function(t){return this.textures=t,this}});var Uc=function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);for(var e="",i=0,n=t.length;i<n;i++)e+=String.fromCharCode(t[i]);try{return decodeURIComponent(escape(e))}catch(t){return e}},Vc=function(t){var e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)};function kc(){fn.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function jc(t,e,i,n){"number"==typeof i&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),Yi.call(this,t,e,i),this.meshPerAttribute=n||1}function Hc(t){Yh.call(this,t)}kc.prototype=Object.assign(Object.create(fn.prototype),{constructor:kc,isInstancedBufferGeometry:!0,copy:function(t){return fn.prototype.copy.call(this,t),this.maxInstancedCount=t.maxInstancedCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t=fn.prototype.toJSON.call(this);return t.maxInstancedCount=this.maxInstancedCount,t.isInstancedBufferGeometry=!0,t}}),jc.prototype=Object.assign(Object.create(Yi.prototype),{constructor:jc,isInstancedBufferAttribute:!0,copy:function(t){return Yi.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){var t=Yi.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}),Hc.prototype=Object.assign(Object.create(Yh.prototype),{constructor:Hc,load:function(t,e,i,n){var r=this,s=new $h(r.manager);s.setPath(r.path),s.load(t,(function(t){e(r.parse(JSON.parse(t)))}),i,n)},parse:function(t){var e=t.isInstancedBufferGeometry?new kc:new fn,i=t.data.index;if(void 0!==i){var n=new Gc[i.type](i.array);e.setIndex(new Yi(n,1))}var r=t.data.attributes;for(var s in r){var o=r[s],a=(n=new Gc[o.type](o.array),new(o.isInstancedBufferAttribute?jc:Yi)(n,o.itemSize,o.normalized));void 0!==o.name&&(a.name=o.name),e.setAttribute(s,a)}var h=t.data.morphAttributes;if(h)for(var s in h){for(var c=h[s],l=[],u=0,d=c.length;u<d;u++){o=c[u],a=new Yi(n=new Gc[o.type](o.array),o.itemSize,o.normalized);void 0!==o.name&&(a.name=o.name),l.push(a)}e.morphAttributes[s]=l}t.data.morphTargetsRelative&&(e.morphTargetsRelative=!0);var p=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==p){u=0;for(var f=p.length;u!==f;++u){var m=p[u];e.addGroup(m.start,m.count,m.materialIndex)}}var g=t.data.boundingSphere;if(void 0!==g){var v=new pe;void 0!==g.center&&v.fromArray(g.center),e.boundingSphere=new di(v,g.radius)}return t.name&&(e.name=t.name),t.userData&&(e.userData=t.userData),e}});var Gc={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Wc(t){Yh.call(this,t)}Wc.prototype=Object.assign(Object.create(Yh.prototype),{constructor:Wc,load:function(t,e,i,n){var r=this,s=""===this.path?Vc(t):this.path;this.resourcePath=this.resourcePath||s;var o=new $h(r.manager);o.setPath(this.path),o.load(t,(function(i){var s=null;try{s=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var o=s.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()?r.parse(s,e):console.error("THREE.ObjectLoader: Can't load "+t)}),i,n)},parse:function(t,e){var i=this.parseShape(t.shapes),n=this.parseGeometries(t.geometries,i),r=this.parseImages(t.images,(function(){void 0!==e&&e(a)})),s=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,s),a=this.parseObject(t.object,n,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseShape:function(t){var e={};if(void 0!==t)for(var i=0,n=t.length;i<n;i++){var r=(new Sc).fromJSON(t[i]);e[r.uuid]=r}return e},parseGeometries:function(t,e){var i={};if(void 0!==t)for(var n=new Hc,r=0,s=t.length;r<s;r++){var o,a=t[r];switch(a.type){case"PlaneGeometry":case"PlaneBufferGeometry":o=new bh[a.type](a.width,a.height,a.widthSegments,a.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":o=new bh[a.type](a.width,a.height,a.depth,a.widthSegments,a.heightSegments,a.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":o=new bh[a.type](a.radius,a.segments,a.thetaStart,a.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":o=new bh[a.type](a.radiusTop,a.radiusBottom,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":o=new bh[a.type](a.radius,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":o=new bh[a.type](a.radius,a.widthSegments,a.heightSegments,a.phiStart,a.phiLength,a.thetaStart,a.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":o=new bh[a.type](a.radius,a.detail);break;case"RingGeometry":case"RingBufferGeometry":o=new bh[a.type](a.innerRadius,a.outerRadius,a.thetaSegments,a.phiSegments,a.thetaStart,a.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":o=new bh[a.type](a.radius,a.tube,a.radialSegments,a.tubularSegments,a.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":o=new bh[a.type](a.radius,a.tube,a.tubularSegments,a.radialSegments,a.p,a.q);break;case"TubeGeometry":case"TubeBufferGeometry":o=new bh[a.type]((new wc[a.path.type]).fromJSON(a.path),a.tubularSegments,a.radius,a.radialSegments,a.closed);break;case"LatheGeometry":case"LatheBufferGeometry":o=new bh[a.type](a.points,a.segments,a.phiStart,a.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":o=new bh[a.type](a.vertices,a.indices,a.radius,a.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":for(var h=[],c=0,l=a.shapes.length;c<l;c++){var u=e[a.shapes[c]];h.push(u)}o=new bh[a.type](h,a.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":for(h=[],c=0,l=a.shapes.length;c<l;c++){u=e[a.shapes[c]];h.push(u)}var d=a.options.extrudePath;void 0!==d&&(a.options.extrudePath=(new wc[d.type]).fromJSON(d)),o=new bh[a.type](h,a.options);break;case"BufferGeometry":case"InstancedBufferGeometry":o=n.parse(a);break;case"Geometry":if("THREE"in window&&"LegacyJSONLoader"in THREE)o=(new THREE.LegacyJSONLoader).parse(a,this.resourcePath).geometry;else console.error('THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+a.type+'"');continue}o.uuid=a.uuid,void 0!==a.name&&(o.name=a.name),!0===o.isBufferGeometry&&void 0!==a.userData&&(o.userData=a.userData),i[a.uuid]=o}return i},parseMaterials:function(t,e){var i={},n={};if(void 0!==t){var r=new Nc;r.setTextures(e);for(var s=0,o=t.length;s<o;s++){var a=t[s];if("MultiMaterial"===a.type){for(var h=[],c=0;c<a.materials.length;c++){var l=a.materials[c];void 0===i[l.uuid]&&(i[l.uuid]=r.parse(l)),h.push(i[l.uuid])}n[a.uuid]=h}else void 0===i[a.uuid]&&(i[a.uuid]=r.parse(a)),n[a.uuid]=i[a.uuid]}}return n},parseAnimations:function(t){for(var e=[],i=0;i<t.length;i++){var n=t[i],r=Hh.parse(n);void 0!==n.uuid&&(r.uuid=n.uuid),e.push(r)}return e},parseImages:function(t,e){var i=this,n={};function r(t){return i.manager.itemStart(t),s.load(t,(function(){i.manager.itemEnd(t)}),void 0,(function(){i.manager.itemError(t),i.manager.itemEnd(t)}))}if(void 0!==t&&t.length>0){var s=new tc(new qh(e));s.setCrossOrigin(this.crossOrigin);for(var o=0,a=t.length;o<a;o++){var h=t[o],c=h.url;if(Array.isArray(c)){n[h.uuid]=[];for(var l=0,u=c.length;l<u;l++){var d=c[l],p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(d)?d:i.resourcePath+d;n[h.uuid].push(r(p))}}else{p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h.url)?h.url:i.resourcePath+h.url;n[h.uuid]=r(p)}}}return n},parseTextures:function(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}var n={};if(void 0!==t)for(var r=0,s=t.length;r<s;r++){var o,a=t[r];void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===e[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image),(o=Array.isArray(e[a.image])?new yr(e[a.image]):new ye(e[a.image])).needsUpdate=!0,o.uuid=a.uuid,void 0!==a.name&&(o.name=a.name),void 0!==a.mapping&&(o.mapping=i(a.mapping,Xc)),void 0!==a.offset&&o.offset.fromArray(a.offset),void 0!==a.repeat&&o.repeat.fromArray(a.repeat),void 0!==a.center&&o.center.fromArray(a.center),void 0!==a.rotation&&(o.rotation=a.rotation),void 0!==a.wrap&&(o.wrapS=i(a.wrap[0],Yc),o.wrapT=i(a.wrap[1],Yc)),void 0!==a.format&&(o.format=a.format),void 0!==a.type&&(o.type=a.type),void 0!==a.encoding&&(o.encoding=a.encoding),void 0!==a.minFilter&&(o.minFilter=i(a.minFilter,Zc)),void 0!==a.magFilter&&(o.magFilter=i(a.magFilter,Zc)),void 0!==a.anisotropy&&(o.anisotropy=a.anisotropy),void 0!==a.flipY&&(o.flipY=a.flipY),void 0!==a.premultiplyAlpha&&(o.premultiplyAlpha=a.premultiplyAlpha),void 0!==a.unpackAlignment&&(o.unpackAlignment=a.unpackAlignment),n[a.uuid]=o}return n},parseObject:function(t,e,i){var n;function r(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function s(t){if(void 0!==t){if(Array.isArray(t)){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];void 0===i[s]&&console.warn("THREE.ObjectLoader: Undefined material",s),e.push(i[s])}return e}return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),i[t]}}switch(t.type){case"Scene":n=new Ze,void 0!==t.background&&Number.isInteger(t.background)&&(n.background=new Ui(t.background)),void 0!==t.fog&&("Fog"===t.fog.type?n.fog=new ro(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(n.fog=new no(t.fog.color,t.fog.density)));break;case"PerspectiveCamera":n=new Xn(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(n.focus=t.focus),void 0!==t.zoom&&(n.zoom=t.zoom),void 0!==t.filmGauge&&(n.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(n.filmOffset=t.filmOffset),void 0!==t.view&&(n.view=Object.assign({},t.view));break;case"OrthographicCamera":n=new Oc(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(n.zoom=t.zoom),void 0!==t.view&&(n.view=Object.assign({},t.view));break;case"AmbientLight":n=new Dc(t.color,t.intensity);break;case"DirectionalLight":n=new Bc(t.color,t.intensity);break;case"PointLight":n=new Ic(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":n=new zc(t.color,t.intensity,t.width,t.height);break;case"SpotLight":n=new Lc(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":n=new Pc(t.color,t.groundColor,t.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var o=r(t.geometry),a=s(t.material);n=o.bones&&o.bones.length>0?new Ao(o,a):new In(o,a);break;case"InstancedMesh":o=r(t.geometry),a=s(t.material);var h=t.count,c=t.instanceMatrix;(n=new zo(o,a,h)).instanceMatrix=new Yi(new Float32Array(c.array),16);break;case"LOD":n=new Po;break;case"Line":n=new Go(r(t.geometry),s(t.material),t.mode);break;case"LineLoop":n=new Yo(r(t.geometry),s(t.material));break;case"LineSegments":n=new Xo(r(t.geometry),s(t.material));break;case"PointCloud":case"Points":n=new ta(r(t.geometry),s(t.material));break;case"Sprite":n=new Mo(s(t.material));break;case"Group":n=new to;break;default:n=new Ye}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(n.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(n.matrixAutoUpdate=t.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.frustumCulled&&(n.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(n.renderOrder=t.renderOrder),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.layers&&(n.layers.mask=t.layers),void 0!==t.children)for(var l=t.children,u=0;u<l.length;u++)n.add(this.parseObject(l[u],e,i));if("LOD"===t.type){void 0!==t.autoUpdate&&(n.autoUpdate=t.autoUpdate);for(var d=t.levels,p=0;p<d.length;p++){var f=d[p],m=n.getObjectByProperty("uuid",f.object);void 0!==m&&n.addLevel(m,f.distance)}}return n}});var qc,Xc={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,SphericalReflectionMapping:305,CubeUVReflectionMapping:lt,CubeUVRefractionMapping:307},Yc={RepeatWrapping:ut,ClampToEdgeWrapping:dt,MirroredRepeatWrapping:pt},Zc={NearestFilter:ft,NearestMipmapNearestFilter:mt,NearestMipmapLinearFilter:vt,LinearFilter:yt,LinearMipmapNearestFilter:1007,LinearMipmapLinearFilter:xt};function $c(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),Yh.call(this,t),this.options=void 0}function Jc(){this.type="ShapePath",this.color=new Ui,this.subPaths=[],this.currentPath=null}function Qc(t){this.type="Font",this.data=t}function Kc(t,e,i,n,r){var s=r.glyphs[t]||r.glyphs["?"];if(s){var o,a,h,c,l,u,d,p,f=new Jc;if(s.o)for(var m=s._cachedOutline||(s._cachedOutline=s.o.split(" ")),g=0,v=m.length;g<v;){switch(m[g++]){case"m":o=m[g++]*e+i,a=m[g++]*e+n,f.moveTo(o,a);break;case"l":o=m[g++]*e+i,a=m[g++]*e+n,f.lineTo(o,a);break;case"q":h=m[g++]*e+i,c=m[g++]*e+n,l=m[g++]*e+i,u=m[g++]*e+n,f.quadraticCurveTo(l,u,h,c);break;case"b":h=m[g++]*e+i,c=m[g++]*e+n,l=m[g++]*e+i,u=m[g++]*e+n,d=m[g++]*e+i,p=m[g++]*e+n,f.bezierCurveTo(l,u,d,p,h,c)}}return{offsetX:s.ha*e,path:f}}console.error('THREE.Font: character "'+t+'" does not exists in font family '+r.familyName+".")}function tl(t){Yh.call(this,t)}$c.prototype=Object.assign(Object.create(Yh.prototype),{constructor:$c,setOptions:function(t){return this.options=t,this},load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var r=this,s=Wh.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;fetch(t).then((function(t){return t.blob()})).then((function(t){return void 0===r.options?createImageBitmap(t):createImageBitmap(t,r.options)})).then((function(i){Wh.add(t,i),e&&e(i),r.manager.itemEnd(t)})).catch((function(e){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)})),r.manager.itemStart(t)}}),Object.assign(Jc.prototype,{moveTo:function(t,e){return this.currentPath=new Tc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this},lineTo:function(t,e){return this.currentPath.lineTo(t,e),this},quadraticCurveTo:function(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this},bezierCurveTo:function(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this},splineThru:function(t){return this.currentPath.splineThru(t),this},toShapes:function(t,e){function i(t){for(var e=[],i=0,n=t.length;i<n;i++){var r=t[i],s=new Sc;s.curves=r.curves,e.push(s)}return e}function n(t,e){for(var i=e.length,n=!1,r=i-1,s=0;s<i;r=s++){var o=e[r],a=e[s],h=a.x-o.x,c=a.y-o.y;if(Math.abs(c)>Number.EPSILON){if(c<0&&(o=e[s],h=-h,a=e[r],c=-c),t.y<o.y||t.y>a.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var l=c*(t.x-o.x)-h*(t.y-o.y);if(0===l)return!0;if(l<0)continue;n=!n}}else{if(t.y!==o.y)continue;if(a.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=a.x)return!0}}return n}var r=Xa.isClockWise,s=this.subPaths;if(0===s.length)return[];if(!0===e)return i(s);var o,a,h,c=[];if(1===s.length)return a=s[0],(h=new Sc).curves=a.curves,c.push(h),c;var l=!r(s[0].getPoints());l=t?!l:l;var u,d,p=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,b=s.length;v<b;v++)o=r(u=(a=s[v]).getPoints()),(o=t?!o:o)?(!l&&f[g]&&g++,f[g]={s:new Sc,p:u},f[g].s.curves=a.curves,l&&g++,m[g]=[]):m[g].push({h:a,p:u[0]});if(!f[0])return i(s);if(f.length>1){for(var y=!1,_=[],x=0,w=f.length;x<w;x++)p[x]=[];for(x=0,w=f.length;x<w;x++)for(var M=m[x],T=0;T<M.length;T++){for(var S=M[T],E=!0,P=0;P<f.length;P++)n(S.p,f[P].p)&&(x!==P&&_.push({froms:x,tos:P,hole:T}),E?(E=!1,p[P].push(S)):y=!0);E&&p[x].push(S)}_.length>0&&(y||(m=p))}v=0;for(var A=f.length;v<A;v++){h=f[v].s,c.push(h);for(var C=0,L=(d=m[v]).length;C<L;C++)h.holes.push(d[C].h)}return c}}),Object.assign(Qc.prototype,{isFont:!0,generateShapes:function(t,e){void 0===e&&(e=100);for(var i=[],n=function(t,e,i){for(var n=Array.from?Array.from(t):String(t).split(""),r=e/i.resolution,s=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,o=[],a=0,h=0,c=0;c<n.length;c++){var l=n[c];if("\n"===l)a=0,h-=s;else{var u=Kc(l,r,a,h,i);a+=u.offsetX,o.push(u.path)}}return o}(t,e,this.data),r=0,s=n.length;r<s;r++)Array.prototype.push.apply(i,n[r].toShapes());return i}}),tl.prototype=Object.assign(Object.create(Yh.prototype),{constructor:tl,load:function(t,e,i,n){var r=this,s=new $h(this.manager);s.setPath(this.path),s.load(t,(function(t){var i;try{i=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(t.substring(65,t.length-2))}var n=r.parse(i);e&&e(n)}),i,n)},parse:function(t){return new Qc(t)}});var el=function(){return void 0===qc&&(qc=new(window.AudioContext||window.webkitAudioContext)),qc};function il(t){Yh.call(this,t)}function nl(){this.coefficients=[];for(var t=0;t<9;t++)this.coefficients.push(new pe)}function rl(t,e){Ec.call(this,void 0,e),this.sh=void 0!==t?t:new nl}function sl(t,e,i){rl.call(this,void 0,i);var n=(new Ui).set(t),r=(new Ui).set(e),s=new pe(n.r,n.g,n.b),o=new pe(r.r,r.g,r.b),a=Math.sqrt(Math.PI),h=a*Math.sqrt(.75);this.sh.coefficients[0].copy(s).add(o).multiplyScalar(a),this.sh.coefficients[1].copy(s).sub(o).multiplyScalar(h)}function ol(t,e){rl.call(this,void 0,e);var i=(new Ui).set(t);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}il.prototype=Object.assign(Object.create(Yh.prototype),{constructor:il,load:function(t,e,i,n){var r=new $h(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),r.load(t,(function(t){var i=t.slice(0);el().decodeAudioData(i,(function(t){e(t)}))}),i,n)}}),Object.assign(nl.prototype,{isSphericalHarmonics3:!0,set:function(t){for(var e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this},zero:function(){for(var t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this},getAt:function(t,e){var i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScale(s[1],.488603*n),e.addScale(s[2],.488603*r),e.addScale(s[3],.488603*i),e.addScale(s[4],i*n*1.092548),e.addScale(s[5],n*r*1.092548),e.addScale(s[6],.315392*(3*r*r-1)),e.addScale(s[7],i*r*1.092548),e.addScale(s[8],.546274*(i*i-n*n)),e},getIrradianceAt:function(t,e){var i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScale(s[1],1.023328*n),e.addScale(s[2],1.023328*r),e.addScale(s[3],1.023328*i),e.addScale(s[4],.858086*i*n),e.addScale(s[5],.858086*n*r),e.addScale(s[6],.743125*r*r-.247708),e.addScale(s[7],.858086*i*r),e.addScale(s[8],.429043*(i*i-n*n)),e},add:function(t){for(var e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this},scale:function(t){for(var e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this},lerp:function(t,e){for(var i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this},equals:function(t){for(var e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0},copy:function(t){return this.set(t.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(t,e){void 0===e&&(e=0);for(var i=this.coefficients,n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);for(var i=this.coefficients,n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}}),Object.assign(nl,{getBasisAt:function(t,e){var i=t.x,n=t.y,r=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*r,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*i*r,e[8]=.546274*(i*i-n*n)}}),rl.prototype=Object.assign(Object.create(Ec.prototype),{constructor:rl,isLightProbe:!0,copy:function(t){return Ec.prototype.copy.call(this,t),this.sh.copy(t.sh),this.intensity=t.intensity,this},toJSON:function(t){return Ec.prototype.toJSON.call(this,t)}}),sl.prototype=Object.assign(Object.create(rl.prototype),{constructor:sl,isHemisphereLightProbe:!0,copy:function(t){return rl.prototype.copy.call(this,t),this},toJSON:function(t){return rl.prototype.toJSON.call(this,t)}}),ol.prototype=Object.assign(Object.create(rl.prototype),{constructor:ol,isAmbientLightProbe:!0,copy:function(t){return rl.prototype.copy.call(this,t),this},toJSON:function(t){return rl.prototype.toJSON.call(this,t)}});var al=new Le,hl=new Le;function cl(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}Object.assign(function(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Xn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Xn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}.prototype,{update:function(t){var e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;var i,n,r=t.projectionMatrix.clone(),s=e.eyeSep/2,o=s*e.near/e.focus,a=e.near*Math.tan(he.DEG2RAD*e.fov*.5)/e.zoom;hl.elements[12]=-s,al.elements[12]=s,i=-a*e.aspect+o,n=a*e.aspect+o,r.elements[0]=2*e.near/(n-i),r.elements[8]=(n+i)/(n-i),this.cameraL.projectionMatrix.copy(r),i=-a*e.aspect-o,n=a*e.aspect-o,r.elements[0]=2*e.near/(n-i),r.elements[8]=(n+i)/(n-i),this.cameraR.projectionMatrix.copy(r)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(hl),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(al)}}),Object.assign(cl.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var e=("undefined"==typeof performance?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}});var ll=new pe,ul=new le,dl=new pe,pl=new pe;function fl(){Ye.call(this),this.type="AudioListener",this.context=el(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new cl}function ml(t){Ye.call(this),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this._startedAt=0,this._pausedAt=0,this.filters=[]}fl.prototype=Object.assign(Object.create(Ye.prototype),{constructor:fl,getInput:function(){return this.gain},removeFilter:function(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},getFilter:function(){return this.filter},setFilter:function(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this},updateMatrixWorld:function(t){Ye.prototype.updateMatrixWorld.call(this,t);var e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ll,ul,dl),pl.set(0,0,-1).applyQuaternion(ul),e.positionX){var n=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ll.x,n),e.positionY.linearRampToValueAtTime(ll.y,n),e.positionZ.linearRampToValueAtTime(ll.z,n),e.forwardX.linearRampToValueAtTime(pl.x,n),e.forwardY.linearRampToValueAtTime(pl.y,n),e.forwardZ.linearRampToValueAtTime(pl.z,n),e.upX.linearRampToValueAtTime(i.x,n),e.upY.linearRampToValueAtTime(i.y,n),e.upZ.linearRampToValueAtTime(i.z,n)}else e.setPosition(ll.x,ll.y,ll.z),e.setOrientation(pl.x,pl.y,pl.z,i.x,i.y,i.z)}}),ml.prototype=Object.assign(Object.create(Ye.prototype),{constructor:ml,getOutput:function(){return this.gain},setNodeSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this},setMediaElementSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this},setMediaStreamSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this},setBuffer:function(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(t){if(void 0===t&&(t=0),!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){this._startedAt=this.context.currentTime+t;var e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._pausedAt+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")},pause:function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._pausedAt=(this.context.currentTime-this._startedAt)*this.playbackRate,this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this._pausedAt=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(t){return t||(t=[]),!0===this.isPlaying?(this.disconnect(),this.filters=t,this.connect()):this.filters=t,this},setDetune:function(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this},getDetune:function(){return this.detune},getFilter:function(){return this.getFilters()[0]},setFilter:function(t){return this.setFilters(t?[t]:[])},setPlaybackRate:function(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")},setLoopStart:function(t){return this.loopStart=t,this},setLoopEnd:function(t){return this.loopEnd=t,this},getVolume:function(){return this.gain.gain.value},setVolume:function(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}});var gl=new pe,vl=new le,bl=new pe,yl=new pe;function _l(t){ml.call(this,t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}function xl(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function wl(t,e,i){this.binding=t,this.valueSize=i;var n,r=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":r=Array,n=this._select;break;default:n=this._lerp}this.buffer=new r(4*i),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}_l.prototype=Object.assign(Object.create(ml.prototype),{constructor:_l,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(t){return this.panner.refDistance=t,this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(t){return this.panner.rolloffFactor=t,this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(t){return this.panner.distanceModel=t,this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(t){return this.panner.maxDistance=t,this},setDirectionalCone:function(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this},updateMatrixWorld:function(t){if(Ye.prototype.updateMatrixWorld.call(this,t),!0!==this.hasPlaybackControl||!1!==this.isPlaying){this.matrixWorld.decompose(gl,vl,bl),yl.set(0,0,1).applyQuaternion(vl);var e=this.panner;if(e.positionX){var i=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(gl.x,i),e.positionY.linearRampToValueAtTime(gl.y,i),e.positionZ.linearRampToValueAtTime(gl.z,i),e.orientationX.linearRampToValueAtTime(yl.x,i),e.orientationY.linearRampToValueAtTime(yl.y,i),e.orientationZ.linearRampToValueAtTime(yl.z,i)}else e.setPosition(gl.x,gl.y,gl.z),e.setOrientation(yl.x,yl.y,yl.z)}}}),Object.assign(xl.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var t=0,e=this.getFrequencyData(),i=0;i<e.length;i++)t+=e[i];return t/e.length}}),Object.assign(wl.prototype,{accumulate:function(t,e){var i=this.buffer,n=this.valueSize,r=t*n+n,s=this.cumulativeWeight;if(0===s){for(var o=0;o!==n;++o)i[r+o]=i[o];s=e}else{var a=e/(s+=e);this._mixBufferRegion(i,r,0,a,n)}this.cumulativeWeight=s},apply:function(t){var e=this.valueSize,i=this.buffer,n=t*e+e,r=this.cumulativeWeight,s=this.binding;if(this.cumulativeWeight=0,r<1){var o=3*e;this._mixBufferRegion(i,n,o,1-r,e)}for(var a=e,h=e+e;a!==h;++a)if(i[a]!==i[a+e]){s.setValue(i,n);break}},saveOriginalState:function(){var t=this.binding,e=this.buffer,i=this.valueSize,n=3*i;t.getValue(e,n);for(var r=i,s=n;r!==s;++r)e[r]=e[n+r%i];this.cumulativeWeight=0},restoreOriginalState:function(){var t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_select:function(t,e,i,n,r){if(n>=.5)for(var s=0;s!==r;++s)t[e+s]=t[i+s]},_slerp:function(t,e,i,n){le.slerpFlat(t,e,t,e,t,i,n)},_lerp:function(t,e,i,n,r){for(var s=1-n,o=0;o!==r;++o){var a=e+o;t[a]=t[a]*s+t[i+o]*n}}});var Ml="\\[\\]\\.:\\/",Tl=new RegExp("[\\[\\]\\.:\\/]","g"),Sl="[^\\[\\]\\.:\\/]",El="[^"+Ml.replace("\\.","")+"]",Pl=/((?:WC+[\/:])*)/.source.replace("WC",Sl),Al=/(WCOD+)?/.source.replace("WCOD",El),Cl=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Sl),Ll=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Sl),Rl=new RegExp("^"+Pl+Al+Cl+Ll+"$"),Il=["material","materials","bones"];function Ol(t,e,i){var n=i||Fl.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function Fl(t,e,i){this.path=e,this.parsedPath=i||Fl.parseTrackName(e),this.node=Fl.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Bl(t,e,i){this._mixer=t,this._clip=e,this._localRoot=i||null;for(var n=e.tracks,r=n.length,s=new Array(r),o={endingStart:$t,endingEnd:$t},a=0;a!==r;++a){var h=n[a].createInterpolant(null);s[a]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Dl(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function zl(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Nl(t,e,i){so.call(this,t,e),this.meshPerAttribute=i||1}function Ul(t,e,i,n){this.ray=new _i(t,e),this.near=i||0,this.far=n||1/0,this.camera=null,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Vl(t,e){return t.distance-e.distance}function kl(t,e,i,n){if(!1!==t.visible&&(t.raycast(e,i),!0===n))for(var r=t.children,s=0,o=r.length;s<o;s++)kl(r[s],e,i,!0)}Object.assign(Ol.prototype,{getValue:function(t,e){this.bind();var i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){for(var i=this._bindings,n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}),Object.assign(Fl,{Composite:Ol,create:function(t,e,i){return t&&t.isAnimationObjectGroup?new Fl.Composite(t,e,i):new Fl(t,e,i)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Tl,"")},parseTrackName:function(t){var e=Rl.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){var r=i.nodeName.substring(n+1);-1!==Il.indexOf(r)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i},findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){var n=function(t){for(var i=0;i<t.length;i++){var r=t[i];if(r.name===e||r.uuid===e)return r;var s=n(r.children);if(s)return s}return null},r=n(t.children);if(r)return r}return null}}),Object.assign(Fl.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){for(var i=this.resolvedProperty,n=0,r=i.length;n!==r;++n)t[e++]=i[n]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){for(var i=this.resolvedProperty,n=0,r=i.length;n!==r;++n)i[n]=t[e++]},function(t,e){for(var i=this.resolvedProperty,n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){for(var i=this.resolvedProperty,n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,i=e.objectName,n=e.propertyName,r=e.propertyIndex;if(t||(t=Fl.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(i){var s=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(var o=0;o<t.length;o++)if(t[o].name===s){s=o;break}break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==s){if(void 0===t[s])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[s]}}var a=t[n];if(void 0!==a){var h=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?h=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(h=this.Versioning.MatrixWorldNeedsUpdate);var c=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(o=0;o<this.node.geometry.morphAttributes.position.length;o++)if(t.geometry.morphAttributes.position[o].name===r){r=o;break}}else{if(!t.geometry.morphTargets)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(o=0;o<this.node.geometry.morphTargets.length;o++)if(t.geometry.morphTargets[o].name===r){r=o;break}}}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else void 0!==a.fromArray&&void 0!==a.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][h]}else{var l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",t)}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Fl.prototype,{_getValue_unbound:Fl.prototype.getValue,_setValue_unbound:Fl.prototype.setValue}),Object.assign(function(){this.uuid=he.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var n=this;this.stats={objects:{get total(){return n._objects.length},get inUse(){return this.total-n.nCachedObjects_}},get bindingsPerObject(){return n._bindings.length}}}.prototype,{isAnimationObjectGroup:!0,add:function(){for(var t=this._objects,e=t.length,i=this.nCachedObjects_,n=this._indicesByUUID,r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length,h=void 0,c=0,l=arguments.length;c!==l;++c){var u=arguments[c],d=u.uuid,p=n[d];if(void 0===p){p=e++,n[d]=p,t.push(u);for(var f=0,m=a;f!==m;++f)o[f].push(new Fl(u,r[f],s[f]))}else if(p<i){h=t[p];var g=--i,v=t[g];n[v.uuid]=p,t[p]=v,n[d]=g,t[g]=u;for(f=0,m=a;f!==m;++f){var b=o[f],y=b[g],_=b[p];b[p]=y,void 0===_&&(_=new Fl(u,r[f],s[f])),b[g]=_}}else t[p]!==h&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=i},remove:function(){for(var t=this._objects,e=this.nCachedObjects_,i=this._indicesByUUID,n=this._bindings,r=n.length,s=0,o=arguments.length;s!==o;++s){var a=arguments[s],h=a.uuid,c=i[h];if(void 0!==c&&c>=e){var l=e++,u=t[l];i[u.uuid]=c,t[c]=u,i[h]=l,t[l]=a;for(var d=0,p=r;d!==p;++d){var f=n[d],m=f[l],g=f[c];f[c]=m,f[l]=g}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,i=this.nCachedObjects_,n=this._indicesByUUID,r=this._bindings,s=r.length,o=0,a=arguments.length;o!==a;++o){var h=arguments[o],c=h.uuid,l=n[c];if(void 0!==l)if(delete n[c],l<i){var u=--i,d=t[u],p=t[b=--e];n[d.uuid]=l,t[l]=d,n[p.uuid]=u,t[u]=p,t.pop();for(var f=0,m=s;f!==m;++f){var g=(y=r[f])[u],v=y[b];y[l]=g,y[u]=v,y.pop()}}else{var b;n[(p=t[b=--e]).uuid]=l,t[l]=p,t.pop();for(f=0,m=s;f!==m;++f){var y;(y=r[f])[l]=y[b],y.pop()}}}this.nCachedObjects_=i},subscribe_:function(t,e){var i=this._bindingsIndicesByPath,n=i[t],r=this._bindings;if(void 0!==n)return r[n];var s=this._paths,o=this._parsedPaths,a=this._objects,h=a.length,c=this.nCachedObjects_,l=new Array(h);n=r.length,i[t]=n,s.push(t),o.push(e),r.push(l);for(var u=c,d=a.length;u!==d;++u){var p=a[u];l[u]=new Fl(p,t,e)}return l},unsubscribe_:function(t){var e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){var n=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,a=s[o];e[t[o]]=i,s[i]=a,s.pop(),r[i]=r[o],r.pop(),n[i]=n[o],n.pop()}}}),Object.assign(Bl.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(t){return this._startTime=t,this},setLoop:function(t,e){return this.loop=t,this.repetitions=e,this},setEffectiveWeight:function(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(t){return this._scheduleFading(t,0,1)},fadeOut:function(t){return this._scheduleFading(t,1,0)},crossFadeFrom:function(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){var n=this._clip.duration,r=t._clip.duration,s=r/n,o=n/r;t.warp(1,s,e),this.warp(o,1,e)}return this},crossFadeTo:function(t,e,i){return t.crossFadeFrom(this,e,i)},stopFading:function(){var t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},setEffectiveTimeScale:function(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(t){return this.timeScale=this._clip.duration/t,this.stopWarping()},syncWith:function(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()},halt:function(t){return this.warp(this._effectiveTimeScale,0,t)},warp:function(t,e,i){var n=this._mixer,r=n.time,s=this._timeScaleInterpolant,o=this.timeScale;null===s&&(s=n._lendControlInterpolant(),this._timeScaleInterpolant=s);var a=s.parameterPositions,h=s.sampleValues;return a[0]=r,a[1]=r+i,h[0]=t/o,h[1]=e/o,this},stopWarping:function(){var t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(t,e,i,n){if(this.enabled){var r=this._startTime;if(null!==r){var s=(t-r)*i;if(s<0||0===i)return;this._startTime=null,e=i*s}e*=this._updateTimeScale(t);var o=this._updateTime(e),a=this._updateWeight(t);if(a>0)for(var h=this._interpolants,c=this._propertyBindings,l=0,u=h.length;l!==u;++l)h[l].evaluate(o),c[l].accumulate(n,a)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var i=this._weightInterpolant;if(null!==i){var n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t,i=this._clip.duration,n=this.loop,r=this._loopCount,s=2202===n;if(0===t)return-1===r?e:s&&1==(1&r)?i-e:e;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=i)e=i;else{if(!(e<0)){this.time=e;break t}e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),e>=i||e<0){var o=Math.floor(e/i);e-=i*o,r+=Math.abs(o);var a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?i:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){var h=t<0;this._setEndings(h,!h,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=e;if(s&&1==(1&r))return i-e}return e},_setEndings:function(t,e,i){var n=this._interpolantSettings;i?(n.endingStart=Jt,n.endingEnd=Jt):(n.endingStart=t?this.zeroSlopeAtStart?Jt:$t:Qt,n.endingEnd=e?this.zeroSlopeAtEnd?Jt:$t:Qt)},_scheduleFading:function(t,e,i){var n=this._mixer,r=n.time,s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);var o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=e,o[1]=r+t,a[1]=i,this}}),Dl.prototype=Object.assign(Object.create(se.prototype),{constructor:Dl,_bindAction:function(t,e){var i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,o=t._interpolants,a=i.uuid,h=this._bindingsByRootAndName,c=h[a];void 0===c&&(c={},h[a]=c);for(var l=0;l!==r;++l){var u=n[l],d=u.name,p=c[d];if(void 0!==p)s[l]=p;else{if(void 0!==(p=s[l])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,a,d));continue}var f=e&&e._propertyBindings[l].binding.parsedPath;++(p=new wl(Fl.create(i,d,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(p,a,d),s[l]=p}o[l].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}for(var r=t._propertyBindings,s=0,o=r.length;s!==o;++s){var a=r[s];0==a.useCount++&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,i=0,n=e.length;i!==n;++i){var r=e[i];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e<this._nActiveActions},_addInactiveAction:function(t,e,i){var n=this._actions,r=this._actionsByClip,s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{var o=s.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t},_removeInactiveAction:function(t){var e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;var r=t._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,h=a[a.length-1],c=t._byClipCacheIndex;h._byClipCacheIndex=c,a[c]=h,a.pop(),t._byClipCacheIndex=null,delete o.actionByRoot[(t._localRoot||this._root).uuid],0===a.length&&delete s[r],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){for(var e=t._propertyBindings,i=0,n=e.length;i!==n;++i){var r=e[i];0==--r.referenceCount&&this._removeInactiveBinding(r)}},_lendAction:function(t){var e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_takeBackAction:function(t){var e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_addInactiveBinding:function(t,e,i){var n=this._bindingsByRootAndName,r=n[e],s=this._bindings;void 0===r&&(r={},n[e]=r),r[i]=t,t._cacheIndex=s.length,s.push(t)},_removeInactiveBinding:function(t){var e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,o=s[n],a=e[e.length-1],h=t._cacheIndex;a._cacheIndex=h,e[h]=a,e.pop(),delete o[r],0===Object.keys(o).length&&delete s[n]},_lendBinding:function(t){var e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_takeBackBinding:function(t){var e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_lendControlInterpolant:function(){var t=this._controlInterpolants,e=this._nActiveControlInterpolants++,i=t[e];return void 0===i&&((i=new Oh(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e,t[e]=i),i},_takeBackControlInterpolant:function(t){var e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e){var i=e||this._root,n=i.uuid,r="string"==typeof t?Hh.findByName(i,t):t,s=null!==r?r.uuid:t,o=this._actionsByClip[s],a=null;if(void 0!==o){var h=o.actionByRoot[n];if(void 0!==h)return h;a=o.knownActions[0],null===r&&(r=a._clip)}if(null===r)return null;var c=new Bl(this,r,e);return this._bindAction(c,a),this._addInactiveAction(c,s,n),c},existingAction:function(t,e){var i=e||this._root,n=i.uuid,r="string"==typeof t?Hh.findByName(i,t):t,s=r?r.uuid:t,o=this._actionsByClip[s];return void 0!==o&&o.actionByRoot[n]||null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,i=this._bindings,n=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var r=0;r!==e;++r)t[r].reset();for(r=0;r!==n;++r)i[r].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1,o=0;o!==i;++o){e[o]._update(n,t,r,s)}var a=this._bindings,h=this._nActiveBindings;for(o=0;o!==h;++o)a[o].apply(s);return this},setTime:function(t){this.time=0;for(var e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){for(var s=r.knownActions,o=0,a=s.length;o!==a;++o){var h=s[o];this._deactivateAction(h);var c=h._cacheIndex,l=e[e.length-1];h._cacheIndex=null,h._byClipCacheIndex=null,l._cacheIndex=c,e[c]=l,e.pop(),this._removeInactiveBindingsForAction(h)}delete n[i]}},uncacheRoot:function(t){var e=t.uuid,i=this._actionsByClip;for(var n in i){var r=i[n].actionByRoot[e];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var s=this._bindingsByRootAndName[e];if(void 0!==s)for(var o in s){var a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}},uncacheAction:function(t,e){var i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}),zl.prototype.clone=function(){return new zl(void 0===this.value.clone?this.value:this.value.clone())},Nl.prototype=Object.assign(Object.create(so.prototype),{constructor:Nl,isInstancedInterleavedBuffer:!0,copy:function(t){return so.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Object.assign(Ul.prototype,{linePrecision:1,set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e,i){var n=i||[];return kl(t,this,n,e),n.sort(Vl),n},intersectObjects:function(t,e,i){var n=i||[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),n;for(var r=0,s=t.length;r<s;r++)kl(t[r],this,n,e);return n.sort(Vl),n}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.phi=void 0!==e?e:0,this.theta=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},makeSafe:function(){var t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this},setFromVector3:function(t){return this.setFromCartesianCoords(t.x,t.y,t.z)},setFromCartesianCoords:function(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(he.clamp(e/this.radius,-1,1))),this}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.theta=e,this.y=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},setFromVector3:function(t){return this.setFromCartesianCoords(t.x,t.y,t.z)},setFromCartesianCoords:function(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}});var jl=new ce;function Hl(t,e){this.min=void 0!==t?t:new ce(1/0,1/0),this.max=void 0!==e?e:new ce(-1/0,-1/0)}Object.assign(Hl.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(t,e){var i=jl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new ce),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new ce),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new ce),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new ce),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return jl.copy(t).clamp(this.min,this.max).sub(t).length()},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var Gl=new pe,Wl=new pe;function ql(t,e){this.start=void 0!==t?t:new pe,this.end=void 0!==e?e:new pe}function Xl(t){Ye.call(this),this.material=t,this.render=function(){}}Object.assign(ql.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new pe),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new pe),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new pe),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){Gl.subVectors(t,this.start),Wl.subVectors(this.end,this.start);var i=Wl.dot(Wl),n=Wl.dot(Gl)/i;return e&&(n=he.clamp(n,0,1)),n},closestPointToPoint:function(t,e,i){var n=this.closestPointToPointParameter(t,e);return void 0===i&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new pe),this.delta(i).multiplyScalar(n).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Xl.prototype=Object.create(Ye.prototype),Xl.prototype.constructor=Xl,Xl.prototype.isImmediateRenderObject=!0;var Yl=new pe;function Zl(t,e){Ye.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;for(var i=new fn,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],r=0,s=1;r<32;r++,s++){var o=r/32*Math.PI*2,a=s/32*Math.PI*2;n.push(Math.cos(o),Math.sin(o),1,Math.cos(a),Math.sin(a),1)}i.setAttribute("position",new nn(n,3));var h=new No({fog:!1});this.cone=new Xo(i,h),this.add(this.cone),this.update()}Zl.prototype=Object.create(Ye.prototype),Zl.prototype.constructor=Zl,Zl.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},Zl.prototype.update=function(){this.light.updateMatrixWorld();var t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Yl.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Yl),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var $l=new pe,Jl=new Le,Ql=new Le;function Kl(t){var e=[];t&&t.isBone&&e.push(t);for(var i=0;i<t.children.length;i++)e.push.apply(e,Kl(t.children[i]));return e}function tu(t){for(var e=Kl(t),i=new fn,n=[],r=[],s=new Ui(0,0,1),o=new Ui(0,1,0),a=0;a<e.length;a++){var h=e[a];h.parent&&h.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(s.r,s.g,s.b),r.push(o.r,o.g,o.b))}i.setAttribute("position",new nn(n,3)),i.setAttribute("color",new nn(r,3));var c=new No({vertexColors:2,depthTest:!1,depthWrite:!1,transparent:!0});Xo.call(this,i,c),this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}function eu(t,e,i){this.light=t,this.light.updateMatrixWorld(),this.color=i;var n=new nh(e,4,2),r=new qi({wireframe:!0,fog:!1});In.call(this,n,r),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}tu.prototype=Object.create(Xo.prototype),tu.prototype.constructor=tu,tu.prototype.updateMatrixWorld=function(t){var e=this.bones,i=this.geometry,n=i.getAttribute("position");Ql.getInverse(this.root.matrixWorld);for(var r=0,s=0;r<e.length;r++){var o=e[r];o.parent&&o.parent.isBone&&(Jl.multiplyMatrices(Ql,o.matrixWorld),$l.setFromMatrixPosition(Jl),n.setXYZ(s,$l.x,$l.y,$l.z),Jl.multiplyMatrices(Ql,o.parent.matrixWorld),$l.setFromMatrixPosition(Jl),n.setXYZ(s+1,$l.x,$l.y,$l.z),s+=2)}i.getAttribute("position").needsUpdate=!0,Ye.prototype.updateMatrixWorld.call(this,t)},eu.prototype=Object.create(In.prototype),eu.prototype.constructor=eu,eu.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},eu.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)};var iu=new pe,nu=new Ui,ru=new Ui;function su(t,e,i){Ye.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;var n=new fa(e);n.rotateY(.5*Math.PI),this.material=new qi({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=2);var r=n.getAttribute("position"),s=new Float32Array(3*r.count);n.setAttribute("color",new Yi(s,3)),this.add(new In(n,this.material)),this.update()}function ou(t,e,i,n){t=t||10,e=e||10,i=new Ui(void 0!==i?i:4473924),n=new Ui(void 0!==n?n:8947848);for(var r=e/2,s=t/e,o=t/2,a=[],h=[],c=0,l=0,u=-o;c<=e;c++,u+=s){a.push(-o,0,u,o,0,u),a.push(u,0,-o,u,0,o);var d=c===r?i:n;d.toArray(h,l),l+=3,d.toArray(h,l),l+=3,d.toArray(h,l),l+=3,d.toArray(h,l),l+=3}var p=new fn;p.setAttribute("position",new nn(a,3)),p.setAttribute("color",new nn(h,3));var f=new No({vertexColors:2});Xo.call(this,p,f)}function au(t,e,i,n,r,s){t=t||10,e=e||16,i=i||8,n=n||64,r=new Ui(void 0!==r?r:4473924),s=new Ui(void 0!==s?s:8947848);var o,a,h,c,l,u,d,p=[],f=[];for(c=0;c<=e;c++)h=c/e*(2*Math.PI),o=Math.sin(h)*t,a=Math.cos(h)*t,p.push(0,0,0),p.push(o,0,a),d=1&c?r:s,f.push(d.r,d.g,d.b),f.push(d.r,d.g,d.b);for(c=0;c<=i;c++)for(d=1&c?r:s,u=t-t/i*c,l=0;l<n;l++)h=l/n*(2*Math.PI),o=Math.sin(h)*u,a=Math.cos(h)*u,p.push(o,0,a),f.push(d.r,d.g,d.b),h=(l+1)/n*(2*Math.PI),o=Math.sin(h)*u,a=Math.cos(h)*u,p.push(o,0,a),f.push(d.r,d.g,d.b);var m=new fn;m.setAttribute("position",new nn(p,3)),m.setAttribute("color",new nn(f,3));var g=new No({vertexColors:2});Xo.call(this,m,g)}su.prototype=Object.create(Ye.prototype),su.prototype.constructor=su,su.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},su.prototype.update=function(){var t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var e=t.geometry.getAttribute("color");nu.copy(this.light.color),ru.copy(this.light.groundColor);for(var i=0,n=e.count;i<n;i++){var r=i<n/2?nu:ru;e.setXYZ(i,r.r,r.g,r.b)}e.needsUpdate=!0}t.lookAt(iu.setFromMatrixPosition(this.light.matrixWorld).negate())},ou.prototype=Object.assign(Object.create(Xo.prototype),{constructor:ou,copy:function(t){return Xo.prototype.copy.call(this,t),this.geometry.copy(t.geometry),this.material.copy(t.material),this},clone:function(){return(new this.constructor).copy(this)}}),au.prototype=Object.create(Xo.prototype),au.prototype.constructor=au;var hu=new pe,cu=new pe,lu=new pe;function uu(t,e,i){Ye.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===e&&(e=1);var n=new fn;n.setAttribute("position",new nn([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));var r=new No({fog:!1});this.lightPlane=new Go(n,r),this.add(this.lightPlane),(n=new fn).setAttribute("position",new nn([0,0,0,0,0,1],3)),this.targetLine=new Go(n,r),this.add(this.targetLine),this.update()}uu.prototype=Object.create(Ye.prototype),uu.prototype.constructor=uu,uu.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},uu.prototype.update=function(){hu.setFromMatrixPosition(this.light.matrixWorld),cu.setFromMatrixPosition(this.light.target.matrixWorld),lu.subVectors(cu,hu),this.lightPlane.lookAt(cu),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(cu),this.targetLine.scale.z=lu.length()};var du=new pe,pu=new qn;function fu(t){var e=new fn,i=new No({color:16777215,vertexColors:1}),n=[],r=[],s={},o=new Ui(16755200),a=new Ui(16711680),h=new Ui(43775),c=new Ui(16777215),l=new Ui(3355443);function u(t,e,i){d(t,i),d(e,i)}function d(t,e){n.push(0,0,0),r.push(e.r,e.g,e.b),void 0===s[t]&&(s[t]=[]),s[t].push(n.length/3-1)}u("n1","n2",o),u("n2","n4",o),u("n4","n3",o),u("n3","n1",o),u("f1","f2",o),u("f2","f4",o),u("f4","f3",o),u("f3","f1",o),u("n1","f1",o),u("n2","f2",o),u("n3","f3",o),u("n4","f4",o),u("p","n1",a),u("p","n2",a),u("p","n3",a),u("p","n4",a),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h),u("c","t",c),u("p","c",l),u("cn1","cn2",l),u("cn3","cn4",l),u("cf1","cf2",l),u("cf3","cf4",l),e.setAttribute("position",new nn(n,3)),e.setAttribute("color",new nn(r,3)),Xo.call(this,e,i),this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}function mu(t,e,i,n,r,s,o){du.set(r,s,o).unproject(n);var a=e[t];if(void 0!==a)for(var h=i.getAttribute("position"),c=0,l=a.length;c<l;c++)h.setXYZ(a[c],du.x,du.y,du.z)}fu.prototype=Object.create(Xo.prototype),fu.prototype.constructor=fu,fu.prototype.update=function(){var t=this.geometry,e=this.pointMap;pu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mu("c",e,t,pu,0,0,-1),mu("t",e,t,pu,0,0,1),mu("n1",e,t,pu,-1,-1,-1),mu("n2",e,t,pu,1,-1,-1),mu("n3",e,t,pu,-1,1,-1),mu("n4",e,t,pu,1,1,-1),mu("f1",e,t,pu,-1,-1,1),mu("f2",e,t,pu,1,-1,1),mu("f3",e,t,pu,-1,1,1),mu("f4",e,t,pu,1,1,1),mu("u1",e,t,pu,.7,1.1,-1),mu("u2",e,t,pu,-.7,1.1,-1),mu("u3",e,t,pu,0,2,-1),mu("cf1",e,t,pu,-1,0,1),mu("cf2",e,t,pu,1,0,1),mu("cf3",e,t,pu,0,-1,1),mu("cf4",e,t,pu,0,1,1),mu("cn1",e,t,pu,-1,0,-1),mu("cn2",e,t,pu,1,0,-1),mu("cn3",e,t,pu,0,-1,-1),mu("cn4",e,t,pu,0,1,-1),t.getAttribute("position").needsUpdate=!0};var gu=new ci;function vu(t,e){this.object=t,void 0===e&&(e=16776960);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new fn;r.setIndex(new Yi(i,1)),r.setAttribute("position",new Yi(n,3)),Xo.call(this,r,new No({color:e})),this.matrixAutoUpdate=!1,this.update()}function bu(t,e){this.type="Box3Helper",this.box=t,e=e||16776960;var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new fn;n.setIndex(new Yi(i,1)),n.setAttribute("position",new nn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),Xo.call(this,n,new No({color:e})),this.geometry.computeBoundingSphere()}function yu(t,e,i){this.type="PlaneHelper",this.plane=t,this.size=void 0===e?1:e;var n=void 0!==i?i:16776960,r=new fn;r.setAttribute("position",new nn([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),r.computeBoundingSphere(),Go.call(this,r,new No({color:n}));var s=new fn;s.setAttribute("position",new nn([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),s.computeBoundingSphere(),this.add(new In(s,new qi({color:n,opacity:.2,transparent:!0,depthWrite:!1})))}vu.prototype=Object.create(Xo.prototype),vu.prototype.constructor=vu,vu.prototype.update=function(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&gu.setFromObject(this.object),!gu.isEmpty()){var e=gu.min,i=gu.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=e.x,r[4]=i.y,r[5]=i.z,r[6]=e.x,r[7]=e.y,r[8]=i.z,r[9]=i.x,r[10]=e.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=e.z,r[15]=e.x,r[16]=i.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=i.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}},vu.prototype.setFromObject=function(t){return this.object=t,this.update(),this},vu.prototype.copy=function(t){return Xo.prototype.copy.call(this,t),this.object=t.object,this},vu.prototype.clone=function(){return(new this.constructor).copy(this)},bu.prototype=Object.create(Xo.prototype),bu.prototype.constructor=bu,bu.prototype.updateMatrixWorld=function(t){var e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),Ye.prototype.updateMatrixWorld.call(this,t))},yu.prototype=Object.create(Go.prototype),yu.prototype.constructor=yu,yu.prototype.updateMatrixWorld=function(t){var e=-this.plane.constant;Math.abs(e)<1e-8&&(e=1e-8),this.scale.set(.5*this.size,.5*this.size,e),this.children[0].material.side=e<0?1:0,this.lookAt(this.plane.normal),Ye.prototype.updateMatrixWorld.call(this,t)};var _u,xu,wu=new pe;function Mu(t,e,i,n,r,s){Ye.call(this),void 0===t&&(t=new pe(0,0,1)),void 0===e&&(e=new pe(0,0,0)),void 0===i&&(i=1),void 0===n&&(n=16776960),void 0===r&&(r=.2*i),void 0===s&&(s=.2*r),void 0===_u&&((_u=new fn).setAttribute("position",new nn([0,0,0,0,1,0],3)),(xu=new ph(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(e),this.line=new Go(_u,new No({color:n})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new In(xu,new qi({color:n})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,s)}function Tu(t){var e=[0,0,0,t=t||1,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new fn;i.setAttribute("position",new nn(e,3)),i.setAttribute("color",new nn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));var n=new No({vertexColors:2});Xo.call(this,i,n)}Mu.prototype=Object.create(Ye.prototype),Mu.prototype.constructor=Mu,Mu.prototype.setDirection=function(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{wu.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(wu,e)}},Mu.prototype.setLength=function(t,e,i){void 0===e&&(e=.2*t),void 0===i&&(i=.2*e),this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()},Mu.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},Mu.prototype.copy=function(t){return Ye.prototype.copy.call(this,t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this},Mu.prototype.clone=function(){return(new this.constructor).copy(this)},Tu.prototype=Object.create(Xo.prototype),Tu.prototype.constructor=Tu;var Su,Eu,Pu,Au,Cu=Math.pow(2,8),Lu=[.125,.215,.35,.446,.526,.582],Ru=5+Lu.length,Iu=20,Ou={[Kt]:0,[te]:1,[ee]:2,3004:3,3005:4,3006:5,3007:6},Fu=new Oc,Bu=(Su=Iu,Eu=new Float32Array(Su),Pu=new pe(0,1,0),(Au=new _h({defines:{n:Su},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:Eu},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:Pu},inputEncoding:{value:Ou[3e3]},outputEncoding:{value:Ou[3e3]}},vertexShader:nd(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float mipInt;\nuniform vec3 poleAxis;\n\n${rd()}\n\n#define ENVMAP_TYPE_CUBE_UV\n#include <cube_uv_reflection_fragment>\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfor (int dir = -1; dir < 2; dir += 2) {\n\t\t\tif (i == 0 && dir == 1)\n\t\t\t\tcontinue;\n\t\t\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\t\t\tif (all(equal(axis, vec3(0.0))))\n\t\t\t\taxis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);\n\t\t\taxis = normalize(axis);\n\t\t\tfloat theta = dTheta * float(dir * i);\n\t\t\tfloat cosTheta = cos(theta);\n\t\t\t// Rodrigues' axis-angle rotation\n\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\t\t\tgl_FragColor.rgb +=\n\t\t\t\t\tweights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);\n\t\t}\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",Au),Du=null,zu=null,{_lodPlanes:Nu,_sizeLods:Uu,_sigmas:Vu}=function(){for(var t=[],e=[],i=[],n=8,r=0;r<Ru;r++){var s=Math.pow(2,n);e.push(s);var o=1/s;r>4?o=Lu[r-8+4-1]:0==r&&(o=0),i.push(o);for(var a=1/(s-1),h=-a/2,c=1+a/2,l=[h,h,c,h,c,c,h,h,c,c,h,c],u=new Float32Array(108),d=new Float32Array(72),p=new Float32Array(36),f=0;f<6;f++){var m=f%3*2/3-1,g=f>2?0:-1,v=[m,g,0,m+2/3,g,0,m+2/3,g+1,0,m,g,0,m+2/3,g+1,0,m,g+1,0];u.set(v,18*f),d.set(l,12*f);var b=[f,f,f,f,f,f];p.set(b,6*f)}var y=new fn;y.setAttribute("position",new Yi(u,3)),y.setAttribute("uv",new Yi(d,2)),y.setAttribute("faceIndex",new Yi(p,1)),t.push(y),n>4&&n--}return{_lodPlanes:t,_sizeLods:e,_sigmas:i}}(),ku=null,ju=null,Hu=(1+Math.sqrt(5))/2,Gu=1/Hu,Wu=[new pe(1,1,1),new pe(-1,1,1),new pe(1,1,-1),new pe(-1,1,-1),new pe(0,Hu,Gu),new pe(0,Hu,-Gu),new pe(Gu,0,Hu),new pe(-Gu,0,Hu),new pe(Hu,Gu,0),new pe(-Hu,Gu,0)];function qu(t){ju=t,Zu(Bu)}function Xu(t){var e={magFilter:ft,minFilter:ft,generateMipmaps:!1,type:t?t.type:Mt,format:t?t.format:1023,encoding:t?t.encoding:ee,depthBuffer:!1,stencilBuffer:!1},i=$u(e);return i.depthBuffer=!t,ku=$u(e),i}function Yu(){ku.dispose(),ju.setRenderTarget(null);var t=ju.getSize(new ce);ju.setViewport(0,0,t.x,t.y)}function Zu(t){var e=new Ze;e.add(new In(Nu[0],t)),ju.compile(e,Fu)}function $u(t){var e=new xe(3*Cu,3*Cu,t);return e.texture.mapping=lt,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Ju(t,e,i,n){var r=1/ju.getPixelRatio();t*=r,e*=r,i*=r,n*=r,ju.setViewport(t,e,i,n),ju.setScissor(t,e,i,n)}function Qu(t){var e=ju.autoClear;ju.autoClear=!1;for(var i=1;i<Ru;i++){Ku(t,i-1,i,Math.sqrt(Vu[i]*Vu[i]-Vu[i-1]*Vu[i-1]),Wu[(i-1)%Wu.length])}ju.autoClear=e}function Ku(t,e,i,n,r){td(t,ku,e,i,n,"latitudinal",r),td(ku,t,i,i,n,"longitudinal",r)}function td(t,e,i,n,r,s,o){"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");var a=new Ze;a.add(new In(Nu[n],Bu));var h=Bu.uniforms,c=Uu[i]-1,l=isFinite(r)?Math.PI/(2*c):2*Math.PI/39,u=r/l,d=isFinite(r)?1+Math.floor(3*u):Iu;d>Iu&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${d} samples when the maximum is set to 20`);for(var p=[],f=0,m=0;m<Iu;++m){var g=m/u,v=Math.exp(-g*g/2);p.push(v),0==m?f+=v:m<d&&(f+=2*v)}for(m=0;m<p.length;m++)p[m]=p[m]/f;h.envMap.value=t.texture,h.samples.value=d,h.weights.value=p,h.latitudinal.value="latitudinal"===s,o&&(h.poleAxis.value=o),h.dTheta.value=l,h.mipInt.value=8-i,h.inputEncoding.value=Ou[t.texture.encoding],h.outputEncoding.value=Ou[t.texture.encoding];var b=Uu[n],y=(g=3*Math.max(0,Cu-2*b),(0===n?0:2*Cu)+2*b*(n>4?n-8+4:0));ju.setRenderTarget(e),Ju(g,y,3*b,2*b),ju.render(a,Fu)}function ed(){var t=new _h({uniforms:{envMap:{value:null},texelSize:{value:new ce(1,1)},inputEncoding:{value:Ou[3e3]},outputEncoding:{value:Ou[3e3]}},vertexShader:nd(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n${rd()}\n\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv;\n\tuv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n\tuv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function id(){var t=new _h({uniforms:{envMap:{value:null},inputEncoding:{value:Ou[3e3]},outputEncoding:{value:Ou[3e3]}},vertexShader:nd(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n\n${rd()}\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1});return t.type="CubemapToCubeUV",t}function nd(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.x *= -1.0;\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.y *= -1.0;\n\t} else if (face == 5.0) {\n\t\tdirection.xz *= -1.0;\n\t}\n\treturn direction;\n}\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t"}function rd(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include <encodings_pars_fragment>\n\nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\n\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t"}qu.prototype={constructor:qu,fromScene:function(t,e=0,i=.1,n=100){var r=Xu();return function(t,e,i,n){var r=new Xn(90,1,e,i),s=[1,1,1,1,-1,1],o=[1,1,-1,-1,-1,1],a=ju.outputEncoding,h=ju.toneMapping,c=ju.toneMappingExposure,l=ju.getClearColor(),u=ju.getClearAlpha();ju.toneMapping=1,ju.toneMappingExposure=1,ju.outputEncoding=Kt,t.scale.z*=-1;var d=t.background;if(d&&d.isColor){d.convertSRGBToLinear();var p=Math.max(d.r,d.g,d.b),f=Math.min(Math.max(Math.ceil(Math.log2(p)),-128),127);d=d.multiplyScalar(Math.pow(2,-f));var m=(f+128)/255;ju.setClearColor(d,m),t.background=null}ju.setRenderTarget(n);for(var g=0;g<6;g++){var v=g%3;0==v?(r.up.set(0,s[g],0),r.lookAt(o[g],0,0)):1==v?(r.up.set(0,0,s[g]),r.lookAt(0,o[g],0)):(r.up.set(0,s[g],0),r.lookAt(0,0,o[g])),Ju(v*Cu,g>2?Cu:0,Cu,Cu),ju.render(t,r)}ju.toneMapping=h,ju.toneMappingExposure=c,ju.outputEncoding=a,ju.setClearColor(l,u),t.scale.z*=-1}(t,i,n,r),e>0&&Ku(r,0,0,e),Qu(r),Yu(),r.scissorTest=!1,r},fromEquirectangular:function(t){return t.magFilter=ft,t.minFilter=ft,t.generateMipmaps=!1,this.fromCubemap(t)},fromCubemap:function(t){var e=Xu(t);return function(t,e){var i=new Ze;t.isCubeTexture?null==zu&&(zu=id()):null==Du&&(Du=ed());var n=t.isCubeTexture?zu:Du;i.add(new In(Nu[0],n));var r=n.uniforms;r.envMap.value=t,t.isCubeTexture||r.texelSize.value.set(1/t.image.width,1/t.image.height);r.inputEncoding.value=Ou[t.encoding],r.outputEncoding.value=Ou[t.encoding],ju.setRenderTarget(e),Ju(0,0,3*Cu,2*Cu),ju.render(i,Fu)}(t,e),Qu(e),Yu(),e.scissorTest=!1,e},compileCubemapShader:function(){null==zu&&Zu(zu=id())},compileEquirectangularShader:function(){null==Du&&Zu(Du=ed())},dispose:function(){Bu.dispose(),null!=zu&&zu.dispose(),null!=Du&&Du.dispose();for(var t=0;t<Nu.length;t++)Nu[t].dispose()}};function sd(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),uc.call(this,t),this.type="catmullrom"}nc.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(nc.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Mc.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var e=new Un,i=0,n=t.length;i<n;i++){var r=t[i];e.vertices.push(new pe(r.x,r.y,r.z||0))}return e}}),Object.assign(Tc.prototype,{fromPoints:function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}}),Object.create(uc.prototype),Object.create(uc.prototype),sd.prototype=Object.create(uc.prototype),Object.assign(sd.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),ou.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},tu.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(Yh.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Vc(t)}}),Yh.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(Wc.prototype,{setTexturePath:function(t){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(t)}}),Object.assign(Hl.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(ci.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),ql.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Object.assign(he,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),he.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),he.ceilPowerOfTwo(t)}}),Object.assign(ge.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(t){return console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(Le.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new pe).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(t){return console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,i,n,r,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,n,i,r,s)}}),Ti.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},le.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Object.assign(_i.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(Bi.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},midpoint:function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},normal:function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},plane:function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)}}),Object.assign(Bi,{barycoordFromPoint:function(t,e,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Bi.getBarycoord(t,e,i,n,r)},normal:function(t,e,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Bi.getNormal(t,e,i,n)}}),Object.assign(Sc.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new $a(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new hh(this,t)}}),Object.assign(ce.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(pe.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(_e.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Un.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}}),Object.assign(Ye.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")}}),Object.defineProperties(Ye.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(In.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(In.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(Po.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Ro.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Ao.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(nc.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),Xn.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(Ec.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(Yi.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===re},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(re)}}}),Object.assign(Yi.prototype,{setDynamic:function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?re:ne),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(fn.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addAttribute:function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new Yi(arguments[1],arguments[2])))},addDrawCall:function(t,e,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)}}),Object.defineProperties(fn.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(so.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===re},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}}),Object.assign(so.prototype,{setDynamic:function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?re:ne),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(Ja.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.defineProperties(zl.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(Wi.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Ui}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}}),Object.defineProperties(Mh.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(Wn.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(io.prototype,{clearTarget:function(t,e,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,i,n)},animate:function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(io.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===t?te:Kt}}}),Object.defineProperties(Xs.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties($n.prototype,{activeCubeFace:{set:function(){console.warn("THREE.WebGLRenderTargetCube: .activeCubeFace has been removed. It is now the second parameter of WebGLRenderer.setRenderTarget().")}},activeMipMapLevel:{set:function(){console.warn("THREE.WebGLRenderTargetCube: .activeMipMapLevel has been removed. It is now the third parameter of WebGLRenderer.setRenderTarget().")}}}),Object.defineProperties(xe.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Object.defineProperties(ml.prototype,{load:{value:function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var e=this;return(new il).load(t,(function(t){e.setBuffer(t)})),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),xl.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Zn.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)};ve.crossOrigin=void 0,ve.loadTexture=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var r=new ic;r.setCrossOrigin(this.crossOrigin);var s=r.load(t,i,void 0,n);return e&&(s.mapping=e),s},ve.loadTextureCube=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var r=new ec;r.setCrossOrigin(this.crossOrigin);var s=r.load(t,i,void 0,n);return e&&(s.mapping=e),s},ve.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ve.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"112"}}));class od extends Ul{constructor(){super()}}function ad(t,e){let i=0;return i=Math.abs(t.x)<.002&&Math.abs(t.y)<.002?t.z>0?Math.PI+hd(e):hd(e):Math.atan2(t.y,t.x),new ce(Math.acos(t.z),i)}function hd(t){if(0===t.x)return t.y>0?Math.PI/2:-Math.PI/2;if(0===t.y)return t.x>0?0:Math.PI;{const e=Math.atan2(Math.abs(t.y),Math.abs(t.x));return t.x<0?t.y<0?e+Math.PI:e+Math.PI/2:t.y<0?e+1.5*Math.PI:e}}function cd(t,e){return e.set(Math.sin(t.x)*Math.cos(t.y),Math.sin(t.x)*Math.sin(t.y),Math.cos(t.x)).normalize()}function ld(t,e){let i=0;return{next:()=>i<t.length?{value:e(t[i++]),done:!1}:{value:void 0,done:!0}}}function ud(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e}function dd(t){const e=t;return void 0!==e.r&&void 0!==e.g&&void 0!==e.b?new Ui(e.r,e.g,e.b):"number"==typeof t||"string"==typeof t?new Ui(t):void 0}function pd(t){return{r:t.r,g:t.g,b:t.b}}function fd(t,e){if(e){const i=(new Le).fromArray(e.elements),n=t.matrixWorld.clone();i.decompose(t.position,t.quaternion,t.scale);const r=i.multiply(n.getInverse(n));t.boundingBox.value.applyMatrix4(r),t.updateMatrixWorld(!0),t.boundingBox.next(t.boundingBox.value)}}function md(t){const e=new ci;return t.forEach((t=>{t.boundingBox&&(t.computeBoundingBox(),e.union(t.boundingBox))})),e}const gd={mm:{inMillimeters:1,symbol:"mm"},cm:{inMillimeters:10,symbol:"cm"},m:{inMillimeters:1e3,symbol:"m"},km:{inMillimeters:1e6,symbol:"km"},ft:{inMillimeters:304.8,symbol:"ft"},in:{inMillimeters:25.4,symbol:"in"},yd:{inMillimeters:914.4,symbol:"yd"},mi:{inMillimeters:1609344,symbol:"mi"},custom:{inMillimeters:1e3,symbol:"m"}};function vd(t,e,i=2){const n=gd[e];return`${function(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}(t/n.inMillimeters,i)} ${n.symbol}`}const bd=(t,e)=>i=>vd(1e3*i,t,e);function yd(t,e){for(let i=0;i<e.length;i++){const n=e[i],r=3*i;t[r]=n.x,t[r+1]=n.y,t[r+2]=n.z}}function _d(t,e,i,n,r){let s,o="index"===e?t.getIndex():t.getAttribute(e);return o&&o.array.length>=i*n&&o.array.length<i*n*2?(o.count=i,o.updateRange.count=i*n,o.needsUpdate=!0):(s=new r(i*n),o=new Yi(s,n),"index"===e?t.setIndex(o):t.setAttribute(e,o)),o}class xd{}xd.zero=Object.freeze(new pe(0,0,0)),xd.one=Object.freeze(new pe(1,1,1)),xd.up=Object.freeze(new pe(0,0,1)),xd.down=Object.freeze(new pe(0,0,-1)),xd.forward=Object.freeze(new pe(0,1,0)),xd.back=Object.freeze(new pe(0,-1,0)),xd.right=Object.freeze(new pe(1,0,0)),xd.left=Object.freeze(new pe(-1,0,0));var wd=function(t,e){return(wd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function Md(t,e){function i(){this.constructor=t}wd(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function Td(t){return"function"==typeof t}var Sd=!1,Ed={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack;Sd=t},get useDeprecatedSynchronousErrorHandling(){return Sd}};function Pd(t){setTimeout((function(){throw t}),0)}var Ad={closed:!0,next:function(t){},error:function(t){if(Ed.useDeprecatedSynchronousErrorHandling)throw t;Pd(t)},complete:function(){}},Cd=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function Ld(t){return null!==t&&"object"==typeof t}var Rd=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),Id=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var i=this,n=i._parentOrParents,r=i._unsubscribe,s=i._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof t)n.remove(this);else if(null!==n)for(var o=0;o<n.length;++o){n[o].remove(this)}if(Td(r))try{r.call(this)}catch(t){e=t instanceof Rd?Od(t.errors):[t]}if(Cd(s)){o=-1;for(var a=s.length;++o<a;){var h=s[o];if(Ld(h))try{h.unsubscribe()}catch(t){e=e||[],t instanceof Rd?e=e.concat(Od(t.errors)):e.push(t)}}}if(e)throw new Rd(e)}},t.prototype.add=function(e){var i=e;if(!e)return t.EMPTY;switch(typeof e){case"function":i=new t(e);case"object":if(i===this||i.closed||"function"!=typeof i.unsubscribe)return i;if(this.closed)return i.unsubscribe(),i;if(!(i instanceof t)){var n=i;(i=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var r=i._parentOrParents;if(null===r)i._parentOrParents=this;else if(r instanceof t){if(r===this)return i;i._parentOrParents=[r,this]}else{if(-1!==r.indexOf(this))return i;r.push(this)}var s=this._subscriptions;return null===s?this._subscriptions=[i]:s.push(i),i},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var i=e.indexOf(t);-1!==i&&e.splice(i,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function Od(t){return t.reduce((function(t,e){return t.concat(e instanceof Rd?e.errors:e)}),[])}var Fd=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),Bd=function(t){function e(i,n,r){var s=t.call(this)||this;switch(s.syncErrorValue=null,s.syncErrorThrown=!1,s.syncErrorThrowable=!1,s.isStopped=!1,arguments.length){case 0:s.destination=Ad;break;case 1:if(!i){s.destination=Ad;break}if("object"==typeof i){i instanceof e?(s.syncErrorThrowable=i.syncErrorThrowable,s.destination=i,i.add(s)):(s.syncErrorThrowable=!0,s.destination=new Dd(s,i));break}default:s.syncErrorThrowable=!0,s.destination=new Dd(s,i,n,r)}return s}return Md(e,t),e.prototype[Fd]=function(){return this},e.create=function(t,i,n){var r=new e(t,i,n);return r.syncErrorThrowable=!1,r},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(Id),Dd=function(t){function e(e,i,n,r){var s,o=t.call(this)||this;o._parentSubscriber=e;var a=o;return Td(i)?s=i:i&&(s=i.next,n=i.error,r=i.complete,i!==Ad&&(Td((a=Object.create(i)).unsubscribe)&&o.add(a.unsubscribe.bind(a)),a.unsubscribe=o.unsubscribe.bind(o))),o._context=a,o._next=s,o._error=n,o._complete=r,o}return Md(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;Ed.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,i=Ed.useDeprecatedSynchronousErrorHandling;if(this._error)i&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)i?(e.syncErrorValue=t,e.syncErrorThrown=!0):Pd(t),this.unsubscribe();else{if(this.unsubscribe(),i)throw t;Pd(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var i=function(){return t._complete.call(t._context)};Ed.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,i),this.unsubscribe()):(this.__tryOrUnsub(i),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),Ed.useDeprecatedSynchronousErrorHandling)throw t;Pd(t)}},e.prototype.__tryOrSetError=function(t,e,i){if(!Ed.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,i)}catch(e){return Ed.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(Pd(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(Bd);var zd=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function Nd(){}function Ud(t){return t?1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}:Nd}var Vd=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var i=new t;return i.source=this,i.operator=e,i},t.prototype.subscribe=function(t,e,i){var n=this.operator,r=function(t,e,i){if(t){if(t instanceof Bd)return t;if(t[Fd])return t[Fd]()}return t||e||i?new Bd(t,e,i):new Bd(Ad)}(t,e,i);if(n?r.add(n.call(r,this.source)):r.add(this.source||Ed.useDeprecatedSynchronousErrorHandling&&!r.syncErrorThrowable?this._subscribe(r):this._trySubscribe(r)),Ed.useDeprecatedSynchronousErrorHandling&&r.syncErrorThrowable&&(r.syncErrorThrowable=!1,r.syncErrorThrown))throw r.syncErrorValue;return r},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){Ed.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),!function(t){for(;t;){var e=t,i=e.closed,n=e.destination,r=e.isStopped;if(i||r)return!1;t=n&&n instanceof Bd?n:null}return!0}(t)?console.warn(e):t.error(e)}},t.prototype.forEach=function(t,e){var i=this;return new(e=kd(e))((function(e,n){var r;r=i.subscribe((function(e){try{t(e)}catch(t){n(t),r&&r.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[zd]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:Ud(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=kd(t))((function(t,i){var n;e.subscribe((function(t){return n=t}),(function(t){return i(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function kd(t){if(t||(t=Ed.Promise||Promise),!t)throw new Error("no Promise impl found");return t}function jd(t){return t&&"function"==typeof t.schedule}var Hd=function(t){function e(e,i,n){var r=t.call(this)||this;return r.parent=e,r.outerValue=i,r.outerIndex=n,r.index=0,r}return Md(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(Bd),Gd=function(t){return function(e){for(var i=0,n=t.length;i<n&&!e.closed;i++)e.next(t[i]);e.complete()}};function Wd(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var qd=Wd(),Xd=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function Yd(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}var Zd=function(t){if(t&&"function"==typeof t[zd])return n=t,function(t){var e=n[zd]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if(Xd(t))return Gd(t);if(Yd(t))return i=t,function(t){return i.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,Pd),t};if(t&&"function"==typeof t[qd])return e=t,function(t){for(var i=e[qd]();;){var n=i.next();if(n.done){t.complete();break}if(t.next(n.value),t.closed)break}return"function"==typeof i.return&&t.add((function(){i.return&&i.return()})),t};var e,i,n,r=Ld(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+r+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")};function $d(t,e,i,n,r){if(void 0===r&&(r=new Hd(t,i,n)),!r.closed)return e instanceof Vd?e.subscribe(r):Zd(e)(r)}var Jd=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Md(e,t),e.prototype.notifyNext=function(t,e,i,n,r){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(Bd);function Qd(t,e){return function(i){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return i.lift(new Kd(t,e))}}var Kd=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new tp(t,this.project,this.thisArg))},t}(),tp=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.project=i,r.count=0,r.thisArg=n||r,r}return Md(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(Bd);function ep(t,e){return new Vd((function(i){var n=new Id,r=0;return n.add(e.schedule((function(){r!==t.length?(i.next(t[r++]),i.closed||n.add(this.schedule())):i.complete()}))),n}))}function ip(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[zd]}(t))return function(t,e){return new Vd((function(i){var n=new Id;return n.add(e.schedule((function(){var r=t[zd]();n.add(r.subscribe({next:function(t){n.add(e.schedule((function(){return i.next(t)})))},error:function(t){n.add(e.schedule((function(){return i.error(t)})))},complete:function(){n.add(e.schedule((function(){return i.complete()})))}}))}))),n}))}(t,e);if(Yd(t))return function(t,e){return new Vd((function(i){var n=new Id;return n.add(e.schedule((function(){return t.then((function(t){n.add(e.schedule((function(){i.next(t),n.add(e.schedule((function(){return i.complete()})))})))}),(function(t){n.add(e.schedule((function(){return i.error(t)})))}))}))),n}))}(t,e);if(Xd(t))return ep(t,e);if(function(t){return t&&"function"==typeof t[qd]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new Vd((function(i){var n,r=new Id;return r.add((function(){n&&"function"==typeof n.return&&n.return()})),r.add(e.schedule((function(){n=t[qd](),r.add(e.schedule((function(){if(!i.closed){var t,e;try{var r=n.next();t=r.value,e=r.done}catch(t){return void i.error(t)}e?i.complete():(i.next(t),this.schedule())}})))}))),r}))}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}function np(t,e){return e?ip(t,e):t instanceof Vd?t:new Vd(Zd(t))}function rp(t,e,i){return void 0===i&&(i=Number.POSITIVE_INFINITY),"function"==typeof e?function(n){return n.pipe(rp((function(i,n){return np(t(i,n)).pipe(Qd((function(t,r){return e(i,t,n,r)})))}),i))}:("number"==typeof e&&(i=e),function(e){return e.lift(new sp(t,i))})}var sp=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new op(t,this.project,this.concurrent))},t}(),op=function(t){function e(e,i,n){void 0===n&&(n=Number.POSITIVE_INFINITY);var r=t.call(this,e)||this;return r.project=i,r.concurrent=n,r.hasCompleted=!1,r.buffer=[],r.active=0,r.index=0,r}return Md(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,i=this.index++;try{e=this.project(t,i)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e,t,i)},e.prototype._innerSub=function(t,e,i){var n=new Hd(this,e,i),r=this.destination;r.add(n);var s=$d(this,t,void 0,void 0,n);s!==n&&r.add(s)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t,e,i,n,r){this.destination.next(e)},e.prototype.notifyComplete=function(t){var e=this.buffer;this.remove(t),this.active--,e.length>0?this._next(e.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(Jd);function ap(t){return t}function hp(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),rp(ap,t)}function cp(t,e){return e?ep(t,e):new Vd(Gd(t))}function lp(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=Number.POSITIVE_INFINITY,n=null,r=t[t.length-1];return jd(r)?(n=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(i=t.pop())):"number"==typeof r&&(i=t.pop()),null===n&&1===t.length&&t[0]instanceof Vd?t[0]:hp(i)(cp(t,n))}function up(t,e,i,n){return Td(i)&&(n=i,i=void 0),n?up(t,e,i).pipe(Qd((function(t){return Cd(t)?n.apply(void 0,t):n(t)}))):new Vd((function(n){dp(t,e,(function(t){arguments.length>1?n.next(Array.prototype.slice.call(arguments)):n.next(t)}),n,i)}))}function dp(t,e,i,n,r){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var o=t;t.addEventListener(e,i,r),s=function(){return o.removeEventListener(e,i,r)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,i),s=function(){return a.off(e,i)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var h=t;t.addListener(e,i),s=function(){return h.removeListener(e,i)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var c=0,l=t.length;c<l;c++)dp(t[c],e,i,n,r)}n.add(s)}function pp(t,e,i){return function(n){return n.lift(new fp(t,e,i))}}var fp=function(){function t(t,e,i){this.nextOrObserver=t,this.error=e,this.complete=i}return t.prototype.call=function(t,e){return e.subscribe(new mp(t,this.nextOrObserver,this.error,this.complete))},t}(),mp=function(t){function e(e,i,n,r){var s=t.call(this,e)||this;return s._tapNext=Nd,s._tapError=Nd,s._tapComplete=Nd,s._tapError=n||Nd,s._tapComplete=r||Nd,Td(i)?(s._context=s,s._tapNext=i):i&&(s._context=i,s._tapNext=i.next||Nd,s._tapError=i.error||Nd,s._tapComplete=i.complete||Nd),s}return Md(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(Bd),gp=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),vp=function(t){function e(e,i){var n=t.call(this)||this;return n.subject=e,n.subscriber=i,n.closed=!1,n}return Md(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var i=e.indexOf(this.subscriber);-1!==i&&e.splice(i,1)}}},e}(Id),bp=function(t){function e(e){var i=t.call(this,e)||this;return i.destination=e,i}return Md(e,t),e}(Bd),yp=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return Md(e,t),e.prototype[Fd]=function(){return new bp(this)},e.prototype.lift=function(t){var e=new _p(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new gp;if(!this.isStopped)for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].next(t)},e.prototype.error=function(t){if(this.closed)throw new gp;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new gp;this.isStopped=!0;for(var t=this.observers,e=t.length,i=t.slice(),n=0;n<e;n++)i[n].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new gp;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new gp;return this.hasError?(t.error(this.thrownError),Id.EMPTY):this.isStopped?(t.complete(),Id.EMPTY):(this.observers.push(t),new vp(this,t))},e.prototype.asObservable=function(){var t=new Vd;return t.source=this,t},e.create=function(t,e){return new _p(t,e)},e}(Vd),_p=function(t){function e(e,i){var n=t.call(this)||this;return n.destination=e,n.source=i,n}return Md(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):Id.EMPTY},e}(yp);var xp=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var i=this.connectable;i._refCount++;var n=new wp(t,i),r=e.subscribe(n);return n.closed||(n.connection=i.connect()),r},t}(),wp=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return Md(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var i=this.connection,n=t._connection;this.connection=null,!n||i&&n!==i||n.unsubscribe()}}else this.connection=null},e}(Bd),Mp=function(t){function e(e,i){var n=t.call(this)||this;return n.source=e,n.subjectFactory=i,n._refCount=0,n._isComplete=!1,n}return Md(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new Id).add(this.source.subscribe(new Sp(this.getSubject(),this))),t.closed&&(this._connection=null,t=Id.EMPTY)),t},e.prototype.refCount=function(){return(t=this).lift(new xp(t));var t},e}(Vd),Tp=function(){var t=Mp.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),Sp=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return Md(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(bp);function Ep(t,e){return function(i){var n;if(n="function"==typeof t?t:function(){return t},"function"==typeof e)return i.lift(new Pp(n,e));var r=Object.create(i,Tp);return r.source=i,r.subjectFactory=n,r}}var Pp=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var i=this.selector,n=this.subjectFactory(),r=i(n).subscribe(t);return r.add(e.subscribe(n)),r},t}();function Ap(t){return t?Ep((function(){return new yp}),t):Ep(new yp)}function Cp(t,e){return function(i){return i.lift(new Lp(t,e))}}var Lp=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new Rp(t,this.predicate,this.thisArg))},t}(),Rp=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.predicate=i,r.thisArg=n,r.count=0,r}return Md(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(Bd);function Ip(t,e){return"function"==typeof e?function(i){return i.pipe(Ip((function(i,n){return np(t(i,n)).pipe(Qd((function(t,r){return e(i,t,n,r)})))})))}:function(e){return e.lift(new Op(t))}}var Op=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new Fp(t,this.project))},t}(),Fp=function(t){function e(e,i){var n=t.call(this,e)||this;return n.project=i,n.index=0,n}return Md(e,t),e.prototype._next=function(t){var e,i=this.index++;try{e=this.project(t,i)}catch(t){return void this.destination.error(t)}this._innerSub(e,t,i)},e.prototype._innerSub=function(t,e,i){var n=this.innerSubscription;n&&n.unsubscribe();var r=new Hd(this,e,i),s=this.destination;s.add(r),this.innerSubscription=$d(this,t,void 0,void 0,r),this.innerSubscription!==r&&s.add(this.innerSubscription)},e.prototype._complete=function(){var e=this.innerSubscription;e&&!e.closed||t.prototype._complete.call(this),this.unsubscribe()},e.prototype._unsubscribe=function(){this.innerSubscription=null},e.prototype.notifyComplete=function(e){this.destination.remove(e),this.innerSubscription=null,this.isStopped&&t.prototype._complete.call(this)},e.prototype.notifyNext=function(t,e,i,n,r){this.destination.next(e)},e}(Jd);function Bp(t){return function(e){return e.lift(new Dp(t))}}var Dp=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var i=new zp(t),n=$d(i,this.notifier);return n&&!i.seenValue?(i.add(n),e.subscribe(i)):i},t}(),zp=function(t){function e(e){var i=t.call(this,e)||this;return i.seenValue=!1,i}return Md(e,t),e.prototype.notifyNext=function(t,e,i,n,r){this.seenValue=!0,this.complete()},e.prototype.notifyComplete=function(){},e}(Jd),Np=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n.pending=!1,n}return Md(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var i=this.id,n=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(n,i,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},e.prototype.requestAsyncId=function(t,e,i){return void 0===i&&(i=0),setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,e,i){if(void 0===i&&(i=0),null!==i&&this.delay===i&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,e);if(i)return i;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var i=!1,n=void 0;try{this.work(t)}catch(t){i=!0,n=!!t&&t||new Error(t)}if(i)return this.unsubscribe(),n},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,i=e.actions,n=i.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&i.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,i){return t.call(this)||this}return Md(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(Id)),Up=function(){function t(e,i){void 0===i&&(i=t.now),this.SchedulerAction=e,this.now=i}return t.prototype.schedule=function(t,e,i){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(i,e)},t.now=function(){return Date.now()},t}(),Vp=function(t){function e(i,n){void 0===n&&(n=Up.now);var r=t.call(this,i,(function(){return e.delegate&&e.delegate!==r?e.delegate.now():n()}))||this;return r.actions=[],r.active=!1,r.scheduled=void 0,r}return Md(e,t),e.prototype.schedule=function(i,n,r){return void 0===n&&(n=0),e.delegate&&e.delegate!==this?e.delegate.schedule(i,n,r):t.prototype.schedule.call(this,i,n,r)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var i;this.active=!0;do{if(i=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,i){for(;t=e.shift();)t.unsubscribe();throw i}}},e}(Up),kp=new Vp(Np);var jp,Hp=new Vd((function(t){return t.complete()}));function Gp(t){return t?function(t){return new Vd((function(e){return t.schedule((function(){return e.complete()}))}))}(t):Hp}function Wp(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return jd(i)?(t.pop(),ep(t,i)):cp(t)}function qp(t){var e=t.error;t.subscriber.error(e)}jp||(jp={});var Xp=function(){function t(t,e,i){this.kind=t,this.value=e,this.error=i,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,i){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return i&&i()}},t.prototype.accept=function(t,e,i){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,i)},t.prototype.toObservable=function(){var t,e;switch(this.kind){case"N":return Wp(this.value);case"E":return t=this.error,new Vd(e?function(i){return e.schedule(qp,0,{error:t,subscriber:i})}:function(e){return e.error(t)});case"C":return Gp()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}();function Yp(t,e){void 0===e&&(e=kp);var i,n=(i=t)instanceof Date&&!isNaN(+i)?+t-e.now():Math.abs(t);return function(t){return t.lift(new Zp(n,e))}}var Zp=function(){function t(t,e){this.delay=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new $p(t,this.delay,this.scheduler))},t}(),$p=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.delay=i,r.scheduler=n,r.queue=[],r.active=!1,r.errored=!1,r}return Md(e,t),e.dispatch=function(t){for(var e=t.source,i=e.queue,n=t.scheduler,r=t.destination;i.length>0&&i[0].time-n.now()<=0;)i.shift().notification.observe(r);if(i.length>0){var s=Math.max(0,i[0].time-n.now());this.schedule(t,s)}else this.unsubscribe(),e.active=!1},e.prototype._schedule=function(t){this.active=!0,this.destination.add(t.schedule(e.dispatch,this.delay,{source:this,destination:this.destination,scheduler:t}))},e.prototype.scheduleNotification=function(t){if(!0!==this.errored){var e=this.scheduler,i=new Jp(e.now()+this.delay,t);this.queue.push(i),!1===this.active&&this._schedule(e)}},e.prototype._next=function(t){this.scheduleNotification(Xp.createNext(t))},e.prototype._error=function(t){this.errored=!0,this.queue=[],this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.scheduleNotification(Xp.createComplete()),this.unsubscribe()},e}(Bd),Jp=function(){return function(t,e){this.time=t,this.notification=e}}();class Qp{constructor(t,e){this.picker=t,this.container=e,this.convertEventToPointerInput=(()=>{let t;return e=>{const i={x:0,y:0,originalEvent:e,isTouch:"undefined"!=typeof TouchEvent&&e instanceof TouchEvent};if("undefined"!=typeof TouchEvent&&e instanceof TouchEvent){const t=function(t){const e={x:0,y:0},i=0!==t.touches.length?t.touches:t.changedTouches;switch(i.length){case 1:e.x=i[0].clientX,e.y=i[0].clientY;break;case 2:e.x=(i[0].clientX+i[1].clientX)/2,e.y=(i[0].clientY+i[1].clientY)/2;break;case 3:e.x=(i[0].clientX+i[2].clientX)/2,e.y=(i[0].clientY+i[2].clientY)/2}return e}(e);i.x=t.x,i.y=t.y,i.touchCount=e.touches.length}else"undefined"!=typeof MouseEvent&&e instanceof MouseEvent&&(i.x=e.x,i.y=e.y,i.mouseButton=e.button,i.anyMouseButtonDown=0!==e.buttons);return t=e,i}})();const i={passive:!1};this._pointerDownObserver=lp(up(e,"mousedown",i),up(e,"touchstart",i)).pipe(pp((t=>t.preventDefault())),Qd((t=>this.convertEventToPointerInput(t)))),this._moveObserver=lp(up(window,"mousemove",i),up(window,"touchmove",i)).pipe(Qd((t=>this.convertEventToPointerInput(t))),Ap()),this._moveObserver.connect(),this._pointerUpObserver=lp(up(window,"mouseup",i),up(window,"touchend",i)).pipe(Qd((t=>this.convertEventToPointerInput(t)))),this.pointerDown$=this._pointerDownObserver.pipe(Ap()),this.pointerDown$.connect(),this.pointerMove$=this._moveObserver.pipe(Ap()),this.pointerMove$.connect(),this.pointerUp$=this._pointerUpObserver.pipe(Ap()),this.pointerUp$.connect(),this.wheel$=up(e,"wheel",i).pipe(Qd((t=>this.fromWheelToScrollEvent(t))),Ap()),this.wheel$.connect(),this.gesture$=lp(up(e,"gesturestart",i),up(e,"gesturechange",i),up(e,"gestureend",i)).pipe(Qd((t=>this.fromGestureToScrollEvent(t))),Ap()),this.gesture$.connect(),this.zoom$="TouchEvent"in window?this.wheel$:lp(this.wheel$,this.gesture$),this.keyDown$=up(document,"keydown",i).pipe(Cp((t=>!t.repeat)),Ap()),this.keyDown$.connect(),this.keyUp$=up(document,"keyup",i).pipe(Cp((t=>!t.repeat)),Ap()),this.keyUp$.connect(),this.contextMenu$=up(e,"contextmenu",i),this.contextMenu$.subscribe((t=>{t.preventDefault()}))}clampScrollSpeed(t){return t=0===t?0:t>0?Math.max(t,.3):Math.min(t,-.3),Math.min(Math.max(t,-2),2)}fromWheelToScrollEvent(t){t.preventDefault();const e=t.ctrlKey?t.deltaY/25:t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?t.deltaY/100:t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY/3:t.deltaMode===WheelEvent.DOM_DELTA_PAGE?80*t.deltaY:0;return{speed:this.clampScrollSpeed(e),x:t.x,y:t.y,originalEvent:t}}fromGestureToScrollEvent(t){t.preventDefault();return{speed:1-t.scale,x:t.clientX,y:t.clientY,originalEvent:t}}set cursor(t){this._cursor=this._cursor||"default",""===t?(this.container.classList.remove(this._cursor),this.container.classList.add("default"),this._cursor="default"):t!==this._cursor&&(this.container.classList.remove(this._cursor),this.container.classList.add(t),this._cursor=t)}get cursor(){return this._cursor=this._cursor||"default",this._cursor}static getInputDistanceVector(t,e){if(t.isTouch&&t.originalEvent instanceof TouchEvent&&e.isTouch&&e.originalEvent instanceof TouchEvent)return Qp.getTouchInputDistanceVector(e.originalEvent.touches[0],t.originalEvent.touches[0],e.originalEvent.touches[1],t.originalEvent.touches[1]);{const i=new pe(e.x,e.y),n=new pe(t.x,t.y);return(new pe).subVectors(n,i)}}static getTouchInputDistanceVector(t,e,i,n){const r=devicePixelRatio,s=devicePixelRatio**1.5/6,o=(t.clientX-i.clientX)*r,a=(t.clientY-i.clientY)*r,h=(e.clientX-n.clientX)*r,c=(e.clientY-n.clientY)*r,l=Math.sqrt(o*o+a*a),u=Math.sqrt(h*h+c*c);return new pe((n.clientX-i.clientX+e.clientX-t.clientX)*s,(n.clientY-i.clientY+e.clientY-t.clientY)*s,u-l)}}const Kp=t=>{const e=t.intersection;return!(!e||!e.object)&&e.object.userData.interactive},tf=(t,e)=>i=>ef(i,t,e);function ef(t,e,i){return t.mouseButton===e&&!t.isTouch||t.touchCount===i&&t.isTouch}const nf=(t,e,i)=>lp(t.pointerUp$.pipe(Cp((t=>t.mouseButton===e||t.touchCount!==i&&t.isTouch))),t.pointerMove$.pipe(Cp((t=>!t.isTouch&&!t.anyMouseButtonDown||t.isTouch&&t.touchCount!==i)))),rf=(t,e)=>{const{button:i,touchCount:n}=e;return t.pointerDown$.pipe(Cp(tf(i,n)),Ip((e=>t.pointerUp$.pipe(Cp(tf(i,0)),Bp(t.pointerMove$.pipe(Yp(150))),pp((t=>t.intersection=e.intersection))))))},sf=t=>!(!t||!t.intersection),of=(t,e)=>async i=>(i.intersection=await t.pick(new ce(i.x,i.y),e),i),af=t=>async e=>(e.intersection=await t.pickForNavigation(new ce(e.x,e.y)),e);class hf{}class cf extends hf{constructor(t,e,i){super(),this._inputs=t,this._camera=e,this._container=i,this.moveCallback=(()=>{const t=new pe,e=new pe;return i=>{const n=Qp.getInputDistanceVector(i,this.previousEvent);return t.copy(xd.forward),e.copy(xd.left),t.applyQuaternion(this._camera.quaternion),e.applyQuaternion(this._camera.quaternion),e.multiplyScalar(-n.x*this._speed),t.multiplyScalar(n.y*this._speed),this._camera.position.add(e).add(t),this._camera.next(this._camera.value),this.previousEvent=i,i}})(),this.mouseButton=1,this.touchCount=2,this._dragBehavior=t.pointerDown$.pipe(Cp((t=>ef(t,this.mouseButton,this.touchCount))),rp(af(t.picker)),Cp((t=>!Kp(t))),pp((t=>this._downCallback(t))),Ip((()=>t.pointerMove$.pipe(Bp(nf(t,this.mouseButton,this.touchCount))))),pp(this.moveCallback)),this.enabled=!0}get name(){return"pan"}set speed(t){let e;if(t)e=this._camera.position.distanceTo(t);else{const t=this._inputs.picker.getNearestModel();e=t.box?t.distance:100}const i=2*this._camera.getViewWorldSize(e);this._speed=i/this._container.clientHeight}_downCallback(t){this.speed=t.intersection?t.intersection.point:null,this.previousEvent=t}set enabled(t){this._dragHandle&&(this._dragHandle.unsubscribe(),this._dragHandle=null),t&&(this._dragHandle=this._dragBehavior.subscribe())}get enabled(){return!!this._dragHandle}}function lf(t,e){return void 0===e&&(e=kp),function(i){return i.lift(new uf(t,e))}}var uf=function(){function t(t,e){this.dueTime=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new df(t,this.dueTime,this.scheduler))},t}(),df=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.dueTime=i,r.scheduler=n,r.debouncedSubscription=null,r.lastValue=null,r.hasValue=!1,r}return Md(e,t),e.prototype._next=function(t){this.clearDebounce(),this.lastValue=t,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(pf,this.dueTime,this))},e.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},e.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var t=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(t)}},e.prototype.clearDebounce=function(){var t=this.debouncedSubscription;null!==t&&(this.remove(t),t.unsubscribe(),this.debouncedSubscription=null)},e}(Bd);function pf(t){t.debouncedNext()}var ff=function(t){function e(e){var i=t.call(this)||this;return i._value=e,i}return Md(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var i=t.prototype._subscribe.call(this,e);return i&&!i.closed&&e.next(this._value),i},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new gp;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(yp);function mf(t,e){var i;return void 0===t&&(t=0),void 0===e&&(e=kp),(Cd(i=t)||!(i-parseFloat(i)+1>=0)||t<0)&&(t=0),e&&"function"==typeof e.schedule||(e=kp),new Vd((function(i){return i.add(e.schedule(gf,t,{subscriber:i,counter:0,period:t})),i}))}function gf(t){var e=t.subscriber,i=t.counter,n=t.period;e.next(i),this.schedule({subscriber:e,counter:i+1,period:n},n)}var vf=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n}return Md(e,t),e.prototype.requestAsyncId=function(e,i,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,i,n):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,i,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,i,n);0===e.actions.length&&(cancelAnimationFrame(i),e.scheduled=void 0)},e}(Np),bf=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Md(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,i=this.actions,n=-1,r=i.length;t=t||i.shift();do{if(e=t.execute(t.state,t.delay))break}while(++n<r&&(t=i.shift()));if(this.active=!1,e){for(;++n<r&&(t=i.shift());)t.unsubscribe();throw e}},e}(Vp))(vf);var yf=function(){function t(t,e){this.predicate=t,this.inclusive=e}return t.prototype.call=function(t,e){return e.subscribe(new _f(t,this.predicate,this.inclusive))},t}(),_f=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.predicate=i,r.inclusive=n,r.index=0,r}return Md(e,t),e.prototype._next=function(t){var e,i=this.destination;try{e=this.predicate(t,this.index++)}catch(t){return void i.error(t)}this.nextOrComplete(t,e)},e.prototype.nextOrComplete=function(t,e){var i=this.destination;Boolean(e)?i.next(t):(this.inclusive&&i.next(t),i.complete())},e}(Bd);function xf(){return hp(1)}function wf(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return xf()(Wp.apply(void 0,t))}const Mf=t=>{return e=()=>{const e=t.now();return mf(0,t).pipe(Qd((()=>t.now()-e)))},new Vd((function(t){var i;try{i=e()}catch(e){return void t.error(e)}return(i?np(i):Gp()).subscribe(t)}));var e},Tf=(t,e=bf)=>{return Mf(e).pipe(Qd((e=>e/t)),(i=t=>t<=1,void 0===n&&(n=!1),function(t){return t.lift(new yf(i,n))}),function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return e.lift.call(wf.apply(void 0,[e].concat(t)))}}(Wp(1)));var i,n},Sf=t=>-t*(t-2),Ef=(t,e,i,n)=>Tf(t).pipe(Qd(e),Qd((t=>i+(n-i)*t)));class Pf extends ff{constructor(t){super(null),this._api=t,this.isCamera=!0,this._defaultWidestFov=60,this.rotateSpherical=(()=>{const t=Math.PI/2,e=new ce,i=new pe,n=new pe,r=new pe,s=new pe,o=new pe,a=new pe,h=new pe,c=new pe;return(l,u,d)=>{e.set(d.x-t,d.y),cd(d,r),cd(e,n),i.crossVectors(r,n),o.copy(r).multiplyScalar(u.y),a.copy(i).multiplyScalar(u.x),h.copy(n).multiplyScalar(u.z),this.position.copy(c.copy(l).sub(o).sub(a).sub(h)),this.lookAt(s.copy(this.position).add(r))}})(),this._frustum=new tr,this._matrix=new Le,this.rig=new Ye,this.rig.up=xd.up,this._api.scene.add(this.rig),this._addCameraToRig(new Xn(this._defaultWidestFov,1,.2,1e4))}getViewWorldSize(t){return Pf.getViewWorldSize(this.value,t)}static getViewWorldSize(t,e){return t instanceof Xn?Pf.getPerspectiveViewWorldSize(t.fov,e):t instanceof Oc?t.top:void 0}static getPerspectiveViewWorldSize(t,e){return Math.tan(t*Math.PI/360)*e}getProjectionType(){return this.value instanceof Xn?"perspective":"ortho"}async setProjectionType(t,e){e||(e=await this._getViewFocusPoint()),"perspective"===t&&this.value instanceof Oc?this._switchToPerspective(e):"ortho"===t&&this.value instanceof Xn&&this._switchToOrthographic(e)}_switchToOrthographic(t){let e=t.distanceTo(this.position);0===e&&(e=1);const i=this.value,n=Pf.getPerspectiveViewWorldSize(i.fov,e),r=i.aspect,s=new Oc(-n*r,n*r,n,-n,i.near,i.far);this._addCameraToRig(s)}_switchToPerspective(t){const e=this.value,i=new Xn(this.aspect>1?this.toVerticalFov(this._defaultWidestFov,this.aspect):this._defaultWidestFov,this.aspect,e.near,e.far),n=e.top/Pf.getPerspectiveViewWorldSize(i.fov,1);this.position.sub(t).normalize().multiplyScalar(n).add(t),this._addCameraToRig(i)}get verticalFov(){return this.value instanceof Xn?this.value.fov:void 0}set verticalFov(t){this.value instanceof Xn&&(this.value.fov=t,this.next(this.value))}get widestFov(){return this.value instanceof Xn?this.value.aspect>1?this.toHorizontalFov(this.verticalFov,this.value.aspect):this.verticalFov:void 0}set widestFov(t){this.value instanceof Xn&&(this.verticalFov=this.value.aspect>1?this.toVerticalFov(t,this.value.aspect):t)}get aspect(){return this.value instanceof Xn?this.value.aspect:this.value instanceof Oc?this.value.right/this.value.top:void 0}toHorizontalFov(t,e){const i=t*Math.PI/180;return 180*(2*Math.atan(Math.tan(i/2)*e))/Math.PI}toVerticalFov(t,e){const i=t*Math.PI/180;return 180*(2*Math.atan(Math.tan(i/2)/e))/Math.PI}get orthoSize(){return this.value instanceof Oc?this.value.top:void 0}set orthoSize(t){this.value instanceof Oc&&(this.value.left=-t*this.aspect,this.value.right=t*this.aspect,this.value.top=t,this.value.bottom=-t,this.next(this.value))}_addCameraToRig(t){const e=new Ye;e.up=xd.up,e.rotateY(Math.PI),e.add(t),this.rig.remove(this.rig.children[0]),this.rig.add(e),this.next(t)}async _getViewFocusPoint(){const t=this._api.renderingManager.renderer.domElement.getBoundingClientRect(),e=await this._api.picker.pickForNavigation(new ce(t.x+t.width/2,t.y+t.height/2));return e?e.point:this._api.models.worldBoundingBox.value.getCenter(new pe)}animate(t,e,i=1e3){if(0!==i)return Promise.all([this.animatePosition(t,i),this.animateRotation(e,i)]);this.position.copy(t),this.quaternion.copy(e),this.next(this.value)}animatePosition(t,e){this.stopMoveAnimation();const i=this.position.clone(),n=i.clone();return new Promise(((r,s)=>{this.cameraMoverComplete=()=>{this.next(this.value),r()},this.cameraMover=Ef(e,Sf,0,1).subscribe((e=>{this.position.equals(n)?(this.position.lerpVectors(i,t,e),this.next(this.value),n.copy(this.position)):this.stopMoveAnimation()}),s,this.cameraMoverComplete)}))}animateRotation(t,e){this.stopRotationAnimation();const i=this.quaternion.clone(),n=i.clone();return new Promise(((r,s)=>{this.cameraRotatorComplete=()=>r(),this.cameraRotator=Ef(e,Sf,0,1).subscribe((e=>{this.quaternion.equals(n)?(le.slerp(i,t,this.quaternion,e),this.next(this.value),n.copy(this.quaternion)):this.stopRotationAnimation()}),s,this.cameraRotatorComplete)}))}stopMoveAnimation(){this.cameraMover&&(this.cameraMover.unsubscribe(),this.cameraMover=null,this.cameraMoverComplete())}stopRotationAnimation(){this.cameraRotator&&(this.cameraRotator.unsubscribe(),this.cameraRotator=null,this.cameraRotatorComplete())}async fitToView(t,e,i){let n=10,r=xd.zero;if(!t.isEmpty()){const e=1.2*t.max.clone().sub(t.min).length(),i=this.value instanceof Xn?this.widestFov:this._defaultWidestFov;if(n=e/2/Pf.getPerspectiveViewWorldSize(i,1),this.value instanceof Oc){const t=e/2;this.value.left=-t*this.aspect,this.value.right=t*this.aspect,this.value.top=t,this.value.bottom=-t}r=t.getCenter(new pe)}const s=0===this.position.x&&0===this.position.y&&0===this.position.z;if(!i&&s&&(i="axon"),i){const t="axon"===i?new pe(.7*n,.7*-n,.25*n):"top"===i?new pe(0,0,n):"bottom"===i?new pe(0,0,-n):"left"===i?new pe(n,0,0):"right"===i?new pe(-n,0,0):"front"===i?new pe(0,n,0):"back"===i?new pe(0,-n,0):null,o="top"===i?(new le).setFromEuler(new Oe(0,Math.PI,0)):"bottom"===i?new le:(new le).setFromRotationMatrix((new Le).lookAt(xd.zero,t,this._api.camera.up));await this.animate(t.add(r),o,s?0:e)}else{const t=this.getWorldDirection(new pe).multiplyScalar(-n);await this.animatePosition(t.add(r),e)}}getWorldDirection(t){return this.rig.getWorldDirection(t)}updateMatrixWorld(t){this.rig.updateMatrixWorld(t)}applyMatrix(t){this.rig.applyMatrix(t)}lookAt(t,e,i){this.rig.lookAt(t,e,i)}getWorldPosition(t){return this.rig.getWorldPosition(t)}getWorldQuaternion(t){return this.rig.getWorldQuaternion(t)}updateProjectionMatrix(){this.value.updateProjectionMatrix()}get position(){return this.rig.position}get up(){return this.rig.up}set up(t){this.rig.up=t}get quaternion(){return this.rig.quaternion}get rotation(){return this.rig.rotation}get matrixWorld(){return this.rig.matrixWorld}get layers(){return this.value.layers}get matrixWorldInverse(){return this.value.matrixWorldInverse}get projectionMatrix(){return this.value.projectionMatrix}get near(){if(this.value instanceof Xn)return this.value.near}get far(){if(this.value instanceof Xn)return this.value.far}get frustum(){this.updateMatrixWorld(!0);const t=this._api.renderingManager.vr.toVRCamera(this.value);return t.updateMatrixWorld(!0),this._matrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromMatrix(this._matrix),this._frustum}}const Af=new pe;function Cf(t,e){const i=e.getWorldPosition(Af).distanceTo(t);return 15/(798/Pf.getViewWorldSize(e,i)/2)}class Lf{constructor(t,e,i,n){this._camera=t,this._models=e,this._container=i,this.settings=n,this.createFrustumFromScreenRect=(()=>{const t=new Ti,e=new Ti,i=new Ti,n=new Ti,r=new Ti,s=new Ti,o=new pe,a=new pe,h=new pe,c=new pe,l=new pe,u=new pe,d=new ce,p=new ce;return(f,m)=>{Of(f,this._container,d),Of(m,this._container,p);const g=this._camera;return o.set(d.x,d.y,1).unproject(g.value),a.set(p.x,d.y,1).unproject(g.value),h.set(d.x,p.y,1).unproject(g.value),c.set(p.x,p.y,1).unproject(g.value),l.set(d.x,d.y,0).unproject(g.value),u.set(p.x,p.y,0).unproject(g.value),t.setFromCoplanarPoints(l,o,a),e.setFromCoplanarPoints(u,a,c),i.setFromCoplanarPoints(u,c,h),n.setFromCoplanarPoints(l,h,o),g.getWorldDirection(r.normal),r.constant=g.position.length(),s.normal=r.normal,s.constant=1/0,new tr(t,i,n,e,r,s)}})()}setWorldBoundingBox(t){this._worldBoundingBox=t}createCaster(t){const e=new od;e.screenPosition=t;const i=Of(e.screenPosition,this._container);return e.setFromCamera(i,this._camera.value),e.frustum=this.createFrustumFromScreenPoint(e.screenPosition,this.settings.snapDistance),e}createFrustumFromScreenPoint(t,e){return this.createFrustumFromScreenRect(t.clone().subScalar(e),t.clone().addScalar(e))}async pickForNavigation(t,e=!0){const i=this.createCaster(t);let n=this.reduceIntersections(await this.pickAllModels(i,void 0,e));return n||(n=this.pickOnWorldBoundingBox(i)),n}async pick(t,e){const i=this.createCaster(t);return this.reduceIntersections(await this.pickAllModels(i,e))}async pickSnapped(t,e){const i=this.createCaster(t);return this.reduceIntersections(await this.pickAllModelsSnapped(i,e))}async getIntersectionFromScreenRect(t,e){const i=new od;delete i.ray,i.frustum=this.createFrustumFromScreenRect(t,e);const n=[],r=this._models.getIterable();for(const t of r){const e=t;e.isSelectable&&n.push(e.pickFrustum(i))}let s=await Promise.all(n);return s=s.filter((t=>!!t)),s}async pickAllModels(t,e,i=!1){if(i&&this.pickerBusy)return;this.pickerBusy=!0;const n=[];for(const i of e||this._models.getIterable()){const e=i;if(e.pick){const i=await e.pick(t);i&&n.push(i)}}return this.pickerBusy=!1,n}async pickAllModelsSnapped(t,e){if(this.pickerBusy)return;this.pickerBusy=!0;const i=[];for(const n of this._models.getIterable()){const r=n;if(r.pickSnapped){const n=await r.pickSnapped(t,e);n&&i.push(...n)}}return this.pickerBusy=!1,i}reduceIntersections(t){return t&&0!==t.length?t.reduce(((t,e)=>{const i=t.distance-e.distance,n=(t.pickPriority?t.pickPriority:0)-(e.pickPriority?e.pickPriority:0),r=(t.snapType?t.snapType:0)-(e.snapType?e.snapType:0);return(0===n?0===r?i:-r:-n)<0?t:e})):void 0}pickOnWorldBoundingBox(t){const e=new pe;if(function(t,e,i,n=!1){let r,s,o,a,h,c;const l=1/t.direction.x,u=1/t.direction.y,d=1/t.direction.z,p=t.origin;return l>=0?(r=(e.min.x-p.x)*l,s=(e.max.x-p.x)*l):(r=(e.max.x-p.x)*l,s=(e.min.x-p.x)*l),u>=0?(o=(e.min.y-p.y)*u,a=(e.max.y-p.y)*u):(o=(e.max.y-p.y)*u,a=(e.min.y-p.y)*u),r>a||o>s?null:((o>r||r!=r)&&(r=o),(a<s||s!=s)&&(s=a),d>=0?(h=(e.min.z-p.z)*d,c=(e.max.z-p.z)*d):(h=(e.max.z-p.z)*d,c=(e.min.z-p.z)*d),r>c||h>s?null:((h>r||r!=r)&&(r=h),(c<s||s!=s)&&(s=c),s<0?null:e.containsPoint(t.origin)||!n?t.at(r>=0?r:s,i):t.at(r>=0?s:r,i)))}(t.ray,this._worldBoundingBox,e,!0)){const i=this.createEmptyIntersection(t);return i.point=e,i}}createEmptyIntersection(t){return{id:void 0,model:void 0,object:void 0,caster:t}}getNearestModel(){let t,e,i=1/0;for(const n of this._models.boundingboxes)e=n.value.distanceToPoint(this._camera.position),i>e&&(i=e,t=n.value);return{box:t,distance:i}}}const Rf=new Ul;function If(t,e,i,n=new _i){return Rf.setFromCamera(Of(t,e),i),n.copy(Rf.ray)}function Of(t,e,i=new ce){const n=e.getBoundingClientRect();return i.x=(t.x-n.left)/e.clientWidth*2-1,i.y=-(t.y-n.top)/e.clientHeight*2+1,i}Rf.linePrecision=.01;const Ff=(()=>{const t=new pe,e=new pe,i=new Le;return(n,r,s,o)=>{if(t.copy(n),e.copy(n),i.getInverse(r.matrixWorld),e.applyMatrix4(i),!(e.z>0))return t.project(r),t.x=(t.x+1)*s/2,t.y=(1-t.y)*o/2,r.getWorldPosition(e),t.z=n.distanceTo(e),t}})();class Bf{constructor(t){this._api=t,this._scrollSpeed=.1,this._pinchSpeed=.001,this.zoomPosition=new pe,this.zoomOffset=new pe,this.cameraDirection=new pe,this.right=new pe,this.up=new pe,this.forward=new pe,this.useWorldCenter=!1,this._camera=t.camera,this._zoomTarget=new pe,this._cameraExpectedPosition=new pe;const e=this._api.inputHandler;let i=!1;this._zoom$=e.zoom$.pipe(rp((async t=>(i||(await this._scrollStart(t),i=!0),t))),Qd((t=>this.applyZoom(this._camera,this._scrollSpeed*t.speed))),lf(200),pp((()=>i=!1))),this._pinch$=e.pointerDown$.pipe(Cp((t=>2===t.touchCount)),rp(af(e.picker)),Cp((t=>!Kp(t))),pp((t=>this.onPinchStart(t))),rp((()=>e.pointerMove$.pipe(Cp((t=>2===t.touchCount)),Qd((t=>this.onPinchMove(t))),Bp(e.pointerUp$))))),this.enabled=!0}get name(){return"zoom"}async _scrollStart(t){this.useWorldCenter?this._api.models.worldBoundingBox.value.getCenter(this._zoomTarget):(t.intersection=await this._api.picker.pickForNavigation(new ce(t.x,t.y),!1),this.setZoomTarget(t))}set enabled(t){this._scrollHandle&&(this._scrollHandle.unsubscribe(),this._pinchHandle.unsubscribe(),this._scrollHandle=null),t&&(this._scrollHandle=this._zoom$.subscribe(),this._pinchHandle=this._pinch$.subscribe())}get enabled(){return!!this._scrollHandle}setZoomTarget(t){const e=t.intersection;this._rayTracePoint=Of(t,this._api.container);const i=!!e&&!!e.point&&!e.object;this._isGeometryPick=!!e&&!!e.point&&!!e.object,this._isGeometryPick||i&&e.point.distanceTo(this._camera.position)>2?this._zoomTarget.copy(e.point):this._zoomTarget.set(this._rayTracePoint.x,this._rayTracePoint.y,1).unproject(this._camera.value)}perspectiveZoom(t,e){const i=t.position;this.zoomOffset.copy(this._zoomTarget).sub(i),this._camera.getWorldDirection(this.cameraDirection),this.zoomOffset.length()>.07&&this.cameraDirection.dot(this.zoomOffset)>0?this.zoomPosition.copy(this.zoomOffset).multiplyScalar(-e).add(i):this.zoomPosition.copy(this.cameraDirection).multiplyScalar(-.5*e).add(i),t.position.copy(this.zoomPosition),this._api.camera.next(this._camera.value)}orthographicZoom(t,e){t.getWorldDirection(this.forward),this.right.copy(xd.left),this.up.copy(xd.forward),this.right.applyQuaternion(this._camera.quaternion),this.up.applyQuaternion(this._camera.quaternion);const i=t.orthoSize,n=t.orthoSize*t.aspect,r=i*this._rayTracePoint.y,s=n*this._rayTracePoint.x,o=(i-r)*(1+e)+r-(1+e)*i,a=(n-s)*(1+e)+s-(1+e)*n;this.up.multiplyScalar(o),this.right.multiplyScalar(a),t.position.add(this.up),t.position.add(this.right),t.orthoSize=t.orthoSize*(1+e);let h=this._isGeometryPick?t.position.distanceTo(this._zoomTarget):0;h-=t.orthoSize/Pf.getPerspectiveViewWorldSize(45,1),t.position.add(this.forward.multiplyScalar(h)),this._api.camera.next(this._camera.value)}applyZoom(t,e){t.value instanceof Xn?this.perspectiveZoom(t,e):t.value instanceof Oc&&this.orthographicZoom(t,e)}onPinchStart(t){this.setZoomTarget(t),this.previousEvent=t}onPinchMove(t){const e=-Qp.getInputDistanceVector(t,this.previousEvent).z;return this.applyZoom(this._camera,e*this._pinchSpeed),this.previousEvent=t,t}}class Df extends hf{constructor(t,e){super(),this.inputs=t,this.EPS=.02,this._offset=new pe,this.updateOriginalCamera=(()=>{this._originalUp=new pe;const t=new pe;return()=>{this._originalDirection=this._camera.getWorldDirection(new pe),this._originalPosition=this._camera.position.clone(),this._originalUp.copy(xd.forward),t.copy(xd.left),this._originalUp.applyQuaternion(this._camera.quaternion),t.applyQuaternion(this._camera.quaternion);const e=(new pe).copy(this._rotationPoint).sub(this._originalPosition),i=this._originalDirection;this._offset.set(e.dot(t),e.dot(i),e.dot(this._originalUp))}})(),this.mouseButton=0,this.touchCount=1,this._camera=e,this.dragBehavior=t.pointerDown$.pipe(Cp((t=>ef(t,this.mouseButton,this.touchCount))),rp((t=>this.pick(t))),Cp((t=>!Kp(t))),pp((t=>this.downCallback(t))),Ip((()=>t.pointerMove$.pipe(Bp(nf(t,this.mouseButton,this.touchCount).pipe(pp((t=>this.upCallback(t)))))))),pp((t=>this.moveCallback(t))))}set enabled(t){this._dragHandle&&(this._dragHandle.unsubscribe(),this._dragHandle=null),t&&(this._dragHandle=this.dragBehavior.subscribe())}get enabled(){return!!this._dragHandle}async pick(t){return t.intersection=await this.inputs.picker.pickForNavigation(new ce(t.x,t.y)),t}downCallback(t){return this._startPoint=new ce(t.x,t.y),this.updateOriginalCamera(),t}moveCallback(t){const e=new ce(t.x,t.y).sub(this._startPoint),i=ad(this._originalDirection,this._originalUp);return this.translateCamera(e,i),this._camera.next(this._camera.value),t}translateCamera(t,e){e.x=Math.max(this.EPS,Math.min(e.x+.007*t.y,Math.PI-this.EPS)),e.y-=.003*t.x,this._camera.rotateSpherical(this._rotationPoint,this._offset,e)}}class zf extends Df{constructor(t,e,i){super(t,e),this._worldBoundingBox=i,this.useWorldCenter=!1,this.enabled=!0}get name(){return"orbit"}async pick(t){return this.useWorldCenter||await super.pick(t),t}downCallback(t){return!this.useWorldCenter&&t.intersection&&t.intersection.point?this._rotationPoint=t.intersection.point:this._rotationPoint=this._worldBoundingBox.value.getCenter(new pe),super.downCallback(t),t}upCallback(t){return t}}var Nf=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Uf(t))},t}(),Uf=function(t){function e(e){var i=t.call(this,e)||this;return i.hasPrev=!1,i}return Md(e,t),e.prototype._next=function(t){var e;this.hasPrev?e=[this.prev,t]:this.hasPrev=!0,this.prev=t,e&&this.destination.next(e)},e}(Bd);class Vf extends Df{constructor(t,e){super(t,e),this._dir=new pe,this._fly=new pe,this._speedIncrease=1e-5,this._minSpeed=.003,this._maxSpeed=.02,this._speed=this._minSpeed,this.mouseButton=2,this.touchCount=3,this._keyBehavior=lp(t.keyDown$,t.keyUp$).pipe(pp((t=>this.processKey(t)))),this._moveBehaviour=Mf(bf).pipe((function(t){return t.lift(new Nf)}),pp((t=>this.move(t[1]-t[0])))),this.enabled=!0}get name(){return"fly"}move(t){0!==this._dir.lengthSq()&&(this._speed=Math.min(this._speed+t*this._speedIncrease,this._maxSpeed),this._fly.copy(this._dir).multiplyScalar(t*this._speed),this._fly.applyQuaternion(this._camera.quaternion),this._camera.position.add(this._fly),this._camera.next(this._camera.value))}processKey(t){const e="keydown"===t.type?1:-1;switch(t.key.toLowerCase()){case"w":this._dir.z+=e;break;case"s":this._dir.z+=-e;break;case"a":this._dir.x+=e;break;case"d":this._dir.x+=-e;break;case"q":this._dir.y+=-e;break;case"e":this._dir.y+=e}this._maxSpeed=t.shiftKey?.1:.02,this._speedIncrease=t.shiftKey?1e-4:1e-5,this._dir.equals(xd.zero)&&(this._speed=this._minSpeed)}moveCallback(t){return document.hasFocus()?super.moveCallback(t):null}async pick(t){return t}downCallback(t){return this._rotationPoint=this._camera.position,super.downCallback(t),this._keyHandle=this._keyBehavior.subscribe(),this._moveHandle=this._moveBehaviour.subscribe(),t}upCallback(t){return this._dir.set(0,0,0),this._keyHandle&&this._keyHandle.unsubscribe(),this._moveHandle&&this._moveHandle.unsubscribe(),t}}class kf{constructor(t){this._speed=0,this._artificialRotationInProgress=!1,this._artificialRotation=0,this._accelerating=!1,this.BASE_SPEED=.015,this.ACC=5e-5,this.ARTIFICIAL_ROT_ANGLE=Math.PI/8,this.ACCELERATION_THRESHOLD=.75,this.INSTANT_BREAK_THRESHOLD=.05,this.update=(()=>{const t=this;let e=0,i=0;return n=>{i=n-e,e=n,t.enabled&&t.move(i)}})(),this._camera=t.camera,this._api=t,this._scene=t.scene,this._refOrientation=new le;const e=this._api.renderingManager.vr.toVRCamera(this._camera.value);e.getWorldQuaternion(this._refOrientation),this._refMatrix=e.matrixWorld.clone()}get name(){return"xrnavigation"}get enabled(){return this._enabled}set enabled(t){this._enabled!==t&&(this._enabled=t)}get _session(){return this._api.renderingManager.renderer.xr.getSession()}static hapticsPulse(t,e=.5,i=100){for(const n of t){if(!n.pad)continue;const t=n.pad;t&&t.hapticActuators&&t.hapticActuators.length>0&&t.hapticActuators[0]&&t.hapticActuators[0].pulse&&t.hapticActuators[0].pulse(e,i)}}move(t){const e=this._session.inputSources;if(!e)return;let i=0,n=0;for(const t of e){const e=t.gamepad?t.gamepad.axes:void 0;e&&(i+=e[0],n-=e[1],i+=e[2],n-=e[3])}const r=this._api.renderingManager.vr.toVRCamera(this._camera.value),s=new le;r.getWorldQuaternion(s);const o=new pe(0,0,-1).applyQuaternion(s);(this._speed>0&&n<this.INSTANT_BREAK_THRESHOLD||this._speed<0&&n>-this.INSTANT_BREAK_THRESHOLD)&&(this._speed=0),Math.abs(n)>this.ACCELERATION_THRESHOLD?(this._speed+=n*Math.abs(Math.pow(n,2))*this.ACC*t,this._accelerating=!0):(this._speed*=Math.pow(Math.abs(n),.01*t),this._accelerating=!1);const a=(this.BASE_SPEED*n*Math.min(n*n,.2)+this._speed)*t;this._camera.position.add(o.clone().multiplyScalar(a));let h=0;Math.abs(n)<.25&&Math.abs(i)>.75&&(this._artificialRotationInProgress||(kf.hapticsPulse(e,.5,100),this._artificialRotationInProgress=!0,h-=Math.sign(i)*this.ARTIFICIAL_ROT_ANGLE)),Math.abs(i)<.7&&(this._artificialRotationInProgress=!1),this._artificialRotation+=h;const c=new pe;this._camera.getWorldDirection(c),c.applyAxisAngle(new pe(0,0,1),h);const l=new pe;this._camera.getWorldPosition(l),this._camera.lookAt(l.clone().add(c))}}class jf extends hf{constructor(t,e,i,n){super(),this._inputs=t,this._selection=e,this._eventDispatcher=i,this._settings=n,this.mode="replace",this.mouseButton=0,this._tapsObservable=t.pointerDown$.pipe(Ip((e=>t.pointerUp$.pipe(Bp(t.pointerMove$.pipe(Yp(150))),Qd((()=>e)),rp(of(t.picker)))))),n.hoverHighlightEnabledSubject.subscribe((()=>{this.enabled&&(this.enabled=!1,this.enabled=!0)}))}get name(){return"selection"}_onSelectionTap(t){const e=t.intersection,i=t.originalEvent,n=i.shiftKey||i.ctrlKey||i.metaKey||i.altKey?"addSubtract":this.mode;if(!e||!e.object)return void("replace"===n&&(this._selection.clear(),this.onChange&&this.onChange(void 0,void 0,n)));const r=e.model;if(!r||!r.isSelectable)return;const s=this._selection.get(r.name),o=s&&void 0!==s.find((t=>e.id===t));this.applySelection(r,e,o,n)}async applySelection(t,e,i,n){if("replace"===n&&i)return;n="addSubtract"===n?i?"subtract":"add":n;let r=e.childrenIds||[e.id];this.onChange&&(r=await this.onChange(t.name,r,n)),"subtract"===n?this._selection.subtract(t.name,r):"add"===n?this._selection.add(t.name,r):this._selection.setOnly(t.name,r)}_onPickTap(t){const e={screenPosition:{x:t.x,y:t.y},worldPosition:t.intersection?t.intersection.point:null,mouseButton:t.mouseButton,touchCount:t.touchCount};t.intersection&&t.intersection.model&&(e.modelId=t.intersection.model.name,e.id=t.intersection.id,e.childrenIds=t.intersection.childrenIds,e.face=t.intersection.face),this._eventDispatcher.picked(e)}clearHover(){this.lastHoverIntersection&&(this.lastHoverIntersection.model.setHovered(null),this.lastHoverIntersection=null)}_onHover(t){if(t.anyMouseButtonDown||t.touchCount>0)return void this.clearHover();const e=t.intersection;if(!e||!e.model)return void this.clearHover();if(this.lastHoverIntersection&&this.lastHoverIntersection.model===e.model&&this.lastHoverIntersection.id===e.id)return;this.clearHover();const i=e.model;i.setHovered&&(i.setHovered(t),this.lastHoverIntersection=e)}set enabled(t){this._tapsSubscription&&(this._tapsSubscription.unsubscribe(),this._tapsSubscription=null),this._moveSubscription&&(this._moveSubscription.unsubscribe(),this._moveSubscription=null),t&&(this._settings.hoverHighlightEnabled&&(this._moveSubscription=this._inputs.pointerMove$.pipe(rp(of(this._inputs.picker))).subscribe((t=>this._onHover(t)))),this._tapsSubscription=this._tapsObservable.subscribe((t=>{(t.mouseButton===this.mouseButton||t.isTouch)&&this._onSelectionTap(t),this._onPickTap(t)})))}get enabled(){return!!this._tapsSubscription}}class Hf extends hf{constructor(t,e,i,n){super(),this._inputs=t,this._selection=e,this._settings=i,this._tools=n,this._conflictingTools=[],this.mode="replace",this.touchCount=1,this.mouseButton=0,this._dragBehavior=t.pointerDown$.pipe(Cp((t=>!Kp(t))),Cp(tf(this.mouseButton,this.touchCount)),pp((t=>this._downCallback(t))),Ip((()=>t.pointerMove$.pipe(Bp(nf(t,this.mouseButton,this.touchCount))))),pp((t=>this._moveCallback(t))),Ip((()=>t.pointerUp$)),pp((t=>this._upCallback(t)))),this._cancelBehavior=this._inputs.keyDown$.pipe(Cp((t=>"Escape"===t.key)),pp((()=>this._cancel()))),this._createSelectionRectangle(),this._startPoint=new ce,this._pointBottomRight=new ce,this._pointTopLeft=new ce}get name(){return"areaSelection"}_cancel(){this.enabled=!1,this._removeSelectionRectangle(),this.onFinished()}_createSelectionRectangle(){this._selectionRectangle=document.createElement("div"),this._selectionRectangle.style.pointerEvents="none",this._selectionRectangle.style.zIndex="9999",this._selectionRectangle.style.opacity="0.2",this._selectionRectangle.style.position="fixed"}_downCallback(t){this._startPoint.set(t.x,t.y),this._pointTopLeft.set(t.x,t.y),this._pointBottomRight.set(t.x,t.y),this._addSelectionRectangle(t)}_addSelectionRectangle(t){this._selectionRectangle.style.left=t.x+"px",this._selectionRectangle.style.top=t.y+"px",this._selectionRectangle.style.width="0px",this._selectionRectangle.style.height="0px",this._selectionRectangle.style.border="1px solid #"+dd(this._settings.color).getHexString(),this._inputs.container.appendChild(this._selectionRectangle)}_moveCallback(t){this._pointBottomRight.x=Math.max(this._startPoint.x,t.x),this._pointBottomRight.y=Math.max(this._startPoint.y,t.y),this._pointTopLeft.x=Math.min(this._startPoint.x,t.x),this._pointTopLeft.y=Math.min(this._startPoint.y,t.y),this._updateSelectionRectangle()}_updateSelectionRectangle(){this._selectionRectangle.style.left=this._pointTopLeft.x+"px",this._selectionRectangle.style.top=this._pointTopLeft.y+"px",this._selectionRectangle.style.width=this._pointBottomRight.x-this._pointTopLeft.x+"px",this._selectionRectangle.style.height=this._pointBottomRight.y-this._pointTopLeft.y+"px"}async _upCallback(t){const e=await this._inputs.picker.getIntersectionFromScreenRect(this._pointTopLeft,this._pointBottomRight);this._selectFromEvent(t,e),this._cancel()}_removeSelectionRectangle(){this._inputs.container.contains(this._selectionRectangle)&&this._inputs.container.removeChild(this._selectionRectangle)}_disableConflictingTools(){for(const t in this._tools){if(!this._tools.hasOwnProperty(t))continue;const e=this._tools[t];void 0!==e.mouseButton&&void 0!==e.touchCount&&e!==this&&(!e.enabled||e.mouseButton!==this.mouseButton&&e.touchCount!==this.touchCount||(e.enabled=!1,this._conflictingTools.push(e)))}}_enableConflictingTools(){for(const t of this._conflictingTools)t.enabled=!0;this._conflictingTools=[]}set enabled(t){t?this._disableConflictingTools():this._enableConflictingTools(),this._dragHandle&&(this._dragHandle.unsubscribe(),this._dragHandle=null,this._cancelHandle.unsubscribe()),t&&(this._dragHandle=this._dragBehavior.subscribe(),this._cancelHandle=this._cancelBehavior.subscribe())}get enabled(){return!!this._dragHandle}_selectFromEvent(t,e){const i=t.originalEvent,n=i.shiftKey||i.ctrlKey||i.metaKey?"add":i.altKey?"subtract":this.mode;"replace"===n&&(this._selection.clear(),this.onChange&&this.onChange(void 0,void 0,n));for(const t of e){const e=t.model;e&&e.isSelectable&&this.applySelection(e,t.childrenIds,n)}}async applySelection(t,e,i){this.onChange&&(e=await this.onChange(t.name,e,i)),"subtract"===i?this._selection.subtract(t.name,e):this._selection.add(t.name,e)}}class Gf{get(t){for(const e in this)if(this.hasOwnProperty(e)&&this[e]instanceof t)return this[e]}}class Wf{constructor(t){this._api=t,this.tools=new Gf,this._camera=this._api.camera,this.addTool(new zf(this._api.inputHandler,t.camera,t.models.worldBoundingBox)),this.addTool(new Vf(this._api.inputHandler,t.camera)),this.addTool(new cf(this._api.inputHandler,t.camera,t.container)),this.addTool(new Bf(this._api)),this.addTool(new kf(this._api)),this.addTool(new jf(this._api.inputHandler,t.selection,t.eventDispatcher,t.settings)),this.addTool(new Hf(this._api.inputHandler,t.selection,this._api.settings,this.tools)),this.activateDefaultTool(),this._startEmittingNavigationEvents()}_startEmittingNavigationEvents(){let t=!1;this._api.camera.pipe(pp((()=>{t||this._api.eventDispatcher.navigation(!0),t=!0})),lf(200),pp((()=>{this._api.eventDispatcher.navigation(!1),t=!1}))).subscribe()}addTool(t){if(this.tools.hasOwnProperty(t.name))throw new Error(`Tool ${t.name} already exists`);this.tools[t.name]=t,t.onFinished=()=>this.activateDefaultTool()}activateDefaultTool(){this.activeTool="selection"}set activeTool(t){this._activeTool&&(this._activeTool.enabled=!1),this._activeTool=this.tools[t],this._activeTool.enabled=!0,this._api.eventDispatcher.dispatch(new CustomEvent("active-tool-changed"))}get activeTool(){return this._activeTool.name}}var qf,Xf,Yf,Zf={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 texel = texture2D( tDiffuse, vUv );","\tgl_FragColor = opacity * texel;","}"].join("\n")};function $f(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}Object.assign($f.prototype,{setSize:function(){},render:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}),$f.FullScreenQuad=(qf=new Oc(-1,1,1,-1,0,1),Xf=new ar(2,2),Yf=function(t){this._mesh=new In(Xf,t)},Object.defineProperty(Yf.prototype,"material",{get:function(){return this._mesh.material},set:function(t){this._mesh.material=t}}),Object.assign(Yf.prototype,{dispose:function(){this._mesh.geometry.dispose()},render:function(t){t.render(this._mesh,qf)}}),Yf);var Jf=function(t,e){$f.call(this),this.textureID=void 0!==e?e:"tDiffuse",t instanceof Wn?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=Gn.clone(t.uniforms),this.material=new Wn({defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new $f.FullScreenQuad(this.material)};Jf.prototype=Object.assign(Object.create($f.prototype),{constructor:Jf,render:function(t,e,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}});var Qf=function(t,e){$f.call(this),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1};Qf.prototype=Object.assign(Object.create($f.prototype),{constructor:Qf,render:function(t,e,i){var n,r,s=t.getContext(),o=t.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0),this.inverse?(n=0,r=1):(n=1,r=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.buffers.stencil.setFunc(s.ALWAYS,n,4294967295),o.buffers.stencil.setClear(r),o.buffers.stencil.setLocked(!0),t.setRenderTarget(i),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(s.EQUAL,1,4294967295),o.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.buffers.stencil.setLocked(!0)}});var Kf=function(){$f.call(this),this.needsSwap=!1};Kf.prototype=Object.create($f.prototype),Object.assign(Kf.prototype,{render:function(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}});var tm=function(t,e){if(this.renderer=t,void 0===e){var i={minFilter:yt,magFilter:yt,format:Ft,stencilBuffer:!1},n=t.getSize(new ce);this._pixelRatio=t.getPixelRatio(),this._width=n.width,this._height=n.height,(e=new xe(this._width*this._pixelRatio,this._height*this._pixelRatio,i)).texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===Zf&&console.error("THREE.EffectComposer relies on CopyShader"),void 0===Jf&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Jf(Zf),this.clock=new cl};Object.assign(tm.prototype,{swapBuffers:function(){var t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t},addPass:function(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)},insertPass:function(t,e){this.passes.splice(e,0,t)},isLastEnabledPass:function(t){for(var e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0},render:function(t){void 0===t&&(t=this.clock.getDelta());var e,i,n=this.renderer.getRenderTarget(),r=!1,s=this.passes.length;for(i=0;i<s;i++)if(!1!==(e=this.passes[i]).enabled){if(e.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),e.render(this.renderer,this.writeBuffer,this.readBuffer,t,r),e.needsSwap){if(r){var o=this.renderer.getContext(),a=this.renderer.state.buffers.stencil;a.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),a.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==Qf&&(e instanceof Qf?r=!0:e instanceof Kf&&(r=!1))}this.renderer.setRenderTarget(n)},reset:function(t){if(void 0===t){var e=this.renderer.getSize(new ce);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(t,e){this._width=t,this._height=e;var i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(var r=0;r<this.passes.length;r++)this.passes[r].setSize(i,n)},setPixelRatio:function(t){this._pixelRatio=t,this.setSize(this._width,this._height)}});var em=function(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1};Object.assign(em.prototype,{setSize:function(){},render:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}),em.FullScreenQuad=function(){var t=new Oc(-1,1,1,-1,0,1),e=new ar(2,2),i=function(t){this._mesh=new In(e,t)};return Object.defineProperty(i.prototype,"material",{get:function(){return this._mesh.material},set:function(t){this._mesh.material=t}}),Object.assign(i.prototype,{dispose:function(){this._mesh.geometry.dispose()},render:function(e){e.render(this._mesh,t)}}),i}();class im{constructor(t){this.api=t,this._update=(()=>()=>this.api.camera.next(this.api.camera.value))()}static async isVRAvailable(){return"xr"in navigator&&(navigator.xr&&await navigator.xr.isSessionSupported("immersive-vr"))}async isAvailable(){return im.isVRAvailable()}set enabled(t){if(t===this.enabled)return;const e=this.api.toolManager.tools.get(kf);this.api.renderingManager.renderer.xr.enabled=t,t?navigator.xr.requestSession("immersive-vr",{optionalFeatures:["local-floor","bounded-floor"]}).then((t=>{this.session=t,this.api.renderingManager.renderer.xr.setSession(t),this.api.renderingManager.addAnimationFrameListener(this._update),this.api.renderingManager.addAnimationFrameListener(e.update),this.origOrderIndependentTransparency=this.api.settings.orderIndependentTransparency,this.api.settings.orderIndependentTransparency=!1;const i=ad(this.api.camera.getWorldDirection(new pe),this.api.camera.up);i.x=Math.PI/2,this.api.camera.rotateSpherical(this.api.camera.position,xd.zero,i),e.enabled=!0})):(e.enabled=!1,this.api.renderingManager.removeAnimationFrameListener(this._update),this.api.renderingManager.removeAnimationFrameListener(e.update),this.api.settings.orderIndependentTransparency=this.origOrderIndependentTransparency,this.session.end(),this.session=void 0)}get enabled(){return!(!this.session||!this.api.renderingManager.renderer.xr.isPresenting)}toVRCamera(t){return t instanceof Xn&&this.enabled?this.api.renderingManager.renderer.xr.getCamera(t):t}}class nm extends $f{constructor(){super(...arguments),this._renderToScreen=!0}get renderToScreen(){return this._renderToScreen}set renderToScreen(t){}setRenderToScreen(t){this._renderToScreen=t}}class rm extends $f{constructor(t,e){super(),this._renderToScreen=e,this.scene=new Ze,this.camera=new Oc(-1,1,1,-1,0,1),this.setFullscreenMaterial(t)}get renderToScreen(){return this._renderToScreen}set renderToScreen(t){}getFullscreenMaterial(){return null!==this.screen?this.screen.material:null}setFullscreenMaterial(t){let e=this.screen;e?e.material=t:(e=new In(function(){if(!sm){const t=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]);sm=new fn,sm.setAttribute("position",new Yi(t,3)),sm.setAttribute("uv",new Yi(e,2))}return sm}(),t),e.frustumCulled=!1,this.scene||(this.scene=new Ze),this.scene.add(e),this.screen=e)}render(t,e,i){t.setRenderTarget(this.renderToScreen?null:i),t.render(this.scene,this.camera)}}let sm;class om extends nm{constructor(t,e,i,n){super(),this.renderingManager=t,this.settings=e,this.scene=i,this.camera=n,this.globalOpacity=1,this.peelsCount=2,this.peelRenderTargets=[],this.depthTextures=[],e.orderIndependentTransparencySubject.subscribe((()=>t.redraw())),t.uniforms.depthPeelingEnabled.value=Number(this.depthPeelingEnabled);for(let e=0;e<this.peelsCount;e++)this.peelRenderTargets.push(new xe(t.width,t.height,{format:Ft,type:Mt})),this.depthTextures.push(new sa(void 0,void 0,t.isWebgl2()?Et:St)),this.peelRenderTargets[e].depthTexture=this.depthTextures[e];this.combinePeelsPass=new rm(this.createCombinePeelsMaterial(),!1),this.renderingManager.uniforms.depthPrecisionFix.value=t.isWebgl2()?0:1e-5}get depthPeelingEnabled(){return this.settings.orderIndependentTransparency&&this.renderingManager.isFragDepthAvailable()&&this.renderingManager.isDepthTextureAvailable()}createCombinePeelsMaterial(){const t=new Wn({uniforms:{inputBuffer:{value:null},depthBuffer:{value:null}},vertexShader:"\n                varying vec2 vUv;\n                \n                void main() {\n                    vUv = uv;\n                    gl_Position = vec4(position.xy, 0.0, 1.0);\n                }\n            ",fragmentShader:"\n                varying vec2 vUv;\n                uniform sampler2D inputBuffer;\n                uniform sampler2D depthBuffer;\n\n                void main() {\n                    gl_FragDepthEXT = texture2D(depthBuffer, vUv).r;\n                    gl_FragColor = texture2D(inputBuffer, vUv);\n                }\n            ",transparent:!0,depthTest:!0,depthWrite:!1});return t.extensions.fragDepth=!0,t}setBackgroundMaterial(t){const e=t.renderLists.get(this.scene,this.camera);e.opaque&&e.opaque.length&&(this.backgroundMaterial=e.opaque[0].material)}getBackgroundMaterial(){return this.backgroundMaterial}renderWithDepthPeeling(t,e){this.renderingManager.traverseMaterials(((t,e)=>e.visible=e.isDepthPeelingMaterial&&(e.transparent||this.globalOpacity<1))),this.renderingManager.uniforms.globalTransparent=!1;const i=this.scene.background;this.scene.background=null,t.setClearColor(0,0);for(let e=0;e<this.peelsCount;e++)this.renderingManager.uniforms.depthPeelingEnabled.value=Number(e>0),this.renderingManager.uniforms.peelingDepthTexture.value=0===e?null:this.depthTextures[e-1],t.setRenderTarget(this.peelRenderTargets[e]),t.clear(),t.render(this.scene,this.camera);this.scene.background=i,this.renderingManager.uniforms.globalTransparent=void 0,this.renderingManager.uniforms.depthPeelingEnabled.value=Number(!0),this.renderingManager.uniforms.peelingDepthTexture.value=this.depthTextures[this.peelsCount-1],this.renderingManager.traverseMaterials(((t,e)=>e.visible=e.depthTest)),this.renderTraditional(t,e),this.renderingManager.uniforms.depthPeelingEnabled.value=Number(!1),this.renderingManager.uniforms.peelingDepthTexture.value=null,this.setBackgroundMaterial(t);for(let i=this.peelsCount-1;i>=0;i--)this.combinePeelsPass.getFullscreenMaterial().uniforms.inputBuffer.value=this.peelRenderTargets[i].texture,this.combinePeelsPass.getFullscreenMaterial().uniforms.depthBuffer.value=this.depthTextures[i],this.combinePeelsPass.render(t,void 0,e);this.scene.background=null,this.renderingManager.traverseMaterials(((t,e)=>e.visible=!e.depthTest)),this.renderTraditional(t,e),this.scene.background=i,this.renderingManager.traverseMaterials(((t,e)=>e.visible=!0))}renderTraditional(t,e){this.renderingManager.uniforms.globalTransparent=this.globalOpacity<1||void 0,t.autoClear=!1,t.setRenderTarget(e),e&&this.scene.background&&t.clearDepth(),t.render(this.scene,this.camera),this.renderingManager.uniforms.globalTransparent=void 0}setSize(t,e){for(let i=0;i<this.peelsCount;i++)this.peelRenderTargets[i].setSize(t,e)}render(t,e,i){this.renderingManager.uniforms.globalOpacity.value=this.globalOpacity;const n=this.renderToScreen?null:i;this.depthPeelingEnabled?this.renderWithDepthPeeling(t,n):(this.renderTraditional(t,n),this.setBackgroundMaterial(t))}}const am=/iPhone/i,hm=/iPod/i,cm=/iPad/i,lm=/\bAndroid(?:.+)Mobile\b/i,um=/Android/i,dm=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,pm=/Silk/i,fm=/Windows Phone/i,mm=/\bWindows(?:.+)ARM\b/i,gm=/BlackBerry/i,vm=/BB10/i,bm=/Opera Mini/i,ym=/\b(CriOS|Chrome)(?:.+)Mobile/i,_m=/Mobile(?:.+)Firefox\b/i;function xm(t,e){return t.test(e)}class wm{constructor(t,e={}){this.camera=new Xn(90,1,.1,10),this.scene=new Ze,this.material=this.createMaterial(t),this.boxMesh=new In(new kn(1,1,1),this.material),this.scene.add(this.boxMesh),this.resolution=e.resolution||1024,this.views=[{t:[1,0,0],u:[0,-1,0]},{t:[-1,0,0],u:[0,-1,0]},{t:[0,1,0],u:[0,0,1]},{t:[0,-1,0],u:[0,0,-1]},{t:[0,0,1],u:[0,-1,0]},{t:[0,0,-1],u:[0,-1,0]}];const i={format:e.format||t.format,magFilter:t.magFilter,minFilter:t.minFilter,type:e.type||t.type,generateMipmaps:t.generateMipmaps,anisotropy:t.anisotropy,encoding:t.encoding};this.renderTarget=new $n(this.resolution,this.resolution,i)}createMaterial(t){const e=new Wn({uniforms:{equirectangularMap:{value:t}},vertexShader:"\n\t\t\t    varying vec3 localPosition;\n        \n                void main() {\n                  localPosition = position;\n                  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n                }\n            ",fragmentShader:"\n\t\t\t\t#include <common>\n                varying vec3 localPosition;\n                uniform sampler2D equirectangularMap;\n                \n                vec2 EquirectangularSampleUV(vec3 v) {\n                  vec2 uv = vec2(atan(v.z, v.x), asin(v.y));\n                  uv *= vec2(0.1591, 0.3183); // inverse atan\n                  uv += 0.5;\n                  return uv;\n                }\n                \n                void main() {\n                  vec2 uv = EquirectangularSampleUV(normalize(localPosition));\n                  gl_FragColor = texture2D(equirectangularMap, uv);\n                }\n            ",blending:0,side:1});return e.type="EquirectangularToCubeGenerator",e}update(t){const e=t.getRenderTarget();for(let e=0;e<6;e++){const i=this.views[e];this.camera.position.set(0,0,0),this.camera.up.set(i.u[0],i.u[1],i.u[2]),this.camera.lookAt(i.t[0],i.t[1],i.t[2]),t.setRenderTarget(this.renderTarget,e),t.clear(),t.render(this.scene,this.camera)}return t.setRenderTarget(e),this.renderTarget}dispose(){this.renderTarget.dispose()}}class Mm{constructor(t,e,i){this.renderingManager=t,this.api=e,nr.cube.vertexShader="\n            uniform mat4 rotMatrix;\n            varying vec3 vWorldDirection; \n            #include <common>\n            void main() {\n                vWorldDirection = transformDirection(position, rotMatrix);\n                // coordinate system correction, Z is up\n                vWorldDirection = vec3(-vWorldDirection.x, vWorldDirection.z, vWorldDirection.y);\n                #include <begin_vertex>\n                #include <project_vertex>\n                gl_Position.z = gl_Position.w; // set z to camera.far\n            }\n        ";const n=new Oe(0,0,0);nr.cube.uniforms.rotMatrix=new zl(new Le),e.settings.backgroundRotationSubject.subscribe((e=>{n.z=e*Math.PI/180;const r=i.getBackgroundMaterial();if(r){r.uniforms.rotMatrix.value.makeRotationFromEuler(n),t.redraw()}})),e.settings.backgroundSubject.subscribe((()=>{this.update(),t.redraw()}))}update(){this.renderingManager.renderer.setClearColor("#FFFFFF"),this.api.scene.background=this.toColor(this.api.settings.background)||this.toGradient(this.api.settings.background)||this.toSkybox(this.api.settings.background)||this.toTexture(this.api.settings.background)}toGradient(t){const e=t;if(e.topColor&&e.bottomColor){const t=document.createElement("canvas");t.width=1,t.height=2;const i=t.getContext("2d");i.fillStyle="#"+dd(e.topColor).getHexString(),i.fillRect(0,0,1,1),i.fillStyle="#"+dd(e.bottomColor).getHexString(),i.fillRect(0,1,1,1);const n=this.toTexture(t);return n.repeat.y=(t.height-1)/t.height,n.offset.y=.5/t.height,n}}toColor(t){return dd(t)}toTexture(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){const e=new ye(t);return e.needsUpdate=!0,e}}toSkybox(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){if(4*t.height==3*t.width){const e=new yr(this.getImagesFromSkyboxAtlas(t));return e.needsUpdate=!0,e}if(2*t.height===t.width){const e=new ye(t);e.needsUpdate=!0;return new wm(e,{resolution:this.nearestPow2(.6*t.height)}).update(this.renderingManager.renderer)}}else if(t instanceof Array){const e=new yr(t);return e.needsUpdate=!0,e}}nearestPow2(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.log(2)))}getImagesFromSkyboxAtlas(t){const e=[],i=t,n=i.height/3;for(let t=0;t<6;t++){const r=document.createElement("canvas"),s=r.getContext("2d");r.height=n,r.width=n,0===t&&s.drawImage(i,2*n,n,n,n,0,0,n,n),1===t&&s.drawImage(i,0,n*t,n,n,0,0,n,n),2===t&&s.drawImage(i,n,0,n,n,0,0,n,n),3===t&&s.drawImage(i,n,2*n,n,n,0,0,n,n),4===t&&s.drawImage(i,n,n,n,n,0,0,n,n),5===t&&s.drawImage(i,3*n,n,n,n,0,0,n,n),e.push(r)}return e}}var Tm=function(t,e,i,n,r){$f.call(this),this.scene=t,this.camera=e,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1};Tm.prototype=Object.assign(Object.create($f.prototype),{constructor:Tm,render:function(t,e,i){var n,r,s=t.autoClear;t.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial,this.clearColor&&(n=t.getClearColor().getHex(),r=t.getClearAlpha(),t.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:i),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor&&t.setClearColor(n,r),this.scene.overrideMaterial=null,t.autoClear=s}});class Sm extends Wn{constructor(t=new ce){super({uniforms:{maskTexture:new zl(null),texelSize:new zl(new ce)},fragmentShader:"\n    uniform sampler2D maskTexture;\n    varying vec2 vUv0;\n    varying vec2 vUv1;\n    varying vec2 vUv2;\n    varying vec2 vUv3;\n    \n    void main(){\n        vec2 c0=texture2D(maskTexture,vUv0).rg;\n        vec2 c1=texture2D(maskTexture,vUv1).rg;\n        vec2 c2=texture2D(maskTexture,vUv2).rg;\n        vec2 c3=texture2D(maskTexture,vUv3).rg;\n        float d0=(c0.x-c1.x)*0.5;\n        float d1=(c2.x-c3.x)*0.5;\n        float d=length(vec2(d0,d1));\n        float a0=min(c0.y,c1.y);\n        float a1=min(c2.y,c3.y);\n        float visibilityFactor=min(a0,a1);\n        gl_FragColor.rg=(1.0-visibilityFactor>0.001)? vec2(d,0.0): vec2(0.0,d);\n    }\n",vertexShader:"\n    uniform vec2 texelSize;\n    varying vec2 vUv0;\n    varying vec2 vUv1;\n    varying vec2 vUv2;\n    varying vec2 vUv3;\n    \n    void main(){\n        vec2 uv=position.xy*0.5+0.5;\n        vUv0=vec2(uv.x+texelSize.x,uv.y);\n        vUv1=vec2(uv.x-texelSize.x,uv.y);\n        vUv2=vec2(uv.x,uv.y+texelSize.y);\n        vUv3=vec2(uv.x,uv.y-texelSize.y);\n        gl_Position=vec4(position.xy,1.0,1.0);\n    }\n",depthWrite:!1,depthTest:!1}),this.setTexelSize(t.x,t.y)}setTexelSize(t,e){this.uniforms.texelSize.value.set(t,e)}}class Em extends rm{constructor(t){const e=new Wn({uniforms:{},vertexShader:"\n                varying vec2 vUv;\n\n                void main() {\n                    vUv = uv;\n                    gl_Position = vec4(position.xy, 0.0, 1.0);\n                }\n            ",fragmentShader:"\nvarying vec2 vUv;    \n    \nuniform sampler2D edgeTexture;\nuniform sampler2D maskTexture;\n\nuniform vec3 color;\nuniform float edgeStrength;\nuniform float fillStrength;\n\nvoid main() {\n\tfloat edge = texture2D(edgeTexture, vUv).r;\n\tfloat mask = texture2D(maskTexture, vUv).r;\n\n\tedge = clamp(edge * edgeStrength * mask, 0.0, 1.0);\n\tmask = (1.0 - mask) * fillStrength;\n    gl_FragColor = vec4(color, edge + mask);\n}\n",transparent:!0,depthTest:!1,depthWrite:!1});super(e,!0),e.transparent=!0,e.uniforms.maskTexture=new zl(null),e.uniforms.edgeTexture=new zl(null),e.uniforms.edgeStrength=new zl(5),e.uniforms.fillStrength=new zl(.25),e.uniforms.color=new zl(dd(16763904)),this.selectionScene=new Ze,this.renderTargetMask=new xe(1,1,{minFilter:yt,magFilter:yt}),this.renderTargetMask.texture.generateMipmaps=!1,this.renderTargetMask.texture.format=Ot,this.renderTargetMask.texture.name="Outline.Mask",this.getFullscreenMaterial().uniforms.maskTexture.value=this.renderTargetMask.texture,this.renderTargetEdges=new xe(1,1,{minFilter:yt,magFilter:yt,stencilBuffer:!1,depthBuffer:!1,format:Ot}),this.renderTargetEdges.texture.name="Outline.Edges",this.renderTargetEdges.texture.generateMipmaps=!1,this.getFullscreenMaterial().uniforms.edgeTexture.value=this.renderTargetEdges.texture,this.maskPass=new Tm(this.selectionScene,t.value),this.maskPass.clearColor=new Ui(16777215),this.maskPass.clearAlpha=1,t.subscribe((t=>this.maskPass.camera=t)),this.maskMaterial=new qi({color:0,side:2}),this.outlineEdgesPass=new rm(new Sm,!1),this.outlineEdgesPass.getFullscreenMaterial().uniforms.maskTexture.value=this.renderTargetMask.texture,this.shouldClear=!0}getId(t){return t.userData&&void 0!==t.userData.id?t.userData.id.toString():""}addObject(t,e,i){let n=this.selectionScene.getObjectByName(t+this.getId(e));n||(n=e.clone(!1),n.name=t+this.getId(e),n.matrixAutoUpdate=!1,n.matrix=e.matrixWorld,n.geometry=new fn,n.material=e instanceof ta?e.material:[this.maskMaterial],this.selectionScene.add(n));const r=n.geometry,s=e.geometry;r.setIndex(s.getIndex()),r.setAttribute("position",s.getAttribute("position")),n instanceof ta&&(r.setAttribute("pointUv",s.getAttribute("pointUv")),s.getAttribute("pointSize")&&r.setAttribute("pointSize",s.getAttribute("pointSize"))),r.clearGroups();for(const t of i)r.addGroup(t.start,t.count,0);return this}removeObject(t,e){return this.removeObjectById(t,this.getId(e))}removeObjectById(t,e){const i=this.selectionScene.getObjectByName(t+e.toString());return this.selectionScene.remove(i),0===this.selectionScene.children.length&&(this.shouldClear=!0),this}render(t,e,i){(this.selectionScene.children.length>0||this.shouldClear)&&(this.maskPass.render(t,void 0,this.renderTargetMask,void 0,void 0),this.outlineEdgesPass.render(t,void 0,this.renderTargetEdges),super.render(t,void 0,void 0),this.shouldClear=!1)}setSize(t,e){this.renderTargetMask.setSize(t,e);const i=t/window.devicePixelRatio*.9,n=e/window.devicePixelRatio*.9;this.maskPass.setSize(i,n),this.renderTargetEdges.setSize(i,n),this.outlineEdgesPass.getFullscreenMaterial().setTexelSize(2.4/t*window.devicePixelRatio,2.4/e*window.devicePixelRatio),this.shouldClear=!0}}class Pm{constructor(t){this._api=t,this.onRenderListeners=[],this.animationFrameListeners=[],this.uniforms={viewSize:new zl(new ce(this.width,this.height)),pixelRatio:new zl(window.devicePixelRatio),globalOpacity:new zl(1),depthPeelingEnabled:new zl(Number(!1)),peelingDepthTexture:new zl(null),depthPrecisionFix:new zl(0)},this._nearPlaneMin=.05,this.fitNearAndFarPlanes=(()=>{const t=new pe;return(e,i,n)=>{const r=i,s=e.planes[4].normal;t.set(s.x<=0?n.max.x:n.min.x,s.y<=0?n.max.y:n.min.y,s.z<=0?n.max.z:n.min.z);const o=e.planes[4].distanceToPoint(t);r.far=r.far-o>0?1.05*(r.far-o):this._farPlaneDefault;const a=e.planes[5].normal;t.set(a.x<=0?n.max.x:n.min.x,a.y<=0?n.max.y:n.min.y,a.z<=0?n.max.z:n.min.z);const h=e.planes[5].distanceToPoint(t);r.near=Math.max(.95*(h+r.near),this._nearPlaneMin),r.updateProjectionMatrix()}})(),this.needsRedraw=!0,this._farPlaneDefault=1e4,this._camera=t.camera;const e=void 0===this._api.settings.antialias?window.devicePixelRatio<=1&&!this.isMobile():this._api.settings.antialias;this._api.settings.antialiasSubject.subscribe((()=>{if(this.composer)throw new Error("Unable to change antialiasing at runtime")}));const i=this._api.container.children[0],n={antialias:e,stencil:!1,alpha:!1,powerPreference:"high-performance",xrCompatible:!0};let r;t.settings.useWebgl2&&(r=i.getContext("webgl2",n)),r||(r=i.getContext("webgl",n));const s={canvas:i,context:r};this.composer=this.initializeRenderer(s),window.addEventListener("focus",(()=>this.updateCanvasSize(!0)),!1),this._api.camera.subscribe((()=>{this._boundingBox&&!this._boundingBox.isEmpty()&&this.fitNearAndFarPlanes(this._api.camera.frustum,this._api.camera.value,this._boundingBox),this.redraw()})),this._api.models.worldBoundingBox.subscribe((t=>{t.isEmpty()||(this._boundingBox=t,this.fitNearAndFarPlanes(this._api.camera.frustum,this._api.camera.value,this._boundingBox),this.redraw())})),this._api.settings.logarithmicDepthBufferSubject.subscribe((t=>{this.logarithmicDepthBuffer=t,this._api.camera.next(this._api.camera.value)}))}isMobile(){return void 0===this._isMobile&&(this._isMobile=function(t){let e=(t=t||("undefined"!=typeof navigator?navigator.userAgent:"")).split("[FBAN");void 0!==e[1]&&(t=e[0]),e=t.split("Twitter"),void 0!==e[1]&&(t=e[0]);const i={apple:{phone:xm(am,t)&&!xm(fm,t),ipod:xm(hm,t),tablet:!xm(am,t)&&xm(cm,t)&&!xm(fm,t),device:(xm(am,t)||xm(hm,t)||xm(cm,t))&&!xm(fm,t)},amazon:{phone:xm(dm,t),tablet:!xm(dm,t)&&xm(pm,t),device:xm(dm,t)||xm(pm,t)},android:{phone:!xm(fm,t)&&xm(dm,t)||!xm(fm,t)&&xm(lm,t),tablet:!xm(fm,t)&&!xm(dm,t)&&!xm(lm,t)&&(xm(pm,t)||xm(um,t)),device:!xm(fm,t)&&(xm(dm,t)||xm(pm,t)||xm(lm,t)||xm(um,t))||xm(/\bokhttp\b/i,t)},windows:{phone:xm(fm,t),tablet:xm(mm,t),device:xm(fm,t)||xm(mm,t)},other:{blackberry:xm(gm,t),blackberry10:xm(vm,t),opera:xm(bm,t),firefox:xm(_m,t),chrome:xm(ym,t),device:xm(gm,t)||xm(vm,t)||xm(bm,t)||xm(_m,t)||xm(ym,t)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}().any),this._isMobile}isWebgl2(){return this.renderer.capabilities.isWebGL2}isFragDepthAvailable(){return this.isWebgl2()||!!this.renderer.extensions.get("EXT_frag_depth")}isDepthTextureAvailable(){return this.isWebgl2()||!!this.renderer.extensions.get("WEBGL_depth_texture")}isHalfFloatTextureTypeAvailable(){return this.isWebgl2()||!!this.renderer.extensions.get("OES_texture_half_float")}get globalOpacity(){return this._renderPass.globalOpacity}set globalOpacity(t){this._renderPass.globalOpacity=t,this.redraw()}redraw(){this.needsRedraw=!0}addOnRenderListener(t){this.onRenderListeners.push(t)}removeOnRenderListener(t){this.onRenderListeners.splice(this.onRenderListeners.indexOf(t),1)}addAnimationFrameListener(t){this.animationFrameListeners.push(t)}removeAnimationFrameListener(t){this.animationFrameListeners.splice(this.animationFrameListeners.indexOf(t),1)}start(){this.renderer.setAnimationLoop((t=>this._render(t)))}_render(t){this.vr.enabled||this.updateCanvasSize(),this.needsRedraw&&this.enabled&&(this.needsRedraw=!1,this.onRenderListeners.forEach((t=>t())),this.composer.render()),this.animationFrameListeners.forEach((e=>e(t)))}async screenshot(){return this.composer.render(),await new Promise((t=>{this.renderer.domElement.toBlob(t)}))}updateCanvasSize(t=!1){const e=this.renderer.domElement;if(e.height!==Math.floor(e.clientHeight*window.devicePixelRatio)||e.width!==Math.floor(e.clientWidth*window.devicePixelRatio)||t){this.renderer.setPixelRatio(window.devicePixelRatio),this.composer&&this.composer.setPixelRatio(window.devicePixelRatio),this.uniforms.pixelRatio.value=window.devicePixelRatio,this.uniforms.viewSize.value.x=this.width,this.uniforms.viewSize.value.y=this.height;const t=e.clientWidth/e.clientHeight;if(this._camera.value instanceof Xn){const e=this._camera.widestFov;this._camera.value.aspect=t,this._camera.widestFov=e}else this._camera.value instanceof Oc&&(this._camera.value.left=-this._camera.value.top*t,this._camera.value.right=this._camera.value.top*t);e.clientWidth>0&&e.clientHeight>0&&(this.composer.setSize(e.clientWidth,e.clientHeight),this.renderer.setSize(e.clientWidth,e.clientHeight,!1)),this._camera.updateProjectionMatrix(),this.redraw()}}initializeRenderer(t){this.enabled=!1,this.renderer=new io(t);const e=this.renderer.getContext();console.log(`Rendering: ${e.getParameter(e.VERSION)}, ${e.getParameter(e.SHADING_LANGUAGE_VERSION)}, ${e.getParameter(e.VENDOR)}, ${e.getParameter(e.getExtension("WEBGL_debug_renderer_info").UNMASKED_RENDERER_WEBGL)}`),this.vr=new im(this._api),this.updateCanvasSize(!0),this.enabled=!0;const i=new tm(this.renderer);return this._renderPass=new om(this,this._api.settings,this._api.scene,this._camera.value),this.backgroundManager=new Mm(this,this._api,this._renderPass),this._camera.subscribe((t=>this._renderPass.camera=t)),i.addPass(this._renderPass),this._api.selectionEffectPass=new Em(this._api.camera),i.addPass(this._api.selectionEffectPass),i}traverseMaterials(t){this._api.scene.traverse((e=>{const i=e;i.material&&(Array.isArray(i.material)&&i.material[0]?t(i,i.material[0]):t(i,i.material))}))}set logarithmicDepthBuffer(t){t=t&&this.isFragDepthAvailable();const e=this.logarithmicDepthBuffer;this.renderer.capabilities.logarithmicDepthBuffer=t,t!==e&&this.traverseMaterials(((t,e)=>e.needsUpdate=!0)),this._nearPlaneMin=this.logarithmicDepthBuffer?.002:.05}get logarithmicDepthBuffer(){return this.renderer.capabilities.logarithmicDepthBuffer}get width(){return this._api.container.clientWidth*window.devicePixelRatio}get height(){return this._api.container.clientHeight*window.devicePixelRatio}}class Am{constructor(t){this._element=t}error(t){const e={detail:t,bubbles:!0,composed:!0};console.error(t),this._element.dispatchEvent(new CustomEvent("error",e))}selected(t){const e=new CustomEvent("selection",{detail:t,bubbles:!0,composed:!0});this._element.dispatchEvent(e)}picked(t){const e=new CustomEvent("pick",{detail:t,bubbles:!0,composed:!0});this._element.dispatchEvent(e)}navigation(t){const e=new CustomEvent(t?"navigationstart":"navigationend",{bubbles:!0,composed:!0});this._element.dispatchEvent(e)}dragStart(){const t=new CustomEvent("dragstart",{bubbles:!0,composed:!0});this._element.dispatchEvent(t)}dispatch(t){this._element.dispatchEvent(t)}subscribe(t,e){this._element.addEventListener(t,e)}}class Cm{constructor(t){this._api=t,this._htmlObjects=new Set,t.renderingManager.addOnRenderListener((()=>this.update()))}addElement(t){this._htmlObjects.has(t)||(this._api.container.appendChild(t),this._htmlObjects.add(t))}removeElement(t){this._htmlObjects.has(t)&&(this._api.container.removeChild(t),this._htmlObjects.delete(t))}update(){const t=this._api.container.getBoundingClientRect();for(const e of this._htmlObjects)e.updatePosition(t)}}class Lm{constructor(t){this._worldBoundingBox=new ci,this.worldBoundingBox=new ff(this._worldBoundingBox),this.boundingboxes=new Set,this._models=new Set,this._modelContainer=new Ye,t.add(this._modelContainer)}addBoundingBox(t){return this.boundingboxes.has(t)?(this.recalcuateWorldBoundingBox(),!1):(t.subscribe((()=>this.recalcuateWorldBoundingBox())),this.boundingboxes.add(t),this._worldBoundingBox.union(t.value),this.worldBoundingBox.next(this._worldBoundingBox),!0)}removeBoundingBox(t){this.boundingboxes.has(t)&&this.boundingboxes.delete(t),this.recalcuateWorldBoundingBox()}add(t,e=!0){this.addBoundingBox(t.boundingBox)&&this._models.add(t),e&&this._modelContainer.add(t)}remove(t){this.removeBoundingBox(t.boundingBox),this._models.delete(t),this._modelContainer.remove(t)}get(t){return Array.from(this._models).find((e=>e.name===t))}getIterable(){return this._models.values()}recalcuateWorldBoundingBox(){this._worldBoundingBox.makeEmpty(),this.boundingboxes.forEach((t=>this._worldBoundingBox.union(t.value))),this.worldBoundingBox.next(this._worldBoundingBox)}}class Rm{constructor(){this.LUT=new Map}register(t,e,i){this.LUT.set(t,{load:e,unload:i})}}class Im extends Map{constructor(){super(...arguments),this.listeners=[]}startSelectionEventEmitter(t){this.subscribe((()=>{const e=Array.from(this.keys()).reduce(((t,e)=>t+this.get(e).length),0);t.selected({count:e})}))}setOnly(t,e){super.clear(),super.set(t,e),this.callListeners()}set(t,e){return super.set(t,e),this.callListeners(),this}delete(t){const e=super.delete(t);return this.callListeners(),e}add(t,e){e=this.has(t)?[...this.get(t),...e]:e;const i=new Set(e);if(this.has(t)){const e=[...i];super.set(t,e)}else super.set(t,[...i]);this.callListeners()}subtract(t,e){if(this.has(t)){const i=this.get(t).filter((t=>!e.includes(t)));i.length>0?this.set(t,i):this.delete(t)}this.callListeners()}clear(){super.clear(),this.callListeners()}callListeners(){this.listeners.forEach((t=>t()))}subscribe(t){this.listeners.push(t)}unsubscribe(t){this.listeners.splice(this.listeners.indexOf(t),1)}}class Om extends Ye{constructor(t){super(),super.name=t,this.boundingBox=new ff(new ci),this.up.copy(xd.up)}getBoundingBox(t){return Promise.resolve(this.boundingBox.value)}dispose(){}}class Fm{constructor(t,e){this.camera=t,this.container=e,this._clusters=[],this.tmpPosition=new pe,this.tmpScreenPosition=new pe,this.clusterRadius=120}get clustersCount(){return this._clustersCount}addPoint(t,e){if(this.tmpPosition.x=t.position.x,this.tmpPosition.y=t.position.y,this.tmpPosition.z=t.position.z,this.tmpScreenPosition.copy(this.tmpPosition),this.tmpPosition.sub(e),this.tmpScreenPosition.project(this.camera.value),this.tmpScreenPosition.x=(1+this.tmpScreenPosition.x)*this.container.clientWidth*.5,this.tmpScreenPosition.y=(1-this.tmpScreenPosition.y)*this.container.clientHeight*.5,this.tmpScreenPosition.x<0||this.tmpScreenPosition.x>this.container.clientWidth||this.tmpScreenPosition.y<0||this.tmpScreenPosition.y>this.container.clientHeight)return;let i=this.findClosestCluster(this.tmpScreenPosition);i?i.add(t.id,this.tmpPosition,this.tmpScreenPosition):this.positions.length>=3*(this._clustersCount+1)&&(this._clusters.length>this._clustersCount?i=this._clusters[this._clustersCount]:(i=new Bm(this._clustersCount),this._clusters.push(i)),i.reset(t,this.positions,this.tmpPosition,this.tmpScreenPosition),this._clustersCount++)}findClosestCluster(t){if(0===this._clustersCount)return null;function e(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}let i,n=null;for(let r=0;r<this._clustersCount;r++){const s=this._clusters[r],o=n?e(n.screenPosition,t):999999,a=e(s.screenPosition,t);(o<this.clusterRadius||a<this.clusterRadius)&&(i=a<o&&a<this.clusterRadius?s:n),n=s}return i}fillBadgeAttributes(t,e,i){let n=0;const r=1/i;for(let s=0;s<this.clustersCount;s++){const o=this._clusters[s];if(o.iconsCount>1){const s=3*n;t[s]=o.x,t[s+1]=o.y,t[s+2]=o.z;const a=4*n;e[a]=Math.min(o.iconsCount,i-1)*r,e[a+1]=0,e[a+2]=e[a]+r,e[a+3]=1,n++}}return n}getCluster(t){return this._clusters[t]}reset(t){this._clustersCount=0,this.positions=t}}class Bm{constructor(t){this.iconsCount=1,this.iconIds=[],this._screenPosition=new ce,this.index=3*t}get screenPosition(){return this._screenPosition}reset(t,e,i,n){this.positions=e,this.iconsCount=1,this.iconIds=[t.id],this._screenPosition.x=n.x,this._screenPosition.y=n.y,this.x=i.x,this.y=i.y,this.z=i.z,this.mainIcon=t}add(t,e,i){this.x=(this.x*this.iconsCount+e.x)/(this.iconsCount+1),this.y=(this.y*this.iconsCount+e.y)/(this.iconsCount+1),this.z=(this.z*this.iconsCount+e.z)/(this.iconsCount+1),this._screenPosition.x=(this._screenPosition.x*this.iconsCount+i.x)/(this.iconsCount+1),this._screenPosition.y=(this._screenPosition.y*this.iconsCount+i.y)/(this.iconsCount+1),this.iconIds.push(t),this.iconsCount++}set x(t){this.positions[this.index]=t}get x(){return this.positions[this.index]}set y(t){this.positions[this.index+1]=t}get y(){return this.positions[this.index+1]}set z(t){this.positions[this.index+2]=t}get z(){return this.positions[this.index+2]}}class Dm extends ta{constructor(t,e,i,n){super(new fn,n),this._camera=t,this._container=e,this.pointSize=i,this.sphere=new di,this.intersectPoint=new pe}raycast(t,e){const i=this.geometry,n=this.matrixWorld;if(null===i.boundingSphere&&i.computeBoundingSphere(),this.sphere.copy(i.boundingSphere),this.sphere.applyMatrix4(n),this.sphere.radius+=this._getWorldSize(this.sphere.center.distanceTo(this._camera.position)+this.sphere.radius),!1===t.ray.intersectsSphere(this.sphere))return;const r=new pe,s=this.geometry.attributes.position.array;for(let i=0,o=s.length/3;i<o;i++)r.fromArray(s,3*i),r.applyMatrix4(n),this._raycastPoint(r,i,t,e)}_getWorldSize(t){return this._camera.getViewWorldSize(t)*this.pointSize/this._container.clientWidth}_raycastPoint(t,e,i,n){const r=this._getWorldSize(t.distanceTo(this._camera.position));if(i.ray.distanceSqToPoint(t)<r*r){i.ray.closestPointToPoint(t,this.intersectPoint);const r=i.ray.origin.distanceTo(this.intersectPoint);if(r<i.near||r>i.far)return;n.push({distance:r,point:this.intersectPoint.clone(),index:e,face:null,object:this})}}}const zm="    \n    uniform int depthPeelingEnabled;\n    uniform int transparent;\n    uniform sampler2D peelingDepthTexture;\n    uniform float depthPrecisionFix;\n    uniform vec2 viewSize;\n    \n    void depthPeelingFragment() {\n        if (depthPeelingEnabled != 0 && transparent != 0) {\n            #if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n                float depth = gl_FragDepthEXT;\n            #else\n                float depth = gl_FragCoord.z;\n            #endif\n            float prevDepth = texture2D(peelingDepthTexture, gl_FragCoord.xy / viewSize).r;\n            if (prevDepth + depthPrecisionFix >= depth) discard;\n        }\n    }\n";class Nm extends Wn{constructor(t,e){super(t),this.isDepthPeelingMaterial=!0,this._globalUniforms=e,this.origOpacity=t.uniforms.opacity.value,this.origTransparent=t.transparent,delete this.transparent}get transparent(){return this._globalUniforms&&void 0!==this._globalUniforms.globalTransparent?this._globalUniforms.globalTransparent:this.origTransparent}set transparent(t){this.origTransparent=t}updateTransparency(){if(this._globalUniforms){this._globalUniforms.globalOpacity&&(this.uniforms.opacity.value=this.origOpacity*this._globalUniforms.globalOpacity.value);const t=this.origTransparent||void 0!==this._globalUniforms.globalTransparent;this.uniforms.transparent.value=Number(t),this.blending=t?1:0}}}class Um extends Nm{constructor(t,e){super(t,e),this.isViewerMaterial=!0,this.clipping=!0,this.alphaTest=.01,this.morphTargets=!1,this.lights=!1}setIntersection(t){this.clipIntersection=t,this.needsUpdate=!0}}const Vm=`\n#include <common>\n#include <color_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nuniform float opacity;\n${zm}\n\nvarying vec4 vUv; // vec4(leftUpUV, rightDownUV)\n\n#ifdef USE_SIZEBUFFER \n    varying vec4 vPointSize; // vec4(leftUpXY, rightDownXY) from BillboardGeometryBuilder\n    varying float pSize;\n#endif\n\nvoid main() {\n    #include <logdepthbuf_fragment>\n    #include <clipping_planes_fragment>\n    depthPeelingFragment();\n    \n\tvec4 diffuseColor = vec4(vec3(1.0), opacity);\n\n\tvec2 uv = vec2(gl_PointCoord.x * (vUv.z - vUv.x) + vUv.x, 1.0 - (gl_PointCoord.y * (vUv.w - vUv.y) + vUv.y));\n    #ifdef USE_SIZEBUFFER\n        vec2 realSize = vPointSize.zy - vPointSize.xw;\n        uv = uv * (pSize / realSize) - ((vPointSize.xw + pSize / 2.0) / realSize);\n        if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) discard;\n    #endif\n\tvec4 mapTexel = texture2D(map, uv);\n\tdiffuseColor *= mapTexelToLinear(mapTexel);\n\t\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\n\tgl_FragColor = diffuseColor;\n    \n\t#include <premultiplied_alpha_fragment>\n\t#include <encodings_fragment>\n}`;class km extends Um{constructor(t,e){const i=Object.assign(Gn.clone(nr.points.uniforms),{map:{type:"t",value:t.map},offset:{value:new ce},size:{value:t.size},opacity:{value:void 0!==t.opacity?t.opacity:1},transparent:{value:void 0!==t.transparent&&t.transparent}},e),n=Object.assign({uniforms:i,defines:{USE_MAP:!!t.map,USE_SIZEBUFFER:!!t.useSizeBuffer},vertexShader:"\nuniform float size;\nuniform float pixelRatio;\nuniform vec2 offset;\nuniform vec2 viewSize;\n\n#include <common>\n#include <color_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n// vec4(leftUpUV, rightDownUV)\nattribute vec4 pointUv;\nvarying vec4 vUv;\n\n#ifdef USE_SIZEBUFFER\n    // vec4(leftUpXY, rightDownXY) from BillboardGeometryBuilder\n    attribute vec4 pointSize; \n    varying vec4 vPointSize;\n\n    varying float pSize;\n#endif\n\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n    \n    gl_Position.xy += offset * vec2(viewSize.y / viewSize.x, 1.0) * gl_Position.w;\n\n    #ifdef USE_SIZEBUFFER\n        pSize = abs(max(max(-pointSize.x, -pointSize.y), max(pointSize.z, pointSize.w))) * 2.0;\n        vPointSize = pointSize;\n    #else\n        float pSize = size; \n    #endif\n\n    #ifdef USE_SIZEATTENUATION       \n\t\tgl_PointSize = viewSize.y * projectionMatrix[1][1] * pSize / gl_Position.w;\n\t#else\n\t\tgl_PointSize = pSize * pixelRatio;\n    #endif    \n    vUv = pointUv;\n\n\t#include <worldpos_vertex>\n\t#include <logdepthbuf_vertex>\n    #include <clipping_planes_vertex>\n}",fragmentShader:Vm},t);delete n.color,delete n.map,delete n.size,delete n.sizeAttenuation,delete n.useSizeBuffer,delete n.offset,super(n,e),this.offset=t.offset,this.sizeAttenuation=t.sizeAttenuation}get isPointsMaterial(){const t=this.uniforms.viewSize.value.y;return!this.sizeAttenuation&&this.offset&&this.uniforms.offset.value.copy(this.offset).multiplyScalar(window.devicePixelRatio/t),this.updateTransparency(),!1}}class jm extends Ye{constructor(t,e,i,n,r,s,o){super(),this._camera=t,this._container=e,this._renderingManager=i,this.badgeTextureAtlas=n,this.badgeAtlasSize=r,this.iconsAtlas=s,this.iconPaths=o,this._data=[],this._clusterer=new Fm(this._camera,this._container)}clearData(){this._data=[]}addIconData(t){this._data.push(t)}isEmpty(){return 0===this._data.length}update(){this.icons||this.createIcons(this._data[0]),this.badges||this.createBadges(this._data[0]),this.updateGeometry(this._data)}getGlobalUniformsWithoutOpacity(){const t=Object.assign({},this._renderingManager.uniforms);return delete t.globalOpacity,delete t.globalTransparent,t}createIcons(t){const e=new km({size:t.size,map:this.iconsAtlas,transparent:!0},this.getGlobalUniformsWithoutOpacity());e.depthTest=!1,e.depthWrite=!1;const i=new Dm(this._camera,this._container,t.size,e);this.add(i),this.icons=i}createBadges(t){const e=new km({size:16,map:this.badgeTextureAtlas,offset:new ce(0,1.4*t.size),transparent:!0},this.getGlobalUniformsWithoutOpacity());e.depthTest=!1,e.depthWrite=!1;const i=new ta(new fn,e);this.add(i),this.badges=i}fillIconUVs(t){for(let e=0;e<this._clusterer.clustersCount;e++){const i=this._clusterer.getCluster(e).mainIcon,n=this.iconPaths.indexOf(i.iconPath),r=4*e;t[r]=n/this.iconPaths.length,t[r+1]=0,t[r+2]=(n+1)/this.iconPaths.length,t[r+3]=1}}getCluster(t){return this._clusterer.getCluster(t)}updateGeometry(t){const e=t.length,i=this.icons.geometry,n=_d(i,"position",Math.min(t.length,500),3,Float32Array).array,r=this._clusterer;r.reset(n);for(let i=0;i<e;i++)r.addPoint(t[i],this.position);{const t=i.getAttribute("position"),e=_d(i,"pointUv",r.clustersCount,4,Float32Array);this.fillIconUVs(e.array),t.count=r.clustersCount,t.updateRange.count=3*r.clustersCount,t.needsUpdate=!0,e.count=r.clustersCount,e.updateRange.count=4*r.clustersCount,e.needsUpdate=!0,i.computeBoundingSphere(),i.computeBoundingBox()}{const t=this.badges.geometry,e=_d(t,"position",r.clustersCount,3,Float32Array),i=_d(t,"pointUv",r.clustersCount,4,Float32Array),n=r.fillBadgeAttributes(e.array,i.array,this.badgeAtlasSize);e.count=n,e.updateRange.count=3*n,e.needsUpdate=!0,i.count=n,i.updateRange.count=4*n,i.needsUpdate=!0}}}class Hm extends Om{constructor(t,e,i,n){super("icons"),this._data=t,this._camera=e,this._container=i,this._renderingManager=n,this.batchSize=400,this.badgeAtlasSize=11,this.iconSizeInAtlas=128,this.iconsAtlas=new ye,this.canvas2d=document.createElement("canvas"),this.context2d=this.canvas2d.getContext("2d"),this.pick=(()=>t=>{if(0===this.batches.length)return;const e=t.intersectObjects(this.batches.map((t=>t.icons)),!1)[0];if(e){const i=this.batches.find((t=>t.icons===e.object)).getCluster(e.index),n={model:this,id:i.mainIcon.id,childrenIds:i.iconIds,object:null,ray:t.ray,pickPriority:1};return Promise.resolve(Object.assign(n,e))}})(),this.badgeTextureAtlas=this.createBadgeTextureAtlas()}get batches(){return this.children}createBadgeTextureAtlas(){const t=64,e=document.createElement("canvas"),i=e.getContext("2d");e.width=t*this.badgeAtlasSize,e.height=t,i.font="51.2px Arial",i.textAlign="center",i.textBaseline="middle";for(let e=0;e<this.badgeAtlasSize;e++)i.fillStyle="white",i.beginPath(),i.rect(t*e,0,t,t),i.fill(),i.lineWidth=6,i.strokeStyle="gray",i.stroke(),i.fillStyle="black",i.fillText(e===this.badgeAtlasSize-1?"•":e.toString(),t*(e+.5),37);const n=new ye(e);return n.needsUpdate=!0,n}async update(){if(0===this._data.length)return this.clear(),void this._renderingManager.redraw();await this.createIconTextureAtlas();for(const t of this.batches)t.clearData();for(const t of this._data){const e=(new pe).copy(t.position).divideScalar(this.batchSize).round().multiplyScalar(this.batchSize);let i=this.batches.find((t=>t.position.distanceToSquared(e)<.01));i||(i=new jm(this._camera,this._container,this._renderingManager,this.badgeTextureAtlas,this.badgeAtlasSize,this.iconsAtlas,this.iconPaths),i.position.copy(e),this.add(i)),i.addIconData(t)}for(const t of this.batches)t.isEmpty()?this.remove(t):t.update();this.computeBoundingBox(),this._renderingManager.redraw()}clear(){this.batches&&this.remove(...this.batches)}async createIconTextureAtlas(){const t=Array.from(new Set(this._data.map((t=>t.iconPath))));if(!this.iconPaths||t.find((t=>!this.iconPaths.includes(t)))){this.iconPaths?(this.iconPaths.length=0,this.iconPaths.push(...t)):this.iconPaths=t,this.canvas2d.width=this.iconSizeInAtlas*t.length,this.canvas2d.height=this.iconSizeInAtlas;for(let e=0;e<t.length;e++)this.context2d.drawImage(await this.createImage(t[e]),this.iconSizeInAtlas*e,0,this.iconSizeInAtlas,this.iconSizeInAtlas);this.iconsAtlas.image=this.canvas2d,this.iconsAtlas.needsUpdate=!0}}async createImage(t){return new Promise((e=>{const i=new Image;i.onload=()=>e(i),i.crossOrigin="anonymous",i.src=t}))}computeBoundingBox(){this.boundingBox.value.makeEmpty();const t=new ci;this.batches.forEach((e=>{e.icons.geometry.boundingBox&&(t.copy(e.icons.geometry.boundingBox).min.add(e.position),t.max.add(e.position),this.boundingBox.value.union(t))})),this.boundingBox.next(this.boundingBox.value)}}class Gm extends Tm{get renderToScreen(){return!0}set renderToScreen(t){}}class Wm{constructor(t){this._api=t,this._data=[],this[Symbol.iterator]=()=>ld(this._data,(t=>t)),this._model=new Hm(this._data,this._api.camera,this._api.container,this._api.renderingManager),this._api.models.add(this._model,!1),this.createRenderPass(),t.eventDispatcher.subscribe("navigationend",(()=>this._model.update()))}createRenderPass(){const t=new Ze;t.add(this._model);const e=new Gm(t,this._api.camera.value);e.clear=!1,this._api.camera.subscribe((t=>e.camera=t)),this._api.renderingManager.composer.addPass(e)}async add(t){(t instanceof Array?t:[t]).forEach((t=>this._data.push(t))),await this._model.update()}async remove(t){(t instanceof Array?t:[t]).forEach((t=>this._data.splice(this._data.indexOf(t),1))),await this._model.update()}clear(){this._data.splice(0,this._data.length),this._model.update()}}class qm{constructor(){this._defaultBackground={topColor:"#FFFFFF",bottomColor:"#AAAAAA"},this._defaultColor="#000000",this._defaultMaterialAttenuation={mul:.5,add:.6},this._defaultLengthUnit="m",this._defaultDecimals=2,this._defaultCustomLengthFormatter=t=>`${Math.round(t)} "unit"`,this.backgroundSubject=new ff(this._defaultBackground),this.backgroundRotationSubject=new ff(0),this.colorSubject=new ff(this._defaultColor),this.materialAttenuationSubject=new ff(this._defaultMaterialAttenuation),this.orderIndependentTransparencySubject=new ff(!0),this.hoverHighlightEnabledSubject=new ff(!1),this.antialiasSubject=new ff(void 0),this.logarithmicDepthBufferSubject=new ff(void 0),this.lengthUnitSubject=new ff(this._defaultLengthUnit),this.decimalsSubject=new ff(this._defaultDecimals),this.customLengthFormatterSubject=new ff(this._defaultCustomLengthFormatter),this.useWebgl2=!0,this.animationTime=1e3,this.selectionColor="#ffcc00",this.hoverColor="#0000ff",this.staticRootUrl=void 0,this.snapDistance=16,this.analyticsEnabled=!0}get background(){return this.backgroundSubject.value}set background(t){this.backgroundSubject.next(t||this._defaultBackground)}get backgroundRotation(){return this.backgroundRotationSubject.value}set backgroundRotation(t){this.backgroundRotationSubject.next(t)}get color(){return this.colorSubject.value}set color(t){this.colorSubject.next(t||this._defaultColor)}get materialAttenuation(){return this.materialAttenuationSubject.value}set materialAttenuation(t){this.materialAttenuationSubject.next(t||this._defaultMaterialAttenuation)}get orderIndependentTransparency(){return this.orderIndependentTransparencySubject.value}set orderIndependentTransparency(t){this.orderIndependentTransparencySubject.next(void 0===t||t)}get hoverHighlightEnabled(){return this.hoverHighlightEnabledSubject.value}set hoverHighlightEnabled(t){this.hoverHighlightEnabledSubject.next(void 0!==t&&t)}get antialias(){return this.antialiasSubject.value}set antialias(t){this.antialiasSubject.next(t)}get logarithmicDepthBuffer(){return this.logarithmicDepthBufferSubject.value}set logarithmicDepthBuffer(t){this.logarithmicDepthBufferSubject.next(t)}get lengthUnit(){return this.lengthUnitSubject.value}set lengthUnit(t){if(!(t in gd))throw new Error("Unsupported length unit: "+t);this.lengthUnitSubject.next(t)}get decimals(){return this.decimalsSubject.value}set decimals(t){this.decimalsSubject.next(t)}get customLengthFormatter(){return this.customLengthFormatterSubject.value}set customLengthFormatter(t){this.customLengthFormatterSubject.next(t)}}const Xm="1.1.830",Ym=new pe,Zm=t=>({orthoScale:({object:e,renderer:i,camera:n})=>{const r=Cf(e.getWorldPosition(Ym),n)/t;e.scale.set(r,r,r)}}),$m=(...t)=>({autoApplyFunctions:t,onBeforeRender:function(t,e,i,n,r,s){const o={object:this,renderer:t,scene:e,camera:i,geometry:n,material:r,group:s};this.autoApplyFunctions.forEach((t=>t(o))),this.updateMatrixWorld(!0)}});class Jm{constructor(t){this._api=t,this.normal=new pe,this.createCursors(),this.createRenderPass(),this.cursor=this.surfaceCursor,this.initNavigationIntegration()}position(){return this.cursor.position}createCursors(){const t=new Un;t.vertices.push(new pe);const e=new ic,i=t=>e.load(this._api.staticRootUrl+t,(t=>{t.premultiplyAlpha=!1,t.generateMipmaps=!1,t.minFilter=yt,t.magFilter=yt,t.needsUpdate=!0})),n=new Zo({map:i("images/snap_face.png"),transparent:!0,depthWrite:!1,depthTest:!1,sizeAttenuation:!1,alphaTest:0,size:15});this.surfaceCursor=new to;const r=new ta(t,n);r.renderOrder=1,this.surfaceCursor.add(r);const s=new qi({color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.3,side:2}),o=new rh(2,2.25,4);o.translate(0,0,.01),o.rotateZ(Math.PI/4);const a=new In(o,s);Object.assign(a,$m(Zm(1).orthoScale)),this.surfaceCursor.add(a),this.surfaceCursor.renderOrder=1,this.pointCursor=new ta(t,new Zo({map:i("images/snap_point.png"),transparent:!0,depthWrite:!1,depthTest:!1,sizeAttenuation:!1,size:15})),this.edgeCursor=new ta(t,new Zo({map:i("images/snap_edge.png"),transparent:!0,depthWrite:!1,depthTest:!1,sizeAttenuation:!1,size:15}))}createRenderPass(){this.renderPass=new Gm(new Ze,this._api.camera.value),this._api.camera.subscribe((t=>this.renderPass.camera=t)),this.renderPass.clear=!1,this._api.renderingManager.composer.addPass(this.renderPass)}initNavigationIntegration(){this.wasSubscribed=!1,this._api.eventDispatcher.subscribe("navigationstart",(()=>{this._moveBehavior&&(this.unsubscribe(),this.wasSubscribed=!0)})),this._api.eventDispatcher.subscribe("navigationend",(()=>{this.wasSubscribed&&(this.subscribe(this.snapTypes),this.wasSubscribed=!1)}))}subscribe(t=[2,1,0]){this.snapTypes=t,this._moveBehavior=this._api.inputHandler.pointerMove$.pipe(rp((t=>this.calculateIntersection(t)))).subscribe(),this.surfaceCursor.visible=!1,this.renderPass.scene.add(this.surfaceCursor),this.pointCursor.visible=!1,this.renderPass.scene.add(this.pointCursor),this.edgeCursor.visible=!1,this.renderPass.scene.add(this.edgeCursor),this._api.renderingManager.redraw()}unsubscribe(){this.wasSubscribed=!1,this._moveBehavior&&(this._moveBehavior.unsubscribe(),this._moveBehavior=void 0,this.renderPass.scene.remove(this.surfaceCursor),this.renderPass.scene.remove(this.pointCursor),this.renderPass.scene.remove(this.edgeCursor),this._api.renderingManager.redraw())}async calculateIntersection(t){t.intersection=await this._api.picker.pickSnapped(new ce(t.x,t.y),this.snapTypes),this.intersection=t.intersection;const e=this.intersection;if(this.cursor.visible=!1,e){if(this.cursor=2===e.snapType?this.pointCursor:1===e.snapType?this.edgeCursor:this.surfaceCursor,this.cursor.position.copy(e.point),e.normal){this.normal.copy(this._api.camera.position).sub(e.point);const t=this.normal.dot(e.normal);this.normal.copy(e.normal),t<0&&this.normal.negate(),this.cursor.lookAt(this.normal.clone().add(e.point))}this.cursor.updateMatrix(),this.cursor.visible=!0}return this._api.renderingManager.redraw(),t}}class Qm{constructor(t){this.settings=t,this.keywords=[],this.init(),this.command("create","UA-155752318-1","auto"),this.send({hitType:"pageview"}),window.addEventListener("error",(t=>{t.error&&this.isViewerStack(t.error.stack)&&this.logError(t.error.stack)}))}isViewerStack(t){for(const e of this.keywords)if(t.includes(e))return!0;return!1}addViewerErrorStackKeyword(t){this.keywords.push(t)}init(){this.settings.analyticsEnabled&&((t,e,i,n,r,s,o)=>{t.GoogleAnalyticsObject=r,t[r]=t[r]||function(){(t[r].q=t[r].q||[]).push(arguments)},t[r].l=(new Date).getTime(),s=e.createElement(i),o=e.getElementsByTagName(i)[0],s.async=1,s.src="https://www.google-analytics.com/analytics.js",o.parentNode.insertBefore(s,o)})(window,document,"script",0,"gawv",void 0,void 0)}command(t,e,i){this.settings.analyticsEnabled&&gawv(t,e,i)}send(t){this.command("send",t)}logLoadEvent(t){this.send({hitType:"event",eventCategory:"Model",eventAction:"Load",eventLabel:t})}logError(t){this.send({hitType:"exception",exDescription:t}),this.send({hitType:"event",eventCategory:"Error",eventAction:"Error",eventLabel:t})}}class Km extends it{constructor(t){super(),console.log("%c🌍 Welcome commander 🌍","font-size:24px;color:#4558c9;"),console.log("webgl-viewer build version: 1.1.830");const e=new qm;Object.assign(e,t||{}),this.whenReady=new Promise((t=>{this._resolveReady=t})),this._initializeApi(e),this._api.analytics.addViewerErrorStackKeyword(this.constructor.name)}render(){return D`
            <style>
                :host {
                    display: block;
                    box-sizing: border-box;
                    height: 100%;
                    width: 100%;
                }

                main {
                    box-sizing: border-box;
                    height: 100%;
                    width: 100%;
                    cursor: default;
                    overflow: hidden;
                    position: relative;
                }

                canvas {
                    width: 100%;
                    height: 100%;
                    display: block;
                    position: relative;
                }

                .grab {
                    cursor: -webkit-grab !important;
                    cursor: -moz-grab !important;
                    cursor: grab !important;
                }

                .grabbing {
                    cursor: -webkit-grabbing !important;
                    cursor: -moz-grabbing !important;
                    cursor: grabbing !important;
                }

                .default {
                    cursor: default;
                }
            </style>`}get settings(){return this._api.settings}get globalOpacity(){return this._api.renderingManager.globalOpacity}set globalOpacity(t){this._api.renderingManager.globalOpacity=t}addPlugin(t){if(t.api=this._api,this.plugins[t.name])throw Error(`Plugin ${t.name} is already initialized`);if(t.version!==Xm)throw Error(`Plugin version mismatch ${t.version}`);return this.plugins[t.name]=t,this._api.analytics.addViewerErrorStackKeyword(t.constructor.name),this}async load(t,e={}){e.fitToView=void 0===e.fitToView||e.fitToView;const i=Array.from(this._api.registry.LUT.entries()).find((i=>i[0](t,e)));if(!i)throw new Error(`Unknown model type: ${t}`);const n=await i[1].load(t,e);if(e.fitToView){const t=this._api.models.worldBoundingBox.value;this._api.camera.fitToView(t,this._api.settings.animationTime).catch((()=>{}))}else this._api.camera.next(this._api.camera.value);this._api.renderingManager.redraw(),this._api.analytics.logLoadEvent(n.name)}async unload(t,e){e=e||{fitToView:!0};for(const i of this._api.registry.LUT)if(i[0](t,e))return await i[1].unload(t,e),this.selection.delete(t),e.fitToView&&this._api.camera.fitToView(this._api.models.worldBoundingBox.value,this._api.settings.animationTime).catch((()=>{})),void this._api.renderingManager.redraw();throw new Error(`model ${t} not found`)}getModel(t){return this._api.models.get(t)}_initializeApi(t){this.initApiForJsdom();const e=this._api;e.staticRootUrl=t.staticRootUrl||window.DEFAULT_STATIC_ROOT_URL||"/",e.container=document.createElement("main"),e.container.setAttribute("id","content"),e.container.appendChild(document.createElement("canvas")),e.eventDispatcher=new Am(this),e.settings=t,e.scene=new Ze,e.models=new Lm(e.scene),e.plugins=new Gf,e.camera=new Pf(this._api),e.picker=new Lf(e.camera,e.models,e.container,e.settings),e.renderingManager=new Pm(e),e.htmlElementPositioner=new Cm(e),e.inputHandler=new Qp(e.picker,e.container),e.cursor=new Jm(e),this.selection=new Im,this.selection.startSelectionEventEmitter(e.eventDispatcher),e.selection=this.selection,e.toolManager=new Wf(e),e.models.worldBoundingBox.subscribe((()=>e.renderingManager.redraw())),e.models.worldBoundingBox.subscribe((t=>e.picker.setWorldBoundingBox(t))),e.icons=new Wm(e),e.analytics=new Qm(e.settings)}initApiForJsdom(){const t={};this._api=t,t.registry=new Rm}firstUpdated(){this.shadowRoot.appendChild(this._api.container),this._api.renderingManager.start(),this._resolveReady(!0)}connectedCallback(){super.connectedCallback(),this._api.renderingManager.enabled=!0}disconnectedCallback(){super.disconnectedCallback(),this._api.renderingManager.enabled=!1}set activeTool(t){this._api.toolManager.activeTool=t}get activeTool(){return this._api.toolManager.activeTool}get tools(){return this._api.toolManager.tools}get icons(){return this._api.icons}get plugins(){return this._api.plugins}getCamera(){const t=this._api.camera.getWorldDirection(new pe),e=this._api.camera.getWorldPosition(new pe);return{position:e,quaternion:this._api.camera.getWorldQuaternion(new le),lookAt:{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z},projectionType:this._api.camera.getProjectionType(),fieldOfView:this._api.camera.widestFov,orthoSize:this._api.camera.orthoSize}}async setCamera(t){await this._api.camera.setProjectionType(t.projectionType),t.fieldOfView&&(this._api.camera.widestFov=t.fieldOfView),t.orthoSize&&(this._api.camera.orthoSize=t.orthoSize);const e=t.position?new pe(t.position.x,t.position.y,t.position.z):this._api.camera.position;let i=t.quaternion?new le(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w):this._api.camera.quaternion;if(t.lookAt){const n=new pe(t.lookAt.x,t.lookAt.y,t.lookAt.z);i=(new le).setFromRotationMatrix((new Le).lookAt(n,e,this._api.camera.up))}await this._api.camera.animate(e,i,this._api.settings.animationTime)}async fitToView(t){if(t&&t.modelIds&&t.modelIds.length>0){const e=t.modelIds.map((t=>{for(const e of this._api.models.getIterable())if(e.name===t)return e;throw new Error(`No model found named ${t}`)}));if(t.entityIds){if(1!==e.length)throw new Error("Only one model can be used when passings Objectids");const i=await e[0].getBoundingBox(t.entityIds);await this._api.camera.fitToView(i,this._api.settings.animationTime,t.viewPreset)}else{const i=e.reduce(((t,e)=>t.union(e.boundingBox.value)),new ci);await this._api.camera.fitToView(i,this._api.settings.animationTime,t.viewPreset)}}else await this._api.camera.fitToView(this._api.models.worldBoundingBox.value,this._api.settings.animationTime,t&&t.viewPreset?t.viewPreset:void 0)}async getBoundingBox(t,e){let i;for(const e of this._api.models.getIterable())e.name===t&&(i=e);if(!i)throw new Error(`Model ${t} not found`);return await i.getBoundingBox(e)}async screenshot(){return this._api.renderingManager.screenshot()}get vr(){return this._api.renderingManager.vr}}window.customElements&&window.customElements.define("webgl-viewer",Km);const tg=`\n    uniform vec3 diffuse;\n    uniform float opacity;\n    ${zm}\n\n    varying vec2 vAttenuation;\n\n    #include <common>\n    #include <color_pars_fragment>\n    #include <uv_pars_fragment>\n    #include <map_pars_fragment>\n    #include <logdepthbuf_pars_fragment>\n    #include <clipping_planes_pars_fragment>\n\n    void main() {\n        #include <logdepthbuf_fragment>\n        #include <clipping_planes_fragment>\n        depthPeelingFragment();        \n\n        #ifdef DOUBLE_SIDED\n            float atten = (gl_FrontFacing) ? vAttenuation.x : vAttenuation.y;\n        #else\n            float atten = vAttenuation.x;\n        #endif\n        vec4 diffuseColor = vec4(diffuse * atten, opacity);\n        \n        #include <map_fragment>\n        #include <color_fragment>\n        #include <alphatest_fragment>\n\n        gl_FragColor = diffuseColor;\n\n        #include <premultiplied_alpha_fragment>\n        #include <encodings_fragment>\n    }\n`;class eg extends Um{constructor(t,e){let i=!1;const n=Object.assign(Gn.clone(nr.basic.uniforms),{diffuse:{value:new Ui(t.color)},opacity:{value:void 0!==t.opacity?t.opacity:1},transparent:{value:void 0!==t.transparent&&t.transparent},map:{type:"t",value:t.map},attenuationFactors:{value:t.attenuationFactors||new ce(.5,.6)}},e||{});t.map&&(i=!0);const r=Object.assign({uniforms:n,defines:{USE_MAP:!!t.map,USE_UV:!!t.map},vertexShader:"\nuniform vec2 attenuationFactors; \n\nvarying vec2 vAttenuation;\n\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\t\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\t\n\t#include <project_vertex>\t\t\n\t\t\n\tvec3 viewVector = normalize(-mvPosition.xyz);\t\n\tvec3 normal = normalize(transformedNormal);\n\tvAttenuation.x = dot(viewVector, normal);\t \n\t#ifdef DOUBLE_SIDED\n\t    vAttenuation.y = dot(viewVector, -normal);\n\t#endif\n\tvAttenuation = clamp(vAttenuation * attenuationFactors.x + attenuationFactors.y, 0.0, 2.0);\n\t\n\t#include <logdepthbuf_vertex>\t\n\t#include <clipping_planes_vertex>\n}    \n",fragmentShader:tg},t),s=r.isDoubleGeometryPart;delete r.isDoubleGeometryPart,delete r.color,delete r.map,delete r.attenuationFactors,super(r,e),this.isViewerMeshMaterial=!0,this.originalSide=r.side,this.hasTexture=i,this.isDoubleGeometryPart=s}get isPointsMaterial(){return this.updateTransparency(),!1}setSidedness(t,e){this.isDoubleGeometryPart||this.hasTexture&&e||(this.side=t,this.needsUpdate=!0)}restoreOriginalSidedness(){this.isDoubleGeometryPart||(this.side=this.originalSide,this.needsUpdate=!0)}static createSettingsAwareMaterial(t,e,i){e.attenuationFactors=new ce(t.materialAttenuation.mul,t.materialAttenuation.add);const n=new eg(e,i);return t.materialAttenuationSubject.subscribe((()=>n.uniforms.attenuationFactors.value=new ce(t.materialAttenuation.mul,t.materialAttenuation.add))),n}}var ig;function ng(t){const e=Uint32Array.from(function(t){const e=[],i=t=>{switch(typeof t){case"number":e.push(t);break;case"string":e.push(...Array.from(t).map((t=>t.charCodeAt(0))));break;case"boolean":e.push(t?1:0);break;case"bigint":e.push(Number(t))}},n=t=>{if(Array.isArray(t))t.forEach(i);else if("object"==typeof t){const e=Object.entries(t);if(0===e.length)return;e.forEach((([t,e])=>{i(t),n(e)}))}else i(t)};return n(t),e}(t)),i=new Uint8Array(4*e.length);for(let t=0;t<e.length;++t)i[4*t]=e[t]>>>24,i[4*t+1]=e[t]>>>16,i[4*t+2]=e[t]>>>8,i[4*t+3]=e[t];return function(t){let e=-1;for(let i=0,n=t.length;i<n;++i){e^=t[i];for(let t=0;t<8;++t)e=1&e?e>>1^2197175160:e>>1}return~e}(i)}!function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Single=0]="Single",t[t.Double=1]="Double",t[t.FrontFace=2]="FrontFace",t[t.BackFace=3]="BackFace"}(e=t.Sidedness||(t.Sidedness={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Normal=0]="Normal",t[t.Border=1]="Border",t[t.Center=2]="Center",t[t.DashDot=3]="DashDot",t[t.Dashed=4]="Dashed",t[t.Divide=5]="Divide",t[t.Dot=6]="Dot",t[t.Hidden=7]="Hidden",t[t.ISO02W100=8]="ISO02W100",t[t.ISO03W100=9]="ISO03W100",t[t.ISO04W100=10]="ISO04W100",t[t.ISO05W100=11]="ISO05W100",t[t.ISO06W100=12]="ISO06W100",t[t.ISO07W100=13]="ISO07W100",t[t.ISO08W100=14]="ISO08W100",t[t.ISO09W100=15]="ISO09W100",t[t.ISO10W100=16]="ISO10W100",t[t.ISO11W100=17]="ISO11W100",t[t.ISO12W100=18]="ISO12W100",t[t.ISO13W100=19]="ISO13W100",t[t.ISO14W100=20]="ISO14W100",t[t.ISO15W100=21]="ISO15W100"}(e=t.LineStyle||(t.LineStyle={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Guid=0]="Guid",t[t.String=1]="String",t[t.SpatialHash=2]="SpatialHash",t[t.DwgHandle=3]="DwgHandle",t[t.None=4]="None"}(e=t.IdentifierType||(t.IdentifierType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.None=0]="None",t[t.BRep=1]="BRep",t[t.TriangleMesh=2]="TriangleMesh",t[t.TriangleMesh8=3]="TriangleMesh8",t[t.SweptDiskSolid=4]="SweptDiskSolid",t[t.GraphicsContainer=5]="GraphicsContainer",t[t.BRepWithUV=6]="BRepWithUV",t[t.BRepWithNormals=7]="BRepWithNormals",t[t.AlignmentCurve=8]="AlignmentCurve",t[t.GridLineContainer=9]="GridLineContainer",t[t.TexturedTriangleMesh=10]="TexturedTriangleMesh",t[t.TexturedTriangleMesh8=11]="TexturedTriangleMesh8",t[t.CoordinateGeometryPoint=12]="CoordinateGeometryPoint",t[t.BillboardText=13]="BillboardText",t[t.Billboard=14]="Billboard",t[t.TexturedBillboard=15]="TexturedBillboard",t[t.Bolt=16]="Bolt"}(e=t.GeometryType||(t.GeometryType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.None=0]="None",t[t.Png=1]="Png",t[t.JPeg=2]="JPeg"}(e=t.TextureType||(t.TextureType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.LineSegment=0]="LineSegment",t[t.PolyLine=1]="PolyLine",t[t.Arc=2]="Arc"}(e=t.SegmentType||(t.SegmentType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Invalid=0]="Invalid",t[t.LineSegment=1]="LineSegment",t[t.CircularArcSegment=2]="CircularArcSegment",t[t.ClothoidalArcSegment=3]="ClothoidalArcSegment",t[t.TransientCurveSegment=4]="TransientCurveSegment"}(e=t.HorizontalSegmentType||(t.HorizontalSegmentType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Invalid=0]="Invalid",t[t.LineSegment=1]="LineSegment",t[t.CircularArcSegment=2]="CircularArcSegment",t[t.ParabolicArcSegment=3]="ParabolicArcSegment"}(e=t.VerticalSegmentType||(t.VerticalSegmentType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Invalid=0]="Invalid",t[t.BiquadraticParabola=1]="BiquadraticParabola",t[t.BlossCurve=2]="BlossCurve",t[t.ClothoidCurve=3]="ClothoidCurve",t[t.CosineCurve=4]="CosineCurve",t[t.CubicParabola=5]="CubicParabola",t[t.SineCurve=6]="SineCurve"}(e=t.HorizontalTransitionCurveType||(t.HorizontalTransitionCurveType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Invalid=0]="Invalid",t[t.LeftToRight=1]="LeftToRight",t[t.RightToLeft=2]="RightToLeft",t[t.Vertical=3]="Vertical"}(e=t.LayoutType||(t.LayoutType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Invalid=0]="Invalid",t[t.LeftTop=1]="LeftTop",t[t.LeftCenter=2]="LeftCenter",t[t.LeftBottom=3]="LeftBottom",t[t.CenterTop=4]="CenterTop",t[t.CenterCenter=5]="CenterCenter",t[t.CenterBottom=6]="CenterBottom",t[t.RightTop=7]="RightTop",t[t.RightCenter=8]="RightCenter",t[t.RightBottom=9]="RightBottom",t[t.LeftBaseLine=10]="LeftBaseLine",t[t.CenterBaseLine=11]="CenterBaseLine",t[t.RightBaseLine=12]="RightBaseLine",t[t.LeftBottomBaseLine=13]="LeftBottomBaseLine",t[t.CenterBottomBaseLine=14]="CenterBottomBaseLine",t[t.RightBottomBaseLine=15]="RightBottomBaseLine"}(e=t.AlignmentType||(t.AlignmentType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.None=0]="None",t[t.Normal=1]="Normal",t[t.Round=2]="Round",t[t.Countersunk=3]="Countersunk",t[t.Stud=4]="Stud"}(e=t.BoltType||(t.BoltType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Undefined=0]="Undefined",t[t.ReadWrite=1]="ReadWrite",t[t.ReadOnly=2]="ReadOnly",t[t.Locked=3]="Locked",t[t.ReadWriteLocked=4]="ReadWriteLocked",t[t.ReadOnlyLocked=5]="ReadOnlyLocked"}(e=t.OwnerHistoryState||(t.OwnerHistoryState={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.NoChange=0]="NoChange",t[t.Modified=1]="Modified",t[t.Added=2]="Added",t[t.Deleted=3]="Deleted"}(e=t.OwnerHistoryChangeAction||(t.OwnerHistoryChangeAction={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.LengthMeasure=0]="LengthMeasure",t[t.AreaMeasure=1]="AreaMeasure",t[t.VolumeMeasure=2]="VolumeMeasure",t[t.MassMeasure=3]="MassMeasure",t[t.AngleMeasure=4]="AngleMeasure",t[t.StringValue=5]="StringValue",t[t.IntValue=6]="IntValue",t[t.DoubleValue=7]="DoubleValue",t[t.DateTime=8]="DateTime",t[t.Logical=9]="Logical",t[t.Boolean=10]="Boolean"}(e=t.PropertyType||(t.PropertyType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.False=0]="False",t[t.True=1]="True",t[t.Unknown=2]="Unknown"}(e=t.Logical||(t.Logical={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){let e;!function(t){t[t.Unknown=0]="Unknown",t[t.SpatialHierarchy=1]="SpatialHierarchy",t[t.SpatialContainment=2]="SpatialContainment",t[t.Containment=3]="Containment",t[t.ElementAssembly=4]="ElementAssembly",t[t.Group=5]="Group",t[t.System=6]="System",t[t.Zone=7]="Zone"}(e=t.HierarchyType||(t.HierarchyType={}))}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Vec3f=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}static createVec3f(t,e,i,n){return t.prep(4,12),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Vec2d=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}x(){return this.bb.readFloat64(this.bb_pos)}y(){return this.bb.readFloat64(this.bb_pos+8)}static createVec2d(t,e,i){return t.prep(8,16),t.writeFloat64(i),t.writeFloat64(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Vec3d=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}x(){return this.bb.readFloat64(this.bb_pos)}y(){return this.bb.readFloat64(this.bb_pos+8)}z(){return this.bb.readFloat64(this.bb_pos+16)}static createVec3d(t,e,i,n){return t.prep(8,24),t.writeFloat64(n),t.writeFloat64(i),t.writeFloat64(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.AABB3f=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}min(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos,this.bb)}max(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos+12,this.bb)}static createAABB3f(t,e,i,n,r,s,o){return t.prep(4,24),t.prep(4,12),t.writeFloat32(o),t.writeFloat32(s),t.writeFloat32(r),t.prep(4,12),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.Placement3=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}origin(e){return(e||new t.Technology.TrimBim.Fbs.Vec3d).__init(this.bb_pos,this.bb)}xAxis(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos+24,this.bb)}yAxis(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos+36,this.bb)}static createPlacement3(t,e,i,n,r,s,o,a,h,c){return t.prep(8,48),t.prep(4,12),t.writeFloat32(c),t.writeFloat32(h),t.writeFloat32(a),t.prep(4,12),t.writeFloat32(o),t.writeFloat32(s),t.writeFloat32(r),t.prep(8,24),t.writeFloat64(n),t.writeFloat64(i),t.writeFloat64(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.Line3f=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}start(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos,this.bb)}end(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos+12,this.bb)}static createLine3f(t,e,i,n,r,s,o){return t.prep(4,24),t.prep(4,12),t.writeFloat32(o),t.writeFloat32(s),t.writeFloat32(r),t.prep(4,12),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.Line3d=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}start(e){return(e||new t.Technology.TrimBim.Fbs.Vec3d).__init(this.bb_pos,this.bb)}end(e){return(e||new t.Technology.TrimBim.Fbs.Vec3d).__init(this.bb_pos+24,this.bb)}static createLine3d(t,e,i,n,r,s,o){return t.prep(8,48),t.prep(8,24),t.writeFloat64(o),t.writeFloat64(s),t.writeFloat64(r),t.prep(8,24),t.writeFloat64(n),t.writeFloat64(i),t.writeFloat64(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsPolyline3f(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}points(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}pointsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}static startPolyline3f(t){t.startObject(1)}static addPoints(t,e){t.addFieldOffset(0,e,0)}static startPointsVector(t,e){t.startVector(12,e,4)}static endPolyline3f(t){return t.endObject()}}e.Polyline3f=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.Arc3f=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}center(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos,this.bb)}axis(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos+12,this.bb)}refDirection(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos+24,this.bb)}radius(){return this.bb.readFloat32(this.bb_pos+36)}angle(){return this.bb.readFloat32(this.bb_pos+40)}static createArc3f(t,e,i,n,r,s,o,a,h,c,l,u){return t.prep(4,44),t.writeFloat32(u),t.writeFloat32(l),t.prep(4,12),t.writeFloat32(c),t.writeFloat32(h),t.writeFloat32(a),t.prep(4,12),t.writeFloat32(o),t.writeFloat32(s),t.writeFloat32(r),t.prep(4,12),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.Arc3d=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}center(e){return(e||new t.Technology.TrimBim.Fbs.Vec3d).__init(this.bb_pos,this.bb)}axis(e){return(e||new t.Technology.TrimBim.Fbs.Vec3d).__init(this.bb_pos+24,this.bb)}refDirection(e){return(e||new t.Technology.TrimBim.Fbs.Vec3d).__init(this.bb_pos+48,this.bb)}radius(){return this.bb.readFloat64(this.bb_pos+72)}angle(){return this.bb.readFloat64(this.bb_pos+80)}static createArc3d(t,e,i,n,r,s,o,a,h,c,l,u){return t.prep(8,88),t.writeFloat64(u),t.writeFloat64(l),t.prep(8,24),t.writeFloat64(c),t.writeFloat64(h),t.writeFloat64(a),t.prep(8,24),t.writeFloat64(o),t.writeFloat64(s),t.writeFloat64(r),t.prep(8,24),t.writeFloat64(n),t.writeFloat64(i),t.writeFloat64(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Guid=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}data1(){return this.bb.readUint32(this.bb_pos)}data2(){return this.bb.readUint16(this.bb_pos+4)}data3(){return this.bb.readUint16(this.bb_pos+6)}data41(){return this.bb.readUint8(this.bb_pos+8)}data42(){return this.bb.readUint8(this.bb_pos+9)}data43(){return this.bb.readUint8(this.bb_pos+10)}data44(){return this.bb.readUint8(this.bb_pos+11)}data45(){return this.bb.readUint8(this.bb_pos+12)}data46(){return this.bb.readUint8(this.bb_pos+13)}data47(){return this.bb.readUint8(this.bb_pos+14)}data48(){return this.bb.readUint8(this.bb_pos+15)}static createGuid(t,e,i,n,r,s,o,a,h,c,l,u){return t.prep(4,16),t.writeInt8(u),t.writeInt8(l),t.writeInt8(c),t.writeInt8(h),t.writeInt8(a),t.writeInt8(o),t.writeInt8(s),t.writeInt8(r),t.writeInt16(n),t.writeInt16(i),t.writeInt32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.SpatialHash=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}x(){return this.bb.readFloat64(this.bb_pos)}y(){return this.bb.readFloat64(this.bb_pos+8)}z(){return this.bb.readFloat64(this.bb_pos+16)}d0(){return this.bb.readFloat64(this.bb_pos+24)}d1(){return this.bb.readFloat64(this.bb_pos+32)}d2(){return this.bb.readFloat64(this.bb_pos+40)}d3(){return this.bb.readFloat64(this.bb_pos+48)}d4(){return this.bb.readFloat64(this.bb_pos+56)}d5(){return this.bb.readFloat64(this.bb_pos+64)}d6(){return this.bb.readFloat64(this.bb_pos+72)}d7(){return this.bb.readFloat64(this.bb_pos+80)}static createSpatialHash(t,e,i,n,r,s,o,a,h,c,l,u){return t.prep(8,88),t.writeFloat64(u),t.writeFloat64(l),t.writeFloat64(c),t.writeFloat64(h),t.writeFloat64(a),t.writeFloat64(o),t.writeFloat64(s),t.writeFloat64(r),t.writeFloat64(n),t.writeFloat64(i),t.writeFloat64(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.SurfaceMaterial=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}r(){return this.bb.readUint8(this.bb_pos)}g(){return this.bb.readUint8(this.bb_pos+1)}b(){return this.bb.readUint8(this.bb_pos+2)}a(){return this.bb.readUint8(this.bb_pos+3)}textureId(){return this.bb.readUint32(this.bb_pos+4)}sidedness(){return this.bb.readInt8(this.bb_pos+8)}lineStyle(){return this.bb.readInt8(this.bb_pos+9)}metallic(){return this.bb.readFloat32(this.bb_pos+12)}roughness(){return this.bb.readFloat32(this.bb_pos+16)}static createSurfaceMaterial(t,e,i,n,r,s,o,a,h,c){return t.prep(4,20),t.writeFloat32(c),t.writeFloat32(h),t.pad(2),t.writeInt8(a),t.writeInt8(o),t.writeInt32(s),t.writeInt8(r),t.writeInt8(n),t.writeInt8(i),t.writeInt8(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.Entity=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}type(){return this.bb.readInt8(this.bb_pos)}identifierIndex(){return this.bb.readUint32(this.bb_pos+4)}classIndex(){return this.bb.readUint32(this.bb_pos+8)}globalPlacement(e){return(e||new t.Technology.TrimBim.Fbs.Placement3).__init(this.bb_pos+16,this.bb)}static createEntity(t,e,i,n,r,s,o,a,h,c,l,u,d){return t.prep(8,64),t.prep(8,48),t.prep(4,12),t.writeFloat32(d),t.writeFloat32(u),t.writeFloat32(l),t.prep(4,12),t.writeFloat32(c),t.writeFloat32(h),t.writeFloat32(a),t.prep(8,24),t.writeFloat64(o),t.writeFloat64(s),t.writeFloat64(r),t.pad(4),t.writeInt32(n),t.writeInt32(i),t.pad(3),t.writeInt8(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsOuterWire(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}vertexIndices(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint16(this.bb.__vector(this.bb_pos+e)+2*t):0}vertexIndicesLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}vertexIndicesArray(){var t=this.bb.__offset(this.bb_pos,4);return t?new Uint16Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startOuterWire(t){t.startObject(1)}static addVertexIndices(t,e){t.addFieldOffset(0,e,0)}static createVertexIndicesVector(t,e){t.startVector(2,e.length,2);for(var i=e.length-1;i>=0;i--)t.addInt16(e[i]);return t.endVector()}static startVertexIndicesVector(t,e){t.startVector(2,e,2)}static endOuterWire(t){var e=t.endObject();return t.requiredField(e,4),e}}t.OuterWire=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInnerWire(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}outerWire(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint16(this.bb_pos+t):0}vertexIndices(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint16(this.bb.__vector(this.bb_pos+e)+2*t):0}vertexIndicesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}vertexIndicesArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Uint16Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startInnerWire(t){t.startObject(2)}static addOuterWire(t,e){t.addFieldInt16(0,e,0)}static addVertexIndices(t,e){t.addFieldOffset(1,e,0)}static createVertexIndicesVector(t,e){t.startVector(2,e.length,2);for(var i=e.length-1;i>=0;i--)t.addInt16(e[i]);return t.endVector()}static startVertexIndicesVector(t,e){t.startVector(2,e,2)}static endInnerWire(t){var e=t.endObject();return t.requiredField(e,6),e}}t.InnerWire=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBRep(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}outerWires(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.OuterWire).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}outerWiresLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}innerWires(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.InnerWire).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}innerWiresLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}vertices(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}verticesLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startBRep(t){t.startObject(3)}static addOuterWires(t,e){t.addFieldOffset(0,e,0)}static createOuterWiresVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startOuterWiresVector(t,e){t.startVector(4,e,4)}static addInnerWires(t,e){t.addFieldOffset(1,e,0)}static createInnerWiresVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startInnerWiresVector(t,e){t.startVector(4,e,4)}static addVertices(t,e){t.addFieldOffset(2,e,0)}static startVerticesVector(t,e){t.startVector(12,e,4)}static endBRep(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),e}}e.BRep=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.UV=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}u(){return this.bb.readFloat32(this.bb_pos)}v(){return this.bb.readFloat32(this.bb_pos+4)}static createUV(t,e,i){return t.prep(4,8),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.PositionUV=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}position(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos,this.bb)}uv(e){return(e||new t.Technology.TrimBim.Fbs.UV).__init(this.bb_pos+12,this.bb)}static createPositionUV(t,e,i,n,r,s){return t.prep(4,20),t.prep(4,8),t.writeFloat32(s),t.writeFloat32(r),t.prep(4,12),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.PositionNormal=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}position(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos,this.bb)}normal(e){return(e||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb_pos+12,this.bb)}static createPositionNormal(t,e,i,n,r,s,o){return t.prep(4,24),t.prep(4,12),t.writeFloat32(o),t.writeFloat32(s),t.writeFloat32(r),t.prep(4,12),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBRepWithUV(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}outerWires(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.OuterWire).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}outerWiresLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}innerWires(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.InnerWire).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}innerWiresLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}vertices(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.PositionUV).__init(this.bb.__vector(this.bb_pos+n)+20*e,this.bb):null}verticesLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startBRepWithUV(t){t.startObject(3)}static addOuterWires(t,e){t.addFieldOffset(0,e,0)}static createOuterWiresVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startOuterWiresVector(t,e){t.startVector(4,e,4)}static addInnerWires(t,e){t.addFieldOffset(1,e,0)}static createInnerWiresVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startInnerWiresVector(t,e){t.startVector(4,e,4)}static addVertices(t,e){t.addFieldOffset(2,e,0)}static startVerticesVector(t,e){t.startVector(20,e,4)}static endBRepWithUV(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),e}}e.BRepWithUV=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBRepWithNormal(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}outerWires(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.OuterWire).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}outerWiresLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}innerWires(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.InnerWire).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}innerWiresLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}vertices(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.PositionNormal).__init(this.bb.__vector(this.bb_pos+n)+24*e,this.bb):null}verticesLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startBRepWithNormal(t){t.startObject(3)}static addOuterWires(t,e){t.addFieldOffset(0,e,0)}static createOuterWiresVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startOuterWiresVector(t,e){t.startVector(4,e,4)}static addInnerWires(t,e){t.addFieldOffset(1,e,0)}static createInnerWiresVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startInnerWiresVector(t,e){t.startVector(4,e,4)}static addVertices(t,e){t.addFieldOffset(2,e,0)}static startVerticesVector(t,e){t.startVector(24,e,4)}static endBRepWithNormal(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),e}}e.BRepWithNormal=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.IndexedVertex=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}positionIndex(){return this.bb.readUint16(this.bb_pos)}normalIndex(){return this.bb.readUint16(this.bb_pos+2)}static createIndexedVertex(t,e,i){return t.prep(2,4),t.writeInt16(i),t.writeInt16(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTriangleMesh(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}positions(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}positionsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}normals(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}normalsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}vertices(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.IndexedVertex).__init(this.bb.__vector(this.bb_pos+n)+4*e,this.bb):null}verticesLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}indices(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readUint16(this.bb.__vector(this.bb_pos+e)+2*t):0}indicesLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}indicesArray(){var t=this.bb.__offset(this.bb_pos,10);return t?new Uint16Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startTriangleMesh(t){t.startObject(4)}static addPositions(t,e){t.addFieldOffset(0,e,0)}static startPositionsVector(t,e){t.startVector(12,e,4)}static addNormals(t,e){t.addFieldOffset(1,e,0)}static startNormalsVector(t,e){t.startVector(12,e,4)}static addVertices(t,e){t.addFieldOffset(2,e,0)}static startVerticesVector(t,e){t.startVector(4,e,2)}static addIndices(t,e){t.addFieldOffset(3,e,0)}static createIndicesVector(t,e){t.startVector(2,e.length,2);for(var i=e.length-1;i>=0;i--)t.addInt16(e[i]);return t.endVector()}static startIndicesVector(t,e){t.startVector(2,e,2)}static endTriangleMesh(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),e}}e.TriangleMesh=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.IndexedVertex8=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}positionIndex(){return this.bb.readUint8(this.bb_pos)}normalIndex(){return this.bb.readUint8(this.bb_pos+1)}static createIndexedVertex8(t,e,i){return t.prep(1,2),t.writeInt8(i),t.writeInt8(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTriangleMesh8(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}positions(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}positionsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}normals(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}normalsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}vertices(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.IndexedVertex8).__init(this.bb.__vector(this.bb_pos+n)+2*e,this.bb):null}verticesLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}indices(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}indicesLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}indicesArray(){var t=this.bb.__offset(this.bb_pos,10);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startTriangleMesh8(t){t.startObject(4)}static addPositions(t,e){t.addFieldOffset(0,e,0)}static startPositionsVector(t,e){t.startVector(12,e,4)}static addNormals(t,e){t.addFieldOffset(1,e,0)}static startNormalsVector(t,e){t.startVector(12,e,4)}static addVertices(t,e){t.addFieldOffset(2,e,0)}static startVerticesVector(t,e){t.startVector(2,e,1)}static addIndices(t,e){t.addFieldOffset(3,e,0)}static createIndicesVector(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startIndicesVector(t,e){t.startVector(1,e,1)}static endTriangleMesh8(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),e}}e.TriangleMesh8=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTexturedTriangleMesh(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}positions(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}positionsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}normals(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}normalsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}uvs(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.UV).__init(this.bb.__vector(this.bb_pos+n)+8*e,this.bb):null}uvsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}vertices(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.IndexedVertex).__init(this.bb.__vector(this.bb_pos+n)+4*e,this.bb):null}verticesLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}indices(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint16(this.bb.__vector(this.bb_pos+e)+2*t):0}indicesLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}indicesArray(){var t=this.bb.__offset(this.bb_pos,12);return t?new Uint16Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startTexturedTriangleMesh(t){t.startObject(5)}static addPositions(t,e){t.addFieldOffset(0,e,0)}static startPositionsVector(t,e){t.startVector(12,e,4)}static addNormals(t,e){t.addFieldOffset(1,e,0)}static startNormalsVector(t,e){t.startVector(12,e,4)}static addUvs(t,e){t.addFieldOffset(2,e,0)}static startUvsVector(t,e){t.startVector(8,e,4)}static addVertices(t,e){t.addFieldOffset(3,e,0)}static startVerticesVector(t,e){t.startVector(4,e,2)}static addIndices(t,e){t.addFieldOffset(4,e,0)}static createIndicesVector(t,e){t.startVector(2,e.length,2);for(var i=e.length-1;i>=0;i--)t.addInt16(e[i]);return t.endVector()}static startIndicesVector(t,e){t.startVector(2,e,2)}static endTexturedTriangleMesh(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),e}}e.TexturedTriangleMesh=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTexturedTriangleMesh8(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}positions(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}positionsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}normals(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.Vec3f).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}normalsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}uvs(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.UV).__init(this.bb.__vector(this.bb_pos+n)+8*e,this.bb):null}uvsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}vertices(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.IndexedVertex8).__init(this.bb.__vector(this.bb_pos+n)+2*e,this.bb):null}verticesLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}indices(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}indicesLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}indicesArray(){var t=this.bb.__offset(this.bb_pos,12);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startTexturedTriangleMesh8(t){t.startObject(5)}static addPositions(t,e){t.addFieldOffset(0,e,0)}static startPositionsVector(t,e){t.startVector(12,e,4)}static addNormals(t,e){t.addFieldOffset(1,e,0)}static startNormalsVector(t,e){t.startVector(12,e,4)}static addUvs(t,e){t.addFieldOffset(2,e,0)}static startUvsVector(t,e){t.startVector(8,e,4)}static addVertices(t,e){t.addFieldOffset(3,e,0)}static startVerticesVector(t,e){t.startVector(2,e,1)}static addIndices(t,e){t.addFieldOffset(4,e,0)}static createIndicesVector(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startIndicesVector(t,e){t.startVector(1,e,1)}static endTexturedTriangleMesh8(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),e}}e.TexturedTriangleMesh8=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.GeometryDefinition=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}type(){return this.bb.readInt8(this.bb_pos)}index(){return this.bb.readUint32(this.bb_pos+4)}boundingBox(e){return(e||new t.Technology.TrimBim.Fbs.AABB3f).__init(this.bb_pos+8,this.bb)}static createGeometryDefinition(t,e,i,n,r,s,o,a,h){return t.prep(4,32),t.prep(4,24),t.prep(4,12),t.writeFloat32(h),t.writeFloat32(a),t.writeFloat32(o),t.prep(4,12),t.writeFloat32(s),t.writeFloat32(r),t.writeFloat32(n),t.writeInt32(i),t.pad(3),t.writeInt8(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.GeometryInstance=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}localPlacementId(){return this.bb.readUint32(this.bb_pos)}entityId(){return this.bb.readUint32(this.bb_pos+4)}definitionId(){return this.bb.readUint32(this.bb_pos+8)}surfaceMaterialId(){return this.bb.readUint32(this.bb_pos+12)}layerId(){return this.bb.readUint32(this.bb_pos+16)}static createGeometryInstance(t,e,i,n,r,s){return t.prep(4,20),t.writeInt32(s),t.writeInt32(r),t.writeInt32(n),t.writeInt32(i),t.writeInt32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTexture(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}type(){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):t.Technology.TrimBim.Fbs.TextureType.None}bytes(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb.__vector(this.bb_pos+e)+t):0}bytesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}bytesArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Int8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startTexture(t){t.startObject(2)}static addType(e,i){e.addFieldInt8(0,i,t.Technology.TrimBim.Fbs.TextureType.None)}static addBytes(t,e){t.addFieldOffset(1,e,0)}static createBytesVector(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startBytesVector(t,e){t.startVector(1,e,1)}static endTexture(t){var e=t.endObject();return t.requiredField(e,6),e}}e.Texture=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDirectrix(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}types(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb.__vector(this.bb_pos+e)+t):0}typesLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}typesArray(){var t=this.bb.__offset(this.bb_pos,4);return t?new Int8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}indexes(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}indexesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}indexesArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}lineSegments(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.Line3f).__init(this.bb.__vector(this.bb_pos+n)+24*e,this.bb):null}lineSegmentsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}polyLines(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.Polyline3f).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}polyLinesLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}arcs(e,i){var n=this.bb.__offset(this.bb_pos,12);return n?(i||new t.Technology.TrimBim.Fbs.Arc3f).__init(this.bb.__vector(this.bb_pos+n)+44*e,this.bb):null}arcsLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startDirectrix(t){t.startObject(5)}static addTypes(t,e){t.addFieldOffset(0,e,0)}static createTypesVector(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startTypesVector(t,e){t.startVector(1,e,1)}static addIndexes(t,e){t.addFieldOffset(1,e,0)}static createIndexesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addInt32(e[i]);return t.endVector()}static startIndexesVector(t,e){t.startVector(4,e,4)}static addLineSegments(t,e){t.addFieldOffset(2,e,0)}static startLineSegmentsVector(t,e){t.startVector(24,e,4)}static addPolyLines(t,e){t.addFieldOffset(3,e,0)}static createPolyLinesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startPolyLinesVector(t,e){t.startVector(4,e,4)}static addArcs(t,e){t.addFieldOffset(4,e,0)}static startArcsVector(t,e){t.startVector(44,e,4)}static endDirectrix(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),e}}e.Directrix=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSweptDiskSolidContainer(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}directrices(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Directrix).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}directricesLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}radius(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}radiusLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}radiusArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startSweptDiskSolidContainer(t){t.startObject(2)}static addDirectrices(t,e){t.addFieldOffset(0,e,0)}static createDirectricesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startDirectricesVector(t,e){t.startVector(4,e,4)}static addRadius(t,e){t.addFieldOffset(1,e,0)}static createRadiusVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startRadiusVector(t,e){t.startVector(8,e,8)}static endSweptDiskSolidContainer(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.SweptDiskSolidContainer=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGraphicsContainer(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}lineSegments(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Line3f).__init(this.bb.__vector(this.bb_pos+n)+24*e,this.bb):null}lineSegmentsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}arcs(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.Arc3f).__init(this.bb.__vector(this.bb_pos+n)+44*e,this.bb):null}arcsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGraphicsContainer(t){t.startObject(2)}static addLineSegments(t,e){t.addFieldOffset(0,e,0)}static startLineSegmentsVector(t,e){t.startVector(24,e,4)}static addArcs(t,e){t.addFieldOffset(1,e,0)}static startArcsVector(t,e){t.startVector(44,e,4)}static endGraphicsContainer(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.GraphicsContainer=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHorizontalLineSegment(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}startTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}endTag(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}startPoint(e){var i=this.bb.__offset(this.bb_pos,8);return i?(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos+i,this.bb):null}startDirection(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}segmentLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}static startHorizontalLineSegment(t){t.startObject(5)}static addStartTag(t,e){t.addFieldOffset(0,e,0)}static addEndTag(t,e){t.addFieldOffset(1,e,0)}static addStartPoint(t,e){t.addFieldStruct(2,e,0)}static addStartDirection(t,e){t.addFieldFloat64(3,e,0)}static addSegmentLength(t,e){t.addFieldFloat64(4,e,0)}static endHorizontalLineSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.HorizontalLineSegment=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHorizontalCircularArcSegment(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}startTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}endTag(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}startPoint(e){var i=this.bb.__offset(this.bb_pos,8);return i?(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos+i,this.bb):null}startDirection(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}segmentLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}radius(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}isCCW(){var t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startHorizontalCircularArcSegment(t){t.startObject(7)}static addStartTag(t,e){t.addFieldOffset(0,e,0)}static addEndTag(t,e){t.addFieldOffset(1,e,0)}static addStartPoint(t,e){t.addFieldStruct(2,e,0)}static addStartDirection(t,e){t.addFieldFloat64(3,e,0)}static addSegmentLength(t,e){t.addFieldFloat64(4,e,0)}static addRadius(t,e){t.addFieldFloat64(5,e,0)}static addIsCCW(t,e){t.addFieldInt8(6,+e,0)}static endHorizontalCircularArcSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.HorizontalCircularArcSegment=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHorizontalClothoidalArcSegment(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}startTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}endTag(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}startPoint(e){var i=this.bb.__offset(this.bb_pos,8);return i?(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos+i,this.bb):null}startDirection(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}segmentLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}startRadius(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}clothoidConstant(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readFloat64(this.bb_pos+t):0}isCCW(){var t=this.bb.__offset(this.bb_pos,18);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}isEntry(){var t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startHorizontalClothoidalArcSegment(t){t.startObject(9)}static addStartTag(t,e){t.addFieldOffset(0,e,0)}static addEndTag(t,e){t.addFieldOffset(1,e,0)}static addStartPoint(t,e){t.addFieldStruct(2,e,0)}static addStartDirection(t,e){t.addFieldFloat64(3,e,0)}static addSegmentLength(t,e){t.addFieldFloat64(4,e,0)}static addStartRadius(t,e){t.addFieldFloat64(5,e,0)}static addClothoidConstant(t,e){t.addFieldFloat64(6,e,0)}static addIsCCW(t,e){t.addFieldInt8(7,+e,0)}static addIsEntry(t,e){t.addFieldInt8(8,+e,0)}static endHorizontalClothoidalArcSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.HorizontalClothoidalArcSegment=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHorizontalTransitionArcSegment(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}startTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}endTag(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}startPoint(e){var i=this.bb.__offset(this.bb_pos,8);return i?(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos+i,this.bb):null}startDirection(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}segmentLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}startRadius(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}endRadius(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readFloat64(this.bb_pos+t):0}isStartRadiusCCW(){var t=this.bb.__offset(this.bb_pos,18);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}isEndRadiusCCW(){var t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}type(){var e=this.bb.__offset(this.bb_pos,22);return e?this.bb.readInt8(this.bb_pos+e):t.Technology.TrimBim.Fbs.HorizontalTransitionCurveType.Invalid}static startHorizontalTransitionArcSegment(t){t.startObject(10)}static addStartTag(t,e){t.addFieldOffset(0,e,0)}static addEndTag(t,e){t.addFieldOffset(1,e,0)}static addStartPoint(t,e){t.addFieldStruct(2,e,0)}static addStartDirection(t,e){t.addFieldFloat64(3,e,0)}static addSegmentLength(t,e){t.addFieldFloat64(4,e,0)}static addStartRadius(t,e){t.addFieldFloat64(5,e,0)}static addEndRadius(t,e){t.addFieldFloat64(6,e,0)}static addIsStartRadiusCCW(t,e){t.addFieldInt8(7,+e,0)}static addIsEndRadiusCCW(t,e){t.addFieldInt8(8,+e,0)}static addType(e,i){e.addFieldInt8(9,i,t.Technology.TrimBim.Fbs.HorizontalTransitionCurveType.Invalid)}static endHorizontalTransitionArcSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.HorizontalTransitionArcSegment=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsVerticalLineSegment(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}startTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}endTag(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}startDistAlong(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat64(this.bb_pos+t):0}horizontalLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}startHeight(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}startGradient(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}static startVerticalLineSegment(t){t.startObject(6)}static addStartTag(t,e){t.addFieldOffset(0,e,0)}static addEndTag(t,e){t.addFieldOffset(1,e,0)}static addStartDistAlong(t,e){t.addFieldFloat64(2,e,0)}static addHorizontalLength(t,e){t.addFieldFloat64(3,e,0)}static addStartHeight(t,e){t.addFieldFloat64(4,e,0)}static addStartGradient(t,e){t.addFieldFloat64(5,e,0)}static endVerticalLineSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}t.VerticalLineSegment=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsVerticalCircularArcSegment(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}startTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}endTag(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}startDistAlong(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat64(this.bb_pos+t):0}horizontalLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}startHeight(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}startGradient(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}radius(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readFloat64(this.bb_pos+t):0}isConvex(){var t=this.bb.__offset(this.bb_pos,18);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startVerticalCircularArcSegment(t){t.startObject(8)}static addStartTag(t,e){t.addFieldOffset(0,e,0)}static addEndTag(t,e){t.addFieldOffset(1,e,0)}static addStartDistAlong(t,e){t.addFieldFloat64(2,e,0)}static addHorizontalLength(t,e){t.addFieldFloat64(3,e,0)}static addStartHeight(t,e){t.addFieldFloat64(4,e,0)}static addStartGradient(t,e){t.addFieldFloat64(5,e,0)}static addRadius(t,e){t.addFieldFloat64(6,e,0)}static addIsConvex(t,e){t.addFieldInt8(7,+e,0)}static endVerticalCircularArcSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}t.VerticalCircularArcSegment=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsVerticalParabolicArcSegment(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}startTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}endTag(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}startDistAlong(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat64(this.bb_pos+t):0}horizontalLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}startHeight(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}startGradient(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}parabolaConstant(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readFloat64(this.bb_pos+t):0}isConvex(){var t=this.bb.__offset(this.bb_pos,18);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startVerticalParabolicArcSegment(t){t.startObject(8)}static addStartTag(t,e){t.addFieldOffset(0,e,0)}static addEndTag(t,e){t.addFieldOffset(1,e,0)}static addStartDistAlong(t,e){t.addFieldFloat64(2,e,0)}static addHorizontalLength(t,e){t.addFieldFloat64(3,e,0)}static addStartHeight(t,e){t.addFieldFloat64(4,e,0)}static addStartGradient(t,e){t.addFieldFloat64(5,e,0)}static addParabolaConstant(t,e){t.addFieldFloat64(6,e,0)}static addIsConvex(t,e){t.addFieldInt8(7,+e,0)}static endVerticalParabolicArcSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}t.VerticalParabolicArcSegment=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHorizontalCurve(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}startAlongDistance(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat64(this.bb_pos+t):0}segmentTypes(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb.__vector(this.bb_pos+e)+t):0}segmentTypesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}segmentTypesArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Int8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}lineSegments(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.HorizontalLineSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}lineSegmentsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}circularArcSegments(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.HorizontalCircularArcSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}circularArcSegmentsLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}clothoidalArcSegments(e,i){var n=this.bb.__offset(this.bb_pos,12);return n?(i||new t.Technology.TrimBim.Fbs.HorizontalClothoidalArcSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}clothoidalArcSegmentsLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}transitionArcSegments(e,i){var n=this.bb.__offset(this.bb_pos,14);return n?(i||new t.Technology.TrimBim.Fbs.HorizontalTransitionArcSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}transitionArcSegmentsLength(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}static startHorizontalCurve(t){t.startObject(6)}static addStartAlongDistance(t,e){t.addFieldFloat64(0,e,0)}static addSegmentTypes(t,e){t.addFieldOffset(1,e,0)}static createSegmentTypesVector(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startSegmentTypesVector(t,e){t.startVector(1,e,1)}static addLineSegments(t,e){t.addFieldOffset(2,e,0)}static createLineSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startLineSegmentsVector(t,e){t.startVector(4,e,4)}static addCircularArcSegments(t,e){t.addFieldOffset(3,e,0)}static createCircularArcSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCircularArcSegmentsVector(t,e){t.startVector(4,e,4)}static addClothoidalArcSegments(t,e){t.addFieldOffset(4,e,0)}static createClothoidalArcSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startClothoidalArcSegmentsVector(t,e){t.startVector(4,e,4)}static addTransitionArcSegments(t,e){t.addFieldOffset(5,e,0)}static createTransitionArcSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startTransitionArcSegmentsVector(t,e){t.startVector(4,e,4)}static endHorizontalCurve(t){var e=t.endObject();return t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),t.requiredField(e,14),e}}e.HorizontalCurve=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsVerticalCurve(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}segmentTypes(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb.__vector(this.bb_pos+e)+t):0}segmentTypesLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}segmentTypesArray(){var t=this.bb.__offset(this.bb_pos,4);return t?new Int8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}lineSegments(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.VerticalLineSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}lineSegmentsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}circularArcSegments(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.VerticalCircularArcSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}circularArcSegmentsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}parabolicArcSegments(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.VerticalParabolicArcSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}parabolicArcSegmentsLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startVerticalCurve(t){t.startObject(4)}static addSegmentTypes(t,e){t.addFieldOffset(0,e,0)}static createSegmentTypesVector(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startSegmentTypesVector(t,e){t.startVector(1,e,1)}static addLineSegments(t,e){t.addFieldOffset(1,e,0)}static createLineSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startLineSegmentsVector(t,e){t.startVector(4,e,4)}static addCircularArcSegments(t,e){t.addFieldOffset(2,e,0)}static createCircularArcSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCircularArcSegmentsVector(t,e){t.startVector(4,e,4)}static addParabolicArcSegments(t,e){t.addFieldOffset(3,e,0)}static createParabolicArcSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startParabolicArcSegmentsVector(t,e){t.startVector(4,e,4)}static endVerticalCurve(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),e}}e.VerticalCurve=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsAlignmentCurve(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}horizontalCurve(e){var i=this.bb.__offset(this.bb_pos,4);return i?(e||new t.Technology.TrimBim.Fbs.HorizontalCurve).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}verticalCurve(e){var i=this.bb.__offset(this.bb_pos,6);return i?(e||new t.Technology.TrimBim.Fbs.VerticalCurve).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}name(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}static startAlignmentCurve(t){t.startObject(3)}static addHorizontalCurve(t,e){t.addFieldOffset(0,e,0)}static addVerticalCurve(t,e){t.addFieldOffset(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static endAlignmentCurve(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),e}}e.AlignmentCurve=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGridLineSegment(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}axisTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}lineSegment(e){var i=this.bb.__offset(this.bb_pos,6);return i?(e||new t.Technology.TrimBim.Fbs.Line3d).__init(this.bb_pos+i,this.bb):null}static startGridLineSegment(t){t.startObject(2)}static addAxisTag(t,e){t.addFieldOffset(0,e,0)}static addLineSegment(t,e){t.addFieldStruct(1,e,0)}static endGridLineSegment(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.GridLineSegment=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGridArc(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}axisTag(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}arc(e){var i=this.bb.__offset(this.bb_pos,6);return i?(e||new t.Technology.TrimBim.Fbs.Arc3d).__init(this.bb_pos+i,this.bb):null}static startGridArc(t){t.startObject(2)}static addAxisTag(t,e){t.addFieldOffset(0,e,0)}static addArc(t,e){t.addFieldStruct(1,e,0)}static endGridArc(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.GridArc=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGridLineContainer(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}gridLineSegments(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.GridLineSegment).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}gridLineSegmentsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}gridArcs(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.GridArc).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}gridArcsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGridLineContainer(t){t.startObject(2)}static addGridLineSegments(t,e){t.addFieldOffset(0,e,0)}static createGridLineSegmentsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startGridLineSegmentsVector(t,e){t.startVector(4,e,4)}static addGridArcs(t,e){t.addFieldOffset(1,e,0)}static createGridArcsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startGridArcsVector(t,e){t.startVector(4,e,4)}static endGridLineContainer(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}e.GridLineContainer=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCoordinateGeometryPoint(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}name(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}symbol(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startCoordinateGeometryPoint(t){t.startObject(2)}static addName(t,e){t.addFieldOffset(0,e,0)}static addSymbol(t,e){t.addFieldOffset(1,e,0)}static endCoordinateGeometryPoint(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}t.CoordinateGeometryPoint=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBillboardText(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}textStyleId(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}text(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startBillboardText(t){t.startObject(2)}static addTextStyleId(t,e){t.addFieldInt32(0,e,0)}static addText(t,e){t.addFieldOffset(1,e,0)}static endBillboardText(t){var e=t.endObject();return t.requiredField(e,6),e}}t.BillboardText=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTextStyle(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}font(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}size(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat64(this.bb_pos+t):0}options(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint32(this.bb_pos+t):0}verticalAlign(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}horizontalAlign(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}rotationAngle(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}layout(){var e=this.bb.__offset(this.bb_pos,16);return e?this.bb.readInt8(this.bb_pos+e):t.Technology.TrimBim.Fbs.LayoutType.Invalid}alignment(){var e=this.bb.__offset(this.bb_pos,18);return e?this.bb.readInt8(this.bb_pos+e):t.Technology.TrimBim.Fbs.AlignmentType.Invalid}maxAutoScale(){var t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readFloat64(this.bb_pos+t):0}verticalDistanceToObject(){var t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readFloat64(this.bb_pos+t):0}static startTextStyle(t){t.startObject(10)}static addFont(t,e){t.addFieldOffset(0,e,0)}static addSize(t,e){t.addFieldFloat64(1,e,0)}static addOptions(t,e){t.addFieldInt32(2,e,0)}static addVerticalAlign(t,e){t.addFieldFloat64(3,e,0)}static addHorizontalAlign(t,e){t.addFieldFloat64(4,e,0)}static addRotationAngle(t,e){t.addFieldFloat64(5,e,0)}static addLayout(e,i){e.addFieldInt8(6,i,t.Technology.TrimBim.Fbs.LayoutType.Invalid)}static addAlignment(e,i){e.addFieldInt8(7,i,t.Technology.TrimBim.Fbs.AlignmentType.Invalid)}static addMaxAutoScale(t,e){t.addFieldFloat64(8,e,0)}static addVerticalDistanceToObject(t,e){t.addFieldFloat64(9,e,0)}static endTextStyle(t){return t.endObject()}}e.TextStyle=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBillboard(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}static startBillboard(t){t.startObject(0)}static endBillboard(t){return t.endObject()}}t.Billboard=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){e.TexturedBillboard=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}leftUpXY(e){return(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos,this.bb)}leftUpUV(e){return(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos+16,this.bb)}rightDownXY(e){return(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos+32,this.bb)}rightDownUV(e){return(e||new t.Technology.TrimBim.Fbs.Vec2d).__init(this.bb_pos+48,this.bb)}IsInWorldUnits(){return!!this.bb.readInt8(this.bb_pos+64)}static createTexturedBillboard(t,e,i,n,r,s,o,a,h,c){return t.prep(8,72),t.pad(7),t.writeInt8(+c),t.prep(8,16),t.writeFloat64(h),t.writeFloat64(a),t.prep(8,16),t.writeFloat64(o),t.writeFloat64(s),t.prep(8,16),t.writeFloat64(r),t.writeFloat64(n),t.prep(8,16),t.writeFloat64(i),t.writeFloat64(e),t.offset()}}}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.BoltTop=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}topDiameter(){return this.bb.readFloat32(this.bb_pos)}thickness(){return this.bb.readFloat32(this.bb_pos+4)}diameter(){return this.bb.readFloat32(this.bb_pos+8)}length(){return this.bb.readFloat32(this.bb_pos+12)}type(){return this.bb.readInt8(this.bb_pos+16)}static createBoltTop(t,e,i,n,r,s){return t.prep(4,20),t.pad(3),t.writeInt8(s),t.writeFloat32(r),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Washer=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readFloat32(this.bb_pos)}innerDiameter(){return this.bb.readFloat32(this.bb_pos+4)}outerDiameter(){return this.bb.readFloat32(this.bb_pos+8)}thickness(){return this.bb.readFloat32(this.bb_pos+12)}static createWasher(t,e,i,n,r){return t.prep(4,16),t.writeFloat32(r),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Nut=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readFloat32(this.bb_pos)}innerDiameter(){return this.bb.readFloat32(this.bb_pos+4)}outerDiameter(){return this.bb.readFloat32(this.bb_pos+8)}thickness(){return this.bb.readFloat32(this.bb_pos+12)}static createNut(t,e,i,n,r){return t.prep(4,16),t.writeFloat32(r),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Hole=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readFloat32(this.bb_pos)}length(){return this.bb.readFloat32(this.bb_pos+4)}diameter(){return this.bb.readFloat32(this.bb_pos+8)}xslot(){return this.bb.readFloat32(this.bb_pos+12)}yslot(){return this.bb.readFloat32(this.bb_pos+16)}static createHole(t,e,i,n,r,s){return t.prep(4,20),t.writeFloat32(s),t.writeFloat32(r),t.writeFloat32(n),t.writeFloat32(i),t.writeFloat32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBolt(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}top(e){var i=this.bb.__offset(this.bb_pos,4);return i?(e||new t.Technology.TrimBim.Fbs.BoltTop).__init(this.bb_pos+i,this.bb):null}washers(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.Washer).__init(this.bb.__vector(this.bb_pos+n)+16*e,this.bb):null}washersLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}nuts(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.Nut).__init(this.bb.__vector(this.bb_pos+n)+16*e,this.bb):null}nutsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}holes(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.Hole).__init(this.bb.__vector(this.bb_pos+n)+20*e,this.bb):null}holesLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startBolt(t){t.startObject(4)}static addTop(t,e){t.addFieldStruct(0,e,0)}static addWashers(t,e){t.addFieldOffset(1,e,0)}static startWashersVector(t,e){t.startVector(16,e,4)}static addNuts(t,e){t.addFieldOffset(2,e,0)}static startNutsVector(t,e){t.startVector(16,e,4)}static addHoles(t,e){t.addFieldOffset(3,e,0)}static startHolesVector(t,e){t.startVector(20,e,4)}static endBolt(t){var e=t.endObject();return t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),e}}e.Bolt=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMapConversion(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}eastings(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat64(this.bb_pos+t):0}northings(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat64(this.bb_pos+t):0}orthogonalHeight(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat64(this.bb_pos+t):0}xAxisAbscissa(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat64(this.bb_pos+t):0}xAxisOrdinate(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat64(this.bb_pos+t):0}scaleToMapProjection(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat64(this.bb_pos+t):0}projectionName(t){var e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb_pos+e,t):null}projectionDescription(t){var e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,t):null}projectionGeodeticDatum(t){var e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb_pos+e,t):null}projectionVerticalDatum(t){var e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__string(this.bb_pos+e,t):null}projectionProjectionType(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}projectionZone(t){var e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}projectionUnitName(t){var e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}projectionScaleToMetric(){var t=this.bb.__offset(this.bb_pos,30);return t?this.bb.readFloat64(this.bb_pos+t):0}static startMapConversion(t){t.startObject(14)}static addEastings(t,e){t.addFieldFloat64(0,e,0)}static addNorthings(t,e){t.addFieldFloat64(1,e,0)}static addOrthogonalHeight(t,e){t.addFieldFloat64(2,e,0)}static addXAxisAbscissa(t,e){t.addFieldFloat64(3,e,0)}static addXAxisOrdinate(t,e){t.addFieldFloat64(4,e,0)}static addScaleToMapProjection(t,e){t.addFieldFloat64(5,e,0)}static addProjectionName(t,e){t.addFieldOffset(6,e,0)}static addProjectionDescription(t,e){t.addFieldOffset(7,e,0)}static addProjectionGeodeticDatum(t,e){t.addFieldOffset(8,e,0)}static addProjectionVerticalDatum(t,e){t.addFieldOffset(9,e,0)}static addProjectionProjectionType(t,e){t.addFieldOffset(10,e,0)}static addProjectionZone(t,e){t.addFieldOffset(11,e,0)}static addProjectionUnitName(t,e){t.addFieldOffset(12,e,0)}static addProjectionScaleToMetric(t,e){t.addFieldFloat64(13,e,0)}static endMapConversion(t){return t.endObject()}}t.MapConversion=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsModelGeometry(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}localPlacements(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Placement3).__init(this.bb.__vector(this.bb_pos+n)+48*e,this.bb):null}localPlacementsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}surfaceMaterials(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.SurfaceMaterial).__init(this.bb.__vector(this.bb_pos+n)+20*e,this.bb):null}surfaceMaterialsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}layers(t,e){var i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}layersLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}definitions(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.GeometryDefinition).__init(this.bb.__vector(this.bb_pos+n)+32*e,this.bb):null}definitionsLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}instances(e,i){var n=this.bb.__offset(this.bb_pos,12);return n?(i||new t.Technology.TrimBim.Fbs.GeometryInstance).__init(this.bb.__vector(this.bb_pos+n)+20*e,this.bb):null}instancesLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}textures(e,i){var n=this.bb.__offset(this.bb_pos,14);return n?(i||new t.Technology.TrimBim.Fbs.Texture).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}texturesLength(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}bReps(e,i){var n=this.bb.__offset(this.bb_pos,16);return n?(i||new t.Technology.TrimBim.Fbs.BRep).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}bRepsLength(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}triangleMeshes(e,i){var n=this.bb.__offset(this.bb_pos,18);return n?(i||new t.Technology.TrimBim.Fbs.TriangleMesh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}triangleMeshesLength(){var t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}triangleMeshes8(e,i){var n=this.bb.__offset(this.bb_pos,20);return n?(i||new t.Technology.TrimBim.Fbs.TriangleMesh8).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}triangleMeshes8Length(){var t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}texturedTriangleMeshes(e,i){var n=this.bb.__offset(this.bb_pos,22);return n?(i||new t.Technology.TrimBim.Fbs.TexturedTriangleMesh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}texturedTriangleMeshesLength(){var t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}texturedTriangleMeshes8(e,i){var n=this.bb.__offset(this.bb_pos,24);return n?(i||new t.Technology.TrimBim.Fbs.TexturedTriangleMesh8).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}texturedTriangleMeshes8Length(){var t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}sweptDiskSolids(e,i){var n=this.bb.__offset(this.bb_pos,26);return n?(i||new t.Technology.TrimBim.Fbs.SweptDiskSolidContainer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}sweptDiskSolidsLength(){var t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}bRepWithUVs(e,i){var n=this.bb.__offset(this.bb_pos,28);return n?(i||new t.Technology.TrimBim.Fbs.BRepWithUV).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}bRepWithUVsLength(){var t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}bRepWithNormals(e,i){var n=this.bb.__offset(this.bb_pos,30);return n?(i||new t.Technology.TrimBim.Fbs.BRepWithNormal).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}bRepWithNormalsLength(){var t=this.bb.__offset(this.bb_pos,30);return t?this.bb.__vector_len(this.bb_pos+t):0}graphicsContainers(e,i){var n=this.bb.__offset(this.bb_pos,32);return n?(i||new t.Technology.TrimBim.Fbs.GraphicsContainer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}graphicsContainersLength(){var t=this.bb.__offset(this.bb_pos,32);return t?this.bb.__vector_len(this.bb_pos+t):0}alignmentCurves(e,i){var n=this.bb.__offset(this.bb_pos,34);return n?(i||new t.Technology.TrimBim.Fbs.AlignmentCurve).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}alignmentCurvesLength(){var t=this.bb.__offset(this.bb_pos,34);return t?this.bb.__vector_len(this.bb_pos+t):0}gridLineContainers(e,i){var n=this.bb.__offset(this.bb_pos,36);return n?(i||new t.Technology.TrimBim.Fbs.GridLineContainer).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}gridLineContainersLength(){var t=this.bb.__offset(this.bb_pos,36);return t?this.bb.__vector_len(this.bb_pos+t):0}coordinateGeometryPoints(e,i){var n=this.bb.__offset(this.bb_pos,38);return n?(i||new t.Technology.TrimBim.Fbs.CoordinateGeometryPoint).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}coordinateGeometryPointsLength(){var t=this.bb.__offset(this.bb_pos,38);return t?this.bb.__vector_len(this.bb_pos+t):0}billboardTexts(e,i){var n=this.bb.__offset(this.bb_pos,40);return n?(i||new t.Technology.TrimBim.Fbs.BillboardText).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}billboardTextsLength(){var t=this.bb.__offset(this.bb_pos,40);return t?this.bb.__vector_len(this.bb_pos+t):0}textStyles(e,i){var n=this.bb.__offset(this.bb_pos,42);return n?(i||new t.Technology.TrimBim.Fbs.TextStyle).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}textStylesLength(){var t=this.bb.__offset(this.bb_pos,42);return t?this.bb.__vector_len(this.bb_pos+t):0}billboards(e,i){var n=this.bb.__offset(this.bb_pos,44);return n?(i||new t.Technology.TrimBim.Fbs.Billboard).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}billboardsLength(){var t=this.bb.__offset(this.bb_pos,44);return t?this.bb.__vector_len(this.bb_pos+t):0}texturedBillboards(e,i){var n=this.bb.__offset(this.bb_pos,46);return n?(i||new t.Technology.TrimBim.Fbs.TexturedBillboard).__init(this.bb.__vector(this.bb_pos+n)+72*e,this.bb):null}texturedBillboardsLength(){var t=this.bb.__offset(this.bb_pos,46);return t?this.bb.__vector_len(this.bb_pos+t):0}bolts(e,i){var n=this.bb.__offset(this.bb_pos,48);return n?(i||new t.Technology.TrimBim.Fbs.Bolt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}boltsLength(){var t=this.bb.__offset(this.bb_pos,48);return t?this.bb.__vector_len(this.bb_pos+t):0}static startModelGeometry(t){t.startObject(23)}static addLocalPlacements(t,e){t.addFieldOffset(0,e,0)}static startLocalPlacementsVector(t,e){t.startVector(48,e,8)}static addSurfaceMaterials(t,e){t.addFieldOffset(1,e,0)}static startSurfaceMaterialsVector(t,e){t.startVector(20,e,4)}static addLayers(t,e){t.addFieldOffset(2,e,0)}static createLayersVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startLayersVector(t,e){t.startVector(4,e,4)}static addDefinitions(t,e){t.addFieldOffset(3,e,0)}static startDefinitionsVector(t,e){t.startVector(32,e,4)}static addInstances(t,e){t.addFieldOffset(4,e,0)}static startInstancesVector(t,e){t.startVector(20,e,4)}static addTextures(t,e){t.addFieldOffset(5,e,0)}static createTexturesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startTexturesVector(t,e){t.startVector(4,e,4)}static addBReps(t,e){t.addFieldOffset(6,e,0)}static createBRepsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startBRepsVector(t,e){t.startVector(4,e,4)}static addTriangleMeshes(t,e){t.addFieldOffset(7,e,0)}static createTriangleMeshesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startTriangleMeshesVector(t,e){t.startVector(4,e,4)}static addTriangleMeshes8(t,e){t.addFieldOffset(8,e,0)}static createTriangleMeshes8Vector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startTriangleMeshes8Vector(t,e){t.startVector(4,e,4)}static addTexturedTriangleMeshes(t,e){t.addFieldOffset(9,e,0)}static createTexturedTriangleMeshesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startTexturedTriangleMeshesVector(t,e){t.startVector(4,e,4)}static addTexturedTriangleMeshes8(t,e){t.addFieldOffset(10,e,0)}static createTexturedTriangleMeshes8Vector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startTexturedTriangleMeshes8Vector(t,e){t.startVector(4,e,4)}static addSweptDiskSolids(t,e){t.addFieldOffset(11,e,0)}static createSweptDiskSolidsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startSweptDiskSolidsVector(t,e){t.startVector(4,e,4)}static addBRepWithUVs(t,e){t.addFieldOffset(12,e,0)}static createBRepWithUVsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startBRepWithUVsVector(t,e){t.startVector(4,e,4)}static addBRepWithNormals(t,e){t.addFieldOffset(13,e,0)}static createBRepWithNormalsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startBRepWithNormalsVector(t,e){t.startVector(4,e,4)}static addGraphicsContainers(t,e){t.addFieldOffset(14,e,0)}static createGraphicsContainersVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startGraphicsContainersVector(t,e){t.startVector(4,e,4)}static addAlignmentCurves(t,e){t.addFieldOffset(15,e,0)}static createAlignmentCurvesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startAlignmentCurvesVector(t,e){t.startVector(4,e,4)}static addGridLineContainers(t,e){t.addFieldOffset(16,e,0)}static createGridLineContainersVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startGridLineContainersVector(t,e){t.startVector(4,e,4)}static addCoordinateGeometryPoints(t,e){t.addFieldOffset(17,e,0)}static createCoordinateGeometryPointsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCoordinateGeometryPointsVector(t,e){t.startVector(4,e,4)}static addBillboardTexts(t,e){t.addFieldOffset(18,e,0)}static createBillboardTextsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startBillboardTextsVector(t,e){t.startVector(4,e,4)}static addTextStyles(t,e){t.addFieldOffset(19,e,0)}static createTextStylesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startTextStylesVector(t,e){t.startVector(4,e,4)}static addBillboards(t,e){t.addFieldOffset(20,e,0)}static createBillboardsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startBillboardsVector(t,e){t.startVector(4,e,4)}static addTexturedBillboards(t,e){t.addFieldOffset(21,e,0)}static startTexturedBillboardsVector(t,e){t.startVector(72,e,8)}static addBolts(t,e){t.addFieldOffset(22,e,0)}static createBoltsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startBoltsVector(t,e){t.startVector(4,e,4)}static endModelGeometry(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),t.requiredField(e,14),t.requiredField(e,16),t.requiredField(e,18),t.requiredField(e,20),t.requiredField(e,22),t.requiredField(e,24),t.requiredField(e,26),t.requiredField(e,28),t.requiredField(e,30),t.requiredField(e,32),t.requiredField(e,34),t.requiredField(e,36),t.requiredField(e,38),t.requiredField(e,40),t.requiredField(e,42),t.requiredField(e,44),t.requiredField(e,46),t.requiredField(e,48),e}}e.ModelGeometry=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsOwner(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}personId(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}personFamilyName(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}personGivenName(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}personMiddleNames(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}personRoles(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}organizationId(t){var e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}organizationName(t){var e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb_pos+e,t):null}organizationDescription(t){var e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,t):null}organizationRoles(t){var e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb_pos+e,t):null}applicationVersion(t){var e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__string(this.bb_pos+e,t):null}applicationFullName(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}applicationIdentifier(t){var e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}static startOwner(t){t.startObject(12)}static addPersonId(t,e){t.addFieldOffset(0,e,0)}static addPersonFamilyName(t,e){t.addFieldOffset(1,e,0)}static addPersonGivenName(t,e){t.addFieldOffset(2,e,0)}static addPersonMiddleNames(t,e){t.addFieldOffset(3,e,0)}static addPersonRoles(t,e){t.addFieldOffset(4,e,0)}static addOrganizationId(t,e){t.addFieldOffset(5,e,0)}static addOrganizationName(t,e){t.addFieldOffset(6,e,0)}static addOrganizationDescription(t,e){t.addFieldOffset(7,e,0)}static addOrganizationRoles(t,e){t.addFieldOffset(8,e,0)}static addApplicationVersion(t,e){t.addFieldOffset(9,e,0)}static addApplicationFullName(t,e){t.addFieldOffset(10,e,0)}static addApplicationIdentifier(t,e){t.addFieldOffset(11,e,0)}static endOwner(t){return t.endObject()}}t.Owner=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.History=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}state(){return this.bb.readInt8(this.bb_pos)}changeAction(){return this.bb.readInt8(this.bb_pos+1)}creationDate(){return this.bb.readInt64(this.bb_pos+8)}lastModificationDate(){return this.bb.readInt64(this.bb_pos+16)}static createHistory(t,e,i,n,r){return t.prep(8,24),t.writeInt64(r),t.writeInt64(n),t.pad(6),t.writeInt8(i),t.writeInt8(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.Product=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}owner(){return this.bb.readUint32(this.bb_pos)}history(){return this.bb.readUint32(this.bb_pos+4)}name(){return this.bb.readUint32(this.bb_pos+8)}description(){return this.bb.readUint32(this.bb_pos+12)}objectType(){return this.bb.readUint32(this.bb_pos+16)}static createProduct(t,e,i,n,r,s){return t.prep(4,20),t.writeInt32(s),t.writeInt32(r),t.writeInt32(n),t.writeInt32(i),t.writeInt32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.ProductBinding=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}entityId(){return this.bb.readUint32(this.bb_pos)}productId(){return this.bb.readUint32(this.bb_pos+4)}static createProductBinding(t,e,i){return t.prep(4,8),t.writeInt32(i),t.writeInt32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.SinglePropertyDefinition=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}name(){return this.bb.readUint32(this.bb_pos)}type(){return this.bb.readInt8(this.bb_pos+4)}static createSinglePropertyDefinition(t,e,i){return t.prep(4,8),t.pad(3),t.writeInt8(i),t.writeInt32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsPropertySetDefinition(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}name(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}properties(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.SinglePropertyDefinition).__init(this.bb.__vector(this.bb_pos+n)+8*e,this.bb):null}propertiesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}static startPropertySetDefinition(t){t.startObject(2)}static addName(t,e){t.addFieldInt32(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static startPropertiesVector(t,e){t.startVector(8,e,4)}static endPropertySetDefinition(t){var e=t.endObject();return t.requiredField(e,6),e}}e.PropertySetDefinition=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsPropertySet(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}definition(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0}values(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}valuesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}valuesArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}entities(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}entitiesLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}entitiesArray(){var t=this.bb.__offset(this.bb_pos,8);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startPropertySet(t){t.startObject(3)}static addDefinition(t,e){t.addFieldInt32(0,e,0)}static addValues(t,e){t.addFieldOffset(1,e,0)}static createValuesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addInt32(e[i]);return t.endVector()}static startValuesVector(t,e){t.startVector(4,e,4)}static addEntities(t,e){t.addFieldOffset(2,e,0)}static createEntitiesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addInt32(e[i]);return t.endVector()}static startEntitiesVector(t,e){t.startVector(4,e,4)}static endPropertySet(t){var e=t.endObject();return t.requiredField(e,6),t.requiredField(e,8),e}}t.PropertySet=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsModelProperties(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}productBindings(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.ProductBinding).__init(this.bb.__vector(this.bb_pos+n)+8*e,this.bb):null}productBindingsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}products(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.Product).__init(this.bb.__vector(this.bb_pos+n)+20*e,this.bb):null}productsLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}owners(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.Owner).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}ownersLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}histories(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.History).__init(this.bb.__vector(this.bb_pos+n)+24*e,this.bb):null}historiesLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}names(t,e){var i=this.bb.__offset(this.bb_pos,12);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}namesLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}descriptions(t,e){var i=this.bb.__offset(this.bb_pos,14);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}descriptionsLength(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}objectTypes(t,e){var i=this.bb.__offset(this.bb_pos,16);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}objectTypesLength(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}propertySetBindings(e,i){var n=this.bb.__offset(this.bb_pos,18);return n?(i||new t.Technology.TrimBim.Fbs.PropertySet).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}propertySetBindingsLength(){var t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}propertySetNames(t,e){var i=this.bb.__offset(this.bb_pos,20);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}propertySetNamesLength(){var t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0}propertyNames(t,e){var i=this.bb.__offset(this.bb_pos,22);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}propertyNamesLength(){var t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0}definitions(e,i){var n=this.bb.__offset(this.bb_pos,24);return n?(i||new t.Technology.TrimBim.Fbs.PropertySetDefinition).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}definitionsLength(){var t=this.bb.__offset(this.bb_pos,24);return t?this.bb.__vector_len(this.bb_pos+t):0}lengthMeasures(t){var e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}lengthMeasuresLength(){var t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0}lengthMeasuresArray(){var t=this.bb.__offset(this.bb_pos,26);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}areaMeasures(t){var e=this.bb.__offset(this.bb_pos,28);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}areaMeasuresLength(){var t=this.bb.__offset(this.bb_pos,28);return t?this.bb.__vector_len(this.bb_pos+t):0}areaMeasuresArray(){var t=this.bb.__offset(this.bb_pos,28);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}volumeMeasures(t){var e=this.bb.__offset(this.bb_pos,30);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}volumeMeasuresLength(){var t=this.bb.__offset(this.bb_pos,30);return t?this.bb.__vector_len(this.bb_pos+t):0}volumeMeasuresArray(){var t=this.bb.__offset(this.bb_pos,30);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}massMeasures(t){var e=this.bb.__offset(this.bb_pos,32);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}massMeasuresLength(){var t=this.bb.__offset(this.bb_pos,32);return t?this.bb.__vector_len(this.bb_pos+t):0}massMeasuresArray(){var t=this.bb.__offset(this.bb_pos,32);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}angleMeasures(t){var e=this.bb.__offset(this.bb_pos,34);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}angleMeasuresLength(){var t=this.bb.__offset(this.bb_pos,34);return t?this.bb.__vector_len(this.bb_pos+t):0}angleMeasuresArray(){var t=this.bb.__offset(this.bb_pos,34);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}stringValues(t,e){var i=this.bb.__offset(this.bb_pos,36);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}stringValuesLength(){var t=this.bb.__offset(this.bb_pos,36);return t?this.bb.__vector_len(this.bb_pos+t):0}doubleValues(t){var e=this.bb.__offset(this.bb_pos,38);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}doubleValuesLength(){var t=this.bb.__offset(this.bb_pos,38);return t?this.bb.__vector_len(this.bb_pos+t):0}doubleValuesArray(){var t=this.bb.__offset(this.bb_pos,38);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}dateTimeValues(t){var e=this.bb.__offset(this.bb_pos,40);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dateTimeValuesLength(){var t=this.bb.__offset(this.bb_pos,40);return t?this.bb.__vector_len(this.bb_pos+t):0}static startModelProperties(t){t.startObject(19)}static addProductBindings(t,e){t.addFieldOffset(0,e,0)}static startProductBindingsVector(t,e){t.startVector(8,e,4)}static addProducts(t,e){t.addFieldOffset(1,e,0)}static startProductsVector(t,e){t.startVector(20,e,4)}static addOwners(t,e){t.addFieldOffset(2,e,0)}static createOwnersVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startOwnersVector(t,e){t.startVector(4,e,4)}static addHistories(t,e){t.addFieldOffset(3,e,0)}static startHistoriesVector(t,e){t.startVector(24,e,8)}static addNames(t,e){t.addFieldOffset(4,e,0)}static createNamesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startNamesVector(t,e){t.startVector(4,e,4)}static addDescriptions(t,e){t.addFieldOffset(5,e,0)}static createDescriptionsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startDescriptionsVector(t,e){t.startVector(4,e,4)}static addObjectTypes(t,e){t.addFieldOffset(6,e,0)}static createObjectTypesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startObjectTypesVector(t,e){t.startVector(4,e,4)}static addPropertySetBindings(t,e){t.addFieldOffset(7,e,0)}static createPropertySetBindingsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startPropertySetBindingsVector(t,e){t.startVector(4,e,4)}static addPropertySetNames(t,e){t.addFieldOffset(8,e,0)}static createPropertySetNamesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startPropertySetNamesVector(t,e){t.startVector(4,e,4)}static addPropertyNames(t,e){t.addFieldOffset(9,e,0)}static createPropertyNamesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startPropertyNamesVector(t,e){t.startVector(4,e,4)}static addDefinitions(t,e){t.addFieldOffset(10,e,0)}static createDefinitionsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startDefinitionsVector(t,e){t.startVector(4,e,4)}static addLengthMeasures(t,e){t.addFieldOffset(11,e,0)}static createLengthMeasuresVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startLengthMeasuresVector(t,e){t.startVector(8,e,8)}static addAreaMeasures(t,e){t.addFieldOffset(12,e,0)}static createAreaMeasuresVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startAreaMeasuresVector(t,e){t.startVector(8,e,8)}static addVolumeMeasures(t,e){t.addFieldOffset(13,e,0)}static createVolumeMeasuresVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startVolumeMeasuresVector(t,e){t.startVector(8,e,8)}static addMassMeasures(t,e){t.addFieldOffset(14,e,0)}static createMassMeasuresVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startMassMeasuresVector(t,e){t.startVector(8,e,8)}static addAngleMeasures(t,e){t.addFieldOffset(15,e,0)}static createAngleMeasuresVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startAngleMeasuresVector(t,e){t.startVector(8,e,8)}static addStringValues(t,e){t.addFieldOffset(16,e,0)}static createStringValuesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startStringValuesVector(t,e){t.startVector(4,e,4)}static addDoubleValues(t,e){t.addFieldOffset(17,e,0)}static createDoubleValuesVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startDoubleValuesVector(t,e){t.startVector(8,e,8)}static addDateTimeValues(t,e){t.addFieldOffset(18,e,0)}static createDateTimeValuesVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addInt64(e[i]);return t.endVector()}static startDateTimeValuesVector(t,e){t.startVector(8,e,8)}static endModelProperties(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),t.requiredField(e,14),t.requiredField(e,16),t.requiredField(e,18),t.requiredField(e,20),t.requiredField(e,22),t.requiredField(e,24),t.requiredField(e,26),t.requiredField(e,28),t.requiredField(e,30),t.requiredField(e,32),t.requiredField(e,34),t.requiredField(e,36),t.requiredField(e,38),t.requiredField(e,40),e}}e.ModelProperties=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){t.HierarchyNode=class{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}parentElementId(){return this.bb.readUint32(this.bb_pos)}childElementId(){return this.bb.readUint32(this.bb_pos+4)}type(){return this.bb.readInt8(this.bb_pos+8)}static createHierarchyNode(t,e,i,n){return t.prep(4,12),t.pad(3),t.writeInt8(n),t.writeInt32(i),t.writeInt32(e),t.offset()}}}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsModelEntities(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}entities(e,i){var n=this.bb.__offset(this.bb_pos,4);return n?(i||new t.Technology.TrimBim.Fbs.Entity).__init(this.bb.__vector(this.bb_pos+n)+64*e,this.bb):null}entitiesLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}hierarchies(e,i){var n=this.bb.__offset(this.bb_pos,6);return n?(i||new t.Technology.TrimBim.Fbs.HierarchyNode).__init(this.bb.__vector(this.bb_pos+n)+12*e,this.bb):null}hierarchiesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}guidIdentifiers(e,i){var n=this.bb.__offset(this.bb_pos,8);return n?(i||new t.Technology.TrimBim.Fbs.Guid).__init(this.bb.__vector(this.bb_pos+n)+16*e,this.bb):null}guidIdentifiersLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}stringIdentifiers(t,e){var i=this.bb.__offset(this.bb_pos,10);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}stringIdentifiersLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}spatialHashIdentifiers(e,i){var n=this.bb.__offset(this.bb_pos,12);return n?(i||new t.Technology.TrimBim.Fbs.SpatialHash).__init(this.bb.__vector(this.bb_pos+n)+88*e,this.bb):null}spatialHashIdentifiersLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}dwgHandleIdentifiers(t){var e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}dwgHandleIdentifiersLength(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}entityClasses(t,e){var i=this.bb.__offset(this.bb_pos,16);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null}entityClassesLength(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startModelEntities(t){t.startObject(7)}static addEntities(t,e){t.addFieldOffset(0,e,0)}static startEntitiesVector(t,e){t.startVector(64,e,8)}static addHierarchies(t,e){t.addFieldOffset(1,e,0)}static startHierarchiesVector(t,e){t.startVector(12,e,4)}static addGuidIdentifiers(t,e){t.addFieldOffset(2,e,0)}static startGuidIdentifiersVector(t,e){t.startVector(16,e,4)}static addStringIdentifiers(t,e){t.addFieldOffset(3,e,0)}static createStringIdentifiersVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startStringIdentifiersVector(t,e){t.startVector(4,e,4)}static addSpatialHashIdentifiers(t,e){t.addFieldOffset(4,e,0)}static startSpatialHashIdentifiersVector(t,e){t.startVector(88,e,8)}static addDwgHandleIdentifiers(t,e){t.addFieldOffset(5,e,0)}static createDwgHandleIdentifiersVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addInt64(e[i]);return t.endVector()}static startDwgHandleIdentifiersVector(t,e){t.startVector(8,e,8)}static addEntityClasses(t,e){t.addFieldOffset(6,e,0)}static createEntityClassesVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startEntityClassesVector(t,e){t.startVector(4,e,4)}static endModelEntities(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),t.requiredField(e,14),t.requiredField(e,16),e}}e.ModelEntities=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(t){!function(t){!function(t){class e{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMetadataEntry(t,i){return(i||new e).__init(t.readInt32(t.position())+t.position(),t)}key(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startMetadataEntry(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endMetadataEntry(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e}}t.MetadataEntry=e}(t.Fbs||(t.Fbs={}))}(t.TrimBim||(t.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={})),function(t){!function(e){!function(e){!function(e){class i{constructor(){this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsModel(t,e){return(e||new i).__init(t.readInt32(t.position())+t.position(),t)}static bufferHasIdentifier(t){return t.__has_identifier("TRB8")}entities(e){var i=this.bb.__offset(this.bb_pos,4);return i?(e||new t.Technology.TrimBim.Fbs.ModelEntities).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}properties(e){var i=this.bb.__offset(this.bb_pos,6);return i?(e||new t.Technology.TrimBim.Fbs.ModelProperties).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}geometry(e){var i=this.bb.__offset(this.bb_pos,8);return i?(e||new t.Technology.TrimBim.Fbs.ModelGeometry).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}mapConversions(e,i){var n=this.bb.__offset(this.bb_pos,10);return n?(i||new t.Technology.TrimBim.Fbs.MapConversion).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}mapConversionsLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}metadata(e,i){var n=this.bb.__offset(this.bb_pos,12);return n?(i||new t.Technology.TrimBim.Fbs.MetadataEntry).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*e),this.bb):null}metadataLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startModel(t){t.startObject(5)}static addEntities(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static addGeometry(t,e){t.addFieldOffset(2,e,0)}static addMapConversions(t,e){t.addFieldOffset(3,e,0)}static createMapConversionsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startMapConversionsVector(t,e){t.startVector(4,e,4)}static addMetadata(t,e){t.addFieldOffset(4,e,0)}static createMetadataVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startMetadataVector(t,e){t.startVector(4,e,4)}static endModel(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),t.requiredField(e,8),t.requiredField(e,10),t.requiredField(e,12),e}static finishModelBuffer(t,e){t.finish(e,"TRB8")}}e.Model=i}(e.Fbs||(e.Fbs={}))}(e.TrimBim||(e.TrimBim={}))}(t.Technology||(t.Technology={}))}(ig||(ig={}));var rg=ig.Technology.TrimBim.Fbs;class sg{constructor(t,e,i,n){this._clipPlanes=t,this._settings=e,this._trimbimSettings=i,this._renderingManager=n,this.materialHashes=new Map,this.materialsByModel=new Map,this.textureByMaterial=new Map,this._intersectingClipPlanes=!1,this._loadingImagesCount=0}forEachMaterial(t){for(const e of this.materialHashes.values()){const i=e;i.isViewerMaterial&&t(i)}}forEachMeshMaterial(t){for(const e of this.materialHashes.values()){const i=e;i.isViewerMeshMaterial&&t(i)}}get intersectingClipPlanes(){return this._intersectingClipPlanes}set intersectingClipPlanes(t){this._intersectingClipPlanes=t,this.forEachMaterial((e=>e.setIntersection(t)))}setMeshMaterialsSidedness(t,e){this.forEachMeshMaterial((i=>i.setSidedness(t,e)))}restoreMeshMaterialsSidedness(){this.forEachMeshMaterial((t=>t.restoreOriginalSidedness()))}_toMaterialParameters(t){return{opacity:void 0!==t.opacity?t.opacity:1,transparent:t.transparent,clippingPlanes:this._clipPlanes,clipIntersection:this.intersectingClipPlanes}}_toMeshMaterialParameters(t,e){const i=this._toMaterialParameters(t);void 0!==this._trimbimSettings.transparentMeshTextures&&!1!==this._trimbimSettings.transparentMeshTextures||(i.transparent=i.opacity<1);const n={color:t.color,map:e,side:t.side===rg.Sidedness.Double?2:0,isDoubleGeometryPart:t.side===rg.Sidedness.BackFace||t.side===rg.Sidedness.FrontFace};return Object.assign(n,i)}createMeshMaterial(t){const{metaMaterial:e,map:i}=t,n=this._toMeshMaterialParameters(e,i);return eg.createSettingsAwareMaterial(this._settings,n,this._renderingManager.uniforms)}createLineMaterial(t){const{metaMaterial:e}=t;return new No(Object.assign({color:e.color},this._toMaterialParameters(e)))}createPointMaterial(t){const{metaMaterial:e,map:i,isAttenuated:n=!1,text:r,textStyle:s}=t,o=Object.assign({color:e.color,map:i,useSizeBuffer:!0},this._toMaterialParameters(e));if(r){const t=sg.createTextTexture(r,s,e);o.map=t.texture,o.transparent=!0,o.useSizeBuffer=!1,o.size=o.map.image.width/2,o.offset=new ce;const i=1<=s.alignment&&s.alignment<=9?s.alignment:rg.AlignmentType.LeftTop,n=.5*~~((i-1)/3),a=.5*~~((i-1)%3);o.offset.set(o.size+t.bbWidth*(-n+s.horizontalAlign),-o.size+t.bbHeight*(a-s.verticalAlign))}const a=new km(o,this._renderingManager.uniforms);return a.sizeAttenuation=n,a}isLoadingImages(){return this._loadingImagesCount>0}getMaterial(t,e,i){const n=ng({modelId:i.modelId,metaMaterialId:t,objectType:i.objectType,text:i.text,textStyle:i.textStyle});return this.queryCache(n,e,i)}queryCache(t,e,i){const n=i.modelId;if(this.materialHashes.has(t))return this.materialHashes.get(t);const r=this.generateMaterial(e,i);return this.materialHashes.set(t,r),this.materialsByModel.has(n)||this.materialsByModel.set(n,new Set),this.materialsByModel.get(n).add(t),r}generateMaterial(t,e){const i={metaMaterial:t};if(t.image)if(this.textureByMaterial.has(t))i.map=this.textureByMaterial.get(t);else{const e=new ye;this.textureByMaterial.set(t,e),i.map=e,e.wrapS=ut,e.wrapT=ut,this._loadingImagesCount++,async function(t){if("undefined"==typeof createImageBitmap)return new Promise((async(e,i)=>{const n=new Image;n.src=URL.createObjectURL(t),n.onload=()=>e(n),n.onerror=()=>i("Image did not load")}));try{return await createImageBitmap(t,{imageOrientation:"flipY"})}catch(e){return await createImageBitmap(t)}}(new Blob([t.image])).then((t=>{e.image=t,e.needsUpdate=!0,this._renderingManager.redraw(),this._loadingImagesCount--}))}let n;return i.isAttenuated=4===e.objectType,e.text&&(i.text=e.text,i.textStyle=e.textStyle),n=0===e.objectType?this.createMeshMaterial(i):1===e.objectType?this.createLineMaterial(i):this.createPointMaterial(i),n}disposeModel(t){if(!this.materialsByModel.has(t))return;const e=this.materialsByModel.get(t);for(const t of e)this.materialHashes.get(t).dispose(),this.materialHashes.delete(t);this.materialsByModel.delete(t)}}sg.createTextTexture=(t,e,i)=>{const n=document.createElement("canvas").getContext("2d"),r=t.split(/\r?\n/),s=2*e.size,o=`${s}px ${e.font}`;n.font=o;const a=n.measureText(t);let h=1.2*s,c=s;"actualBoundingBoxAscent"in a&&"actualBoundingBoxDescent"in a&&(c=a.actualBoundingBoxAscent,h=c+a.actualBoundingBoxDescent);const l=1.2*s*(r.length-1)+h;let u=0;for(const t of r){const e=n.measureText(t).width;e>u&&(u=e)}n.canvas.width=Math.max(u,l),n.canvas.height=Math.max(u,l),n.font=o,n.fillStyle="#"+(16777216|(i.color||0)).toString(16).slice(-6),n.globalAlpha=isNaN(i.opacity)?1:i.opacity;for(let t=0;t<r.length;++t)n.fillText(r[t],0,c+t*s*1.2);return{texture:new ra(n.canvas),bbWidth:u,bbHeight:l}};class og extends HTMLElement{constructor(t,e,i="default",n,r){super(),this.camera=t,this.position=e,this.align=i,this._width=n,this._height=r,this.visible=!0,this.style.position="absolute",this.style.zIndex="1",this._currentLeft=0,this._currentTop=0,this.style.left=this._currentLeft+"px",this.style.top=this._currentTop+"px",this.style.willChange="transform",this._originalPosition=e.clone()}static get is(){return"sticky-element"}get height(){return this._height?this._height:this.clientHeight}get width(){return this._width?this._width:this.clientWidth}applyMatrix4(){this.matrix&&(this.position.copy(this._originalPosition),this.position.applyMatrix4(this.matrix))}updatePosition(t){this.applyMatrix4();const e=Ff(this.position,this.camera.value,t.width,t.height);if(e&&this.visible){let i=0,n=0;if("above"===this.align)i=e.y-this.height,n=e.x-this.width/2;else if("default"===this.align)i=e.y,n=e.x;else if("center"===this.align)i=e.y-this.height/2,n=e.x-this.width/2;else if("left"===this.align)i=e.y-this.height,n=e.x;else{if("right"!==this.align)return;i=e.y-this.height,n=e.x-this.width}e.x>=og.delta&&e.x<=t.right-og.delta&&e.y>=og.delta&&e.y<=t.bottom-og.delta?("block"!==this.style.display&&(this.style.display="block"),i===this._currentTop&&this._currentLeft===n||(this.style.transform=`translate3d(${n}px,${i}px,0px)`,this._currentLeft=n,this._currentTop=i)):"none"!==this.style.display&&(this.style.display="none")}else this.style.display="none"}}og.delta=-.01,window.customElements&&!window.customElements.get(og.is)&&window.customElements.define(og.is,og);class ag extends og{constructor(t,e,i){super(t,e,"above",28,28),this.isGridLabel=!0,this.style.fontSize="24px",this.style.fontFamily="'Open Sans', sans-serif",this.style.color="rgba(0,0,0,0.87)",this.style.textAlign="center",this.style.lineHeight="100%",this.style.textShadow="-1px 0 #ffffff,0 1px #ffffff,1px 0 #ffffff,0 -1px #ffffff",this.style.width="28px",this.style.height="28px",this.innerHTML=i}static get is(){return"grid-label"}}window.customElements&&!window.customElements.get(ag.is)&&window.customElements.define(ag.is,ag);class hg extends fn{initLabels(t,e,i,n){this.htmlElementPositioner=n,this.labels=[];for(const r of t.gridLabels){const s=r.position,o=new ag(i,new pe(s[0],s[1],s[2]),r.text);o.matrix=e,this.labels.push(o);const a=new ag(i,new pe(s[3],s[4],s[5]),r.text);a.matrix=e,this.labels.push(a),0===t.state.visible[0].start&&(n.addElement(o),n.addElement(a))}}addGroup(t,e,i){this.labels&&(0===i&&0===t?this.labels.forEach((t=>this.htmlElementPositioner.addElement(t))):this.labels.forEach((t=>this.htmlElementPositioner.removeElement(t)))),super.addGroup(t,e,i)}dispose(){this.labels&&this.labels.forEach((t=>this.htmlElementPositioner.removeElement(t))),super.dispose()}}class cg{constructor(t,e,i,n,r,s){this._selectionEffect=t,this._settings=e,this._trimbimSettings=i,this._renderingManager=n,this._camera=r,this.htmlElementPositioner=s,this._materials=new Map,this.models=new Map,this._actionQueue=[],this.hoverMaterial=new qi({color:e.hoverColor,transparent:!0,opacity:.1,depthWrite:!1,side:2}),this._gridMaterial=new Ah({color:0,linewidth:1,scale:1,dashSize:1,gapSize:.5}),n.addAnimationFrameListener((()=>this._updateScene()))}set clipPlanes(t){this._materialFactory=new sg(t,this._settings,this._trimbimSettings,this._renderingManager),this.hoverMaterial.clippingPlanes=t}addToQueue(t){for(const e of t)this.mergeWithQueue(e)||this._actionQueue.push(e);this._actionQueue.sort(((t,e)=>t.actionType-e.actionType))}mergeWithQueue(t){if(0!==t.actionType&&1!==t.actionType||(this._actionQueue=this._actionQueue.filter((e=>!((0===e.actionType||1===e.actionType)&&e.modelId===t.modelId&&e.batchId===t.batchId)))),2===t.actionType){const e=this._actionQueue.find((e=>3!==e.actionType&&e.modelId===t.modelId&&e.batchId===t.batchId));if(e)return 0!==e.actionType&&2!==e.actionType||(e.state=t.state),!0}return!1}isProcessingQueue(){return this._actionQueue.length>0||this._materialFactory.isLoadingImages()}removePendingUpdateFinishedAction(t){this._actionQueue=this._actionQueue.filter((e=>e.modelId!==t||3!==e.actionType))}set intersectingClipPlanes(t){this._materialFactory.intersectingClipPlanes=t,this._renderingManager.redraw()}get intersectingClipPlanes(){return this._materialFactory.intersectingClipPlanes}_updateScene(){const t=performance.now();for(;this._actionQueue.length>0;){const e=this._actionQueue.shift(),i=this.models.get(e.modelId);if(i){switch(e.actionType){case 0:this.add(i,e);break;case 1:this.remove(i,e);break;case 2:this.setState(i,e);break;case 3:i.onGeometryUpdateFinished()}if(this._renderingManager.redraw(),performance.now()-t>4)return}}}addMaterials(t){this._materials.has(t.modelId)?this._materials.get(t.modelId).push(...t.materials):this._materials.set(t.modelId,t.materials)}setMeshMaterialsSidedness(t,e){this._materialFactory.setMeshMaterialsSidedness(t,e)}restoreMeshMaterialsSidedness(){this._materialFactory.restoreMeshMaterialsSidedness()}buildMesh(t){const e=new fn;function i(){this.array=[]}e.setIndex(new Yi(t.indices,1)),e.setAttribute("position",new Yi(t.positions,3)),e.setAttribute("normal",new Yi(t.normals,3,!0)),e.attributes.normal.onUpload(i),e.attributes.position.onUpload(i),e.index.onUpload(i),0!==t.uvs.length&&(e.setAttribute("uv",new Yi(t.uvs,2)),e.attributes.uv.onUpload(i));const{visible:n,selected:r,hovered:s}=t.state;for(const t of n)e.addGroup(t.start,t.count,0);if(s)for(const t of s)e.addGroup(t.start,t.count,1);const o=this._materials.get(t.modelId)[t.materialId],a=new In(e,[this._materialFactory.getMaterial(t.materialId,o,t),this.hoverMaterial]);return a.userData=t.userData,a.position.set(t.position[0],t.position[1],t.position[2]),a.matrixAutoUpdate=!1,a.updateMatrix(),a.frustumCulled=!1,r.length>0&&this._selectionEffect.addObject(t.modelId,a,r),a}buildPoint(t){const e=new fn;e.setAttribute("position",new Yi(t.positions,3)),0!==t.uvs.length&&e.setAttribute("pointUv",new Yi(t.uvs,4)),0!==t.pointSizes.length&&e.setAttribute("pointSize",new Yi(t.pointSizes,4)),e.computeBoundingBox();const{visible:i,selected:n}=t.state;for(const t of i)e.addGroup(t.start,t.count,0);for(const t of n)e.addGroup(t.start,t.count,1);const r=this._materials.get(t.modelId)[t.materialId],s=new ta(e,[this._materialFactory.getMaterial(t.materialId,r,t),this.hoverMaterial]);return s.userData=t.userData,s.position.set(t.position[0],t.position[1],t.position[2]),s.matrixAutoUpdate=!1,s.updateMatrix(),s.frustumCulled=!1,n.length>0&&this._selectionEffect.addObject(t.modelId,s,n),s}buildLine(t){const e=this._materials.get(t.modelId)[t.materialId],i=this._materialFactory.getMaterial(t.materialId,e,t);return this.createLine(new fn,[i,this.hoverMaterial],t)}createLine(t,e,i){t.setAttribute("position",new Yi(i.positions,3)),t.computeBoundingBox();const{visible:n,selected:r,hovered:s}=i.state;for(const e of n)t.addGroup(e.start,e.count,0);if(s)for(const e of s)t.addGroup(e.start,e.count,0);const o=new Xo(t,e);o.userData=i.userData,o.position.set(i.position[0],i.position[1],i.position[2]),o.matrixAutoUpdate=!1,o.updateMatrix(),o.frustumCulled=!1;return i.state&&r.length>0&&this._selectionEffect.addObject(i.modelId,o,r),o}buildGrid(t){const e=new hg,i=this.createLine(e,[this._gridMaterial,this.hoverMaterial],t);return i.computeLineDistances(),i.updateMatrixWorld(),e.initLabels(t,i.matrixWorld,this._camera,this.htmlElementPositioner),i}setState(t,e){const i=t._batches.get(e.batchId);if(!i)return;const n=i.geometry,{visible:r,selected:s,hovered:o}=e.state;n.clearGroups();for(const t of r)n.addGroup(t.start,t.count,0);if(o)for(const t of o)n.addGroup(t.start,t.count,1);s.length>0?this._selectionEffect.addObject(t.name,i,s):this._selectionEffect.removeObject(t.name,i)}remove(t,e){const i=t._batches.get(e.batchId);i&&this.removeBatch(t,e.batchId,i)}removeBatch(t,e,i){t.remove(i),i.geometry.dispose(),t._batches.delete(e),this._selectionEffect.removeObjectById(t.name,e)}add(t,e){const i=this.buildObject(e);t.add(i),t._batches.set(i.userData.id,i)}buildObject(t){if(0===t.objectType)return this.buildMesh(t);if(1===t.objectType)return this.buildLine(t);if(2===t.objectType)return this.buildGrid(t);if(3===t.objectType)return this.buildPoint(t);if(4===t.objectType)return this.buildPoint(t);throw new Error("unsupported object type! "+t.objectType)}disposeMaterials(t){this._materialFactory.disposeModel(t)}}const lg=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","_","$"];class ug{constructor({data:t,ifcGuid:e,msGuid:i}){this.type="UUID",t?this.data=t:e?this.setIfcGuid(e):i?this.setMsGuid(i):this.data=new Uint8Array(16)}fromJSON({type:t,data:e}){if("UUID"!==t)throw TypeError("Incorrect type, type needs to be UUID");this.data=new Uint8Array(JSON.parse("["+e+"]"))}equals(t){for(let e=0;e<16;e++)if(this.data[e]!==t.data[e])return!1;return!0}toString(){return this.msGuid}get msGuid(){const t=this.data.byteOffset,e=new DataView(this.data.buffer,t,16);return`${e.getUint32(0,!0).toString(16).padStart(8,"0")}-${e.getUint16(4,!0).toString(16).padStart(4,"0")}-${e.getUint16(6,!0).toString(16).padStart(4,"0")}-${e.getUint8(8).toString(16).padStart(2,"0")}${e.getUint8(9).toString(16).padStart(2,"0")}-${e.getUint8(10).toString(16).padStart(2,"0")}${e.getUint8(11).toString(16).padStart(2,"0")}${e.getUint8(12).toString(16).padStart(2,"0")}${e.getUint8(13).toString(16).padStart(2,"0")}${e.getUint8(14).toString(16).padStart(2,"0")}${e.getUint8(15).toString(16).padStart(2,"0")}`}setMsGuid(t){this.data=this.data||new Uint8Array(16);const e=this.data.byteOffset,i=new DataView(this.data.buffer,e,16),n=(e,i)=>parseInt(t.slice(e,e+i),16);i.setUint32(0,n(0,8),!0),i.setUint16(4,n(9,4),!0),i.setUint16(6,n(14,4),!0),i.setUint8(8,n(19,2)),i.setUint8(9,n(21,2)),i.setUint8(10,n(24,2)),i.setUint8(11,n(26,2)),i.setUint8(12,n(28,2)),i.setUint8(13,n(30,2)),i.setUint8(14,n(32,2)),i.setUint8(15,n(34,2))}get ifcGuid(){const t=new Uint8Array(24),e=this.data;t[0]=e[15],t[1]=e[14],t[2]=e[13],t[3]=0,t[4]=e[12],t[5]=e[11],t[6]=e[10],t[7]=0,t[8]=e[9],t[9]=e[8],t[10]=e[6],t[11]=0,t[12]=e[7],t[13]=e[4],t[14]=e[5],t[15]=0,t[16]=e[0],t[17]=e[1],t[18]=e[2],t[19]=0,t[20]=e[3],t[21]=0,t[22]=0,t[23]=0;const i=new Uint32Array(t.buffer);return this.toBase64(i[5],8)+this.toBase64(i[4],24)+this.toBase64(i[3],24)+this.toBase64(i[2],24)+this.toBase64(i[1],24)+this.toBase64(i[0],24)}setIfcGuid(t){this.data=new Uint8Array(16);const e=this.fromBase64(t[0],6)+this.fromBase64(t[1],0),i=this.fromBase64(t[2],18)+this.fromBase64(t[3],12)+this.fromBase64(t[4],6)+this.fromBase64(t[5],0),n=this.fromBase64(t[6],18)+this.fromBase64(t[7],12)+this.fromBase64(t[8],6)+this.fromBase64(t[9],0),r=this.fromBase64(t[10],18)+this.fromBase64(t[11],12)+this.fromBase64(t[12],6)+this.fromBase64(t[13],0),s=this.fromBase64(t[14],18)+this.fromBase64(t[15],12)+this.fromBase64(t[16],6)+this.fromBase64(t[17],0),o=this.fromBase64(t[18],18)+this.fromBase64(t[19],12)+this.fromBase64(t[20],6)+this.fromBase64(t[21],0),a=this.getBytes(o),h=this.getBytes(s),c=this.getBytes(r),l=this.getBytes(n),u=this.getBytes(i),d=this.getBytes(e);this.data[15]=a[0],this.data[14]=a[1],this.data[13]=a[2],this.data[12]=h[0],this.data[11]=h[1],this.data[10]=h[2],this.data[9]=c[0],this.data[8]=c[1],this.data[6]=c[2],this.data[7]=l[0],this.data[4]=l[1],this.data[5]=l[2],this.data[0]=u[0],this.data[1]=u[1],this.data[2]=u[2],this.data[3]=d[0]}setFromBufferData(t,e){this.data=new Uint8Array(t,e,16)}toBase64(t,e){let i="";if(e>0){i+=lg[63&t],i=this.toBase64(t>>6,e-6)+i}return i}fromBase64(t,e){let i=0;for(;i<64&&lg[i]!=t;)i++;return i<<e}getBytes(t){const e=new ArrayBuffer(8);return new Int32Array(e)[0]=t,new Uint8Array(e)}}for(var dg=[],pg=0;pg<256;pg++)dg[pg]=(pg<16?"0":"")+pg.toString(16);var fg={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(dg[255&t]+dg[t>>8&255]+dg[t>>16&255]+dg[t>>24&255]+"-"+dg[255&e]+dg[e>>8&255]+"-"+dg[e>>16&15|64]+dg[e>>24&255]+"-"+dg[63&i|128]+dg[i>>8&255]+"-"+dg[i>>16&255]+dg[i>>24&255]+dg[255&n]+dg[n>>8&255]+dg[n>>16&255]+dg[n>>24&255]).toUpperCase()},clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*fg.DEG2RAD},radToDeg:function(t){return t*fg.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}};function mg(t,e,i,n){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==n?n:1}Object.assign(mg,{slerp:function(t,e,i,n){return i.copy(t).slerp(e,n)},slerpFlat:function(t,e,i,n,r,s,o){var a=i[n+0],h=i[n+1],c=i[n+2],l=i[n+3],u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(l!==f||a!==u||h!==d||c!==p){var m=1-o,g=a*u+h*d+c*p+l*f,v=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){var y=Math.sqrt(b),_=Math.atan2(y,g*v);m=Math.sin(m*_)/y,o=Math.sin(o*_)/y}var x=o*v;if(a=a*m+u*x,h=h*m+d*x,c=c*m+p*x,l=l*m+f*x,m===1-o){var w=1/Math.sqrt(a*a+h*h+c*c+l*l);a*=w,h*=w,c*=w,l*=w}}t[e]=a,t[e+1]=h,t[e+2]=c,t[e+3]=l}}),Object.defineProperties(mg.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()}}}),Object.assign(mg.prototype,{isQuaternion:!0,set:function(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=t._x,n=t._y,r=t._z,s=t.order,o=Math.cos,a=Math.sin,h=o(i/2),c=o(n/2),l=o(r/2),u=a(i/2),d=a(n/2),p=a(r/2);return"XYZ"===s?(this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p):"YXZ"===s?(this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p):"ZXY"===s?(this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p):"ZYX"===s?(this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p):"YZX"===s?(this._x=u*c*l+h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l-u*d*p):"XZY"===s&&(this._x=u*c*l-h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l+u*d*p),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,i=t.elements,n=i[0],r=i[4],s=i[8],o=i[1],a=i[5],h=i[9],c=i[2],l=i[6],u=i[10],d=n+a+u;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(l-h)*e,this._y=(s-c)*e,this._z=(o-r)*e):n>a&&n>u?(e=2*Math.sqrt(1+n-a-u),this._w=(l-h)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(s+c)/e):a>u?(e=2*Math.sqrt(1+a-n-u),this._w=(s-c)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(h+l)/e):(e=2*Math.sqrt(1+u-n-a),this._w=(o-r)/e,this._x=(s+c)/e,this._y=(h+l)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var i=t.dot(e)+1;return i<1e-6?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(fg.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var i=this.angleTo(t);if(0===i)return this;var n=Math.min(1,e/i);return this.slerp(t,n),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var i=t._x,n=t._y,r=t._z,s=t._w,o=e._x,a=e._y,h=e._z,c=e._w;return this._x=i*c+s*o+n*h-r*a,this._y=n*c+s*a+r*o-i*h,this._z=r*c+s*h+i*a-n*o,this._w=s*c-i*o-n*a-r*h,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,n=this._y,r=this._z,s=this._w,o=s*t._w+i*t._x+n*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;var a=1-o*o;if(a<=Number.EPSILON){var h=1-e;return this._w=h*s+e*this._w,this._x=h*i+e*this._x,this._y=h*n+e*this._y,this._z=h*r+e*this._z,this.normalize(),this._onChangeCallback(),this}var c=Math.sqrt(a),l=Math.atan2(c,o),u=Math.sin((1-e)*l)/c,d=Math.sin(e*l)/c;return this._w=s*u+this._w*d,this._x=i*u+this._x*d,this._y=n*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},_onChange:function(t){return this._onChangeCallback=t,this},_onChangeCallback:function(){}});var gg=new bg,vg=new mg;function bg(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}Object.assign(bg.prototype,{isVector3:!0,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(vg.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(vg.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this},applyNormalMatrix:function(t){return this.applyMatrix3(t).normalize()},applyMatrix4:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this},applyQuaternion:function(t){var e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,o=t.z,a=t.w,h=a*e+s*n-o*i,c=a*i+o*e-r*n,l=a*n+r*i-s*e,u=-r*e-s*i-o*n;return this.x=h*a+u*-r+c*-o-l*-s,this.y=c*a+u*-s+l*-r-h*-o,this.z=l*a+u*-o+h*-s-c*-r,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){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:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var i=t.x,n=t.y,r=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return gg.copy(this).projectOnVector(t),this.sub(gg)},reflect:function(t){return this.sub(gg.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());0===e&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var i=this.dot(t)/e;return Math.acos(fg.clamp(i,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,i){var n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var yg=new bg;function _g(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.assign(_g.prototype,{isMatrix3:!0,set:function(t,e,i,n,r,s,o,a,h){var c=this.elements;return c[0]=t,c[1]=n,c[2]=o,c[3]=e,c[4]=r,c[5]=a,c[6]=i,c[7]=s,c[8]=h,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(t){for(var e=0,i=t.count;e<i;e++)yg.x=t.getX(e),yg.y=t.getY(e),yg.z=t.getZ(e),yg.applyMatrix3(this),t.setXYZ(e,yg.x,yg.y,yg.z);return t},multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[3],a=i[6],h=i[1],c=i[4],l=i[7],u=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],v=n[1],b=n[4],y=n[7],_=n[2],x=n[5],w=n[8];return r[0]=s*f+o*v+a*_,r[3]=s*m+o*b+a*x,r[6]=s*g+o*y+a*w,r[1]=h*f+c*v+l*_,r[4]=h*m+c*b+l*x,r[7]=h*g+c*y+l*w,r[2]=u*f+d*v+p*_,r[5]=u*m+d*b+p*x,r[8]=u*g+d*y+p*w,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],h=t[7],c=t[8];return e*s*c-e*o*h-i*r*c+i*o*a+n*r*h-n*s*a},getInverse:function(t,e){t&&t.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=t.elements,n=this.elements,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],c=i[5],l=i[6],u=i[7],d=i[8],p=d*h-c*u,f=c*l-d*a,m=u*a-h*l,g=r*p+s*f+o*m;if(0===g){var v="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(v);return console.warn(v),this.identity()}var b=1/g;return n[0]=p*b,n[1]=(o*u-d*s)*b,n[2]=(c*s-o*h)*b,n[3]=f*b,n[4]=(d*r-o*l)*b,n[5]=(o*a-c*r)*b,n[6]=m*b,n[7]=(s*l-u*r)*b,n[8]=(h*r-s*a)*b,this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},setUvTransform:function(t,e,i,n,r,s,o){var a=Math.cos(r),h=Math.sin(r);this.set(i*a,i*h,-i*(a*s+h*o)+s+t,-n*h,n*a,-n*(-h*s+a*o)+o+e,0,0,1)},scale:function(t,e){var i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),n=this.elements,r=n[0],s=n[3],o=n[6],a=n[1],h=n[4],c=n[7];return n[0]=e*r+i*a,n[3]=e*s+i*h,n[6]=e*o+i*c,n[1]=-i*r+e*a,n[4]=-i*s+e*h,n[7]=-i*o+e*c,this},translate:function(t,e){var i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this},equals:function(t){for(var e=this.elements,i=t.elements,n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}});var xg=new bg,wg=new bg,Mg=new _g;function Tg(t,e){this.normal=void 0!==t?t:new bg(1,0,0),this.constant=void 0!==e?e:0}Object.assign(Tg.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,i){var n=xg.subVectors(i,e).cross(wg.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new bg),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new bg);var i=t.delta(xg),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?void 0:e.copy(i).multiplyScalar(r).add(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new bg),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var i=e||Mg.getNormalMatrix(t),n=this.coplanarPoint(xg).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this},translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}});var Sg=new bg,Eg=new bg,Pg=new bg,Ag=new bg,Cg=new bg,Lg=new bg,Rg=new bg,Ig=new bg,Og=new bg,Fg=new bg;function Bg(t,e,i){this.a=void 0!==t?t:new bg,this.b=void 0!==e?e:new bg,this.c=void 0!==i?i:new bg}Object.assign(Bg,{getNormal:function(t,e,i,n){void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new bg),n.subVectors(i,e),Sg.subVectors(t,e),n.cross(Sg);var r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)},getBarycoord:function(t,e,i,n,r){Sg.subVectors(n,e),Eg.subVectors(i,e),Pg.subVectors(t,e);var s=Sg.dot(Sg),o=Sg.dot(Eg),a=Sg.dot(Pg),h=Eg.dot(Eg),c=Eg.dot(Pg),l=s*h-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new bg),0===l)return r.set(-2,-1,-1);var u=1/l,d=(h*a-o*c)*u,p=(s*c-o*a)*u;return r.set(1-d-p,p,d)},containsPoint:function(t,e,i,n){return Bg.getBarycoord(t,e,i,n,Ag),Ag.x>=0&&Ag.y>=0&&Ag.x+Ag.y<=1},getUV:function(t,e,i,n,r,s,o,a){return this.getBarycoord(t,e,i,n,Ag),a.set(0,0),a.addScaledVector(r,Ag.x),a.addScaledVector(s,Ag.y),a.addScaledVector(o,Ag.z),a},isFrontFacing:function(t,e,i,n){return Sg.subVectors(i,e),Eg.subVectors(t,e),Sg.cross(Eg).dot(n)<0}}),Object.assign(Bg.prototype,{set:function(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this},setFromPointsAndIndices:function(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return Sg.subVectors(this.c,this.b),Eg.subVectors(this.a,this.b),.5*Sg.cross(Eg).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new bg),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Bg.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Tg),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Bg.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,i,n,r){return Bg.getUV(t,this.a,this.b,this.c,e,i,n,r)},containsPoint:function(t){return Bg.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Bg.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new bg);var i,n,r=this.a,s=this.b,o=this.c;Cg.subVectors(s,r),Lg.subVectors(o,r),Ig.subVectors(t,r);var a=Cg.dot(Ig),h=Lg.dot(Ig);if(a<=0&&h<=0)return e.copy(r);Og.subVectors(t,s);var c=Cg.dot(Og),l=Lg.dot(Og);if(c>=0&&l<=c)return e.copy(s);var u=a*l-c*h;if(u<=0&&a>=0&&c<=0)return i=a/(a-c),e.copy(r).addScaledVector(Cg,i);Fg.subVectors(t,o);var d=Cg.dot(Fg),p=Lg.dot(Fg);if(p>=0&&d<=p)return e.copy(o);var f=d*h-a*p;if(f<=0&&h>=0&&p<=0)return n=h/(h-p),e.copy(r).addScaledVector(Lg,n);var m=c*p-d*l;if(m<=0&&l-c>=0&&d-p>=0)return Rg.subVectors(o,s),n=(l-c)/(l-c+(d-p)),e.copy(s).addScaledVector(Rg,n);var g=1/(m+f+u);return i=f*g,n=u*g,e.copy(r).addScaledVector(Cg,i).addScaledVector(Lg,n)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.phi=void 0!==e?e:0,this.theta=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},makeSafe:function(){var t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this},setFromVector3:function(t){return this.setFromCartesianCoords(t.x,t.y,t.z)},setFromCartesianCoords:function(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(fg.clamp(e/this.radius,-1,1))),this}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.theta=e,this.y=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},setFromVector3:function(t){return this.setFromCartesianCoords(t.x,t.y,t.z)},setFromCartesianCoords:function(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}});var Dg=[new bg,new bg,new bg,new bg,new bg,new bg,new bg,new bg],zg=new bg,Ng=new Zg,Ug=new bg,Vg=new bg,kg=new bg,jg=new bg,Hg=new bg,Gg=new bg,Wg=new bg,qg=new bg,Xg=new bg,Yg=new bg;function Zg(t,e){this.min=void 0!==t?t:new bg(1/0,1/0,1/0),this.max=void 0!==e?e:new bg(-1/0,-1/0,-1/0)}function $g(t,e,i,n,r){var s,o;for(s=0,o=t.length-3;s<=o;s+=3){Yg.fromArray(t,s);var a=r.x*Math.abs(Yg.x)+r.y*Math.abs(Yg.y)+r.z*Math.abs(Yg.z),h=e.dot(Yg),c=i.dot(Yg),l=n.dot(Yg);if(Math.max(-Math.max(h,c,l),Math.min(h,c,l))>a)return!1}return!0}Object.assign(Zg.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0,a=0,h=t.length;a<h;a+=3){var c=t[a],l=t[a+1],u=t[a+2];c<e&&(e=c),l<i&&(i=l),u<n&&(n=u),c>r&&(r=c),l>s&&(s=l),u>o&&(o=u)}return this.min.set(e,i,n),this.max.set(r,s,o),this},setFromBufferAttribute:function(t){for(var e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0,a=0,h=t.count;a<h;a++){var c=t.getX(a),l=t.getY(a),u=t.getZ(a);c<e&&(e=c),l<i&&(i=l),u<n&&(n=u),c>r&&(r=c),l>s&&(s=l),u>o&&(o=u)}return this.min.set(e,i,n),this.max.set(r,s,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(t,e){var i=zg.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){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:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new bg),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new bg),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(t){t.updateWorldMatrix(!1,!1);var e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),Ng.copy(e.boundingBox),Ng.applyMatrix4(t.matrixWorld),this.expandByPoint(Ng.min),this.expandByPoint(Ng.max));for(var i=t.children,n=0,r=i.length;n<r;n++)this.expandByObject(i[n]);return this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new bg),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,zg),zg.distanceToSquared(t.center)<=t.radius*t.radius},intersectsPlane:function(t){var e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant},intersectsTriangle:function(t){if(this.isEmpty())return!1;this.getCenter(Wg),qg.subVectors(this.max,Wg),Ug.subVectors(t.a,Wg),Vg.subVectors(t.b,Wg),kg.subVectors(t.c,Wg),jg.subVectors(Vg,Ug),Hg.subVectors(kg,Vg),Gg.subVectors(Ug,kg);var e=[0,-jg.z,jg.y,0,-Hg.z,Hg.y,0,-Gg.z,Gg.y,jg.z,0,-jg.x,Hg.z,0,-Hg.x,Gg.z,0,-Gg.x,-jg.y,jg.x,0,-Hg.y,Hg.x,0,-Gg.y,Gg.x,0];return!!$g(e,Ug,Vg,kg,qg)&&(!!$g(e=[1,0,0,0,1,0,0,0,1],Ug,Vg,kg,qg)&&(Xg.crossVectors(jg,Hg),$g(e=[Xg.x,Xg.y,Xg.z],Ug,Vg,kg,qg)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new bg),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return zg.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(zg).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()||(Dg[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Dg[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Dg[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Dg[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Dg[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Dg[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Dg[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Dg[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Dg)),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var Jg=new Zg;function Qg(t,e){this.center=void 0!==t?t:new bg,this.radius=void 0!==e?e:0}Object.assign(Qg.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var i=this.center;void 0!==e?i.copy(e):Jg.setFromPoints(t).getCenter(i);for(var n=0,r=0,s=t.length;r<s;r++)n=Math.max(n,i.distanceToSquared(t[r]));return this.radius=Math.sqrt(n),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius},clampPoint:function(t,e){var i=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new bg),e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new Zg),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var Kg=new Qg,tv=new bg;function ev(t,e,i,n,r,s){this.planes=[void 0!==t?t:new Tg,void 0!==e?e:new Tg,void 0!==i?i:new Tg,void 0!==n?n:new Tg,void 0!==r?r:new Tg,void 0!==s?s:new Tg]}Object.assign(ev.prototype,{set:function(t,e,i,n,r,s){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(s),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,i=0;i<6;i++)e[i].copy(t.planes[i]);return this},setFromMatrix:function(t){var e=this.planes,i=t.elements,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],h=i[5],c=i[6],l=i[7],u=i[8],d=i[9],p=i[10],f=i[11],m=i[12],g=i[13],v=i[14],b=i[15];return e[0].setComponents(o-n,l-a,f-u,b-m).normalize(),e[1].setComponents(o+n,l+a,f+u,b+m).normalize(),e[2].setComponents(o+r,l+h,f+d,b+g).normalize(),e[3].setComponents(o-r,l-h,f-d,b-g).normalize(),e[4].setComponents(o-s,l-c,f-p,b-v).normalize(),e[5].setComponents(o+s,l+c,f+p,b+v).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),Kg.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Kg)},intersectsSprite:function(t){return Kg.center.set(0,0,0),Kg.radius=.7071067811865476,Kg.applyMatrix4(t.matrixWorld),this.intersectsSphere(Kg)},intersectsSphere:function(t){for(var e=this.planes,i=t.center,n=-t.radius,r=0;r<6;r++){if(e[r].distanceToPoint(i)<n)return!1}return!0},intersectsBox:function(t){for(var e=this.planes,i=0;i<6;i++){var n=e[i];if(tv.x=n.normal.x>0?t.max.x:t.min.x,tv.y=n.normal.y>0?t.max.y:t.min.y,tv.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(tv)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}});var iv=new bg,nv=new bg,rv=new bg,sv=new bg,ov=new bg,av=new bg,hv=new bg;Object.assign(function(t,e){this.origin=void 0!==t?t:new bg,this.direction=void 0!==e?e:new bg(0,0,-1)}.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new bg),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,iv)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new bg),e.subVectors(t,this.origin);var i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=iv.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(iv.copy(this.direction).multiplyScalar(e).add(this.origin),iv.distanceToSquared(t))},distanceSqToSegment:function(t,e,i,n){nv.copy(t).add(e).multiplyScalar(.5),rv.copy(e).sub(t).normalize(),sv.copy(this.origin).sub(nv);var r,s,o,a,h=.5*t.distanceTo(e),c=-this.direction.dot(rv),l=sv.dot(this.direction),u=-sv.dot(rv),d=sv.lengthSq(),p=Math.abs(1-c*c);if(p>0)if(s=c*l-u,a=h*p,(r=c*u-l)>=0)if(s>=-a)if(s<=a){var f=1/p;o=(r*=f)*(r+c*(s*=f)+2*l)+s*(c*r+s+2*u)+d}else s=h,o=-(r=Math.max(0,-(c*s+l)))*r+s*(s+2*u)+d;else s=-h,o=-(r=Math.max(0,-(c*s+l)))*r+s*(s+2*u)+d;else s<=-a?o=-(r=Math.max(0,-(-c*h+l)))*r+(s=r>0?-h:Math.min(Math.max(-h,-u),h))*(s+2*u)+d:s<=a?(r=0,o=(s=Math.min(Math.max(-h,-u),h))*(s+2*u)+d):o=-(r=Math.max(0,-(c*h+l)))*r+(s=r>0?h:Math.min(Math.max(-h,-u),h))*(s+2*u)+d;else s=c>0?-h:h,o=-(r=Math.max(0,-(c*s+l)))*r+s*(s+2*u)+d;return i&&i.copy(this.direction).multiplyScalar(r).add(this.origin),n&&n.copy(rv).multiplyScalar(s).add(nv),o},intersectSphere:function(t,e){iv.subVectors(t.center,this.origin);var i=iv.dot(this.direction),n=iv.dot(iv)-i*i,r=t.radius*t.radius;if(n>r)return null;var s=Math.sqrt(r-n),o=i-s,a=i+s;return o<0&&a<0?null:o<0?this.at(a,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null},intersectPlane:function(t,e){var i=this.distanceToPlane(t);return null===i?null:this.at(i,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var i,n,r,s,o,a,h=1/this.direction.x,c=1/this.direction.y,l=1/this.direction.z,u=this.origin;return h>=0?(i=(t.min.x-u.x)*h,n=(t.max.x-u.x)*h):(i=(t.max.x-u.x)*h,n=(t.min.x-u.x)*h),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),i>s||r>n?null:((r>i||i!=i)&&(i=r),(s<n||n!=n)&&(n=s),l>=0?(o=(t.min.z-u.z)*l,a=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,a=(t.min.z-u.z)*l),i>a||o>n?null:((o>i||i!=i)&&(i=o),(a<n||n!=n)&&(n=a),n<0?null:this.at(i>=0?i:n,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,iv)},intersectTriangle:function(t,e,i,n,r){ov.subVectors(e,t),av.subVectors(i,t),hv.crossVectors(ov,av);var s,o=this.direction.dot(hv);if(o>0){if(n)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}sv.subVectors(this.origin,t);var a=s*this.direction.dot(av.crossVectors(sv,av));if(a<0)return null;var h=s*this.direction.dot(ov.cross(sv));if(h<0)return null;if(a+h>o)return null;var c=-s*sv.dot(hv);return c<0?null:this.at(c/o,r)},applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}});var cv=new bg,lv=new gv,uv=new bg(0,0,0),dv=new bg(1,1,1),pv=new bg,fv=new bg,mv=new bg;function gv(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function vv(t,e){this.x=t||0,this.y=e||0}Object.assign(gv.prototype,{isMatrix4:!0,set:function(t,e,i,n,r,s,o,a,h,c,l,u,d,p,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=o,g[13]=a,g[2]=h,g[6]=c,g[10]=l,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new gv).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},copyPosition:function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},extractBasis:function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,i=t.elements,n=1/cv.setFromMatrixColumn(t,0).length(),r=1/cv.setFromMatrixColumn(t,1).length(),s=1/cv.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),o=Math.sin(i),a=Math.cos(n),h=Math.sin(n),c=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){var u=s*c,d=s*l,p=o*c,f=o*l;e[0]=a*c,e[4]=-a*l,e[8]=h,e[1]=d+p*h,e[5]=u-f*h,e[9]=-o*a,e[2]=f-u*h,e[6]=p+d*h,e[10]=s*a}else if("YXZ"===t.order){var m=a*c,g=a*l,v=h*c,b=h*l;e[0]=m+b*o,e[4]=v*o-g,e[8]=s*h,e[1]=s*l,e[5]=s*c,e[9]=-o,e[2]=g*o-v,e[6]=b+m*o,e[10]=s*a}else if("ZXY"===t.order){m=a*c,g=a*l,v=h*c,b=h*l;e[0]=m-b*o,e[4]=-s*l,e[8]=v+g*o,e[1]=g+v*o,e[5]=s*c,e[9]=b-m*o,e[2]=-s*h,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){u=s*c,d=s*l,p=o*c,f=o*l;e[0]=a*c,e[4]=p*h-d,e[8]=u*h+f,e[1]=a*l,e[5]=f*h+u,e[9]=d*h-p,e[2]=-h,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){var y=s*a,_=s*h,x=o*a,w=o*h;e[0]=a*c,e[4]=w-y*l,e[8]=x*l+_,e[1]=l,e[5]=s*c,e[9]=-o*c,e[2]=-h*c,e[6]=_*l+x,e[10]=y-w*l}else if("XZY"===t.order){y=s*a,_=s*h,x=o*a,w=o*h;e[0]=a*c,e[4]=-l,e[8]=h*c,e[1]=y*l+w,e[5]=s*c,e[9]=_*l-x,e[2]=x*l-_,e[6]=o*c,e[10]=w*l+y}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){return this.compose(uv,t,dv)},lookAt:function(t,e,i){var n=this.elements;return mv.subVectors(t,e),0===mv.lengthSq()&&(mv.z=1),mv.normalize(),pv.crossVectors(i,mv),0===pv.lengthSq()&&(1===Math.abs(i.z)?mv.x+=1e-4:mv.z+=1e-4,mv.normalize(),pv.crossVectors(i,mv)),pv.normalize(),fv.crossVectors(mv,pv),n[0]=pv.x,n[4]=fv.x,n[8]=mv.x,n[1]=pv.y,n[5]=fv.y,n[9]=mv.y,n[2]=pv.z,n[6]=fv.z,n[10]=mv.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[4],a=i[8],h=i[12],c=i[1],l=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],v=i[3],b=i[7],y=i[11],_=i[15],x=n[0],w=n[4],M=n[8],T=n[12],S=n[1],E=n[5],P=n[9],A=n[13],C=n[2],L=n[6],R=n[10],I=n[14],O=n[3],F=n[7],B=n[11],D=n[15];return r[0]=s*x+o*S+a*C+h*O,r[4]=s*w+o*E+a*L+h*F,r[8]=s*M+o*P+a*R+h*B,r[12]=s*T+o*A+a*I+h*D,r[1]=c*x+l*S+u*C+d*O,r[5]=c*w+l*E+u*L+d*F,r[9]=c*M+l*P+u*R+d*B,r[13]=c*T+l*A+u*I+d*D,r[2]=p*x+f*S+m*C+g*O,r[6]=p*w+f*E+m*L+g*F,r[10]=p*M+f*P+m*R+g*B,r[14]=p*T+f*A+m*I+g*D,r[3]=v*x+b*S+y*C+_*O,r[7]=v*w+b*E+y*L+_*F,r[11]=v*M+b*P+y*R+_*B,r[15]=v*T+b*A+y*I+_*D,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(t){for(var e=0,i=t.count;e<i;e++)cv.x=t.getX(e),cv.y=t.getY(e),cv.z=t.getZ(e),cv.applyMatrix4(this),t.setXYZ(e,cv.x,cv.y,cv.z);return t},determinant:function(){var t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],o=t[5],a=t[9],h=t[13],c=t[2],l=t[6],u=t[10],d=t[14];return t[3]*(+r*a*l-n*h*l-r*o*u+i*h*u+n*o*d-i*a*d)+t[7]*(+e*a*d-e*h*u+r*s*u-n*s*d+n*h*c-r*a*c)+t[11]*(+e*h*l-e*o*d-r*s*l+i*s*d+r*o*c-i*h*c)+t[15]*(-n*o*c-e*a*l+e*o*u+n*s*l-i*s*u+i*a*c)},transpose:function(){var t,e=this.elements;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:function(t,e,i){var n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this},getInverse:function(t,e){var i=this.elements,n=t.elements,r=n[0],s=n[1],o=n[2],a=n[3],h=n[4],c=n[5],l=n[6],u=n[7],d=n[8],p=n[9],f=n[10],m=n[11],g=n[12],v=n[13],b=n[14],y=n[15],_=p*b*u-v*f*u+v*l*m-c*b*m-p*l*y+c*f*y,x=g*f*u-d*b*u-g*l*m+h*b*m+d*l*y-h*f*y,w=d*v*u-g*p*u+g*c*m-h*v*m-d*c*y+h*p*y,M=g*p*l-d*v*l-g*c*f+h*v*f+d*c*b-h*p*b,T=r*_+s*x+o*w+a*M;if(0===T){var S="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(S);return console.warn(S),this.identity()}var E=1/T;return i[0]=_*E,i[1]=(v*f*a-p*b*a-v*o*m+s*b*m+p*o*y-s*f*y)*E,i[2]=(c*b*a-v*l*a+v*o*u-s*b*u-c*o*y+s*l*y)*E,i[3]=(p*l*a-c*f*a-p*o*u+s*f*u+c*o*m-s*l*m)*E,i[4]=x*E,i[5]=(d*b*a-g*f*a+g*o*m-r*b*m-d*o*y+r*f*y)*E,i[6]=(g*l*a-h*b*a-g*o*u+r*b*u+h*o*y-r*l*y)*E,i[7]=(h*f*a-d*l*a+d*o*u-r*f*u-h*o*m+r*l*m)*E,i[8]=w*E,i[9]=(g*p*a-d*v*a-g*s*m+r*v*m+d*s*y-r*p*y)*E,i[10]=(h*v*a-g*c*a+g*s*u-r*v*u-h*s*y+r*c*y)*E,i[11]=(d*c*a-h*p*a-d*s*u+r*p*u+h*s*m-r*c*m)*E,i[12]=M*E,i[13]=(d*v*o-g*p*o+g*s*f-r*v*f-d*s*b+r*p*b)*E,i[14]=(g*c*o-h*v*o-g*s*l+r*v*l+h*s*b-r*c*b)*E,i[15]=(h*p*o-d*c*o+d*s*l-r*p*l-h*s*f+r*c*f)*E,this},scale:function(t){var e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))},makeTranslation:function(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,o=t.y,a=t.z,h=r*s,c=r*o;return this.set(h*s+i,h*o-n*a,h*a+n*o,0,h*o+n*a,c*o+i,c*a-n*s,0,h*a-n*o,c*a+n*s,r*a*a+i,0,0,0,0,1),this},makeScale:function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this},compose:function(t,e,i){var n=this.elements,r=e._x,s=e._y,o=e._z,a=e._w,h=r+r,c=s+s,l=o+o,u=r*h,d=r*c,p=r*l,f=s*c,m=s*l,g=o*l,v=a*h,b=a*c,y=a*l,_=i.x,x=i.y,w=i.z;return n[0]=(1-(f+g))*_,n[1]=(d+y)*_,n[2]=(p-b)*_,n[3]=0,n[4]=(d-y)*x,n[5]=(1-(u+g))*x,n[6]=(m+v)*x,n[7]=0,n[8]=(p+b)*w,n[9]=(m-v)*w,n[10]=(1-(u+f))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this},decompose:function(t,e,i){var n=this.elements,r=cv.set(n[0],n[1],n[2]).length(),s=cv.set(n[4],n[5],n[6]).length(),o=cv.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],lv.copy(this);var a=1/r,h=1/s,c=1/o;return lv.elements[0]*=a,lv.elements[1]*=a,lv.elements[2]*=a,lv.elements[4]*=h,lv.elements[5]*=h,lv.elements[6]*=h,lv.elements[8]*=c,lv.elements[9]*=c,lv.elements[10]*=c,e.setFromRotationMatrix(lv),i.x=r,i.y=s,i.z=o,this},makePerspective:function(t,e,i,n,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var o=this.elements,a=2*r/(e-t),h=2*r/(i-n),c=(e+t)/(e-t),l=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return o[0]=a,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=h,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makeOrthographic:function(t,e,i,n,r,s){var o=this.elements,a=1/(e-t),h=1/(i-n),c=1/(s-r),l=(e+t)*a,u=(i+n)*h,d=(s+r)*c;return o[0]=2*a,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(t){for(var e=this.elements,i=t.elements,n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}),Object.defineProperties(vv.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(vv.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){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:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}});var bv=new vv;Object.assign(function(t,e){this.min=void 0!==t?t:new vv(1/0,1/0),this.max=void 0!==e?e:new vv(-1/0,-1/0)}.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(t,e){var i=bv.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new vv),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new vv),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new vv),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new vv),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return bv.copy(t).clamp(this.min,this.max).sub(t).length()},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var yv=new bg,_v=new bg;Object.assign(function(t,e){this.start=void 0!==t?t:new bg,this.end=void 0!==e?e:new bg}.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new bg),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new bg),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new bg),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){yv.subVectors(t,this.start),_v.subVectors(this.end,this.start);var i=_v.dot(_v),n=_v.dot(yv)/i;return e&&(n=fg.clamp(n,0,1)),n},closestPointToPoint:function(t,e,i){var n=this.closestPointToPointParameter(t,e);return void 0===i&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new bg),this.delta(i).multiplyScalar(n).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}});var xv=new gv,wv=new mg;function Mv(t,e,i,n){this._x=t||0,this._y=e||0,this._z=i||0,this._order=n||Mv.DefaultOrder}function Tv(t,e,i,n){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==n?n:1}Mv.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Mv.DefaultOrder="XYZ",Object.defineProperties(Mv.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this._onChangeCallback()}}}),Object.assign(Mv.prototype,{isEuler:!0,set:function(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._order=n||this._order,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this},setFromRotationMatrix:function(t,e,i){var n=fg.clamp,r=t.elements,s=r[0],o=r[4],a=r[8],h=r[1],c=r[5],l=r[9],u=r[2],d=r[6],p=r[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(h,c)):(this._y=Math.atan2(-u,s),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(h,s))):"ZYX"===e?(this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(h,s)):(this._x=0,this._z=Math.atan2(-o,c))):"YZX"===e?(this._z=Math.asin(n(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,p))):"XZY"===e?(this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-l,p),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==i&&this._onChangeCallback(),this},setFromQuaternion:function(t,e,i){return xv.makeRotationFromQuaternion(t),this.setFromRotationMatrix(xv,e,i)},setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(t){return wv.setFromEuler(this),this.setFromQuaternion(wv,t)},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new bg(this._x,this._y,this._z)},_onChange:function(t){return this._onChangeCallback=t,this},_onChangeCallback:function(){}}),Object.defineProperties(Tv.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(Tv.prototype,{isVector4:!0,set:function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){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: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,i,n,r,s=.01,o=.1,a=t.elements,h=a[0],c=a[4],l=a[8],u=a[1],d=a[5],p=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(c-u)<s&&Math.abs(l-f)<s&&Math.abs(p-m)<s){if(Math.abs(c+u)<o&&Math.abs(l+f)<o&&Math.abs(p+m)<o&&Math.abs(h+d+g-3)<o)return this.set(1,0,0,0),this;e=Math.PI;var v=(h+1)/2,b=(d+1)/2,y=(g+1)/2,_=(c+u)/4,x=(l+f)/4,w=(p+m)/4;return v>b&&v>y?v<s?(i=0,n=.707106781,r=.707106781):(n=_/(i=Math.sqrt(v)),r=x/i):b>y?b<s?(i=.707106781,n=0,r=.707106781):(i=_/(n=Math.sqrt(b)),r=w/n):y<s?(i=.707106781,n=.707106781,r=0):(i=x/(r=Math.sqrt(y)),n=w/r),this.set(i,n,r,e),this}var M=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-c)*(u-c));return Math.abs(M)<.001&&(M=1),this.x=(m-p)/M,this.y=(l-f)/M,this.z=(u-c)/M,this.w=Math.acos((h+d+g-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){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:function(){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:function(){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:function(){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:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}});var Sv={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},Ev={h:0,s:0,l:0},Pv={h:0,s:0,l:0};function Av(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}function Cv(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function Lv(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Rv(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}Object.assign(Av.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this},setHSL:function(t,e,i){if(t=fg.euclideanModulo(t,1),e=fg.clamp(e,0,1),i=fg.clamp(i,0,1),0===e)this.r=this.g=this.b=i;else{var n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=Cv(r,n,t+1/3),this.g=Cv(r,n,t),this.b=Cv(r,n,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,r=i[1],s=i[2];switch(r){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(s)){var o=parseFloat(n[1])/360,a=parseInt(n[2],10)/100,h=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(o,a,h)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c=i[1],l=c.length;if(3===l)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},setColorName:function(t){var e=Sv[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this},convertGammaToLinear:function(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=Lv(t.r),this.g=Lv(t.g),this.b=Lv(t.b),this},copyLinearToSRGB:function(t){return this.r=Rv(t.r),this.g=Rv(t.g),this.b=Rv(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,i,n=this.r,r=this.g,s=this.b,o=Math.max(n,r,s),a=Math.min(n,r,s),h=(a+o)/2;if(a===o)e=0,i=0;else{var c=o-a;switch(i=h<=.5?c/(o+a):c/(2-o-a),o){case n:e=(r-s)/c+(r<s?6:0);break;case r:e=(s-n)/c+2;break;case s:e=(n-r)/c+4}e/=6}return t.h=e,t.s=i,t.l=h,t},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,i){return this.getHSL(Ev),Ev.h+=t,Ev.s+=e,Ev.l+=i,this.setHSL(Ev.h,Ev.s,Ev.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},lerpHSL:function(t,e){this.getHSL(Ev),t.getHSL(Pv);var i=fg.lerp(Ev.h,Pv.h,e),n=fg.lerp(Ev.s,Pv.s,e),r=fg.lerp(Ev.l,Pv.l,e);return this.setHSL(i,n,r),this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},toJSON:function(){return this.getHex()}}),Av.NAMES=Sv,Object.assign(function(t,e,i,n,r,s){this.a=t,this.b=e,this.c=i,this.normal=n&&n.isVector3?n:new bg,this.vertexNormals=Array.isArray(n)?n:[],this.color=r&&r.isColor?r:new Av,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==s?s:0}.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var e=0,i=t.vertexNormals.length;e<i;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(e=0,i=t.vertexColors.length;e<i;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}});class Iv{}Iv.zero=Object.freeze(new bg(0,0,0)),Iv.one=Object.freeze(new bg(1,1,1)),Iv.up=Object.freeze(new bg(0,0,1)),Iv.down=Object.freeze(new bg(0,0,-1)),Iv.forward=Object.freeze(new bg(0,1,0)),Iv.back=Object.freeze(new bg(0,-1,0)),Iv.right=Object.freeze(new bg(1,0,0)),Iv.left=Object.freeze(new bg(-1,0,0));class Ov{static transformFrustum(t,e,i=new ev){for(let n=0;n<i.planes.length;n++)i.planes[n].copy(t.planes[n]).applyMatrix4(e);return i}static planesIntersectBox(t,e){return Ov.planesIntersectBoxInternal(t,e,!1)}static planesContainBox(t,e){return Ov.planesIntersectBoxInternal(t,e,!0)}static insideNonIntersectingPlanes(t,e){let i=!0;for(const n of e)i=i&&n.distanceToPoint(t)>0;return i}}Ov.planesIntersectBoxInternal=(()=>{const t=new bg;return(e,i,n)=>{for(let r=0,s=e.length;r<s;r++){const s=e[r].normal;if(t.set(s.x>=0!==n?i.max.x:i.min.x,s.y>=0!==n?i.max.y:i.min.y,s.z>=0!==n?i.max.z:i.min.z),e[r].distanceToPoint(t)<0)return!1}return!0}})();class Fv extends Om{constructor(t,e,i,n,r,s){super(t),this._api=e,this._modelBuilder=i,this._clipPlaneTool=n,this._settings=r,this._messenger=s,this._batches=new Map,this.isSelectable=!0,this._customMaterialEntityIds=new Set,this.transformedRay=new _i,this.transformedFrustum=new tr,this.updateCamera=(()=>{const t=new pe;return async(e,i)=>{this._updatingGeometry=!0,this._modelBuilder.removePendingUpdateFinishedAction(this.name),this._inverseTransform.getInverse(this.matrixWorld);const n={type:5,modelId:this.name,frustum:Ov.transformFrustum(e,this._inverseTransform),position:t.copy(i).applyMatrix4(this._inverseTransform)};await this._messenger.request(n)}})(),this._inverseTransform=new Le,this.frustumCulled=!1,this._onSelectionChange=()=>{const t=this._api.selection.get(this.name);t&&0!==t.length?this._setSelection(t):this.clearSelection()}}async load(t){await this._loadFromBuffer(this.name,t),await this._updateSettings(this._settings),this._loaded=!0,this._updatingGeometry=!0,this._api.selection.subscribe(this._onSelectionChange)}isBuilding(){return!this._loaded||this._updatingGeometry||this._modelBuilder.isProcessingQueue()}async _updateSettings(t){await this._messenger.request({type:10,modelId:this.name,settings:t})}transform(t){fd(this,t),this._api.camera.next(this._api.camera.value)}async getBoundingBox(t){if(!t)return this.boundingBox.value;const e={type:6,modelId:this.name,entityIdGroups:[t]},i=(await this._messenger.request(e)).boundingBoxes[0];return(new ci).copy(i).applyMatrix4(this.matrixWorld)}async getUntransformedBoundingBoxes(t){const e={type:6,modelId:this.name,entityIdGroups:t.map((t=>[t]))};return(await this._messenger.request(e)).boundingBoxes.map((t=>(new ci).copy(t)))}onGeometryUpdateFinished(){this._updatingGeometry=!1}_setSelection(t){const e={type:7,modelId:this.name,stateType:2,entityIds:t};this._messenger.request(e)}getClipPlanes(){const t=[];for(const e of this._clipPlaneTool)t.push(e.plane);return t}toIntersection(t,e,i){return{point:(new pe).copy(t.point).applyMatrix4(this.matrixWorld),normal:t.normal?(new pe).copy(t.normal).transformDirection(this.matrixWorld).normalize():void 0,distance:t.distance,id:t.entityId,childrenIds:e,object:this,model:this,caster:i,pickPriority:t.pickPriority,snapType:t.snapType}}createPickMessage(t){if(!t.frustum.intersectsBox(this.boundingBox.value))return;this._inverseTransform.getInverse(this.matrixWorld);const e={type:9};return e.modelId=this.name,e.clipPlanes=this.getClipPlanes().map((t=>t.clone().applyMatrix4(this._inverseTransform))),t.ray&&(this.transformedRay.copy(t.ray).applyMatrix4(this._inverseTransform),e.ray=this.transformedRay),Ov.transformFrustum(t.frustum,this._inverseTransform,this.transformedFrustum),e.frustum=this.transformedFrustum,e}async pick(t){if(!t.frustum.intersectsBox(this.boundingBox.value))return;const e=this.createPickMessage(t);if(!e)return;const i=await this._messenger.request(e);return i.hits&&i.hits.length?this.toIntersection(i.hits[0],i.childrenEntityIds,t):void 0}async pickSnapped(t,e){if(!t.frustum.intersectsBox(this.boundingBox.value))return;const i=this.createPickMessage(t);if(!i)return;i.snapTypes=e;const n=await this._messenger.request(i);return n.hits?n.hits.map((e=>this.toIntersection(e,n.childrenEntityIds,t))):void 0}async pickFrustum(t){delete t.ray;const e=this.createPickMessage(t);if(!e)return;const i=await this._messenger.request(e);return{id:i.childrenEntityIds&&i.childrenEntityIds.length>0?i.childrenEntityIds[0]:null,childrenIds:i.childrenEntityIds,object:this,model:this}}setHovered(t){const e={type:7,modelId:this.name,stateType:3,entityIds:t?[t.intersection.id]:null};this._messenger.request(e)}async setVisibility(t,e){if(t&&!e)return this.resetVisibility();const i={type:7,modelId:this.name,stateType:1,entityIds:e,visible:t};await this._messenger.request(i)}async getVisibleEntityIds(t){const e={type:13,modelId:this.name,visible:t};return(await this._messenger.request(e)).entityIds}async resetVisibility(){const t={type:8,modelId:this.name,stateType:1};await this._messenger.request(t)}async setMaterial(t,e){e||(e=(await this.query({find:{}})).output.find.entityIds);const i={color:t.color?dd(t.color).getHex():void 0,opacity:t.opacity};this.setMetaMaterial(i,e)}async setMetaMaterial(t,e){const i={type:7,modelId:this.name,stateType:0,entityIds:e,material:t};await this._messenger.request(i),e.forEach((t=>this._customMaterialEntityIds.add(t)))}async resetMaterial(t){const e={type:8,modelId:this.name,stateType:0,entityIds:t};await this._messenger.request(e),t?t.forEach((t=>this._customMaterialEntityIds.delete(t))):this._customMaterialEntityIds.clear()}getCustomMaterialEntityIds(){return Array.from(this._customMaterialEntityIds)}async getMaterials(t){const e={type:4,modelId:this.name,entityIds:t};return(await this._messenger.request(e)).materials}async setPickPriority(t,e){const i={type:7,modelId:this.name,stateType:4,entityIds:e,pickPriority:t};await this._messenger.request(i)}async resetPickPriority(){const t={type:8,modelId:this.name,stateType:4};await this._messenger.request(t)}async getEntityIdsByPickPriority(t){const e={type:13,modelId:this.name,pickPriority:t};return(await this._messenger.request(e)).entityIds}getHierarchy(t,e){const i={type:19,modelId:this.name,hierarchyType:t,options:e};return this._messenger.request(i).then((t=>{const e=t.hierarchy;return void 0===e.products&&void 0===e.entities&&void 0===e.propertySets||Fv._unpackHierarchy(t.hierarchy.hierarchy,e),t.hierarchy.hierarchy}))}getHierarchyTree(t,e){const i={type:20,modelId:this.name,hierarchyType:e,entityIds:t};return this._messenger.request(i).then((t=>({parentIds:t.parentIds,childrenIds:t.childrenIds})))}static _unpackHierarchy(t,e){for(const i of t){if(void 0!==e.products&&(i.product=e.products.get(i.productId)),void 0!==e.entities&&(i.entity=e.entities.get(i.id)),void 0!==e.propertySets)if(void 0!==i.propertySetIds){const t=new Array(i.propertySetIds.length);for(let n=0;n<i.propertySetIds.length;n++){const r=i.propertySetIds[n];t[n]=e.propertySets.get(r)}i.properties=t}else i.properties=void 0;Fv._unpackHierarchy(i.children,e)}}guidsToEntityIds(t){const e={type:18,modelId:this.name,guids:t};return this._messenger.request(e).then((t=>t.entityIds))}getEntityInfo(t,e){const i={type:22,modelId:this.name,id:t,hierarchyType:e};return this._messenger.request(i).then((e=>{const i=e.entity;return 0===i.identifierType&&(i.identifier=new ug({data:i.identifier.data})),{id:t,entity:e.entity,product:e.product,properties:e.properties}}))}getPropertySetNames(){const t={type:14,modelId:this.name};return this._messenger.request(t).then((t=>t.names))}getPropertyDefinitions(t){const e={type:15,modelId:this.name,setName:t};return this._messenger.request(e).then((t=>t.properties))}getPropertyValues(t){const e={type:17,modelId:this.name,propertyName:t};return this._messenger.request(e).then((t=>t.properties))}async aggregateProperties(t,e){const i={type:23,modelId:this.name,entityIds:t,aggregations:e};return(await this._messenger.request(i)).aggregations}async query(t){const e={type:11,modelId:this.name,query:t},i=await this._messenger.request(e);if(e.query.find&&e.query.find.stream){const t=t=>{const e={type:12,modelId:this.name,streamId:i.query.output.find.streamId,page:t.page,pageSize:t.pageSize};return this._messenger.request(e).then((t=>t.data))},e=i.query.output;return e.find.callback=t,{output:e}}return{output:i.query.output}}getEntityIdsByQuery(t){const e={type:16,modelId:this.name,conditions:t};return this._messenger.request(e).then((t=>t.entities))}getEntities(t){const e={type:21,modelId:this.name,entityIds:t};return this._messenger.request(e).then((t=>{const e=t.entities;for(let t=0,i=e.length;t<i;t++){const i=e[t];0===i.identifierType&&(i.identifier=new ug({data:i.identifier.data}))}return e}))}updateGeometry(t){this._modelBuilder.addToQueue(t.actions)}addMaterial(t){this._modelBuilder.addMaterials(t)}async _loadFromBuffer(t,e){const i={type:2,modelId:t,buffer:e},n=await this._messenger.request(i,[i.buffer]);this.boundingBox.value.min.copy(n.boundingBox.min),this.boundingBox.value.max.copy(n.boundingBox.max),this.boundingBox.next(this.boundingBox.value)}clearSelection(){const t={type:8,modelId:this.name,stateType:2};this._messenger.request(t)}async dispose(){this._loaded=!1,this._api.selection.unsubscribe(this._onSelectionChange),await this._messenger.request({type:3,modelId:this.name});for(const[t,e]of this._batches)this._modelBuilder.removeBatch(this,t,e);this._modelBuilder.disposeMaterials(this.name)}}class Bv{get version(){return Xm}}class Dv extends Om{constructor(t,e,i,n,r,s,o,a){super("clipPlane"),this.modelBoundingBox=i,this._scissorBw=n,this._settings=o,this.renderingManager=a,this.clear=()=>{this.parent.remove(this)},this.handle=new Dm(s,r,44),this.add(this.handle),this.plane=(new Ti).setFromNormalAndCoplanarPoint(e,t),this.handle.geometry=new fn,this.handle.geometry.setAttribute("position",new Yi(new Float32Array([0,0,0]),3)),this.handle.geometry.computeBoundingSphere(),this.handle.material=new Zo({size:this.handle.pointSize,sizeAttenuation:!1,map:this._scissorBw,depthTest:!1,transparent:!0}),this.position.copy(t),this.handle.geometry.boundingSphere.radius=this.handle.pointSize,this.visualPlane=this.createPlane(),this.add(this.visualPlane),this.userData.interactive=!0,this.userData.travelRay=new _i(t,e)}get coplanarPoint(){return this.position}set coplanarPoint(t){this.position.copy(t)}get normal(){return this.plane.normal}set normal(t){this.plane.normal=t}get constant(){return this.plane.constant}set constant(t){this.plane.constant=t}invert(){this.normal.negate(),this.constant*=-1,this.updateVisual()}makeVertical(){this.normal.z=0,this.normal.normalize(),this.normal.equals(xd.zero)&&this.normal.set(1,0,0),this.updateVisual()}makeHorizontal(){this.normal.set(0,0,1),this.normal.normalize(),this.updateVisual()}updateVisual(){this.plane.setFromNormalAndCoplanarPoint(this.normal,this.position);const t=this.userData.travelRay;t.origin=this.position,t.direction=this.normal,this.remove(this.visualPlane),this.visualPlane=this.createPlane(),this.add(this.visualPlane),this.renderingManager.redraw()}getDirectionalOutline(t,e){const i=new pe,n=function(t){const e=t.min.x===1/0?new pe(-50,-50,-50):t.min,i=t.max.x===-1/0?new pe(50,50,50):t.max,n=[];return n.push(new pe(i.x,i.y,i.z)),n.push(new pe(e.x,i.y,i.z)),n.push(new pe(e.x,e.y,i.z)),n.push(new pe(i.x,e.y,i.z)),n.push(new pe(i.x,i.y,e.z)),n.push(new pe(e.x,i.y,e.z)),n.push(new pe(e.x,e.y,e.z)),n.push(new pe(i.x,e.y,e.z)),n}(e),r=new pe;t.projectPoint(e.getCenter(i),r);const s=[],o=new pe;let a=0;for(const e of n){const i=new pe;t.projectPoint(e,i).sub(r),s.push(i);const n=i.lengthSq();n>a&&(a=n,o.copy(i))}const h=new pe;let c=0;const l=new pe;let u=0;const d=new pe;let p=0;const f=(new pe).crossVectors(t.normal,o);for(const t of s){const e=o.dot(t),i=f.dot(t);e<c&&(c=e,h.copy(t)),i>u&&(u=i,l.copy(t)),i<p&&(p=i,d.copy(t))}return[o.add(r),d.add(r),h.add(r),l.add(r)]}createPlane(){const t=new Un,e=this.getDirectionalOutline(this.plane,this.modelBoundingBox);e.forEach((t=>t.sub(this.position))),t.vertices=[...e],t.vertices.push(e[0]);const i=new No({color:dd(this._settings.color)});this._settings.colorSubject.subscribe((()=>i.color=dd(this._settings.color)));const n=new Go(t,i),r=new Un;r.vertices=e,r.faces.push(new Hi(0,1,2)),r.faces.push(new Hi(3,0,2));const s=new In(r,new qi({color:15987703,transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,side:2}));return s.add(n),s}pick(t){const e=t.intersectObjects([this.handle],!1)[0];if(e){e.object.userData.interactive=!0;const i={object:null,id:this.id,caster:t,model:this,pickPriority:1};return Promise.resolve(Object.assign(i,e))}}}class zv{constructor(t,e,i){this._inputs=t,this._api=e,this._modelBuilder=i,this._clipPlanes=[],this[Symbol.iterator]=()=>ld(this._clipPlanes,(t=>t)),this._isClipPlane=t=>Kp(t)&&!!this.getClipPlane(t),this._modelBuilder.clipPlanes=this._clipPlanes;t.pointerDown$.pipe(Cp(tf(0,1)),rp(of(t.picker,this._clipPlanes)),Cp(this._isClipPlane),pp((t=>this._selectCliplane(t))),Ip((()=>t.pointerMove$.pipe(Bp(nf(t,0,1))))),pp((t=>this._translateClipPlane(t))),pp((()=>e.camera.next(e.camera.value))),Ip((()=>t.pointerUp$)),pp((()=>{this._inputs.cursor="",this.clipPlaneHighLight=!1}))).subscribe(),this._rayCaster=new Ul,this._scissorBw=(new ic).load(this._api.staticRootUrl+"images/scissors.png",(()=>{this._api.renderingManager.redraw()})),this._scissorBw.wrapS=dt,this._scissorBw.wrapT=dt,this._scissorBw.minFilter=yt}get name(){return"clipPlanes"}set intersectingClipPlanes(t){this._modelBuilder.intersectingClipPlanes=t}get intersectingClipPlanes(){return this._modelBuilder.intersectingClipPlanes}get length(){return this._clipPlanes.length}set enabled(t){if(this._tapsHandle&&(this._tapsHandle.unsubscribe(),this._tapsHandle=null,this._cursor3D.unsubscribe(),this._cursor3D=null),!t)return;const e=rf(this._inputs,{button:0,touchCount:1});this._tapsHandle=e.pipe(rp((t=>this._cursor3D.calculateIntersection(t)))).subscribe((t=>{this._addClipPlane(t),this.onFinished()})),this._cursor3D=this._api.cursor,this._cursor3D.subscribe([0,1])}get enabled(){return!!this._tapsHandle}getClipPlane(t){const e=t.intersection.model;return e instanceof Dv?e:null}add(t){const e=new Dv(new pe(t.coplanarPoint.x,t.coplanarPoint.y,t.coplanarPoint.z),new pe(t.normal.x,t.normal.y,t.normal.z),this._api.models.worldBoundingBox.value,this._scissorBw,this._api.container,this._api.camera,this._api.settings,this._api.renderingManager);this._clipPlanes.push(e),this._api.models.add(e),this._modelBuilder.setMeshMaterialsSidedness(2,!0),this._api.renderingManager.renderer.localClippingEnabled=!0,this._api.renderingManager.redraw(),this._api.eventDispatcher.dispatch(new CustomEvent("clipplaneadded",{detail:e}))}remove(t){const e=this._clipPlanes.find((e=>e.coplanarPoint.x===t.coplanarPoint.x&&e.coplanarPoint.y===t.coplanarPoint.y&&e.coplanarPoint.z===t.coplanarPoint.z&&e.plane.normal.x===t.normal.x&&e.plane.normal.y===t.normal.y&&e.plane.normal.z===t.normal.z));this._remove(e)}removeById(t){const e=this._clipPlanes.find((e=>e.id===t));this._remove(e)}_remove(t){t&&(this._clipPlanes.splice(this._clipPlanes.indexOf(t),1),this._api.models.remove(t),this._api.renderingManager.redraw()),0===this._clipPlanes.length&&(this._modelBuilder.restoreMeshMaterialsSidedness(),this._api.renderingManager.renderer.localClippingEnabled=!1,this._api.renderingManager.redraw())}_addClipPlane(t){return this.add({coplanarPoint:this._cursor3D.normal.clone().multiplyScalar(.01).add(this._cursor3D.position()),normal:this._cursor3D.normal.clone().negate()}),t}clear(){for(const t of this._clipPlanes)this._api.models.remove(t);this._clipPlanes.length=0,this._modelBuilder.restoreMeshMaterialsSidedness(),this._api.renderingManager.renderer.localClippingEnabled=!1,this._api.camera.next(this._api.camera.value)}_selectCliplane(t){this._api.inputHandler.cursor="grabbing";const e=this.getClipPlane(t);return e&&(this._selectedClipPlane=e,this.clipPlaneHighLight=!0),t}_translateClipPlane(t){this._api.inputHandler.cursor="grabbing";const e=Of(t,this._api.container);this._rayCaster.setFromCamera(e,this._api.camera.value);const i=(new _i).copy(this._selectedClipPlane.userData.travelRay);return this._intersectionPoint=function(t,e){const i=(new pe).subVectors(t.origin,e.origin),n=-t.direction.dot(e.direction),r=i.dot(t.direction),s=(i.length(),Math.abs(1-n*n));let o;o=s>=0?(n*-i.dot(e.direction)-r)*(1/s):-r;return(new pe).copy(t.origin).add(t.direction.multiplyScalar(o))}(i,this._rayCaster.ray),this._selectedClipPlane.position.copy(this._intersectionPoint),this._selectedClipPlane.constant=-this._selectedClipPlane.normal.dot(this._intersectionPoint),t}set clipPlaneHighLight(t){if(this._selectedClipPlane){const e=this._selectedClipPlane.children[1];e.material.opacity=t?.3:0,e.material.needsUpdate=!0,this._api.renderingManager.redraw()}}}class Nv{constructor(t,e,i){this.worker=t,this.analytics=e,this.onMessage=t=>e=>{void 0!==e.data.messageId?this.responseHandler(e.data):t(e.data)},this.responseHandler=t=>{const e=this.callbacks.get(t.messageId);this.callbacks.delete(t.messageId),e(t)},this.nextMessageId=0,this.callbacks=new Map,t.addEventListener("message",this.onMessage(i))}request(t,e){return t.messageId=this.nextMessageId++,new Promise(((i,n)=>{this.callbacks.set(t.messageId,(t=>{if(t.error)return this.analytics.logError(t.error),n(new Error(t.error));i(t)})),this.worker.postMessage(t,e)}))}}class Uv extends Bv{constructor(t){super(),this.settings=t,this._processMessage=t=>{const e=this._trimbimModels.get(t.modelId);if(e)switch(t.type){case 0:e.updateGeometry(t);break;case 1:e.addMaterial(t)}},this.isTrbFile=(t,e)=>t instanceof Blob&&this.isTrimbim(t.name,e),this.isTrbBuffer=(t,e)=>t instanceof ArrayBuffer&&this.isTrimbim(void 0,e),this.isTrbUrl=(t,e)=>"string"==typeof t&&this.isTrimbim(t,e),void 0===this.settings&&(this.settings={})}get name(){return"trimbim"}set api(t){this._api=t;let e=this.settings.workerRootUrl?this.settings.workerRootUrl:t.settings.staticRootUrl;e||(e=window.DEFAULT_STATIC_ROOT_URL||"/"),e+="dist/workers/threadworker.min.js",this._modelBuilder=new cg(this._api.selectionEffectPass,this._api.settings,this.settings,this._api.renderingManager,this._api.camera,this._api.htmlElementPositioner),this._trimbimModels=this._modelBuilder.models,this._clipPlaneTool=new zv(t.inputHandler,t,this._modelBuilder),t.toolManager.addTool(this._clipPlaneTool),t.camera.subscribe((()=>this.updateCamera(t.camera.frustum,t.camera.position))),t.registry.register(this.isTrbFile,((t,e)=>this.loadTrimbimFile(t,e)),(t=>this.unload(t))),t.registry.register(this.isTrbUrl,((t,e)=>this.loadTrimbimUrl(t,e)),(t=>this.unload(t))),t.registry.register(this.isTrbBuffer,((t,e)=>this.loadTrimbimBuffer(t,e)),(t=>this.unload(t))),this._setupWorkers(e)}_setupWorkers(t){const e=new Worker(t);this._messenger=new Nv(e,this._api.analytics,this._processMessage),e.onerror=t=>this._api.eventDispatcher.error(t.message)}isTrimbim(t,e){return this.isTrb(t)||e&&this.isTrb(e.modelId)}isTrb(t){return/.*\.trb.*/.test(t)}async updateCamera(t,e){for(const i of this._trimbimModels.values())await i.updateCamera(t,e)}transform(t,e){fd(this._getModel(t),e)}async loadTrimbimFile(t,e){void 0===e.modelId&&(e.modelId=t.name);const i=await function(t){return new Promise(((e,i)=>{const n=new FileReader;n.onload=t=>{const i=t.target;e(i.result)},n.onerror=t=>(console.error(t),i(t)),n.readAsArrayBuffer(t)}))}(t);return this.loadTrimbimBuffer(i,e)}async loadTrimbimUrl(t,e){void 0===e.modelId&&(e.modelId=t);const i=await this.createModelBufferFromUrl(t);return this.loadTrimbimBuffer(i,e)}async loadTrimbimBuffer(t,e){if(this._trimbimModels.has(e.modelId))throw new Error("A model with the same id is already loaded.");!function(t,e,i=8){if(t.byteLength<10)throw new Error("File size is too small to be a TrimBIM");if("TextDecoder"in window){const n=new Uint8Array(t,4,6),r=(new TextDecoder).decode(n);if(!r.includes("TRB"))throw new Error("The file is not a TrimBIM file");const s=/\d+/.exec(r)[0];if(!s||Number(s)<i)throw new Error(`The TrimBIM plugin only supports TrimBIM ${i} or newer, it received TrimBIM ${s}.`);e&&(e.version=r,e.versionNumber=Number(s))}else console.warn("This browser does not support TextDecoder, the trimbim file cannot be fully validated.")}(t,{});const i=await this.createModel(e.modelId,t);return this._api.models.add(i),fd(i,e.transform),i}async unload(t){const e=this._getModel(t);this._trimbimModels.delete(t),this._api.models.remove(e),await e.dispose(),this._api.renderingManager.redraw()}async resetMaterial(t,e){if(e&&e.length>0&&!t)throw new TypeError("EntityIds cannot be defined while modelId isn't");const i=t?[this._getModel(t)]:[...this._trimbimModels.values()];await Promise.all(i.map((t=>t.resetMaterial(e))))}async resetVisibility(t){const e=t?[this._getModel(t)]:[...this._trimbimModels.values()];await Promise.all(e.map((t=>t.resetVisibility())))}setVisibility({modelId:t,entityIds:e,visible:i}){if(void 0===i)throw new TypeError("visible needs to be defined");if(e&&e.length>0&&!t)throw new TypeError("EntityIds cannot be defined while modelId isn't");const n=t?[this._getModel(t)]:[...this._trimbimModels.values()];return e&&0===e.length?Promise.resolve(new Array(n.length).fill(!0)):Promise.all(n.map((t=>t.setVisibility(i,e))))}getVisibleEntityIds(t,e){return this._getModel(t).getVisibleEntityIds(e)}setMaterial({modelId:t,entityIds:e,material:i}){if(!i)throw new TypeError("Material needs to be defined");if(e&&e.length>0&&!t)throw new TypeError("EntityIds cannot be defined while modelId isn't");const n=t?[this._getModel(t)]:[...this._trimbimModels.values()];if(e&&0===e.length)return Promise.resolve(new Array(n.length).fill(!0));const r=n.map((t=>t.setMaterial(i,e)));return Promise.all(r)}async resetPickPriority(t){const e=t?[this._getModel(t)]:[...this._trimbimModels.values()];await Promise.all(e.map((t=>t.resetPickPriority())))}setPickPriority({modelId:t,entityIds:e,pickPriority:i}){if(e&&e.length>0&&!t)throw new TypeError("EntityIds cannot be defined while modelId isn't");const n=t?[this._getModel(t)]:[...this._trimbimModels.values()];return e&&0===e.length?Promise.resolve(new Array(n.length).fill(!0)):Promise.all(n.map((t=>t.setPickPriority(i,e))))}getEntityIds(t,e){return this._getModel(t).guidsToEntityIds(e)}getEntityInfo(t,e,i){return this._getModel(t).getEntityInfo(e,i)}getHierarchy(t,e,i){return this._getModel(t).getHierarchy(e,i)}getPropertySetNames(t){return this._getModel(t).getPropertySetNames()}getPropertyDefinitions(t,e){return this._getModel(t).getPropertyDefinitions(e)}getPropertyValues(t,e){return this._getModel(t).getPropertyValues(e)}getEntityIdsByQuery(t,e){return this._getModel(t).getEntityIdsByQuery(e)}getEntities(t,e){return this._getModel(t).getEntities(e)}getSelectedEntities(){return Promise.all(Array.from(this._trimbimModels.keys()).filter((t=>this._api.selection.has(t))).map((t=>{const e=this._api.selection.get(t);return this._trimbimModels.get(t).getEntities(e).then((e=>({modelId:t,entities:e})))})))}query(t){return this._getModel(t.modelId).query(t)}getModelIds(){return Array.from(this._trimbimModels.keys())}getModel(t){return this._trimbimModels.get(t)}_getModel(t){if(this._trimbimModels.has(t))return this._trimbimModels.get(t);throw new Error(`Unknown model ${t}`)}async createModelBufferFromUrl(t){return new Promise(((e,i)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.withCredentials=!0,n.responseType="arraybuffer",n.onload=()=>e(n.response),n.onerror=()=>i("Error loading "+t),n.send()}))}async createModel(t,e){const i=new Fv(t,this._api,this._modelBuilder,this._clipPlaneTool,this.settings,this._messenger);try{this._trimbimModels.set(t,i),await i.load(e)}catch(e){throw this._trimbimModels.delete(t),e}return i}}i(9),i(10);class Vv{constructor(){this._listeners={}}addEventListener(t,e){const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){let i=this._listeners[t];if(void 0!==i){let t=i.indexOf(e);-1!==t&&i.splice(t,1)}}removeEventListeners(t){void 0!==this._listeners[t]&&delete this._listeners[t]}dispatchEvent(t){let e=this._listeners[t.type];if(void 0!==e){t.target=this;for(let i of e.slice(0))i.call(this,t)}}}const kv={config:{withCredentials:!1,customHeaders:[{header:null,value:null}]},createXMLHttpRequest:function(){let t=new XMLHttpRequest;if(this.config.customHeaders&&Array.isArray(this.config.customHeaders)&&this.config.customHeaders.length>0){let e=t.open,i=this.config.customHeaders;t.open=function(){e.apply(this,[].slice.call(arguments)),i.forEach((function(e){e.header&&e.value&&t.setRequestHeader(e.header,e.value)}))}}return t}};class jv extends Ye{constructor(t){super();let e=new ye;e.minFilter=yt,e.magFilter=yt;let i=new co({map:e,depthTest:!1,depthWrite:!1});this.material=i,this.sprite=new Mo(i),this.add(this.sprite),this.borderThickness=4,this.fontface="Arial",this.fontsize=28,this.borderColor={r:0,g:0,b:0,a:1},this.backgroundColor={r:255,g:255,b:255,a:1},this.textColor={r:255,g:255,b:255,a:1},this.text="",this.setText(t)}setText(t){this.text!==t&&(this.text=t,this.update())}setTextColor(t){this.textColor=t,this.update()}setBorderColor(t){this.borderColor=t,this.update()}setBackgroundColor(t){this.backgroundColor=t,this.update()}update(){let t=document.createElement("canvas"),e=t.getContext("2d");e.font="Bold "+this.fontsize+"px "+this.fontface;let i=e.measureText(this.text).width,n=10+i+2*this.borderThickness,r=1.4*this.fontsize+2*this.borderThickness;e.canvas.width=n,e.canvas.height=r,e.font="Bold "+this.fontsize+"px "+this.fontface,e.fillStyle="rgba("+this.backgroundColor.r+","+this.backgroundColor.g+","+this.backgroundColor.b+","+this.backgroundColor.a+")",e.strokeStyle="rgba("+this.borderColor.r+","+this.borderColor.g+","+this.borderColor.b+","+this.borderColor.a+")",e.lineWidth=this.borderThickness,this.roundRect(e,this.borderThickness/2,this.borderThickness/2,i+this.borderThickness+10,1.4*this.fontsize+this.borderThickness,6),e.strokeStyle="rgba(0, 0, 0, 1.0)",e.strokeText(this.text,this.borderThickness+5,this.fontsize+this.borderThickness),e.fillStyle="rgba("+this.textColor.r+","+this.textColor.g+","+this.textColor.b+","+this.textColor.a+")",e.fillText(this.text,this.borderThickness+5,this.fontsize+this.borderThickness);let s=new ye(t);s.minFilter=yt,s.magFilter=yt,s.needsUpdate=!0,this.sprite.material.map=s,this.sprite.scale.set(.01*n,.01*r,1)}roundRect(t,e,i,n,r,s){t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+r-s),t.quadraticCurveTo(e+n,i+r,e+n-s,i+r),t.lineTo(e+s,i+r),t.quadraticCurveTo(e,i+r,e,i+r-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath(),t.fill(),t.stroke()}}class Hv extends Ye{constructor(t={}){super(),"Volume"===this.constructor.name&&console.warn("Can't create object of class Volume directly. Use classes BoxVolume or SphereVolume instead."),this._clip=t.clip||!1,this._visible=!0,this.showVolumeLabel=!0,this._modifiable=t.modifiable||!0,this.label=new jv("0"),this.label.setBorderColor({r:0,g:255,b:0,a:0}),this.label.setBackgroundColor({r:0,g:255,b:0,a:0}),this.label.material.depthTest=!1,this.label.material.depthWrite=!1,this.label.material.transparent=!0,this.label.position.y-=.5,this.add(this.label),this.label.updateMatrixWorld=()=>{let t=new pe;t.setFromMatrixPosition(this.matrixWorld),this.label.position.copy(t),this.label.updateMatrix(),this.label.matrixWorld.copy(this.label.matrix),this.label.matrixWorldNeedsUpdate=!1;for(let t=0,e=this.label.children.length;t<e;t++)this.label.children[t].updateMatrixWorld(!0)},this.addEventListener("select",(t=>{})),this.addEventListener("deselect",(t=>{}))}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this.dispatchEvent({type:"visibility_changed",object:this}))}getVolume(){console.warn("override this in subclass")}update(){}raycast(t,e){}get clip(){return this._clip}set clip(t){this._clip!==t&&(this._clip=t,this.update(),this.dispatchEvent({type:"clip_changed",object:this}))}get modifieable(){return this._modifiable}set modifieable(t){this._modifiable=t,this.update()}}class Gv extends Ye{constructor(){super(),this.constructor.counter=void 0===this.constructor.counter?0:this.constructor.counter+1,this.name="Profile_"+this.constructor.counter,this.points=[],this.spheres=[],this.edges=[],this.boxes=[],this.width=1,this.height=20,this._modifiable=!0,this.sphereGeometry=new ih(.4,10,10),this.color=new Ui(16711680),this.lineColor=new Ui(16711680)}createSphereMaterial(){return new Eh({color:16711680,depthTest:!1,depthWrite:!1})}getSegments(){let t=[];for(let e=0;e<this.points.length-1;e++){let i=this.points[e].clone(),n=this.points[e+1].clone();t.push({start:i,end:n})}return t}getSegmentMatrices(){let t=this.getSegments(),e=[];for(let i of t){let{start:t,end:n}=i,r=new Ye,s=t.clone().setZ(0).distanceTo(n.clone().setZ(0));r.scale.set(s,1e4,this.width),r.up.set(0,0,1);let o=(new pe).addVectors(t,n).multiplyScalar(.5),a=(new pe).subVectors(n,t),h=new pe(a.y,-a.x,0);r.position.set(0,0,0),r.lookAt(h),r.position.copy(o),r.updateMatrixWorld(),e.push(r.matrixWorld)}return e}addMarker(t){this.points.push(t);let e=new In(this.sphereGeometry,this.createSphereMaterial());if(this.add(e),this.spheres.push(e),this.points.length>1){let t=new Un;t.vertices.push(new pe,new pe),t.colors.push(this.lineColor,this.lineColor,this.lineColor);let e=new No({vertexColors:2,linewidth:2,transparent:!0,opacity:.4});e.depthTest=!1;let i=new Go(t,e);i.visible=!1,this.add(i),this.edges.push(i);let n=new In(new Vn(1,1,1),new qi({color:16711680,transparent:!0,opacity:.2}));n.visible=!1,this.add(n),this.boxes.push(n)}{let t=t=>{let e=tb.getMousePointCloudIntersection(t.drag.end,t.viewer.scene.getActiveCamera(),t.viewer,t.viewer.scene.pointclouds);if(e){let i=this.spheres.indexOf(t.drag.object);-1!==i&&this.setPosition(i,e.location)}},i=t=>{let e=this.spheres.indexOf(t.drag.object);-1!==e&&this.dispatchEvent({type:"marker_dropped",profile:this,index:e})},n=t=>t.object.material.emissive.setHex(8947848),r=t=>t.object.material.emissive.setHex(0);e.addEventListener("drag",t),e.addEventListener("drop",i),e.addEventListener("mouseover",n),e.addEventListener("mouseleave",r)}let i={type:"marker_added",profile:this,sphere:e};this.dispatchEvent(i),this.setPosition(this.points.length-1,t)}removeMarker(t){this.points.splice(t,1),this.remove(this.spheres[t]);let e=0===t?0:t-1;this.remove(this.edges[e]),this.edges.splice(e,1),this.remove(this.boxes[e]),this.boxes.splice(e,1),this.spheres.splice(t,1),this.update(),this.dispatchEvent({type:"marker_removed",profile:this})}setPosition(t,e){let i=this.points[t];i.copy(e);let n={type:"marker_moved",profile:this,index:t,position:i.clone()};this.dispatchEvent(n),this.update()}setWidth(t){this.width=t;let e={type:"width_changed",profile:this,width:t};this.dispatchEvent(e),this.update()}getWidth(){return this.width}update(){if(0===this.points.length)return;if(1===this.points.length){let t=this.points[0];return void this.spheres[0].position.copy(t)}let t=this.points[0].clone(),e=this.points[0].clone(),i=new pe,n=this.points.length-1;for(let r=0;r<=n;r++){let s=this.points[r],o=this.spheres[r],a=0===r?n:r-1,h=this.points[a],c=this.edges[a],l=this.edges[r],u=this.boxes[a];if(o.position.copy(s),this._modifiable?o.visible=!0:o.visible=!1,c&&(c.geometry.vertices[1].copy(s),c.geometry.verticesNeedUpdate=!0,c.geometry.computeBoundingSphere()),l&&(l.geometry.vertices[0].copy(s),l.geometry.verticesNeedUpdate=!0,l.geometry.computeBoundingSphere()),u){let t=h,e=s,i=t.clone().setZ(0).distanceTo(e.clone().setZ(0));u.scale.set(i,1e6,this.width),u.up.set(0,0,1);let n=(new pe).addVectors(t,e).multiplyScalar(.5),r=(new pe).subVectors(e,t),o=new pe(r.y,-r.x,0);u.position.set(0,0,0),u.lookAt(o),u.position.copy(n)}i.add(s),t.min(s),e.max(s)}i.multiplyScalar(1/this.points.length);for(let i=0;i<this.boxes.length;i++){this.boxes[i].position.z=t.z+(e.z-t.z)/2}}raycast(t,e){for(let i=0;i<this.points.length;i++){this.spheres[i].raycast(t,e)}for(let i=0;i<e.length;i++){let n=e[i];n.distance=t.ray.origin.distanceTo(n.point)}e.sort((function(t,e){return t.distance-e.distance}))}get modifiable(){return this._modifiable}set modifiable(t){this._modifiable=t,this.update()}}class Wv extends Ye{constructor(){super(),this.constructor.counter=void 0===this.constructor.counter?0:this.constructor.counter+1,this.name="Measure_"+this.constructor.counter,this.points=[],this._showDistances=!0,this._showCoordinates=!1,this._showArea=!1,this._closed=!0,this._showAngles=!1,this._showHeight=!1,this.maxMarkers=Number.MAX_SAFE_INTEGER,this.sphereGeometry=new ih(.4,10,10),this.color=new Ui(16711680),this.lengthUnit={code:"m"},this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[],this.angleLabels=[],this.coordinateLabels=[];{let t=new Un;t.vertices.push(new pe,new pe,new pe,new pe),t.colors.push(this.color,this.color,this.color);let e=new Ah({color:16711680,dashSize:5,gapSize:2});e.depthTest=!1,this.heightEdge=new Go(t,e),this.heightEdge.visible=!1,this.add(this.heightEdge)}this.heightLabel=new jv(""),this.heightLabel.setBorderColor({r:0,g:0,b:0,a:.8}),this.heightLabel.setBackgroundColor({r:0,g:0,b:0,a:.3}),this.heightLabel.setTextColor({r:180,g:220,b:180,a:1}),this.heightLabel.material.depthTest=!1,this.heightLabel.material.opacity=1,this.heightLabel.visible=!1,this.add(this.heightLabel),this.areaLabel=new jv(""),this.areaLabel.setBorderColor({r:0,g:0,b:0,a:.8}),this.areaLabel.setBackgroundColor({r:0,g:0,b:0,a:.3}),this.areaLabel.setTextColor({r:180,g:220,b:180,a:1}),this.areaLabel.material.depthTest=!1,this.areaLabel.material.opacity=1,this.areaLabel.visible=!1,this.add(this.areaLabel)}createSphereMaterial(){return new Eh({color:this.color,depthTest:!1,depthWrite:!1})}addMarker(t){t instanceof pe?t={position:t}:t instanceof Array&&(t={position:new pe(...t)}),this.points.push(t);let e=new In(this.sphereGeometry,this.createSphereMaterial());this.add(e),this.spheres.push(e);{let t=new Un;t.vertices.push(new pe,new pe),t.colors.push(this.color,this.color,this.color);let e=new No({linewidth:1});e.depthTest=!1;let i=new Go(t,e);i.visible=!0,this.add(i),this.edges.push(i)}{let t=new jv;t.setBorderColor({r:0,g:0,b:0,a:.8}),t.setBackgroundColor({r:0,g:0,b:0,a:.3}),t.material.depthTest=!1,t.visible=!1,this.edgeLabels.push(t),this.add(t)}{let t=new jv;t.setBorderColor({r:0,g:0,b:0,a:.8}),t.setBackgroundColor({r:0,g:0,b:0,a:.3}),t.material.depthTest=!1,t.material.opacity=1,t.visible=!1,this.angleLabels.push(t),this.add(t)}{let t=new jv;t.setBorderColor({r:0,g:0,b:0,a:.8}),t.setBackgroundColor({r:0,g:0,b:0,a:.3}),t.material.depthTest=!1,t.material.opacity=1,t.visible=!1,this.coordinateLabels.push(t),this.add(t)}{let t=t=>{let e=tb.getMousePointCloudIntersection(t.drag.end,t.viewer.scene.getActiveCamera(),t.viewer,t.viewer.scene.pointclouds,{pickClipped:!0});if(e){let i=this.spheres.indexOf(t.drag.object);if(-1!==i){let t=this.points[i];for(let i of Object.keys(e.point).filter((t=>"position"!==t)))t[i]=e.point[i];this.setPosition(i,e.location)}}},i=t=>{let e=this.spheres.indexOf(t.drag.object);-1!==e&&this.dispatchEvent({type:"marker_dropped",measurement:this,index:e})},n=t=>t.object.material.emissive.setHex(8947848),r=t=>t.object.material.emissive.setHex(0);e.addEventListener("drag",t),e.addEventListener("drop",i),e.addEventListener("mouseover",n),e.addEventListener("mouseleave",r)}let i={type:"marker_added",measurement:this,sphere:e};this.dispatchEvent(i),this.setMarker(this.points.length-1,t)}removeMarker(t){this.points.splice(t,1),this.remove(this.spheres[t]);let e=0===t?0:t-1;this.remove(this.edges[e]),this.edges.splice(e,1),this.remove(this.edgeLabels[e]),this.edgeLabels.splice(e,1),this.coordinateLabels.splice(t,1),this.spheres.splice(t,1),this.update(),this.dispatchEvent({type:"marker_removed",measurement:this})}setMarker(t,e){this.points[t]=e;let i={type:"marker_moved",measure:this,index:t,position:e.position.clone()};this.dispatchEvent(i),this.update()}setPosition(t,e){this.points[t].position.copy(e);let i={type:"marker_moved",measure:this,index:t,position:e.clone()};this.dispatchEvent(i),this.update()}getArea(){let t=0,e=this.points.length-1;for(let i=0;i<this.points.length;i++){let n=this.points[i].position,r=this.points[e].position;t+=(r.x+n.x)*(n.y-r.y),e=i}return Math.abs(t/2)}getTotalDistance(){if(0===this.points.length)return 0;let t=0;for(let e=1;e<this.points.length;e++){let i=this.points[e-1].position,n=this.points[e].position;t+=i.distanceTo(n)}if(this.closed&&this.points.length>1){let e=this.points[0].position;t+=this.points[this.points.length-1].position.distanceTo(e)}return t}getAngleBetweenLines(t,e,i){let n=(new pe).subVectors(e.position,t.position),r=(new pe).subVectors(i.position,t.position);return n.angleTo(r)}getAngle(t){if(this.points.length<3||t>=this.points.length)return 0;let e=0===t?this.points[this.points.length-1]:this.points[t-1],i=this.points[t],n=this.points[(t+1)%this.points.length];return this.getAngleBetweenLines(i,e,n)}update(){if(0===this.points.length)return;if(1===this.points.length){let t=this.points[0].position;this.spheres[0].position.copy(t);{let e=this.coordinateLabels[0],i=t.toArray().map((t=>tb.addCommas(t.toFixed(2)))).join(", ");e.setText(i),e.visible=this.showCoordinates}return}let t=this.points.length-1,e=new pe;for(let i=0;i<=t;i++){let t=this.points[i];e.add(t.position)}e.divideScalar(this.points.length);for(let e=0;e<=t;e++){let i=e,n=e+1>t?0:e+1,r=0===e?t:e-1,s=this.points[i],o=this.points[n],a=this.points[r],h=this.spheres[i];h.position.copy(s.position),h.material.color=this.color;{let e=this.edges[i];e.material.color=this.color,e.position.copy(s.position),e.geometry.vertices[0].set(0,0,0),e.geometry.vertices[1].copy(o.position).sub(s.position),e.geometry.verticesNeedUpdate=!0,e.geometry.computeBoundingSphere(),e.visible=i<t||this.closed}{let n=this.edgeLabels[e],r=(new pe).add(s.position);r.add(o.position),r=r.multiplyScalar(.5);let a=s.position.distanceTo(o.position);n.position.copy(r),n.setText(tb.addCommas(a.toFixed(2))+" "+this.lengthUnit.code),n.visible=this.showDistances&&(i<t||this.closed)&&this.points.length>=2&&a>0}{let n=this.angleLabels[e],r=this.getAngleBetweenLines(s,a,o),h=o.position.clone().sub(a.position);h.multiplyScalar(.5),h=a.position.clone().add(h).sub(s.position).normalize();let c=Math.min(s.position.distanceTo(a.position),s.position.distanceTo(o.position));c/=9;let l=s.position.clone().add(h.multiplyScalar(c));n.position.copy(l);let u=tb.addCommas((r*(180/Math.PI)).toFixed(1))+"°";n.setText(u),n.visible=this.showAngles&&(i<t||this.closed)&&this.points.length>=3&&r>0}}{let t=this.heightEdge;if(t.visible=this.showHeight,this.heightLabel.visible=this.showHeight,this.showHeight){let e=this.points.slice().sort(((t,e)=>t.position.z-e.position.z)),i=e[0].position.clone(),n=e[e.length-1].position.clone(),r=i.z,s=n.z,o=s-r,a=new pe(n.x,n.y,r),h=new pe(n.x,n.y,s);t.position.copy(i),t.geometry.vertices[0].set(0,0,0),t.geometry.vertices[1].copy(a).sub(i),t.geometry.vertices[2].copy(a).sub(i),t.geometry.vertices[3].copy(h).sub(i),t.geometry.verticesNeedUpdate=!0,t.geometry.computeBoundingSphere();let c=a.clone().add(h).multiplyScalar(.5);this.heightLabel.position.copy(c);let l=tb.addCommas(o.toFixed(2))+" "+this.lengthUnit.code;this.heightLabel.setText(l)}}{this.areaLabel.position.copy(e),this.areaLabel.visible=this.showArea&&this.points.length>=3;let t=tb.addCommas(this.getArea().toFixed(1))+" "+this.lengthUnit.code+"²";this.areaLabel.setText(t)}}raycast(t,e){for(let i=0;i<this.points.length;i++){this.spheres[i].raycast(t,e)}for(let i=0;i<e.length;i++){let n=e[i];n.distance=t.ray.origin.distanceTo(n.point)}e.sort((function(t,e){return t.distance-e.distance}))}get showCoordinates(){return this._showCoordinates}set showCoordinates(t){this._showCoordinates=t,this.update()}get showAngles(){return this._showAngles}set showAngles(t){this._showAngles=t,this.update()}get showHeight(){return this._showHeight}set showHeight(t){this._showHeight=t,this.update()}get showArea(){return this._showArea}set showArea(t){this._showArea=t,this.update()}get closed(){return this._closed}set closed(t){this._closed=t,this.update()}get showDistances(){return this._showDistances}set showDistances(t){this._showDistances=t,this.update()}}class qv extends Ye{constructor(t){super(),this.constructor.counter=void 0===this.constructor.counter?0:this.constructor.counter+1,this.name="polygon_clip_volume_"+this.constructor.counter,this.camera=t.clone(),this.camera.rotation.set(...t.rotation.toArray()),this.camera.updateMatrixWorld(),this.camera.updateProjectionMatrix(),this.camera.matrixWorldInverse.getInverse(this.camera.matrixWorld),this.viewMatrix=this.camera.matrixWorldInverse.clone(),this.projMatrix=this.camera.projectionMatrix.clone(),this._vec2=new ce,this.markers=[],this.initialized=!1}addMarker(){let t,e=new In,i=t=>{let i=t.viewer.renderer.getSize(this._vec2),n=new pe(t.drag.end.x/i.width*2-1,t.drag.end.y/i.height*-2+1,0);e.position.copy(n)},n=e=>{t()};t=t=>{e.removeEventListener("drag",i),e.removeEventListener("drop",n)},e.addEventListener("drag",i),e.addEventListener("drop",n),this.markers.push(e)}removeLastMarker(){this.markers.length>0&&this.markers.splice(this.markers.length-1,1)}}const Xv={NONE:0,HIGHLIGHT:1,SHOW_INSIDE:2,SHOW_OUTSIDE:3},Yv={INSIDE_ANY:0,INSIDE_ALL:1},Zv={FIXED:0,ATTENUATED:1,ADAPTIVE:2},$v={SQUARE:0,CIRCLE:1,PARABOLOID:2},Jv={RGB:0,COLOR:1,DEPTH:2,HEIGHT:3,ELEVATION:3,INTENSITY:4,INTENSITY_GRADIENT:5,LOD:6,LEVEL_OF_DETAIL:6,POINT_INDEX:7,CLASSIFICATION:8,RETURN_NUMBER:9,SOURCE:10,NORMAL:11,PHONG:12,RGB_HEIGHT:13,COMPOSITE:50},Qv=0,Kv=1;class tb{static loadShapefileFeatures(t,e){let i=[];shapefile.open(t).then((t=>{t.read().then((function n(r){if(!r.done)return r.value&&"Feature"===r.value.type&&void 0!==r.value.geometry&&i.push(r.value),t.read().then(n);e(i)}))}))}static toString(t){return t instanceof pe?t.x.toFixed(2)+", "+t.y.toFixed(2)+", "+t.z.toFixed(2):""+t}static normalizeURL(t){let e=new URL(t);return e.protocol+"//"+e.hostname+e.pathname.replace(/\/+/g,"/")}static pathExists(t){let e=kv.createXMLHttpRequest();return e.open("GET",t,!1),e.send(null),200===e.status}static debugSphere(t,e,i,n){let r,s=new ih(1,8,8);r=void 0!==n?new qi({color:n}):new Sh;let o=new In(s,r);o.position.copy(e),o.scale.set(i,i,i),t.add(o)}static debugLine(t,e,i,n){let r=new No({color:n}),s=new Un;s.vertices.push(e,i);let o=new Go(s,r);t.add(o)}static debugBox(t,e,i=new Le,n=16776960){let r=[[e.min.x,e.min.y,e.min.z],[e.min.x,e.min.y,e.max.z],[e.min.x,e.max.y,e.min.z],[e.min.x,e.max.y,e.max.z],[e.max.x,e.min.y,e.min.z],[e.max.x,e.min.y,e.max.z],[e.max.x,e.max.y,e.min.z],[e.max.x,e.max.y,e.max.z]].map((t=>new pe(...t))),s=[[0,4],[4,5],[5,1],[1,0],[2,6],[6,7],[7,3],[3,2],[0,2],[4,6],[5,7],[1,3]],o=e.getCenter(new pe),a=[{position:[e.min.x,o.y,o.z],color:16711680},{position:[e.max.x,o.y,o.z],color:8912896},{position:[o.x,e.min.y,o.z],color:65280},{position:[o.x,e.max.y,o.z],color:34816},{position:[o.x,o.y,e.min.z],color:255},{position:[o.x,o.y,e.max.z],color:136}];for(let e of r){let n=e.clone().applyMatrix4(i);tb.debugSphere(t,n,.1,16711680)}for(let e of s){let s=r[e[0]].clone().applyMatrix4(i),o=r[e[1]].clone().applyMatrix4(i);tb.debugLine(t,s,o,n)}for(let e of a){let n=new pe(...e.position).applyMatrix4(i);tb.debugSphere(t,n,.1,e.color)}}static debugPlane(t,e,i=1,n=255){let r=new yu(e,i,n);t.add(r)}static computeTransformedBoundingBox(t,e){let i=[new pe(t.min.x,t.min.y,t.min.z).applyMatrix4(e),new pe(t.min.x,t.min.y,t.min.z).applyMatrix4(e),new pe(t.max.x,t.min.y,t.min.z).applyMatrix4(e),new pe(t.min.x,t.max.y,t.min.z).applyMatrix4(e),new pe(t.min.x,t.min.y,t.max.z).applyMatrix4(e),new pe(t.min.x,t.max.y,t.max.z).applyMatrix4(e),new pe(t.max.x,t.max.y,t.min.z).applyMatrix4(e),new pe(t.max.x,t.min.y,t.max.z).applyMatrix4(e),new pe(t.max.x,t.max.y,t.max.z).applyMatrix4(e)],n=new ci;return n.setFromPoints(i),n}static addCommas(t){let e=(t+="").split("."),i=e[0],n=e.length>1?"."+e[1]:"",r=/(\d+)(\d{3})/;for(;r.test(i);)i=i.replace(r,"$1,$2");return i+n}static removeCommas(t){return t.replace(/,/g,"")}static createWorker(t){let e=new Blob([t],{type:"application/javascript"});return new Worker(URL.createObjectURL(e))}static moveTo(t,e,i){let n=t.view,r=t.getActiveCamera(),s=TWEEN.Easing.Quartic.Out;{let t=new TWEEN.Tween(n.position).to(e,500);t.easing(s),t.start()}{let t=r.position.distanceTo(i),e=(new pe).addVectors(r.position,r.getWorldDirection(new pe).clone().multiplyScalar(t)),o=new TWEEN.Tween(e).to(i,500);o.easing(s),o.onUpdate((()=>{n.lookAt(e)})),o.onComplete((()=>{n.lookAt(e)})),o.start()}}static loadSkybox(t){let e=new Xn(75,window.innerWidth/window.innerHeight,1,1e5);e.up.set(0,0,1);let i=new Ze,n=".jpg",r=[t+"px"+n,t+"nx"+n,t+"py"+n,t+"ny"+n,t+"pz"+n,t+"nz"+n],s=[];for(let t=0;t<6;t++){let e=new qi({map:null,side:1,depthTest:!1,depthWrite:!1,color:4343126});s.push(e),(new ic).load(r[t],(function(t){e.map=t,e.needsUpdate=!0,e.color.setHex(16777215)}),(function(t){}),(function(t){console.log("An error happened",t)}))}let o=new In(new Vn(5e3,5e3,5e3),s);return i.add(o),i.rotation.x=Math.PI/2,{camera:e,scene:i}}static createGrid(t,e,i,n){let r=new No({color:n||8947848}),s=new Un;for(let n=0;n<=e;n++)s.vertices.push(new pe(-i*t/2,n*i-i*e/2,0)),s.vertices.push(new pe(+i*t/2,n*i-i*e/2,0));for(let n=0;n<=t;n++)s.vertices.push(new pe(n*i-i*t/2,-i*e/2,0)),s.vertices.push(new pe(n*i-i*t/2,+i*e/2,0));let o=new Xo(s,r,1);return o.receiveShadow=!0,o}static createBackgroundTexture(t,e){function i(t,e){return 1/(2*Math.PI)*Math.exp(-(t*t+e*e)/2)}let n=new Uint8Array(3*(t*e)),r=[1,1.5,1.7],s=i(0,0);for(let o=0;o<t;o++)for(let a=0;a<e;a++){let h=o+t*a,c=i(2*(o/t*2-1),2*(a/e*2-1))/s,l=(Math.random()+Math.random()+Math.random())/3;l=(.5*c+.5)*l*.03,l*=.4,n[3*h+0]=255*(c/15+.05+l)*r[0],n[3*h+1]=255*(c/15+.05+l)*r[1],n[3*h+2]=255*(c/15+.05+l)*r[2]}let o=new Jn(n,t,e,Ot);return o.needsUpdate=!0,o}static getMousePointCloudIntersection(t,e,i,n,r={}){let s=i.renderer,o={x:t.x/s.domElement.clientWidth*2-1,y:-t.y/s.domElement.clientHeight*2+1},a={};r.pickClipped&&(a.pickClipped=r.pickClipped),a.x=t.x,a.y=s.domElement.clientHeight-t.y;let h=new Ul;h.setFromCamera(o,e);let c=h.ray,l=null,u=1/0,d=null,p=null;for(let t of n){let n=t.pick(i,e,c,a);if(!n)continue;let r=e.position.distanceTo(n.position);r<u&&(u=r,l=t,d=n.position,p=n)}return l?{location:d,distance:u,pointcloud:l,point:p}:null}static pixelsArrayToImage(t,e,i){let n=document.createElement("canvas");n.width=e,n.height=i;let r=n.getContext("2d");t=new t.constructor(t);for(let e=0;e<t.length;e++)t[4*e+3]=255;let s=r.createImageData(e,i);s.data.set(t),r.putImageData(s,0,0);let o=new Image;return o.src=n.toDataURL(),o}static pixelsArrayToDataUrl(t,e,i){let n=document.createElement("canvas");n.width=e,n.height=i;let r=n.getContext("2d");t=new t.constructor(t);for(let e=0;e<t.length;e++)t[4*e+3]=255;let s=r.createImageData(e,i);return s.data.set(t),r.putImageData(s,0,0),n.toDataURL()}static pixelsArrayToCanvas(t,e,i){let n=document.createElement("canvas");n.width=e,n.height=i;let r=n.getContext("2d");t=new t.constructor(t);let s=4*e;for(let e=0;e<parseInt(i/2);e++){let n=i-e-1,r=t.slice(e*s,e*s+s),o=t.slice(n*s,n*s+s);t.set(o,e*s),t.set(r,n*s)}let o=r.createImageData(e,i);return o.data.set(t),r.putImageData(o,0,0),n}static removeListeners(t,e){void 0!==t._listeners&&t._listeners[e]&&delete t._listeners[e]}static mouseToRay(t,e,i,n){let r={x:t.x/i*2-1,y:-t.y/n*2+1},s=new pe(r.x,r.y,.5),o=new pe(r.x,r.y,0);return s.unproject(e),o.unproject(e),new _i(o,(new pe).subVectors(s,o).normalize())}static projectedRadius(t,e,i,n,r){if(e instanceof Oc)return tb.projectedRadiusOrtho(t,e.projectionMatrix,n,r);if(e instanceof Xn)return tb.projectedRadiusPerspective(t,e.fov*Math.PI/180,i,r);throw new Error("invalid parameters")}static projectedRadiusPerspective(t,e,i,n){let r=1/Math.tan(e/2)/i;return r=r*n/2,t*r}static projectedRadiusOrtho(t,e,i,n){let r=new _e(0),s=new _e(t);return r.applyMatrix4(e),s.applyMatrix4(e),r=new pe(r.x,r.y,r.z),s=new pe(s.x,s.y,s.z),r.x=.5*(r.x+1)*i,r.y=.5*(r.y+1)*n,s.x=.5*(s.x+1)*i,s.y=.5*(s.y+1)*n,r.distanceTo(s)}static topView(t,e){t.position.set(0,1,0),t.rotation.set(-Math.PI/2,0,0),t.zoomTo(e,1)}static frontView(t,e){t.position.set(0,0,1),t.rotation.set(0,0,0),t.zoomTo(e,1)}static leftView(t,e){t.position.set(-1,0,0),t.rotation.set(0,-Math.PI/2,0),t.zoomTo(e,1)}static rightView(t,e){t.position.set(1,0,0),t.rotation.set(0,Math.PI/2,0),t.zoomTo(e,1)}static frustumSphereIntersection(t,e){let i=t.planes,n=e.center,r=-e.radius,s=Number.MAX_VALUE;for(let t=0;t<6;t++){let e=i[t].distanceToPoint(n);if(e<r)return 0;s=Math.min(s,e)}return s>=e.radius?2:1}static generateDataTexture(t,e,i){let n=t*e,r=new Uint8Array(4*t*e),s=Math.floor(255*i.r),o=Math.floor(255*i.g),a=Math.floor(255*i.b);for(let t=0;t<n;t++)r[3*t]=s,r[3*t+1]=o,r[3*t+2]=a;let h=new Jn(r,t,e,Ft);return h.needsUpdate=!0,h.magFilter=ft,h}static getParameterByName(t){t=t.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");let e=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(document.location.search);return null===e?null:decodeURIComponent(e[1].replace(/\+/g," "))}static setParameter(t,e){t=t.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");let i=new RegExp("([\\?&])("+t+"=([^&#]*))").exec(document.location.search),n=window.location.href;if(null===i)0===window.location.search.length?n+="?":n+="&",n=n+t+"="+e;else{let r=t+"="+e;n=n.replace(i[2],r)}window.history.replaceState({},"",n)}static createChildAABB(t,e){let i=t.min.clone(),n=t.max.clone(),r=(new pe).subVectors(n,i);return(1&e)>0?i.z+=r.z/2:n.z-=r.z/2,(2&e)>0?i.y+=r.y/2:n.y-=r.y/2,(4&e)>0?i.x+=r.x/2:n.x-=r.x/2,new ci(i,n)}static clipboardCopy(t){let e=document.createElement("textarea");e.style.position="fixed",e.style.top=0,e.style.left=0,e.style.width="2em",e.style.height="2em",e.style.padding=0,e.style.border="none",e.style.outline="none",e.style.boxShadow="none",e.style.background="transparent",e.value=t,document.body.appendChild(e),e.select();try{document.execCommand("copy")?console.log("copied text to clipboard"):console.log("copy to clipboard failed")}catch(t){console.log("error while trying to copy to clipboard")}document.body.removeChild(e)}static getMeasurementIcon(t){return t instanceof Wv?!t.showDistances||t.showArea||t.showAngles?t.showDistances&&t.showArea&&!t.showAngles?`${Potree.resourcePath}/icons/area.svg`:1===t.maxMarkers?`${Potree.resourcePath}/icons/point.svg`:t.showDistances||t.showArea||!t.showAngles?t.showHeight?`${Potree.resourcePath}/icons/height.svg`:`${Potree.resourcePath}/icons/distance.svg`:`${Potree.resourcePath}/icons/angle.png`:`${Potree.resourcePath}/icons/distance.svg`:t instanceof Gv?`${Potree.resourcePath}/icons/profile.svg`:t instanceof Hv?`${Potree.resourcePath}/icons/volume.svg`:t instanceof qv?`${Potree.resourcePath}/icons/clip-polygon.svg`:void 0}static toMaterialID(t){return"RGB"===t?Jv.RGB:"Color"===t?Jv.COLOR:"Elevation"===t?Jv.HEIGHT:"Intensity"===t?Jv.INTENSITY:"Intensity Gradient"===t?Jv.INTENSITY_GRADIENT:"Classification"===t?Jv.CLASSIFICATION:"Return Number"===t?Jv.RETURN_NUMBER:"Source"===t?Jv.SOURCE:"Level of Detail"===t?Jv.LOD:"Point Index"===t?Jv.POINT_INDEX:"Normal"===t?Jv.NORMAL:"Phong"===t?Jv.PHONG:"Index"===t?Jv.POINT_INDEX:"RGB and Elevation"===t?Jv.RGB_HEIGHT:"Composite"===t?Jv.COMPOSITE:void 0}static toMaterialName(t){return t===Jv.RGB?"RGB":t===Jv.COLOR?"Color":t===Jv.HEIGHT?"Elevation":t===Jv.INTENSITY?"Intensity":t===Jv.INTENSITY_GRADIENT?"Intensity Gradient":t===Jv.CLASSIFICATION?"Classification":t===Jv.RETURN_NUMBER?"Return Number":t===Jv.SOURCE?"Source":t===Jv.LOD?"Level of Detail":t===Jv.NORMAL?"Normal":t===Jv.PHONG?"Phong":t===Jv.POINT_INDEX?"Index":t===Jv.RGB_HEIGHT?"RGB and Elevation":t===Jv.COMPOSITE?"Composite":void 0}}tb.screenPass=new function(){this.screenScene=new Ze,this.screenQuad=new In(new ar(2,2,0)),this.screenQuad.material.depthTest=!0,this.screenQuad.material.depthWrite=!0,this.screenQuad.material.transparent=!0,this.screenScene.add(this.screenQuad),this.camera=new qn,this.render=function(t,e,i){this.screenQuad.material=e,void 0===i?t.render(this.screenScene,this.camera):t.render(this.screenScene,this.camera,i)}};(function(){let t,e,i=document.createElement("canvas");if(i.getContext("webgl2")?(e=i.getContext("webgl2"),t=!0):(i.getContext("webgl")||i.getContext("experimental-webgl"))&&(e=i.getContext("webgl")||i.getContext("experimental-webgl"),t=!1),null===e)return null;let n,r=e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT),s=e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT),o=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT),a=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT),h=r.precision>0&&o.precision>0,c=s.precision>0&&a.precision>0;n=h?"highp":c?"mediump":"lowp"})(),"A".charCodeAt(0),"S".charCodeAt(0),"D".charCodeAt(0),"W".charCodeAt(0),"Q".charCodeAt(0),"E".charCodeAt(0),"R".charCodeAt(0),"F".charCodeAt(0);class eb{constructor(t){this.previous=null,this.next=null,this.node=t}}class ib extends Vv{constructor(){super(),this.needsTransformUpdate=!0}getChildren(){throw new Error("override function")}getBoundingBox(){throw new Error("override function")}isLoaded(){throw new Error("override function")}isGeometryNode(){throw new Error("override function")}isTreeNode(){throw new Error("override function")}getLevel(){throw new Error("override function")}getBoundingSphere(){throw new Error("override function")}}class nb extends Ye{constructor(){super(),this.minimumNodePixelSize=void 0,this.boundingBox=void 0,this.material=void 0}initialized(){return null!==this.root}}class rb{constructor(){this.url=null,this.octreeDir=null,this.spacing=0,this.boundingBox=null,this.root=null,this.nodes=null,this.pointAttributes=null,this.hierarchyStepSize=-1,this.loader=null}}class sb extends ib{constructor(t,e,i){super(),this.id=sb.IDCount++,this.name=t,this.index=parseInt(t.charAt(t.length-1)),this.pcoGeometry=e,this.geometry=null,this.boundingBox=i,this.boundingSphere=i.getBoundingSphere(new di),this.children={},this.numPoints=0,this.level=null,this.loaded=!1,this.oneTimeDisposeHandlers=[]}isGeometryNode(){return!0}getLevel(){return this.level}isTreeNode(){return!1}isLoaded(){return this.loaded}getBoundingSphere(){return this.boundingSphere}getBoundingBox(){return this.boundingBox}getChildren(){let t=[];for(let e=0;e<8;e++)this.children[e]&&t.push(this.children[e]);return t}getBoundingBox(){return this.boundingBox}getURL(){let t="",e=this.pcoGeometry.loader.version;return e.equalOrHigher("1.5")?t=this.pcoGeometry.octreeDir+"/"+this.getHierarchyPath()+"/"+this.name:(e.equalOrHigher("1.4")||e.upTo("1.3"))&&(t=this.pcoGeometry.octreeDir+"/"+this.name),t}getHierarchyPath(){let t="r/",e=this.pcoGeometry.hierarchyStepSize,i=this.name.substr(1),n=Math.floor(i.length/e);for(let r=0;r<n;r++)t+=i.substr(r*e,e)+"/";return t=t.slice(0,-1),t}addChild(t){this.children[t.index]=t,t.parent=this}load(){!0===this.loading||!0===this.loaded||Potree.numNodesLoading>=Potree.maxNodesLoading||(this.loading=!0,Potree.numNodesLoading++,this.pcoGeometry.loader.version.equalOrHigher("1.5")&&this.level%this.pcoGeometry.hierarchyStepSize==0&&this.hasChildren?this.loadHierachyThenPoints():this.loadPoints())}loadPoints(){this.pcoGeometry.loader.load(this)}loadHierachyThenPoints(){let t=this;if(t.level%t.pcoGeometry.hierarchyStepSize==0){let e=t.pcoGeometry.octreeDir+"/"+t.getHierarchyPath()+"/"+t.name+".hrc",i=kv.createXMLHttpRequest();i.open("GET",e,!0),i.responseType="arraybuffer",i.overrideMimeType("text/plain; charset=x-user-defined"),i.onreadystatechange=()=>{if(4===i.readyState)if(200===i.status||0===i.status){let e=i.response;!function(t,e){let i=new DataView(e),n=[],r=i.getUint8(0),s=i.getUint32(1,!0);t.numPoints=s,n.push({children:r,numPoints:s,name:t.name});let o=[],a=5;for(;n.length>0;){let t=n.shift(),r=1;for(let e=0;e<8;e++){if(0!=(t.children&r)){let r=t.name+e,s=i.getUint8(a),h=i.getUint32(a+1,!0);n.push({children:s,numPoints:h,name:r}),o.push({children:s,numPoints:h,name:r}),a+=5}r*=2}if(a===e.byteLength)break}let h={};h[t.name]=t;let c=t.pcoGeometry;for(let t=0;t<o.length;t++){let e=o[t].name,i=o[t].numPoints,n=parseInt(e.charAt(e.length-1)),r=h[e.substring(0,e.length-1)],s=e.length-1,a=tb.createChildAABB(r.boundingBox,n),l=new sb(e,c,a);l.level=s,l.numPoints=i,l.hasChildren=o[t].children>0,l.spacing=c.spacing/Math.pow(2,s),r.addChild(l),h[e]=l}t.loadPoints()}(t,e)}else console.log("Failed to load file! HTTP status: "+i.status+", file: "+e),Potree.numNodesLoading--};try{i.send(null)}catch(t){console.log("fehler beim laden der punktwolke: "+t)}}}getNumPoints(){return this.numPoints}dispose(){if(this.geometry&&null!=this.parent){this.geometry.dispose(),this.geometry=null,this.loaded=!1;for(let t=0;t<this.oneTimeDisposeHandlers.length;t++){(0,this.oneTimeDisposeHandlers[t])()}this.oneTimeDisposeHandlers=[]}}}sb.IDCount=0;let ob={RAINBOW:[[0,new Ui(.278,0,.714)],[1/6,new Ui(0,0,1)],[2/6,new Ui(0,1,1)],[.5,new Ui(0,1,0)],[4/6,new Ui(1,1,0)],[5/6,new Ui(1,.64,0)],[1,new Ui(1,0,0)]],SPECTRAL:[[0,new Ui(.3686,.3098,.6353)],[.1,new Ui(.1961,.5333,.7412)],[.2,new Ui(.4,.7608,.6471)],[.3,new Ui(.6706,.8667,.6431)],[.4,new Ui(.902,.9608,.5961)],[.5,new Ui(1,1,.749)],[.6,new Ui(.9961,.8784,.5451)],[.7,new Ui(.9922,.6824,.3804)],[.8,new Ui(.9569,.4275,.2627)],[.9,new Ui(.8353,.2431,.3098)],[1,new Ui(.6196,.0039,.2588)]],PLASMA:[[0,new Ui(.241,.015,.61)],[.1,new Ui(.387,.001,.654)],[.2,new Ui(.524,.025,.653)],[.3,new Ui(.651,.125,.596)],[.4,new Ui(.752,.227,.513)],[.5,new Ui(.837,.329,.431)],[.6,new Ui(.907,.435,.353)],[.7,new Ui(.963,.554,.272)],[.8,new Ui(.992,.681,.195)],[.9,new Ui(.987,.822,.144)],[1,new Ui(.94,.975,.131)]],YELLOW_GREEN:[[0,new Ui(.1647,.2824,.3451)],[.1,new Ui(.1338,.3555,.4227)],[.2,new Ui(.061,.4319,.4864)],[.3,new Ui(0,.5099,.5319)],[.4,new Ui(0,.5881,.5569)],[.5,new Ui(.137,.665,.5614)],[.6,new Ui(.2906,.7395,.5477)],[.7,new Ui(.4453,.8099,.5201)],[.8,new Ui(.6102,.8748,.485)],[.9,new Ui(.7883,.9323,.4514)],[1,new Ui(.9804,.9804,.4314)]],VIRIDIS:[[0,new Ui(.267,.005,.329)],[.1,new Ui(.283,.141,.458)],[.2,new Ui(.254,.265,.53)],[.3,new Ui(.207,.372,.553)],[.4,new Ui(.164,.471,.558)],[.5,new Ui(.128,.567,.551)],[.6,new Ui(.135,.659,.518)],[.7,new Ui(.267,.749,.441)],[.8,new Ui(.478,.821,.318)],[.9,new Ui(.741,.873,.15)],[1,new Ui(.993,.906,.144)]],INFERNO:[[0,new Ui(.077,.042,.206)],[.1,new Ui(.225,.036,.388)],[.2,new Ui(.373,.074,.432)],[.3,new Ui(.522,.128,.42)],[.4,new Ui(.665,.182,.37)],[.5,new Ui(.797,.255,.287)],[.6,new Ui(.902,.364,.184)],[.7,new Ui(.969,.516,.063)],[.8,new Ui(.988,.683,.072)],[.9,new Ui(.961,.859,.298)],[1,new Ui(.988,.998,.645)]],GRAYSCALE:[[0,new Ui(0,0,0)],[1,new Ui(1,1,1)]]},ab={"pointcloud.vs":"\nprecision highp float;\nprecision highp int;\n\n#define max_clip_polygons 8\n#define PI 3.141592653589793\n\nattribute vec3 position;\nattribute vec3 color;\nattribute float intensity;\nattribute float classification;\nattribute float returnNumber;\nattribute float numberOfReturns;\nattribute float pointSourceID;\nattribute vec4 indices;\nattribute float spacing;\n\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 uViewInv;\n\nuniform float uScreenWidth;\nuniform float uScreenHeight;\nuniform float fov;\nuniform float near;\nuniform float far;\nuniform float logDepthBufFC;\n\nuniform bool uDebug;\n\nuniform bool uUseOrthographicCamera;\nuniform float uOrthoWidth;\nuniform float uOrthoHeight;\n\n\n#define CLIPTASK_NONE 0\n#define CLIPTASK_HIGHLIGHT 1\n#define CLIPTASK_SHOW_INSIDE 2\n#define CLIPTASK_SHOW_OUTSIDE 3\n\n#define CLIPMETHOD_INSIDE_ANY 0\n#define CLIPMETHOD_INSIDE_ALL 1\n\nuniform int clipTask;\nuniform int clipMethod;\n#if defined(num_clipboxes) && num_clipboxes > 0\n\tuniform mat4 clipBoxes[num_clipboxes];\n#endif\n\n#if defined(num_clipspheres) && num_clipspheres > 0\n\tuniform mat4 uClipSpheres[num_clipspheres];\n#endif\n\n#if defined(num_clippolygons) && num_clippolygons > 0\n\tuniform int uClipPolygonVCount[num_clippolygons];\n\tuniform vec3 uClipPolygonVertices[num_clippolygons * 8];\n\tuniform mat4 uClipPolygonWVP[num_clippolygons];\n#endif\n\n\nuniform float size;\nuniform float minSize;\nuniform float maxSize;\n\nuniform float uPCIndex;\nuniform float uOctreeSpacing;\nuniform float uNodeSpacing;\nuniform float uOctreeSize;\nuniform vec3 uBBSize;\nuniform float uLevel;\nuniform float uVNStart;\nuniform bool uIsLeafNode;\n\nuniform vec3 uColor;\nuniform float uOpacity;\n\nuniform vec2 elevationRange;\nuniform vec2 intensityRange;\nuniform float intensityGamma;\nuniform float intensityContrast;\nuniform float intensityBrightness;\nuniform float rgbGamma;\nuniform float rgbContrast;\nuniform float rgbBrightness;\nuniform float uTransition;\nuniform float wRGB;\nuniform float wIntensity;\nuniform float wElevation;\nuniform float wClassification;\nuniform float wReturnNumber;\nuniform float wSourceID;\n\nuniform vec3 uShadowColor;\n\nuniform sampler2D visibleNodes;\nuniform sampler2D gradient;\nuniform sampler2D classificationLUT;\n\n#if defined(num_shadowmaps) && num_shadowmaps > 0\nuniform sampler2D uShadowMap[num_shadowmaps];\nuniform mat4 uShadowWorldView[num_shadowmaps];\nuniform mat4 uShadowProj[num_shadowmaps];\n#endif\n\nvarying vec3\tvColor;\nvarying float\tvLogDepth;\nvarying float\tvFragDepth;\nvarying vec3\tvViewPosition;\nvarying float \tvRadius;\nvarying float \tvPointSize;\n\n\nfloat round(float number){\n\treturn floor(number + 0.5);\n}\n\n// \n//    ###    ########     ###    ########  ######## #### ##     ## ########     ######  #### ######## ########  ######  \n//   ## ##   ##     ##   ## ##   ##     ##    ##     ##  ##     ## ##          ##    ##  ##       ##  ##       ##    ## \n//  ##   ##  ##     ##  ##   ##  ##     ##    ##     ##  ##     ## ##          ##        ##      ##   ##       ##       \n// ##     ## ##     ## ##     ## ########     ##     ##  ##     ## ######       ######   ##     ##    ######    ######  \n// ######### ##     ## ######### ##           ##     ##   ##   ##  ##                ##  ##    ##     ##             ## \n// ##     ## ##     ## ##     ## ##           ##     ##    ## ##   ##          ##    ##  ##   ##      ##       ##    ## \n// ##     ## ########  ##     ## ##           ##    ####    ###    ########     ######  #### ######## ########  ######  \n// \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\n\n// ---------------------\n// OCTREE\n// ---------------------\n\n#if (defined(adaptive_point_size) || defined(color_type_lod)) && defined(tree_type_octree)\n/**\n * number of 1-bits up to inclusive index position\n * number is treated as if it were an integer in the range 0-255\n *\n */\nint numberOfOnes(int number, int index){\n\tint numOnes = 0;\n\tint tmp = 128;\n\tfor(int i = 7; i >= 0; i--){\n\t\t\n\t\tif(number >= tmp){\n\t\t\tnumber = number - tmp;\n\n\t\t\tif(i <= index){\n\t\t\t\tnumOnes++;\n\t\t\t}\n\t\t}\n\t\t\n\t\ttmp = tmp / 2;\n\t}\n\n\treturn numOnes;\n}\n\n\n/**\n * checks whether the bit at index is 1\n * number is treated as if it were an integer in the range 0-255\n *\n */\nbool isBitSet(int number, int index){\n\n\t// weird multi else if due to lack of proper array, int and bitwise support in WebGL 1.0\n\tint powi = 1;\n\tif(index == 0){\n\t\tpowi = 1;\n\t}else if(index == 1){\n\t\tpowi = 2;\n\t}else if(index == 2){\n\t\tpowi = 4;\n\t}else if(index == 3){\n\t\tpowi = 8;\n\t}else if(index == 4){\n\t\tpowi = 16;\n\t}else if(index == 5){\n\t\tpowi = 32;\n\t}else if(index == 6){\n\t\tpowi = 64;\n\t}else if(index == 7){\n\t\tpowi = 128;\n\t}else{\n\t\treturn false;\n\t}\n\n\tint ndp = number / powi;\n\n\treturn mod(float(ndp), 2.0) != 0.0;\n}\n\n\n/**\n * find the LOD at the point position\n */\nfloat getLOD(){\n\t\n\tvec3 offset = vec3(0.0, 0.0, 0.0);\n\tint iOffset = int(uVNStart);\n\tfloat depth = uLevel;\n\tfor(float i = 0.0; i <= 30.0; i++){\n\t\tfloat nodeSizeAtLevel = uOctreeSize  / pow(2.0, i + uLevel + 0.0);\n\t\t\n\t\tvec3 index3d = (position-offset) / nodeSizeAtLevel;\n\t\tindex3d = floor(index3d + 0.5);\n\t\tint index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));\n\t\t\n\t\tvec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));\n\t\tint mask = int(round(value.r * 255.0));\n\n\t\tif(isBitSet(mask, index)){\n\t\t\t// there are more visible child nodes at this position\n\t\t\tint advanceG = int(round(value.g * 255.0)) * 256;\n\t\t\tint advanceB = int(round(value.b * 255.0));\n\t\t\tint advanceChild = numberOfOnes(mask, index - 1);\n\t\t\tint advance = advanceG + advanceB + advanceChild;\n\n\t\t\tiOffset = iOffset + advance;\n\t\t\t\n\t\t\tdepth++;\n\t\t}else{\n\t\t\t// no more visible child nodes at this position\n\t\t\treturn value.a * 255.0;\n\t\t\t//return depth;\n\t\t}\n\t\t\n\t\toffset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;\n\t}\n\t\t\n\treturn depth;\n}\n\nfloat getSpacing(){\n\tvec3 offset = vec3(0.0, 0.0, 0.0);\n\tint iOffset = int(uVNStart);\n\tfloat depth = uLevel;\n\tfloat spacing = uNodeSpacing;\n\tfor(float i = 0.0; i <= 30.0; i++){\n\t\tfloat nodeSizeAtLevel = uOctreeSize  / pow(2.0, i + uLevel + 0.0);\n\t\t\n\t\tvec3 index3d = (position-offset) / nodeSizeAtLevel;\n\t\tindex3d = floor(index3d + 0.5);\n\t\tint index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));\n\t\t\n\t\tvec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));\n\t\tint mask = int(round(value.r * 255.0));\n\t\tfloat spacingFactor = value.a;\n\n\t\tif(i > 0.0){\n\t\t\tspacing = spacing / (255.0 * spacingFactor);\n\t\t}\n\t\t\n\n\t\tif(isBitSet(mask, index)){\n\t\t\t// there are more visible child nodes at this position\n\t\t\tint advanceG = int(round(value.g * 255.0)) * 256;\n\t\t\tint advanceB = int(round(value.b * 255.0));\n\t\t\tint advanceChild = numberOfOnes(mask, index - 1);\n\t\t\tint advance = advanceG + advanceB + advanceChild;\n\n\t\t\tiOffset = iOffset + advance;\n\n\t\t\t//spacing = spacing / (255.0 * spacingFactor);\n\t\t\t//spacing = spacing / 3.0;\n\t\t\t\n\t\t\tdepth++;\n\t\t}else{\n\t\t\t// no more visible child nodes at this position\n\t\t\treturn spacing;\n\t\t}\n\t\t\n\t\toffset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;\n\t}\n\t\t\n\treturn spacing;\n}\n\nfloat getPointSizeAttenuation(){\n\treturn pow(2.0, getLOD());\n}\n\n\n#endif\n\n\n// ---------------------\n// KD-TREE\n// ---------------------\n\n#if (defined(adaptive_point_size) || defined(color_type_lod)) && defined(tree_type_kdtree)\n\nfloat getLOD(){\n\tvec3 offset = vec3(0.0, 0.0, 0.0);\n\tfloat iOffset = 0.0;\n\tfloat depth = 0.0;\n\t\t\n\t\t\n\tvec3 size = uBBSize;\t\n\tvec3 pos = position;\n\t\t\n\tfor(float i = 0.0; i <= 1000.0; i++){\n\t\t\n\t\tvec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));\n\t\t\n\t\tint children = int(value.r * 255.0);\n\t\tfloat next = value.g * 255.0;\n\t\tint split = int(value.b * 255.0);\n\t\t\n\t\tif(next == 0.0){\n\t\t \treturn depth;\n\t\t}\n\t\t\n\t\tvec3 splitv = vec3(0.0, 0.0, 0.0);\n\t\tif(split == 1){\n\t\t\tsplitv.x = 1.0;\n\t\t}else if(split == 2){\n\t\t \tsplitv.y = 1.0;\n\t\t}else if(split == 4){\n\t\t \tsplitv.z = 1.0;\n\t\t}\n\t\t\n\t\tiOffset = iOffset + next;\n\t\t\n\t\tfloat factor = length(pos * splitv / size);\n\t\tif(factor < 0.5){\n\t\t\t// left\n\t\tif(children == 0 || children == 2){\n\t\t\t\treturn depth;\n\t\t\t}\n\t\t}else{\n\t\t\t// right\n\t\t\tpos = pos - size * splitv * 0.5;\n\t\t\tif(children == 0 || children == 1){\n\t\t\t\treturn depth;\n\t\t\t}\n\t\t\tif(children == 3){\n\t\t\t\tiOffset = iOffset + 1.0;\n\t\t\t}\n\t\t}\n\t\tsize = size * ((1.0 - (splitv + 1.0) / 2.0) + 0.5);\n\t\t\n\t\tdepth++;\n\t}\n\t\t\n\t\t\n\treturn depth;\t\n}\n\nfloat getPointSizeAttenuation(){\n\treturn 0.5 * pow(1.3, getLOD());\n}\n\n#endif\n\n\n\n// \n//    ###    ######## ######## ########  #### ########  ##     ## ######## ########  ######  \n//   ## ##      ##       ##    ##     ##  ##  ##     ## ##     ##    ##    ##       ##    ## \n//  ##   ##     ##       ##    ##     ##  ##  ##     ## ##     ##    ##    ##       ##       \n// ##     ##    ##       ##    ########   ##  ########  ##     ##    ##    ######    ######  \n// #########    ##       ##    ##   ##    ##  ##     ## ##     ##    ##    ##             ## \n// ##     ##    ##       ##    ##    ##   ##  ##     ## ##     ##    ##    ##       ##    ## \n// ##     ##    ##       ##    ##     ## #### ########   #######     ##    ########  ######                                                                               \n// \n\n\n\n// formula adapted from: http://www.dfstudios.co.uk/articles/programming/image-programming-algorithms/image-processing-algorithms-part-5-contrast-adjustment/\nfloat getContrastFactor(float contrast){\n\treturn (1.0158730158730156 * (contrast + 1.0)) / (1.0158730158730156 - contrast);\n}\n\nvec3 getRGB(){\n\tvec3 rgb = color;\n\t\n\trgb = pow(rgb, vec3(rgbGamma));\n\trgb = rgb + rgbBrightness;\n\t//rgb = (rgb - 0.5) * getContrastFactor(rgbContrast) + 0.5;\n\trgb = clamp(rgb, 0.0, 1.0);\n\n\t\t//rgb = indices.rgb;\n\t//rgb.b = pcIndex / 255.0;\n\t\n\t\n\treturn rgb;\n}\n\nfloat getIntensity(){\n\tfloat w = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\n\tw = pow(w, intensityGamma);\n\tw = w + intensityBrightness;\n\tw = (w - 0.5) * getContrastFactor(intensityContrast) + 0.5;\n\tw = clamp(w, 0.0, 1.0);\n\n\t//w = w + color.x * 0.0001;\n\t\n\t//float w = color.x * 0.001 + intensity / 1.0;\n\n\treturn w;\n}\n\nvec3 getElevation(){\n\tvec4 world = modelMatrix * vec4( position, 1.0 );\n\tfloat w = (world.z - elevationRange.x) / (elevationRange.y - elevationRange.x);\n\tvec3 cElevation = texture2D(gradient, vec2(w,1.0-w)).rgb;\n\t\n\treturn cElevation;\n}\n\nvec4 getClassification(){\n\tvec2 uv = vec2(classification / 255.0, 0.5);\n\tvec4 classColor = texture2D(classificationLUT, uv);\n\t\n\treturn classColor;\n}\n\nvec3 getReturnNumber(){\n\tif(numberOfReturns == 1.0){\n\t\treturn vec3(1.0, 1.0, 0.0);\n\t}else{\n\t\tif(returnNumber == 1.0){\n\t\t\treturn vec3(1.0, 0.0, 0.0);\n\t\t}else if(returnNumber == numberOfReturns){\n\t\t\treturn vec3(0.0, 0.0, 1.0);\n\t\t}else{\n\t\t\treturn vec3(0.0, 1.0, 0.0);\n\t\t}\n\t}\n}\n\nvec3 getSourceID(){\n\tfloat w = mod(pointSourceID, 10.0) / 10.0;\n\treturn texture2D(gradient, vec2(w,1.0 - w)).rgb;\n}\n\nvec3 getCompositeColor(){\n\tvec3 c;\n\tfloat w;\n\n\tc += wRGB * getRGB();\n\tw += wRGB;\n\t\n\tc += wIntensity * getIntensity() * vec3(1.0, 1.0, 1.0);\n\tw += wIntensity;\n\t\n\tc += wElevation * getElevation();\n\tw += wElevation;\n\t\n\tc += wReturnNumber * getReturnNumber();\n\tw += wReturnNumber;\n\t\n\tc += wSourceID * getSourceID();\n\tw += wSourceID;\n\t\n\tvec4 cl = wClassification * getClassification();\n    c += cl.a * cl.rgb;\n\tw += wClassification * cl.a;\n\n\tc = c / w;\n\t\n\tif(w == 0.0){\n\t\t//c = color;\n\t\tgl_Position = vec4(100.0, 100.0, 100.0, 0.0);\n\t}\n\t\n\treturn c;\n}\n\n\n// \n//  ######  ##       #### ########  ########  #### ##    ##  ######   \n// ##    ## ##        ##  ##     ## ##     ##  ##  ###   ## ##    ##  \n// ##       ##        ##  ##     ## ##     ##  ##  ####  ## ##        \n// ##       ##        ##  ########  ########   ##  ## ## ## ##   #### \n// ##       ##        ##  ##        ##         ##  ##  #### ##    ##  \n// ##    ## ##        ##  ##        ##         ##  ##   ### ##    ##  \n//  ######  ######## #### ##        ##        #### ##    ##  ######                                                          \n// \n\n\n\nvec3 getColor(){\n\tvec3 color;\n\t\n\t#ifdef color_type_rgb\n\t\tcolor = getRGB();\n\t#elif defined color_type_height\n\t\tcolor = getElevation();\n\t#elif defined color_type_rgb_height\n\t\tvec3 cHeight = getElevation();\n\t\tcolor = (1.0 - uTransition) * getRGB() + uTransition * cHeight;\n\t#elif defined color_type_depth\n\t\tfloat linearDepth = gl_Position.w;\n\t\tfloat expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;\n\t\tcolor = vec3(linearDepth, expDepth, 0.0);\n\t#elif defined color_type_intensity\n\t\tfloat w = getIntensity();\n\t\tcolor = vec3(w, w, w);\n\t#elif defined color_type_intensity_gradient\n\t\tfloat w = getIntensity();\n\t\tcolor = texture2D(gradient, vec2(w,1.0-w)).rgb;\n\t#elif defined color_type_color\n\t\tcolor = uColor;\n\t#elif defined color_type_lod\n\t\tfloat depth = getLOD();\n\t\tfloat w = depth / 10.0;\n\t\tcolor = texture2D(gradient, vec2(w,1.0-w)).rgb;\n\t#elif defined color_type_point_index\n\t\tcolor = indices.rgb;\n\t#elif defined color_type_classification\n\t\tvec4 cl = getClassification(); \n\t\tcolor = cl.rgb;\n\t#elif defined color_type_return_number\n\t\tcolor = getReturnNumber();\n\t#elif defined color_type_source\n\t\tcolor = getSourceID();\n\t#elif defined color_type_normal\n\t\tcolor = (modelMatrix * vec4(normal, 0.0)).xyz;\n\t#elif defined color_type_phong\n\t\tcolor = color;\n\t#elif defined color_type_composite\n\t\tcolor = getCompositeColor();\n\t#endif\n\t\n\treturn color;\n}\n\nfloat getPointSize(){\n\tfloat pointSize = 1.0;\n\t\n\tfloat slope = tan(fov / 2.0);\n\tfloat projFactor = -0.5 * uScreenHeight / (slope * vViewPosition.z);\n\t\n\tfloat r = uOctreeSpacing * 1.7;\n\tvRadius = r;\n\t#if defined fixed_point_size\n\t\tpointSize = size;\n\t#elif defined attenuated_point_size\n\t\tif(uUseOrthographicCamera){\n\t\t\tpointSize = size;\n\t\t}else{\n\t\t\tpointSize = size * spacing * projFactor;\n\t\t\t//pointSize = pointSize * projFactor;\n\t\t}\n\t#elif defined adaptive_point_size\n\t\tif(uUseOrthographicCamera) {\n\t\t\tfloat worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();\n\t\t\tpointSize = (worldSpaceSize / uOrthoWidth) * uScreenWidth;\n\t\t} else {\n\n\t\t\tif(uIsLeafNode && false){\n\t\t\t\tpointSize = size * spacing * projFactor;\n\t\t\t}else{\n\t\t\t\tfloat worldSpaceSize = 1.0 * size * r / getPointSizeAttenuation();\n\t\t\t\tpointSize = worldSpaceSize * projFactor;\n\t\t\t}\n\t\t}\n\t#endif\n\n\tpointSize = max(minSize, pointSize);\n\tpointSize = min(maxSize, pointSize);\n\t\n\tvRadius = pointSize / projFactor;\n\n\treturn pointSize;\n}\n\n#if defined(num_clippolygons) && num_clippolygons > 0\nbool pointInClipPolygon(vec3 point, int polyIdx) {\n\n\tmat4 wvp = uClipPolygonWVP[polyIdx];\n\t//vec4 screenClipPos = uClipPolygonVP[polyIdx] * modelMatrix * vec4(point, 1.0);\n\t//screenClipPos.xy = screenClipPos.xy / screenClipPos.w * 0.5 + 0.5;\n\n\tvec4 pointNDC = wvp * vec4(point, 1.0);\n\tpointNDC.xy = pointNDC.xy / pointNDC.w;\n\n\tint j = uClipPolygonVCount[polyIdx] - 1;\n\tbool c = false;\n\tfor(int i = 0; i < 8; i++) {\n\t\tif(i == uClipPolygonVCount[polyIdx]) {\n\t\t\tbreak;\n\t\t}\n\n\t\t//vec4 verti = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + i], 1);\n\t\t//vec4 vertj = wvp * vec4(uClipPolygonVertices[polyIdx * 8 + j], 1);\n\n\t\t//verti.xy = verti.xy / verti.w;\n\t\t//vertj.xy = vertj.xy / vertj.w;\n\n\t\t//verti.xy = verti.xy / verti.w * 0.5 + 0.5;\n\t\t//vertj.xy = vertj.xy / vertj.w * 0.5 + 0.5;\n\n\t\tvec3 verti = uClipPolygonVertices[polyIdx * 8 + i];\n\t\tvec3 vertj = uClipPolygonVertices[polyIdx * 8 + j];\n\n\t\tif( ((verti.y > pointNDC.y) != (vertj.y > pointNDC.y)) && \n\t\t\t(pointNDC.x < (vertj.x-verti.x) * (pointNDC.y-verti.y) / (vertj.y-verti.y) + verti.x) ) {\n\t\t\tc = !c;\n\t\t}\n\t\tj = i;\n\t}\n\n\treturn c;\n}\n#endif\n\nvoid doClipping(){\n\n\t#if !defined color_type_composite\n\t\tvec4 cl = getClassification(); \n\t\tif(cl.a == 0.0){\n\t\t\tgl_Position = vec4(100.0, 100.0, 100.0, 0.0);\n\t\t\t\n\t\t\treturn;\n\t\t}\n\t#endif\n\n\tint clipVolumesCount = 0;\n\tint insideCount = 0;\n\n\t#if defined(num_clipboxes) && num_clipboxes > 0\n\t\tfor(int i = 0; i < num_clipboxes; i++){\n\t\t\tvec4 clipPosition = clipBoxes[i] * modelMatrix * vec4( position, 1.0 );\n\t\t\tbool inside = -0.5 <= clipPosition.x && clipPosition.x <= 0.5;\n\t\t\tinside = inside && -0.5 <= clipPosition.y && clipPosition.y <= 0.5;\n\t\t\tinside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5;\n\n\t\t\tinsideCount = insideCount + (inside ? 1 : 0);\n\t\t\tclipVolumesCount++;\n\t\t}\t\n\t#endif\n\n\t#if defined(num_clippolygons) && num_clippolygons > 0\n\t\tfor(int i = 0; i < num_clippolygons; i++) {\n\t\t\tbool inside = pointInClipPolygon(position, i);\n\n\t\t\tinsideCount = insideCount + (inside ? 1 : 0);\n\t\t\tclipVolumesCount++;\n\t\t}\n\t#endif\n\n\tbool insideAny = insideCount > 0;\n\tbool insideAll = (clipVolumesCount > 0) && (clipVolumesCount == insideCount);\n\n\tif(clipMethod == CLIPMETHOD_INSIDE_ANY){\n\t\tif(insideAny && clipTask == CLIPTASK_HIGHLIGHT){\n\t\t\tvColor.r += 0.5;\n\t\t}else if(!insideAny && clipTask == CLIPTASK_SHOW_INSIDE){\n\t\t\tgl_Position = vec4(100.0, 100.0, 100.0, 1.0);\n\t\t}else if(insideAny && clipTask == CLIPTASK_SHOW_OUTSIDE){\n\t\t\tgl_Position = vec4(100.0, 100.0, 100.0, 1.0);\n\t\t}\n\t}else if(clipMethod == CLIPMETHOD_INSIDE_ALL){\n\t\tif(insideAll && clipTask == CLIPTASK_HIGHLIGHT){\n\t\t\tvColor.r += 0.5;\n\t\t}else if(!insideAll && clipTask == CLIPTASK_SHOW_INSIDE){\n\t\t\tgl_Position = vec4(100.0, 100.0, 100.0, 1.0);\n\t\t}else if(insideAll && clipTask == CLIPTASK_SHOW_OUTSIDE){\n\t\t\tgl_Position = vec4(100.0, 100.0, 100.0, 1.0);\n\t\t}\n\t}\n}\n\n\n\n// \n// ##     ##    ###    #### ##    ## \n// ###   ###   ## ##    ##  ###   ## \n// #### ####  ##   ##   ##  ####  ## \n// ## ### ## ##     ##  ##  ## ## ## \n// ##     ## #########  ##  ##  #### \n// ##     ## ##     ##  ##  ##   ### \n// ##     ## ##     ## #### ##    ## \n//\n\nvoid main() {\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tvViewPosition = mvPosition.xyz;\n\tgl_Position = projectionMatrix * mvPosition;\n\tvLogDepth = log2(-mvPosition.z);\n\tvFragDepth = 1.0 + gl_Position.w;\n\n\t// POINT SIZE\n\tfloat pointSize = getPointSize();\n\tgl_PointSize = pointSize;\n\tvPointSize = pointSize;\n\n\t// COLOR\n\tvColor = getColor();\n\n\n\t#if defined hq_depth_pass\n\t\tfloat originalDepth = gl_Position.w;\n\t\tfloat adjustedDepth = originalDepth + 2.0 * vRadius;\n\t\tfloat adjust = adjustedDepth / originalDepth;\n\n\t\tmvPosition.xyz = mvPosition.xyz * adjust;\n\t\tgl_Position = projectionMatrix * mvPosition;\n\t#endif\n\n\n\t// CLIPPING\n\tdoClipping();\n\n\t#if defined(num_clipspheres) && num_clipspheres > 0\n\t\tfor(int i = 0; i < num_clipspheres; i++){\n\t\t\tvec4 sphereLocal = uClipSpheres[i] * mvPosition;\n\n\t\t\tfloat distance = length(sphereLocal.xyz);\n\n\t\t\tif(distance < 1.0){\n\t\t\t\tfloat w = distance;\n\t\t\t\tvec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb;\n\t\t\t\t\n\t\t\t\tvColor = cGradient;\n\t\t\t\t//vColor = cGradient * 0.7 + vColor * 0.3;\n\t\t\t}\n\t\t}\n\t#endif\n\n\t#if defined(num_shadowmaps) && num_shadowmaps > 0\n\n\t\tconst float sm_near = 0.1;\n\t\tconst float sm_far = 10000.0;\n\n\t\tfor(int i = 0; i < num_shadowmaps; i++){\n\t\t\tvec3 viewPos = (uShadowWorldView[i] * vec4(position, 1.0)).xyz;\n\t\t\tfloat distanceToLight = abs(viewPos.z);\n\t\t\t\n\t\t\tvec4 projPos = uShadowProj[i] * uShadowWorldView[i] * vec4(position, 1);\n\t\t\tvec3 nc = projPos.xyz / projPos.w;\n\t\t\t\n\t\t\tfloat u = nc.x * 0.5 + 0.5;\n\t\t\tfloat v = nc.y * 0.5 + 0.5;\n\n\t\t\tvec2 sampleStep = vec2(1.0 / (2.0*1024.0), 1.0 / (2.0*1024.0)) * 1.5;\n\t\t\tvec2 sampleLocations[9];\n\t\t\tsampleLocations[0] = vec2(0.0, 0.0);\n\t\t\tsampleLocations[1] = sampleStep;\n\t\t\tsampleLocations[2] = -sampleStep;\n\t\t\tsampleLocations[3] = vec2(sampleStep.x, -sampleStep.y);\n\t\t\tsampleLocations[4] = vec2(-sampleStep.x, sampleStep.y);\n\n\t\t\tsampleLocations[5] = vec2(0.0, sampleStep.y);\n\t\t\tsampleLocations[6] = vec2(0.0, -sampleStep.y);\n\t\t\tsampleLocations[7] = vec2(sampleStep.x, 0.0);\n\t\t\tsampleLocations[8] = vec2(-sampleStep.x, 0.0);\n\n\t\t\tfloat visibleSamples = 0.0;\n\t\t\tfloat numSamples = 0.0;\n\n\t\t\tfloat bias = vRadius * 2.0;\n\n\t\t\tfor(int j = 0; j < 9; j++){\n\t\t\t\tvec4 depthMapValue = texture2D(uShadowMap[i], vec2(u, v) + sampleLocations[j]);\n\n\t\t\t\tfloat linearDepthFromSM = depthMapValue.x + bias;\n\t\t\t\tfloat linearDepthFromViewer = distanceToLight;\n\n\t\t\t\tif(linearDepthFromSM > linearDepthFromViewer){\n\t\t\t\t\tvisibleSamples += 1.0;\n\t\t\t\t}\n\n\t\t\t\tnumSamples += 1.0;\n\t\t\t}\n\n\t\t\tfloat visibility = visibleSamples / numSamples;\n\n\t\t\tif(u < 0.0 || u > 1.0 || v < 0.0 || v > 1.0 || nc.x < -1.0 || nc.x > 1.0 || nc.y < -1.0 || nc.y > 1.0 || nc.z < -1.0 || nc.z > 1.0){\n\t\t\t\t//vColor = vec3(0.0, 0.0, 0.2);\n\t\t\t}else{\n\t\t\t\t//vColor = vec3(1.0, 1.0, 1.0) * visibility + vec3(1.0, 1.0, 1.0) * vec3(0.5, 0.0, 0.0) * (1.0 - visibility);\n\t\t\t\tvColor = vColor * visibility + vColor * uShadowColor * (1.0 - visibility);\n\t\t\t}\n\t\t}\n\n\t#endif\n\n\t//vColor = vec3(1.0, 0.0, 0.0);\n\n\t//if(uDebug){\n\t//\tvColor.b = (vColor.r + vColor.g + vColor.b) / 3.0;\n\t//\tvColor.r = 1.0;\n\t//\tvColor.g = 1.0;\n\t//}\n\n}\n","pointcloud.fs":"\n// #if defined paraboloid_point_shape\n#if defined USE_LOGDEPTHBUF_EXT\n\t#extension GL_EXT_frag_depth : enable\n#endif\n\nprecision highp float;\nprecision highp int;\n\nuniform mat4 viewMatrix;\nuniform mat4 uViewInv;\nuniform mat4 uProjInv;\nuniform vec3 cameraPosition;\n\n\nuniform mat4 projectionMatrix;\nuniform float uOpacity;\n\nuniform float blendHardness;\nuniform float blendDepthSupplement;\nuniform float fov;\nuniform float uSpacing;\nuniform float near;\nuniform float far;\nuniform float uPCIndex;\nuniform float uScreenWidth;\nuniform float uScreenHeight;\nuniform float logDepthBufFC;\n\nvarying vec3\tvColor;\nvarying float\tvLogDepth;\nvarying float\tvFragDepth;\nvarying vec3\tvViewPosition;\nvarying float\tvRadius;\nvarying float \tvPointSize;\nvarying vec3 \tvPosition;\n\n\nfloat specularStrength = 1.0;\n\nvoid main() {\n\n\tvec3 color = vColor;\n\tfloat depth = gl_FragCoord.z;\n\n\t#if defined(circle_point_shape) || defined(paraboloid_point_shape) \n\t\tfloat u = 2.0 * gl_PointCoord.x - 1.0;\n\t\tfloat v = 2.0 * gl_PointCoord.y - 1.0;\n\t#endif\n\t\n\t#if defined(circle_point_shape) \n\t\tfloat cc = u*u + v*v;\n\t\tif(cc > 1.0){\n\t\t\tdiscard;\n\t\t}\n\t#endif\n\t\t\n\t#if defined color_type_point_index\n\t\tgl_FragColor = vec4(color, uPCIndex / 255.0);\n\t#else\n\t\tgl_FragColor = vec4(color, uOpacity);\n\t#endif\n\n\t#if defined paraboloid_point_shape\n\t\tfloat wi = 0.0 - ( u*u + v*v);\n\t\tvec4 pos = vec4(vViewPosition, 1.0);\n\t\tpos.z += wi * vRadius;\n\t\tfloat linearDepth = -pos.z;\n\t\tpos = projectionMatrix * pos;\n\t\tpos = pos / pos.w;\n\t\tfloat expDepth = pos.z;\n\t\tdepth = (pos.z + 1.0) / 2.0;\n\t\t\n\t\t#if defined(color_type_depth)\n\t\t\tcolor.r = linearDepth;\n\t\t\tcolor.g = expDepth;\n\t\t#endif\n\t\t\n\t\t#if defined(use_edl)\n\t\t\tgl_FragColor.a = log2(linearDepth);\n\t\t#endif\n\t\t\n\t#else\n\t\t#if defined(use_edl)\n\t\t\tgl_FragColor.a = vLogDepth;\n\t\t#endif\n\t#endif\n\n\t#if defined(weighted_splats)\n\t\tfloat distance = 2.0 * length(gl_PointCoord.xy - 0.5);\n\t\tfloat weight = max(0.0, 1.0 - distance);\n\t\tweight = pow(weight, 1.5);\n\n\t\tgl_FragColor.a = weight;\n\t\tgl_FragColor.xyz = gl_FragColor.xyz * weight;\n\t#endif\n\t#if defined USE_LOGDEPTHBUF_EXT\n\t\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n\t#endif\n\t\n}\n\n\n","pointcloud_sm.vs":"\nprecision mediump float;\nprecision mediump int;\n\nattribute vec3 position;\nattribute vec3 color;\n\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\n\nuniform float uScreenWidth;\nuniform float uScreenHeight;\nuniform float near;\nuniform float far;\n\nuniform float uSpacing;\nuniform float uOctreeSize;\nuniform float uLevel;\nuniform float uVNStart;\n\nuniform sampler2D visibleNodes;\n\nvarying float vLinearDepth;\nvarying vec3 vColor;\n\n#define PI 3.141592653589793\n\n\n\n// ---------------------\n// OCTREE\n// ---------------------\n\n#if defined(adaptive_point_size)\n/**\n * number of 1-bits up to inclusive index position\n * number is treated as if it were an integer in the range 0-255\n *\n */\nfloat numberOfOnes(float number, float index){\n\tfloat tmp = mod(number, pow(2.0, index + 1.0));\n\tfloat numOnes = 0.0;\n\tfor(float i = 0.0; i < 8.0; i++){\n\t\tif(mod(tmp, 2.0) != 0.0){\n\t\t\tnumOnes++;\n\t\t}\n\t\ttmp = floor(tmp / 2.0);\n\t}\n\treturn numOnes;\n}\n\n\n/**\n * checks whether the bit at index is 1\n * number is treated as if it were an integer in the range 0-255\n *\n */\nbool isBitSet(float number, float index){\n\treturn mod(floor(number / pow(2.0, index)), 2.0) != 0.0;\n}\n\n\n/**\n * find the LOD at the point position\n */\nfloat getLOD(){\n\t\n\tvec3 offset = vec3(0.0, 0.0, 0.0);\n\tfloat iOffset = uVNStart;\n\tfloat depth = uLevel;\n\tfor(float i = 0.0; i <= 30.0; i++){\n\t\tfloat nodeSizeAtLevel = uOctreeSize  / pow(2.0, i + uLevel + 0.0);\n\t\t\n\t\tvec3 index3d = (position-offset) / nodeSizeAtLevel;\n\t\tindex3d = floor(index3d + 0.5);\n\t\tfloat index = 4.0 * index3d.x + 2.0 * index3d.y + index3d.z;\n\t\t\n\t\tvec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));\n\t\tfloat mask = value.r * 255.0;\n\t\tif(isBitSet(mask, index)){\n\t\t\t// there are more visible child nodes at this position\n\t\t\tiOffset = iOffset + value.g * 255.0 * 256.0 + value.b * 255.0 + numberOfOnes(mask, index - 1.0);\n\t\t\tdepth++;\n\t\t}else{\n\t\t\t// no more visible child nodes at this position\n\t\t\treturn depth;\n\t\t}\n\t\t\n\t\toffset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d;\n\t}\n\t\t\n\treturn depth;\n}\n\n#endif\n\nfloat getPointSize(){\n\tfloat pointSize = 1.0;\n\t\n\tfloat slope = tan(fov / 2.0);\n\tfloat projFactor =  -0.5 * uScreenHeight / (slope * vViewPosition.z);\n\t\n\tfloat r = uOctreeSpacing * 1.5;\n\tvRadius = r;\n\t#if defined fixed_point_size\n\t\tpointSize = size;\n\t#elif defined attenuated_point_size\n\t\tif(uUseOrthographicCamera){\n\t\t\tpointSize = size;\t\t\t\n\t\t}else{\n\t\t\tpointSize = pointSize * projFactor;\n\t\t}\n\t#elif defined adaptive_point_size\n\t\tif(uUseOrthographicCamera) {\n\t\t\tfloat worldSpaceSize = 1.5 * size * r / getPointSizeAttenuation();\n\t\t\tpointSize = (worldSpaceSize / uOrthoWidth) * uScreenWidth;\n\t\t} else {\n\t\t\tfloat worldSpaceSize = 1.5 * size * r / getPointSizeAttenuation();\n\t\t\tpointSize = worldSpaceSize * projFactor;\n\t\t}\n\t#endif\n\n\tpointSize = max(minSize, pointSize);\n\tpointSize = min(maxSize, pointSize);\n\t\n\tvRadius = pointSize / projFactor;\n\n\treturn pointSize;\n}\n\n\nvoid main() {\n\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tvLinearDepth = gl_Position.w;\n\n\tfloat pointSize = getPointSize();\n\tgl_PointSize = pointSize;\n\n}\n","pointcloud_sm.fs":"\nprecision mediump float;\nprecision mediump int;\n\nvarying vec3 vColor;\nvarying float vLinearDepth;\n\nvoid main() {\n\n\t//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\t//gl_FragColor = vec4(vColor, 1.0);\n\t//gl_FragColor = vec4(vLinearDepth, pow(vLinearDepth, 2.0), 0.0, 1.0);\n\tgl_FragColor = vec4(vLinearDepth, vLinearDepth / 30.0, vLinearDepth / 30.0, 1.0);\n\t\n}\n\n\n","normalize.vs":"\nprecision mediump float;\nprecision mediump int;\n\nattribute vec3 position;\nattribute vec2 uv;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\n\nvarying vec2 vUv;\n\nvoid main() {\n\tvUv = uv;\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n}","normalize.fs":"\n#extension GL_EXT_frag_depth : enable\n\nprecision mediump float;\nprecision mediump int;\n\nuniform sampler2D uWeightMap;\nuniform sampler2D uDepthMap;\n\nvarying vec2 vUv;\n\nvoid main() {\n\tfloat depth = texture2D(uDepthMap, vUv).r;\n\t\n\tif(depth >= 1.0){\n\t\tdiscard;\n\t}\n\n\tgl_FragColor = vec4(depth, 1.0, 0.0, 1.0);\n\n\tvec4 color = texture2D(uWeightMap, vUv); \n\tcolor = color / color.w;\n\t\n\tgl_FragColor = vec4(color.xyz, 1.0); \n\t\n\tgl_FragDepthEXT = depth;\n\n\n}","normalize_and_edl.fs":"\n#extension GL_EXT_frag_depth : enable\n\nprecision mediump float;\nprecision mediump int;\n\nuniform sampler2D uWeightMap;\nuniform sampler2D uEDLMap;\nuniform sampler2D uDepthMap;\n\nuniform float screenWidth;\nuniform float screenHeight;\nuniform vec2 neighbours[NEIGHBOUR_COUNT];\nuniform float edlStrength;\nuniform float radius;\n\nvarying vec2 vUv;\n\nfloat response(float depth){\n\tvec2 uvRadius = radius / vec2(screenWidth, screenHeight);\n\t\n\tfloat sum = 0.0;\n\t\n\tfor(int i = 0; i < NEIGHBOUR_COUNT; i++){\n\t\tvec2 uvNeighbor = vUv + uvRadius * neighbours[i];\n\t\t\n\t\tfloat neighbourDepth = texture2D(uEDLMap, uvNeighbor).a;\n\n\t\tif(neighbourDepth != 0.0){\n\t\t\tif(depth == 0.0){\n\t\t\t\tsum += 100.0;\n\t\t\t}else{\n\t\t\t\tsum += max(0.0, depth - neighbourDepth);\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn sum / float(NEIGHBOUR_COUNT);\n}\n\nvoid main() {\n\n\tfloat edlDepth = texture2D(uEDLMap, vUv).a;\n\tfloat res = response(edlDepth);\n\tfloat shade = exp(-res * 300.0 * edlStrength);\n\n\tfloat depth = texture2D(uDepthMap, vUv).r;\n\tif(depth >= 1.0 && res == 0.0){\n\t\tdiscard;\n\t}\n\t\n\tvec4 color = texture2D(uWeightMap, vUv); \n\tcolor = color / color.w;\n\tcolor = color * shade;\n\n\tgl_FragColor = vec4(color.xyz, 1.0); \n\n\tgl_FragDepthEXT = depth;\n}","edl.vs":"\n\nvarying vec2 vUv;\n\nvoid main() {\n\tvUv = uv;\n\t\n\tvec4 mvPosition = modelViewMatrix * vec4(position,1.0);\n\n\tgl_Position = projectionMatrix * mvPosition;\n}","edl.fs":"// \n// adapted from the EDL shader code from Christian Boucheny in cloud compare:\n// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL\n//\n\nuniform float screenWidth;\nuniform float screenHeight;\nuniform vec2 neighbours[NEIGHBOUR_COUNT];\nuniform float edlStrength;\nuniform float radius;\nuniform float opacity;\n\n//uniform sampler2D colorMap;\nuniform sampler2D uRegularColor;\nuniform sampler2D uRegularDepth;\nuniform sampler2D uEDLColor;\nuniform sampler2D uEDLDepth;\n\nvarying vec2 vUv;\n\nfloat response(float depth){\n\tvec2 uvRadius = radius / vec2(screenWidth, screenHeight);\n\t\n\tfloat sum = 0.0;\n\t\n\tfor(int i = 0; i < NEIGHBOUR_COUNT; i++){\n\t\tvec2 uvNeighbor = vUv + uvRadius * neighbours[i];\n\t\t\n\t\tfloat neighbourDepth = texture2D(uEDLColor, uvNeighbor).a;\n\t\tneighbourDepth = (neighbourDepth == 1.0) ? 0.0 : neighbourDepth;\n\n\t\tif(neighbourDepth != 0.0){\n\t\t\tif(depth == 0.0){\n\t\t\t\tsum += 100.0;\n\t\t\t}else{\n\t\t\t\tsum += max(0.0, depth - neighbourDepth);\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn sum / float(NEIGHBOUR_COUNT);\n}\n\nvoid main(){\n\tvec4 cReg = texture2D(uRegularColor, vUv);\n\tvec4 cEDL = texture2D(uEDLColor, vUv);\n\t\n\tfloat depth = cEDL.a;\n\tdepth = (depth == 1.0) ? 0.0 : depth;\n\tfloat res = response(depth);\n\tfloat shade = exp(-res * 300.0 * edlStrength);\n\n\tfloat dReg = texture2D(uRegularDepth, vUv).r;\n\tfloat dEDL = texture2D(uEDLDepth, vUv).r;\n\n\tif(dEDL < dReg){\n\t\tgl_FragColor = vec4(cEDL.rgb * shade, opacity);\n\t}else{\n\t\tgl_FragColor = vec4(cReg.rgb * shade, cReg.a);\n\t}\n\n}\n","blur.vs":"\nvarying vec2 vUv;\n\nvoid main() {\n\tvUv = uv;\n\n\tgl_Position =   projectionMatrix * modelViewMatrix * vec4(position,1.0);\n}","blur.fs":"\nuniform mat4 projectionMatrix;\n\nuniform float screenWidth;\nuniform float screenHeight;\nuniform float near;\nuniform float far;\n\nuniform sampler2D map;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tfloat dx = 1.0 / screenWidth;\n\tfloat dy = 1.0 / screenHeight;\n\n\tvec3 color = vec3(0.0, 0.0, 0.0);\n\tcolor += texture2D(map, vUv + vec2(-dx, -dy)).rgb;\n\tcolor += texture2D(map, vUv + vec2(  0, -dy)).rgb;\n\tcolor += texture2D(map, vUv + vec2(+dx, -dy)).rgb;\n\tcolor += texture2D(map, vUv + vec2(-dx,   0)).rgb;\n\tcolor += texture2D(map, vUv + vec2(  0,   0)).rgb;\n\tcolor += texture2D(map, vUv + vec2(+dx,   0)).rgb;\n\tcolor += texture2D(map, vUv + vec2(-dx,  dy)).rgb;\n\tcolor += texture2D(map, vUv + vec2(  0,  dy)).rgb;\n\tcolor += texture2D(map, vUv + vec2(+dx,  dy)).rgb;\n\n\tcolor = color / 9.0;\n\t\n\tgl_FragColor = vec4(color, 1.0);\n}"};const hb={DEFAULT:{0:new _e(.5,.5,.5,1),1:new _e(.5,.5,.5,1),2:new _e(.63,.32,.18,1),3:new _e(0,1,0,1),4:new _e(0,.8,0,1),5:new _e(0,.6,0,1),6:new _e(1,.66,0,1),7:new _e(1,0,1,1),8:new _e(1,0,0,1),9:new _e(0,0,1,1),12:new _e(1,1,0,1),DEFAULT:new _e(.3,.6,.6,.5)}};Object.defineProperty(hb,"RANDOM",{get:function(){let t={};for(let e=0;e<=255;e++)t[e]=new _e(Math.random(),Math.random(),Math.random());return t.DEFAULT=new _e(Math.random(),Math.random(),Math.random()),t}});class cb extends _h{constructor(t={}){super(),this.visibleNodesTexture=tb.generateDataTexture(2048,1,new Ui(16777215)),this.visibleNodesTexture.minFilter=ft,this.visibleNodesTexture.magFilter=ft;let e=(t,e)=>void 0!==t?t:e,i=e(t.size,1),n=e(t.minSize,2),r=e(t.maxSize,50),s=e(t.treeType,Qv);this._pointSizeType=Zv.FIXED,this._shape=$v.SQUARE,this._pointColorType=Jv.RGB,this._useClipBox=!1,this.clipBoxes=[],this.clipPolygons=[],this._weighted=!1,this._gradient=ob.SPECTRAL,this.gradientTexture=cb.generateGradientTexture(this._gradient),this.lights=!1,this.fog=!1,this._treeType=s,this._useEDL=!1,this._snapEnabled=!1,this._numSnapshots=0,this.defines=new Map,this._defaultIntensityRangeChanged=!1,this._defaultElevationRangeChanged=!1,this.attributes={position:{type:"fv",value:[]},color:{type:"fv",value:[]},normal:{type:"fv",value:[]},intensity:{type:"f",value:[]},classification:{type:"f",value:[]},returnNumber:{type:"f",value:[]},numberOfReturns:{type:"f",value:[]},pointSourceID:{type:"f",value:[]},indices:{type:"fv",value:[]}},this.uniforms={level:{type:"f",value:0},vnStart:{type:"f",value:0},spacing:{type:"f",value:1},blendHardness:{type:"f",value:2},blendDepthSupplement:{type:"f",value:0},fov:{type:"f",value:1},screenWidth:{type:"f",value:1},screenHeight:{type:"f",value:1},near:{type:"f",value:.1},far:{type:"f",value:1},uColor:{type:"c",value:new Ui(16777215)},uOpacity:{type:"f",value:1},size:{type:"f",value:i},minSize:{type:"f",value:n},maxSize:{type:"f",value:r},octreeSize:{type:"f",value:0},bbSize:{type:"fv",value:[0,0,0]},elevationRange:{type:"2fv",value:[0,0]},clipBoxCount:{type:"f",value:0},clipPolygonCount:{type:"i",value:0},clipBoxes:{type:"Matrix4fv",value:[]},clipPolygons:{type:"3fv",value:[]},clipPolygonVCount:{type:"iv",value:[]},clipPolygonVP:{type:"Matrix4fv",value:[]},visibleNodes:{type:"t",value:this.visibleNodesTexture},pcIndex:{type:"f",value:0},gradient:{type:"t",value:this.gradientTexture},classificationLUT:{type:"t",value:this.classificationTexture},uHQDepthMap:{type:"t",value:null},toModel:{type:"Matrix4f",value:[]},diffuse:{type:"fv",value:[1,1,1]},transition:{type:"f",value:.5},intensityRange:{type:"fv",value:[0,65e3]},intensityGamma:{type:"f",value:1},intensityContrast:{type:"f",value:0},intensityBrightness:{type:"f",value:0},rgbGamma:{type:"f",value:1},rgbContrast:{type:"f",value:0},rgbBrightness:{type:"f",value:0},wRGB:{type:"f",value:1},wIntensity:{type:"f",value:0},wElevation:{type:"f",value:0},wClassification:{type:"f",value:0},wReturnNumber:{type:"f",value:0},wSourceID:{type:"f",value:0},logDepthBufFC:{type:"f",value:2/(Math.log(2001)/Math.LN2)},useOrthographicCamera:{type:"b",value:!1},clipTask:{type:"i",value:1},clipMethod:{type:"i",value:1},uSnapshot:{type:"tv",value:[]},uSnapshotDepth:{type:"tv",value:[]},uSnapView:{type:"Matrix4fv",value:[]},uSnapProj:{type:"Matrix4fv",value:[]},uSnapProjInv:{type:"Matrix4fv",value:[]},uSnapViewInv:{type:"Matrix4fv",value:[]},uShadowColor:{type:"3fv",value:[0,0,0]}},this.classification=hb.DEFAULT,this.defaultAttributeValues.normal=[0,0,0],this.defaultAttributeValues.classification=[0,0,0],this.defaultAttributeValues.indices=[0,0,0,0],this.vertexShader=this.getDefines()+ab["pointcloud.vs"],this.fragmentShader=this.getDefines()+ab["pointcloud.fs"],this.vertexColors=2}setDefine(t,e){null!=e?this.defines.get(t)!==e&&(this.defines.set(t,e),this.updateShaderSource()):this.removeDefine(t)}removeDefine(t){this.defines.delete(t)}updateShaderSource(){this.vertexShader=this.getDefines()+ab["pointcloud.vs"],this.fragmentShader=this.getDefines()+ab["pointcloud.fs"],1===this.opacity?(this.blending=0,this.transparent=!1,this.depthTest=!0,this.depthWrite=!0,this.depthFunc=3):this.opacity<1&&!this.useEDL&&(this.blending=2,this.transparent=!0,this.depthTest=!1,this.depthWrite=!0,this.depthFunc=1),this.weighted&&(this.blending=2,this.transparent=!0,this.depthTest=!0,this.depthWrite=!1),this.needsUpdate=!0}getDefines(){let t=[];this.pointSizeType===Zv.FIXED?t.push("#define fixed_point_size"):this.pointSizeType===Zv.ATTENUATED?t.push("#define attenuated_point_size"):this.pointSizeType===Zv.ADAPTIVE&&t.push("#define adaptive_point_size"),this.shape===$v.SQUARE?t.push("#define square_point_shape"):this.shape===$v.CIRCLE?t.push("#define circle_point_shape"):this.shape===$v.PARABOLOID&&t.push("#define paraboloid_point_shape"),this._useEDL&&t.push("#define use_edl"),this._snapEnabled&&t.push("#define snap_enabled"),this._pointColorType===Jv.RGB?t.push("#define color_type_rgb"):this._pointColorType===Jv.COLOR?t.push("#define color_type_color"):this._pointColorType===Jv.DEPTH?t.push("#define color_type_depth"):this._pointColorType===Jv.HEIGHT?t.push("#define color_type_height"):this._pointColorType===Jv.INTENSITY?t.push("#define color_type_intensity"):this._pointColorType===Jv.INTENSITY_GRADIENT?t.push("#define color_type_intensity_gradient"):this._pointColorType===Jv.LOD?t.push("#define color_type_lod"):this._pointColorType===Jv.POINT_INDEX?t.push("#define color_type_point_index"):this._pointColorType===Jv.CLASSIFICATION?t.push("#define color_type_classification"):this._pointColorType===Jv.RETURN_NUMBER?t.push("#define color_type_return_number"):this._pointColorType===Jv.SOURCE?t.push("#define color_type_source"):this._pointColorType===Jv.NORMAL?t.push("#define color_type_normal"):this._pointColorType===Jv.PHONG?t.push("#define color_type_phong"):this._pointColorType===Jv.RGB_HEIGHT?t.push("#define color_type_rgb_height"):this._pointColorType===Jv.COMPOSITE&&t.push("#define color_type_composite"),this._treeType===Qv?t.push("#define tree_type_octree"):this._treeType===Kv&&t.push("#define tree_type_kdtree"),this.weighted&&t.push("#define weighted_splats");for(let[e,i]of this.defines)t.push(i);return t.join("\n")}setClipBoxes(t){if(!t)return;let e=this.clipBoxes.length!==t.length&&(0===t.length||0===this.clipBoxes.length);this.uniforms.clipBoxCount.value=this.clipBoxes.length,this.clipBoxes=t,e&&this.updateShaderSource(),this.uniforms.clipBoxes.value=new Float32Array(16*this.clipBoxes.length);for(let e=0;e<this.clipBoxes.length;e++){let i=t[e];this.uniforms.clipBoxes.value.set(i.inverse.elements,16*e)}for(let t=0;t<this.uniforms.clipBoxes.value.length;t++)Number.isNaN(this.uniforms.clipBoxes.value[t])&&(this.uniforms.clipBoxes.value[t]=1/0)}setClipPolygons(t,e){if(!t)return;this.clipPolygons=t,this.clipPolygons.length!==t.length&&this.updateShaderSource()}get gradient(){return this._gradient}set gradient(t){this._gradient!==t&&(this._gradient=t,this.gradientTexture=cb.generateGradientTexture(this._gradient),this.uniforms.gradient.value=this.gradientTexture)}get useOrthographicCamera(){return this.uniforms.useOrthographicCamera.value}set useOrthographicCamera(t){this.uniforms.useOrthographicCamera.value!==t&&(this.uniforms.useOrthographicCamera.value=t)}get classification(){return this._classification}set classification(t){let e={};for(let i of Object.keys(t))e[i]=t[i].clone();let i=!1;if(void 0===this._classification)i=!1;else{i=Object.keys(e).length===Object.keys(this._classification).length;for(let t of Object.keys(e))i=i&&void 0!==this._classification[t],i=i&&e[t].equals(this._classification[t])}i||(this._classification=e,this.recomputeClassification())}recomputeClassification(){this.classificationTexture=cb.generateClassificationTexture(this._classification),this.uniforms.classificationLUT.value=this.classificationTexture,this.dispatchEvent({type:"material_property_changed",target:this})}get numSnapshots(){return this._numSnapshots}set numSnapshots(t){this._numSnapshots=t}get snapEnabled(){return this._snapEnabled}set snapEnabled(t){this._snapEnabled!==t&&(this._snapEnabled=t,this.updateShaderSource())}get spacing(){return this.uniforms.spacing.value}set spacing(t){this.uniforms.spacing.value!==t&&(this.uniforms.spacing.value=t)}get useClipBox(){return this._useClipBox}set useClipBox(t){this._useClipBox!==t&&(this._useClipBox=t,this.updateShaderSource())}get clipTask(){return this.uniforms.clipTask.value}set clipTask(t){this.uniforms.clipTask.value=t}get clipMethod(){return this.uniforms.clipMethod.value}set clipMethod(t){this.uniforms.clipMethod.value=t}get weighted(){return this._weighted}set weighted(t){this._weighted!==t&&(this._weighted=t,this.updateShaderSource())}get fov(){return this.uniforms.fov.value}set fov(t){this.uniforms.fov.value!==t&&(this.uniforms.fov.value=t)}get screenWidth(){return this.uniforms.screenWidth.value}set screenWidth(t){this.uniforms.screenWidth.value!==t&&(this.uniforms.screenWidth.value=t)}get screenHeight(){return this.uniforms.screenHeight.value}set screenHeight(t){this.uniforms.screenHeight.value!==t&&(this.uniforms.screenHeight.value=t)}get near(){return this.uniforms.near.value}set near(t){this.uniforms.near.value!==t&&(this.uniforms.near.value=t)}get far(){return this.uniforms.far.value}set far(t){this.uniforms.far.value!==t&&(this.uniforms.far.value=t)}get opacity(){return this.uniforms.uOpacity.value}set opacity(t){this.uniforms&&this.uniforms.uOpacity&&this.uniforms.uOpacity.value!==t&&(this.uniforms.uOpacity.value=t,this.updateShaderSource(),this.dispatchEvent({type:"opacity_changed",target:this}),this.dispatchEvent({type:"material_property_changed",target:this}))}get pointColorType(){return this._pointColorType}set pointColorType(t){this._pointColorType!==t&&(this._pointColorType=t,this.updateShaderSource(),this.dispatchEvent({type:"point_color_type_changed",target:this}),this.dispatchEvent({type:"material_property_changed",target:this}))}get pointSizeType(){return this._pointSizeType}set pointSizeType(t){this._pointSizeType!==t&&(this._pointSizeType=t,this.updateShaderSource(),this.dispatchEvent({type:"point_size_type_changed",target:this}),this.dispatchEvent({type:"material_property_changed",target:this}))}get useEDL(){return this._useEDL}set useEDL(t){this._useEDL!==t&&(this._useEDL=t,this.updateShaderSource())}get color(){return this.uniforms.uColor.value}set color(t){this.uniforms.uColor.value.equals(t)||(this.uniforms.uColor.value.copy(t),this.dispatchEvent({type:"color_changed",target:this}),this.dispatchEvent({type:"material_property_changed",target:this}))}get shape(){return this._shape}set shape(t){this._shape!==t&&(this._shape=t,this.updateShaderSource(),this.dispatchEvent({type:"point_shape_changed",target:this}),this.dispatchEvent({type:"material_property_changed",target:this}))}get treeType(){return this._treeType}set treeType(t){this._treeType!==t&&(this._treeType=t,this.updateShaderSource())}get bbSize(){return this.uniforms.bbSize.value}set bbSize(t){this.uniforms.bbSize.value=t}get size(){return this.uniforms.size.value}set size(t){this.uniforms.size.value!==t&&(this.uniforms.size.value=t,this.dispatchEvent({type:"point_size_changed",target:this}),this.dispatchEvent({type:"material_property_changed",target:this}))}get elevationRange(){return this.uniforms.elevationRange.value}set elevationRange(t){(this.uniforms.elevationRange.value[0]!==t[0]||this.uniforms.elevationRange.value[1]!==t[1])&&(this.uniforms.elevationRange.value=t,this._defaultElevationRangeChanged=!0,this.dispatchEvent({type:"material_property_changed",target:this}))}get heightMin(){return this.uniforms.elevationRange.value[0]}set heightMin(t){this.elevationRange=[t,this.elevationRange[1]]}get heightMax(){return this.uniforms.elevationRange.value[1]}set heightMax(t){this.elevationRange=[this.elevationRange[0],t]}get transition(){return this.uniforms.transition.value}set transition(t){this.uniforms.transition.value=t}get intensityRange(){return this.uniforms.intensityRange.value}set intensityRange(t){t instanceof Array&&2===t.length&&(t[0]===this.uniforms.intensityRange.value[0]&&t[1]===this.uniforms.intensityRange.value[1]||(this.uniforms.intensityRange.value=t,this._defaultIntensityRangeChanged=!0,this.dispatchEvent({type:"material_property_changed",target:this})))}get intensityGamma(){return this.uniforms.intensityGamma.value}set intensityGamma(t){this.uniforms.intensityGamma.value!==t&&(this.uniforms.intensityGamma.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get intensityContrast(){return this.uniforms.intensityContrast.value}set intensityContrast(t){this.uniforms.intensityContrast.value!==t&&(this.uniforms.intensityContrast.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get intensityBrightness(){return this.uniforms.intensityBrightness.value}set intensityBrightness(t){this.uniforms.intensityBrightness.value!==t&&(this.uniforms.intensityBrightness.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get rgbGamma(){return this.uniforms.rgbGamma.value}set rgbGamma(t){this.uniforms.rgbGamma.value!==t&&(this.uniforms.rgbGamma.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get rgbContrast(){return this.uniforms.rgbContrast.value}set rgbContrast(t){this.uniforms.rgbContrast.value!==t&&(this.uniforms.rgbContrast.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get rgbBrightness(){return this.uniforms.rgbBrightness.value}set rgbBrightness(t){this.uniforms.rgbBrightness.value!==t&&(this.uniforms.rgbBrightness.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get weightRGB(){return this.uniforms.wRGB.value}set weightRGB(t){this.uniforms.wRGB.value!==t&&(this.uniforms.wRGB.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get weightIntensity(){return this.uniforms.wIntensity.value}set weightIntensity(t){this.uniforms.wIntensity.value!==t&&(this.uniforms.wIntensity.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get weightElevation(){return this.uniforms.wElevation.value}set weightElevation(t){this.uniforms.wElevation.value!==t&&(this.uniforms.wElevation.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get weightClassification(){return this.uniforms.wClassification.value}set weightClassification(t){this.uniforms.wClassification.value!==t&&(this.uniforms.wClassification.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get weightReturnNumber(){return this.uniforms.wReturnNumber.value}set weightReturnNumber(t){this.uniforms.wReturnNumber.value!==t&&(this.uniforms.wReturnNumber.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}get weightSourceID(){return this.uniforms.wSourceID.value}set weightSourceID(t){this.uniforms.wSourceID.value!==t&&(this.uniforms.wSourceID.value=t,this.dispatchEvent({type:"material_property_changed",target:this}))}static generateGradientTexture(t){let e=64,i=document.createElement("canvas");i.width=e,i.height=e;let n=i.getContext("2d");n.rect(0,0,e,e);let r=n.createLinearGradient(0,0,e,e);for(let e=0;e<t.length;e++){let i=t[e];r.addColorStop(i[0],"#"+i[1].getHexString())}n.fillStyle=r,n.fill();let s=new ra(i);return s.needsUpdate=!0,s.minFilter=yt,s}static generateClassificationTexture(t){let e=256,i=new Uint8Array(262144);for(let n=0;n<e;n++)for(let r=0;r<256;r++){let s,o=n+e*r;s=t[n]?t[n]:t[n%32]?t[n%32]:t.DEFAULT,i[4*o+0]=255*s.x,i[4*o+1]=255*s.y,i[4*o+2]=255*s.z,i[4*o+3]=255*s.w}let n=new Jn(i,e,256,Ft);return n.magFilter=ft,n.needsUpdate=!0,n}disableEvents(){void 0===this._hiddenListeners&&(this._hiddenListeners=this._listeners,this._listeners={})}enableEvents(){this._listeners=this._hiddenListeners,this._hiddenListeners=void 0}copyFrom(t){for(let e of this.uniforms)this.uniforms[e].value=t.uniforms[e].value}}const lb=new ce;class ub extends ib{constructor(){super(),this.children=[],this.sceneNode=null,this.octree=null}getNumPoints(){return this.geometryNode.numPoints}isLoaded(){return!0}isTreeNode(){return!0}isGeometryNode(){return!1}getLevel(){return this.geometryNode.level}getBoundingSphere(){return this.geometryNode.boundingSphere}getBoundingBox(){return this.geometryNode.boundingBox}getChildren(){let t=[];for(let e=0;e<8;e++)this.children[e]&&t.push(this.children[e]);return t}getPointsInBox(t){if(!this.sceneNode)return null;let e=this.geometryNode.buffer,i=e.offset("position"),n=e.stride,r=new DataView(e.data),s=(new Le).getInverse(t.matrixWorld),o=(new Le).multiplyMatrices(s,this.sceneNode.matrixWorld),a=[],h=new _e;for(let t=0;t<e.numElements;t++){let e=r.getFloat32(t*n+i+0,!0),s=r.getFloat32(t*n+i+4,!0),c=r.getFloat32(t*n+i+8,!0);h.set(e,s,c,1),h.applyMatrix4(o),-.5<h.x&&h.x<.5&&-.5<h.y&&h.y<.5&&-.5<h.z&&h.z<.5&&(h.set(e,s,c,1).applyMatrix4(this.sceneNode.matrixWorld),a.push(new pe(h.x,h.y,h.z)))}return a}get name(){return this.geometryNode.name}}class db extends nb{constructor(t,e){super(),this.pointBudget=1/0,this.pcoGeometry=t,this.boundingBox=this.pcoGeometry.boundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(new di),this.material=e||new cb,this.visiblePointsTarget=2e6,this.minimumNodePixelSize=150,this.level=0,this.position.copy(t.offset),this.updateMatrix(),this.showBoundingBox=!1,this.boundingBoxNodes=[],this.loadQueue=[],this.visibleBounds=new ci,this.visibleNodes=[],this.visibleGeometry=[],this.generateDEM=!1,this.profileRequests=[],this.name="",this._visible=!0;{let t=[this.pcoGeometry.tightBoundingBox,this.getBoundingBoxWorld()].find((t=>void 0!==t));this.updateMatrixWorld(!0),t=tb.computeTransformedBoundingBox(t,this.matrixWorld);let e=t.min.z,i=t.max.z;this.material.heightMin=e,this.material.heightMax=i}this.projection=t.projection,this.root=this.pcoGeometry.root}setName(t){this.name!==t&&(this.name=t,this.dispatchEvent({type:"name_changed",name:t,pointcloud:this}))}getName(){return this.name}toTreeNode(t,e){let i=new ub,n=new ta(t.geometry,this.material);n.name=t.name,n.position.copy(t.boundingBox.min),n.frustumCulled=!1,n.onBeforeRender=(e,n,r,s,o,a)=>{if(o.program){if(e.getContext().useProgram(o.program.program),o.program.getUniforms().map.level){let i=t.getLevel();o.uniforms.level.value=i,o.program.getUniforms().map.level.setValue(e.getContext(),i)}if(this.visibleNodeTextureOffsets&&o.program.getUniforms().map.vnStart){let t=this.visibleNodeTextureOffsets.get(i);o.uniforms.vnStart.value=t,o.program.getUniforms().map.vnStart.setValue(e.getContext(),t)}if(o.program.getUniforms().map.pcIndex){let t=i.pcIndex?i.pcIndex:this.visibleNodes.indexOf(i);o.uniforms.pcIndex.value=t,o.program.getUniforms().map.pcIndex.setValue(e.getContext(),t)}}},i.geometryNode=t,i.sceneNode=n,i.pointcloud=this,i.children=[];for(let e=0;e<8;e++)i.children[e]=t.children[e];if(e){let r=parseInt(t.name[t.name.length-1]);e.sceneNode.add(n),e.children[r]=i}else this.root=i,this.add(n);return t.oneTimeDisposeHandlers.push((function(){let n=parseInt(t.name[t.name.length-1]);e.sceneNode.remove(i.sceneNode),e.children[n]=t})),i}updateVisibleBounds(){let t=[];for(let e=0;e<this.visibleNodes.length;e++){let i=this.visibleNodes[e],n=!0;for(let t=0;t<i.children.length;t++){let e=i.children[t];e instanceof ub?n=n&&!e.sceneNode.visible:e instanceof sb&&(n=!0)}n&&t.push(i)}this.visibleBounds.min=new pe(1/0,1/0,1/0),this.visibleBounds.max=new pe(-1/0,-1/0,-1/0);for(let e=0;e<t.length;e++){let i=t[e];this.visibleBounds.expandByPoint(i.getBoundingBox().min),this.visibleBounds.expandByPoint(i.getBoundingBox().max)}}updateMaterial(t,e,i,n){t.fov=i.fov*(Math.PI/180),t.screenWidth=n.domElement.clientWidth,t.screenHeight=n.domElement.clientHeight,t.spacing=this.pcoGeometry.spacing*Math.max(this.scale.x,this.scale.y,this.scale.z),t.near=i.near,t.far=i.far,t.uniforms.logDepthBufFC.value=2/(Math.log(i.far+1)/Math.LN2),t.uniforms.octreeSize.value=this.pcoGeometry.boundingBox.getSize(new pe).x}computeVisibilityTextureData(t,e){Potree.measureTimings&&performance.mark("computeVisibilityTextureData-start");let i=new Uint8Array(4*t.length),n=new Map;(t=t.slice()).sort((function(t,e){let i=t.geometryNode.name,n=e.geometryNode.name;return i.length!==n.length?i.length-n.length:i<n?-1:i>n?1:0}));new pe,new Map,new Map,new ci,new di;let r=new pe;new _i(e.position,e.getWorldDirection(r));for(let e=0;e<t.length;e++){let r=t[e];n.set(r,e),i[4*e+0]=0,i[4*e+1]=0,i[4*e+2]=0,i[4*e+3]=r.getLevel();for(let n=0,s=0;n<8;n++){let o=r.children[n];if(o&&o.constructor===ub&&o.sceneNode.visible){let n=parseInt(o.geometryNode.name.substr(-1));if(i[4*e+0]+=Math.pow(2,n),0===s){let n=t.indexOf(o,e);i[4*e+1]=n-e>>8,i[4*e+2]=(n-e)%256}s++}}}return Potree.measureTimings&&(performance.mark("computeVisibilityTextureData-end"),performance.measure("render.computeVisibilityTextureData","computeVisibilityTextureData-start","computeVisibilityTextureData-end")),{data:i,offsets:n}}nodeIntersectsProfile(t,e){let i=t.boundingBox.clone().applyMatrix4(this.matrixWorld).getBoundingSphere(new di),n=!1;for(let t=0;t<e.points.length-1;t++){let r=new ql(new pe(e.points[t+0].x,e.points[t+0].y,i.center.z),new pe(e.points[t+1].x,e.points[t+1].y,i.center.z)).closestPointToPoint(i.center,!0,new pe).distanceTo(i.center);n=n||r<i.radius+e.width}return n}nodesOnRay(t,e){let i=[],n=e.clone();for(let e=0;e<t.length;e++){let r=t[e],s=r.getBoundingSphere().clone().applyMatrix4(this.matrixWorld);n.intersectsSphere(s)&&i.push(r)}return i}updateMatrixWorld(t){!0===this.matrixAutoUpdate&&this.updateMatrix(),!0!==this.matrixWorldNeedsUpdate&&!0!==t||(this.parent?this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0)}hideDescendants(t){let e=[];for(let i=0;i<t.children.length;i++){let n=t.children[i];n.visible&&e.push(n)}for(;e.length>0;){let t=e.shift();t.visible=!1;for(let i=0;i<t.children.length;i++){let n=t.children[i];n.visible&&e.push(n)}}}moveToOrigin(){this.position.set(0,0,0),this.updateMatrixWorld(!0);let t=this.boundingBox,e=this.matrixWorld,i=tb.computeTransformedBoundingBox(t,e);this.position.set(0,0,0).sub(i.getCenter(new pe))}moveToGroundPlane(){this.updateMatrixWorld(!0);let t=this.boundingBox,e=this.matrixWorld,i=tb.computeTransformedBoundingBox(t,e);this.position.y+=-i.min.y}getBoundingBoxWorld(){this.updateMatrixWorld(!0);let t=this.boundingBox,e=this.matrixWorld;return tb.computeTransformedBoundingBox(t,e)}getPointsInProfile(t,e,i){if(i){let n=new Potree.ProfileRequest(this,t,e,i);return this.profileRequests.push(n),n}let n={segments:[],boundingBox:new ci,projectedBoundingBox:new Hl};for(let i=0;i<t.points.length-1;i++){let r=t.points[i],s=t.points[i+1],o=this.getProfile(r,s,t.width,e),a={start:r,end:s,points:o,project:null};n.segments.push(a),n.boundingBox.expandByPoint(o.boundingBox.min),n.boundingBox.expandByPoint(o.boundingBox.max)}let r=new pe;for(let t=0;t<n.segments.length;t++){let e=n.segments[t],i=e.start,s=e.end,o=function(t,e,i,n){let r=t,s=e,o=i,a=n,h=new pe(1,0,0),c=(new pe).subVectors(s,r);c.y=0,c.normalize();let l=Math.acos(h.dot(c));return c.z>0&&(l=-l),function(t){let e=(new Le).makeTranslation(-r.x,-a.min.y,-r.z),i=(new Le).makeRotationY(-l),n=(new Le).makeTranslation(o.x,0,0),s=t.clone();return s.applyMatrix4(e),s.applyMatrix4(i),s.applyMatrix4(n),s}}(i,s,r.clone(),n.boundingBox.clone());e.project=o,r.x+=new pe(i.x,0,i.z).distanceTo(new pe(s.x,0,s.z)),r.y+=s.y-i.y}return n.projectedBoundingBox.min.x=0,n.projectedBoundingBox.min.y=n.boundingBox.min.y,n.projectedBoundingBox.max.x=r.x,n.projectedBoundingBox.max.y=n.boundingBox.max.y,n}getProfile(t,e,i,n,r){let s=new Potree.ProfileRequest(t,e,i,n,r);this.profileRequests.push(s)}getVisibleExtent(){return this.visibleBounds.applyMatrix4(this.matrixWorld)}pick(t,e,i,n={}){let r=t.renderer,s=t.pRenderer;performance.mark("pick-start");let o=(t,e)=>void 0!==t?t:e,a=o(n.pickWindowSize,17),h=(o(n.pickOutsideClipRegion,!1),r.getSize(lb)),c=Math.ceil(o(n.width,h.width)),l=Math.ceil(o(n.height,h.height)),u=o(n.pointSizeType,this.material.pointSizeType),d=o(n.pointSize,this.material.size),p=this.nodesOnRay(this.visibleNodes,i);if(0===p.length)return null;if(!this.pickState){let t=new Ze,e=new Potree.PointCloudMaterial;e.pointColorType=Potree.PointColorType.POINT_INDEX;let i=new xe(1,1,{minFilter:yt,magFilter:ft,format:Ft});this.pickState={renderTarget:i,material:e,scene:t}}let f=this.pickState,m=f.material;m.pointSizeType=u,m.shape=this.material.shape,m.size=d,m.uniforms.minSize.value=this.material.uniforms.minSize.value,m.uniforms.maxSize.value=this.material.uniforms.maxSize.value,m.classification=this.material.classification,n.pickClipped?(m.clipBoxes=this.material.clipBoxes,this.material.clipTask===Potree.ClipTask.HIGHLIGHT?m.clipTask=Potree.ClipTask.NONE:m.clipTask=this.material.clipTask):m.clipBoxes=[],this.updateMaterial(m,p,e,r),f.renderTarget.setSize(c,l);let g=new ce(n.x,n.y),v=r.getContext();v.enable(v.SCISSOR_TEST),v.scissor(parseInt(g.x-(a-1)/2),parseInt(g.y-(a-1)/2),parseInt(a),parseInt(a)),r.state.buffers.depth.setTest(m.depthTest),r.state.buffers.depth.setMask(m.depthWrite),r.state.setBlending(0);{r.setRenderTarget(f.renderTarget),v.clearColor(0,0,0,0),r.clear();let t=this.material;this.material=m,s.renderOctree(this,p,e,f.renderTarget),this.material=t}let b=(t,e,i)=>Math.min(Math.max(e,t),i),y=parseInt(b(g.x-(a-1)/2,0,c)),_=parseInt(b(g.y-(a-1)/2,0,l)),x=parseInt(Math.min(y+a,c)-y),w=parseInt(Math.min(_+a,l)-_),M=new Uint8Array(4*(x*w));v.readPixels(y,_,a,a,v.RGBA,v.UNSIGNED_BYTE,M),r.setRenderTarget(null),r.state.reset(),r.setScissorTest(!1),v.disable(v.SCISSOR_TEST);let T=M,S=new Uint32Array(M.buffer),E=(Number.MAX_VALUE,[]);for(let t=0;t<a;t++)for(let e=0;e<a;e++){let i=t+e*a,r=Math.pow(t-(a-1)/2,2)+Math.pow(e-(a-1)/2,2),s=T[4*i+3];T[4*i+3]=0;let o=S[i];if((0!==s||0!==o)&&void 0!==s&&void 0!==o){let t={pIndex:o,pcIndex:s,distanceToCenter:r};n.all?E.push(t):E.length>0?r<E[0].distanceToCenter&&(E[0]=t):E.push(t)}}for(let t of E){let e={};if(!p[t.pcIndex])return null;let i=p[t.pcIndex],n=i.sceneNode,r=i.geometryNode.geometry;for(let i in r.attributes){let s=r.attributes[i];if("position"===i){let r=new pe(s.array[3*t.pIndex+0],s.array[3*t.pIndex+1],s.array[3*t.pIndex+2]);r.applyMatrix4(n.matrixWorld),e[i]=r}}t.point=e}return performance.mark("pick-end"),performance.measure("pick","pick-start","pick-end"),n.all?E.map((t=>t.point)):0===E.length?null:E[0].point}*getFittedBoxGen(t){let e=performance.now(),i=new ci,n=(new Le).getInverse(t.matrixWorld);for(let t of this.visibleNodes){if(!t.sceneNode)continue;let e=t.geometryNode.buffer,r=e.offset("position"),s=e.stride,o=new DataView(e.data),a=(new Le).multiplyMatrices(n,t.sceneNode.matrixWorld),h=new _e;for(let t=0;t<e.numElements;t++){let e=o.getFloat32(t*s+r+0,!0),n=o.getFloat32(t*s+r+4,!0),c=o.getFloat32(t*s+r+8,!0);h.set(e,n,c,1),h.applyMatrix4(a),-.5<h.x&&h.x<.5&&-.5<h.y&&h.y<.5&&-.5<h.z&&h.z<.5&&i.expandByPoint(h)}yield}let r=i.getCenter(new pe).applyMatrix4(t.matrixWorld),s=new Ye;s.position.copy(r),s.scale.copy(t.scale),s.rotation.copy(t.rotation);let o=(new pe).subVectors(i.max,i.min);s.scale.multiply(o);let a=performance.now()-e;console.log("duration: ",a),yield s}getFittedBox(t,e=1/0){let i=performance.now(),n=new ci,r=(new Le).getInverse(t.matrixWorld);for(let t of this.visibleNodes){if(!t.sceneNode||t.getLevel()>Infinity)continue;let e=t.geometryNode.buffer,i=e.offset("position"),s=e.stride,o=new DataView(e.data),a=(new Le).multiplyMatrices(r,t.sceneNode.matrixWorld),h=new _e;for(let t=0;t<e.numElements;t++){let e=o.getFloat32(t*s+i+0,!0),r=o.getFloat32(t*s+i+4,!0),c=o.getFloat32(t*s+i+8,!0);h.set(e,r,c,1),h.applyMatrix4(a),-.5<h.x&&h.x<.5&&-.5<h.y&&h.y<.5&&-.5<h.z&&h.z<.5&&n.expandByPoint(h)}}let s=n.getCenter(new pe).applyMatrix4(t.matrixWorld),o=new Ye;o.position.copy(s),o.scale.copy(t.scale),o.rotation.copy(t.rotation);let a=(new pe).subVectors(n.max,n.min);o.scale.multiply(a);let h=performance.now()-i;return console.log("duration: ",h),o}get progress(){return this.visibleNodes.length/this.visibleGeometry.length}find(t){let e=null;for(let i of t)e="r"===i?this.root:e.children[i];return e}get visible(){return this._visible}set visible(t){t!==this._visible&&(this._visible=t,this.dispatchEvent({type:"visibility_changed",pointcloud:this}))}}class pb extends Xo{constructor(t,e){void 0===e&&(e=16776960);let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array([t.min.x,t.min.y,t.min.z,t.max.x,t.min.y,t.min.z,t.max.x,t.min.y,t.max.z,t.min.x,t.min.y,t.max.z,t.min.x,t.max.y,t.min.z,t.max.x,t.max.y,t.min.z,t.max.x,t.max.y,t.max.z,t.min.x,t.max.y,t.max.z]),r=new fn;r.setIndex(new Yi(i,1)),r.setAttribute("position",new Yi(n,3)),super(r,new No({color:e}))}}function fb(t,e,i){for(let e of t){let t=performance.now();for(let i of e.profileRequests){if(i.update(),performance.now()-t>5)break}performance.now()}let n=function(t,e,i){let n=0,r=new Map(t.map((t=>[t,0]))),s=[],o=[],a=[],h=1/0,c=function(t,e,i){let n=[],r=[],s=new BinaryHeap((function(t){return 1/t.weight}));for(let i=0;i<t.length;i++){let o=t[i];if(!o.initialized())continue;o.numVisibleNodes=0,o.numVisiblePoints=0,o.deepestVisibleLevel=0,o.visibleNodes=[],o.visibleGeometry=[],e.updateMatrixWorld();let a=new tr,h=e.matrixWorldInverse,c=o.matrixWorld,l=e.clone();l.near=Math.min(e.near,.1),l.updateProjectionMatrix();let u=e.projectionMatrix,d=(new Le).multiply(u).multiply(h).multiply(c);a.setFromMatrix(d),n.push(a);let p=e.matrixWorld,f=(new Le).getInverse(c),m=(new Le).multiply(f).multiply(p),g=(new pe).setFromMatrixPosition(m);r.push(g),o.visible&&null!==o.root&&s.push({pointcloud:i,node:o.root,weight:Number.MAX_VALUE}),o.root.isTreeNode()&&o.hideDescendants(o.root.sceneNode);for(let t=0;t<o.boundingBoxNodes.length;t++)o.boundingBoxNodes[t].visible=!1}return{frustums:n,camObjPositions:r,priorityQueue:s}}(t,e),l=c.frustums,u=c.camObjPositions,d=c.priorityQueue,p=0,f=(i.domElement.clientWidth,i.domElement.clientHeight);Potree._pointcloudTransformVersion||(Potree._pointcloudTransformVersion=new Map);let m=Potree._pointcloudTransformVersion;for(let e of t)if(e.visible)if(e.updateMatrixWorld(),m.has(e)){let t=m.get(e);t.transform.equals(e.matrixWorld)||(t.number++,t.transform.copy(e.matrixWorld),e.dispatchEvent({type:"transformation_changed",target:e}))}else m.set(e,{number:0,transform:e.matrixWorld.clone()});for(;d.size()>0;){let i=d.pop(),c=i.node,g=i.parent,v=t[i.pointcloud],b=c.getBoundingBox(),y=l[i.pointcloud],_=u[i.pointcloud],x=y.intersectsBox(b),w=v.maxLevel||1/0,M=c.getLevel(),T=x;T=T&&!(n+c.getNumPoints()>Potree.pointBudget),T=T&&!(r.get(v)+c.getNumPoints()>v.pointBudget),T=T&&M<w,window.warned125||(window.warned125=!0);let S=v.material.clipBoxes;if(S.length>0){let t=0,e=0;for(let i of S){let n=(new Le).getInverse(v.matrixWorld),r=(n.multiply(i.box.matrixWorld),new pe(.5,0,0).applyMatrix4(n)),s=new pe(-.5,0,0).applyMatrix4(n),o=new pe(0,.5,0).applyMatrix4(n),a=new pe(0,-.5,0).applyMatrix4(n),h=new pe(0,0,.5).applyMatrix4(n),c=new pe(0,0,-.5).applyMatrix4(n),l=(new pe).subVectors(s,r).normalize(),u=l.clone().multiplyScalar(-1),d=(new pe).subVectors(a,o).normalize(),p=d.clone().multiplyScalar(-1),f=(new pe).subVectors(c,h).normalize(),m=f.clone().multiplyScalar(-1);new tr((new Ti).setFromNormalAndCoplanarPoint(l,r),(new Ti).setFromNormalAndCoplanarPoint(u,s),(new Ti).setFromNormalAndCoplanarPoint(d,o),(new Ti).setFromNormalAndCoplanarPoint(p,a),(new Ti).setFromNormalAndCoplanarPoint(f,h),(new Ti).setFromNormalAndCoplanarPoint(m,c)).intersectsBox(b)&&t++,e++}let i=t>0,n=t===e;v.material.clipTask===Xv.SHOW_INSIDE?v.material.clipMethod===Yv.INSIDE_ANY&&i||v.material.clipMethod===Yv.INSIDE_ALL&&n||(T=!1):v.material.clipTask}if(c.spacing?h=Math.min(h,c.spacing):c.geometryNode&&c.geometryNode.spacing&&(h=Math.min(h,c.geometryNode.spacing)),n+c.getNumPoints()>Potree.pointBudget)break;if(!T)continue;n+=c.getNumPoints();let E=r.get(v);if(r.set(v,E+c.getNumPoints()),v.numVisibleNodes++,v.numVisiblePoints+=c.getNumPoints(),!c.isGeometryNode()||g&&!g.isTreeNode()||(c.isLoaded()&&p<2?(c=v.toTreeNode(c,g),p++):(a.push(c),o.push(c))),c.isTreeNode()){Potree.lru.touch(c.geometryNode),c.sceneNode.visible=!0,c.sceneNode.material=v.material,s.push(c),v.visibleNodes.push(c),void 0===c._transformVersion&&(c._transformVersion=-1);let t=m.get(v);if(c._transformVersion!==t.number&&(c.sceneNode.updateMatrix(),c.sceneNode.matrixWorld.multiplyMatrices(v.matrixWorld,c.sceneNode.matrix),c._transformVersion=t.number),v.showBoundingBox&&!c.boundingBoxNode&&c.getBoundingBox){let t=new pb(c.getBoundingBox());t.matrixAutoUpdate=!1,v.boundingBoxNodes.push(t),c.boundingBoxNode=t,c.boundingBoxNode.matrix.copy(v.matrixWorld)}else v.showBoundingBox?(c.boundingBoxNode.visible=!0,c.boundingBoxNode.matrix.copy(v.matrixWorld)):!v.showBoundingBox&&c.boundingBoxNode&&(c.boundingBoxNode.visible=!1)}let P=c.getChildren();for(let t=0;t<P.length;t++){let n=P[t],r=0;if(e.isPerspectiveCamera){let t=n.getBoundingSphere(),i=t.center,s=_.x-i.x,o=_.y-i.y,a=_.z-i.z,h=s*s+o*o+a*a,c=Math.sqrt(h),l=t.radius,u=e.fov*Math.PI/180,d=l*(.5*f/(Math.tan(u/2)*c));if(d<v.minimumNodePixelSize)continue;r=d,c-l<0&&(r=Number.MAX_VALUE)}else{let t=n.getBoundingBox(),e=n.getBoundingSphere().center.distanceTo(_);r=t.max.clone().sub(t.min).length()/e}d.push({pointcloud:i.pointcloud,node:n,parent:c,weight:r})}}{let e=4,i=t.filter((t=>t.generateDEM&&t.dem instanceof Potree.DEM));for(let t of i){let i=t.visibleNodes.filter((t=>t.getLevel()<=e));t.dem.update(i)}}for(let t=0;t<Math.min(Potree.maxNodesLoading,a.length);t++)a[t].load();return{visibleNodes:s,numVisiblePoints:n,lowestSpacing:h}}(t,e,i);for(let n of t)n.updateMaterial(n.material,n.visibleNodes,e,i),n.updateVisibleBounds();return Potree.lru.freeMemory(),n}window.Potree=window.Potree||function(){},Potree.updatePointClouds=fb;class mb extends ib{constructor(){super(),this.left=null,this.right=null,this.sceneNode=null,this.kdtree=null,this._vec2=new ce}getNumPoints(){return this.geometryNode.numPoints}isLoaded(){return!0}isTreeNode(){return!0}isGeometryNode(){return!1}getLevel(){return this.geometryNode.level}getBoundingSphere(){return this.geometryNode.boundingSphere}getBoundingBox(){return this.geometryNode.boundingBox}toTreeNode(t){let e=null;if(this.left===t?e=this.left:this.right===t&&(e=this.right),!e.loaded)return;let i=new mb,n=function(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new ta(t,e)}(e.geometry,this.kdtree.material);n.visible=!1,i.kdtree=this.kdtree,i.geometryNode=e,i.sceneNode=n,i.parent=this,i.left=this.geometryNode.left,i.right=this.geometryNode.right}getChildren(){let t=[];return this.left&&t.push(this.left),this.right&&t.push(this.right),t}}function gb(t,e){let i;if(e===ut)return t.REPEAT;if(e===dt)return t.CLAMP_TO_EDGE;if(e===pt)return t.MIRRORED_REPEAT;if(e===ft)return t.NEAREST;if(e===gt)return t.NEAREST_MIPMAP_NEAREST;if(e===bt)return t.NEAREST_MIPMAP_LINEAR;if(e===yt)return t.LINEAR;if(e===_t)return t.LINEAR_MIPMAP_NEAREST;if(e===wt)return t.LINEAR_MIPMAP_LINEAR;if(e===Mt)return t.UNSIGNED_BYTE;if(e===At)return t.UNSIGNED_SHORT_4_4_4_4;if(e===Ct)return t.UNSIGNED_SHORT_5_5_5_1;if(e===Lt)return t.UNSIGNED_SHORT_5_6_5;if(1010===e)return t.BYTE;if(1011===e)return t.SHORT;if(e===Tt)return t.UNSIGNED_SHORT;if(1013===e)return t.INT;if(e===St)return t.UNSIGNED_INT;if(e===Et)return t.FLOAT;if(e===Pt&&(i=extensions.get("OES_texture_half_float"),null!==i))return i.HALF_FLOAT_OES;if(e===It)return t.ALPHA;if(e===Ot)return t.RGB;if(e===Ft)return t.RGBA;if(e===Bt)return t.LUMINANCE;if(e===Dt)return t.LUMINANCE_ALPHA;if(e===zt)return t.DEPTH_COMPONENT;if(e===Nt)return t.DEPTH_STENCIL;if(e===nt)return t.FUNC_ADD;if(101===e)return t.FUNC_SUBTRACT;if(102===e)return t.FUNC_REVERSE_SUBTRACT;if(e===ot)return t.ZERO;if(e===at)return t.ONE;if(202===e)return t.SRC_COLOR;if(203===e)return t.ONE_MINUS_SRC_COLOR;if(e===ht)return t.SRC_ALPHA;if(e===ct)return t.ONE_MINUS_SRC_ALPHA;if(206===e)return t.DST_ALPHA;if(207===e)return t.ONE_MINUS_DST_ALPHA;if(208===e)return t.DST_COLOR;if(209===e)return t.ONE_MINUS_DST_COLOR;if(210===e)return t.SRC_ALPHA_SATURATE;if((e===Ut||e===RGBA_S3TC_DXT1_Format||e===kt||e===RGBA_S3TC_DXT5_Format)&&(i=extensions.get("WEBGL_compressed_texture_s3tc"),null!==i)){if(e===Ut)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Vt)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===kt)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===jt)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((e===Ht||e===Gt||e===Wt||e===qt)&&(i=extensions.get("WEBGL_compressed_texture_pvrtc"),null!==i)){if(e===Ht)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Gt)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===Wt)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===qt)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e&&(i=extensions.get("WEBGL_compressed_texture_etc1"),null!==i))return i.COMPRESSED_RGB_ETC1_WEBGL;if(e===rt||e===st)if(this.capabilities.isWebGL2){if(e===rt)return t.MIN;if(e===st)return t.MAX}else if(i=extensions.get("EXT_blend_minmax"),null!==i){if(e===rt)return i.MIN_EXT;if(e===st)return i.MAX_EXT}if(e===UnsignedInt248Type){if(this.capabilities.isWebGL2)return t.UNSIGNED_INT_24_8;if(i=extensions.get("WEBGL_depth_texture"),null!==i)return i.UNSIGNED_INT_24_8_WEBGL}return 0}let vb={position:0,color:1,intensity:2,classification:3,returnNumber:4,numberOfReturns:5,pointSourceID:6,indices:7,normal:8,spacing:9};class bb{constructor(t,e,i,n){this.gl=t,this.name=e,this.vsSource=i,this.fsSource=n,this.cache=new Map,this.vs=null,this.fs=null,this.program=null,this.uniformLocations={},this.attributeLocations={},this.update(i,n)}update(t,e){this.vsSource=t,this.fsSource=e,this.linkProgram()}compileShader(t,e){let i=this.gl;if(i.shaderSource(t,e),i.compileShader(t),!i.getShaderParameter(t,i.COMPILE_STATUS)){let n=i.getShaderInfoLog(t),r=e.split("\n").map(((t,e)=>`${e+1}`.padEnd(5)+t)).join("\n");throw`could not compile shader ${this.name}: ${n}, \n${r}`}}linkProgram(){let t=this.gl;this.uniformLocations={},this.attributeLocations={},t.useProgram(null);let e=this.cache.get(`${this.vsSource}, ${this.fsSource}`);if(e)return this.program=e.program,this.vs=e.vs,this.fs=e.fs,this.attributeLocations=e.attributeLocations,void(this.uniformLocations=e.uniformLocations);{this.vs=t.createShader(t.VERTEX_SHADER),this.fs=t.createShader(t.FRAGMENT_SHADER),this.program=t.createProgram();for(let e of Object.keys(vb)){let i=vb[e];t.bindAttribLocation(this.program,i,e)}this.compileShader(this.vs,this.vsSource),this.compileShader(this.fs,this.fsSource);let e=this.program;if(t.attachShader(e,this.vs),t.attachShader(e,this.fs),t.linkProgram(e),t.detachShader(e,this.vs),t.detachShader(e,this.fs),!t.getProgramParameter(e,t.LINK_STATUS)){let i=t.getProgramInfoLog(e);throw`could not link program ${this.name}: ${i}`}{let i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){let i=t.getActiveAttrib(e,n),r=t.getAttribLocation(e,i.name);this.attributeLocations[i.name]=r}}{let i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){let i=t.getActiveUniform(e,n),r=t.getUniformLocation(e,i.name);this.uniformLocations[i.name]=r}}let i={program:this.program,vs:this.vs,fs:this.fs,attributeLocations:this.attributeLocations,uniformLocations:this.uniformLocations};this.cache.set(`${this.vsSource}, ${this.fsSource}`,i)}}setUniformMatrix4(t,e){const i=this.gl,n=this.uniformLocations[t];if(null==n)return;let r=new Float32Array(e.elements);i.uniformMatrix4fv(n,!1,r)}setUniform1f(t,e){const i=this.gl,n=this.uniformLocations[t];null!=n&&i.uniform1f(n,e)}setUniformBoolean(t,e){const i=this.gl,n=this.uniformLocations[t];null!=n&&i.uniform1i(n,e)}setUniformTexture(t,e){const i=this.gl,n=this.uniformLocations[t];null!=n&&i.uniform1i(n,e)}setUniform2f(t,e){const i=this.gl,n=this.uniformLocations[t];null!=n&&i.uniform2f(n,e[0],e[1])}setUniform3f(t,e){const i=this.gl,n=this.uniformLocations[t];null!=n&&i.uniform3f(n,e[0],e[1],e[2])}setUniform(t,e){e.constructor===Le?this.setUniformMatrix4(t,e):"number"==typeof e?this.setUniform1f(t,e):"boolean"==typeof e?this.setUniformBoolean(t,e):e instanceof yb?this.setUniformTexture(t,e):e instanceof Array?2===e.length?this.setUniform2f(t,e):3===e.length&&this.setUniform3f(t,e):console.error("unhandled uniform type: ",t,e)}setUniform1i(t,e){let i=this.gl,n=this.uniformLocations[t];null!=n&&i.uniform1i(n,e)}}class yb{constructor(t,e){this.gl=t,this.texture=e,this.id=t.createTexture(),this.target=t.TEXTURE_2D,this.version=-1,this.update(e)}update(){if(!this.texture.image)return void(this.version=this.texture.version);let t=this.gl,e=this.texture;if(this.version===e.version)return;this.target=t.TEXTURE_2D,t.bindTexture(this.target,this.id);let i,n=gb(t,e.format),r=e.image.width,s=e.image.height,o=n,a=gb(t,e.type);t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,e.unpackAlignment),e instanceof Jn?(i=e.image.data,t.texParameteri(this.target,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(this.target,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(this.target,t.TEXTURE_MAG_FILTER,gb(t,e.magFilter)),t.texParameteri(this.target,t.TEXTURE_MIN_FILTER,gb(t,e.minFilter)),t.texImage2D(this.target,0,n,r,s,0,o,a,i)):e instanceof ra&&(i=e.image,t.texParameteri(this.target,t.TEXTURE_WRAP_S,gb(t,e.wrapS)),t.texParameteri(this.target,t.TEXTURE_WRAP_T,gb(t,e.wrapT)),t.texParameteri(this.target,t.TEXTURE_MAG_FILTER,gb(t,e.magFilter)),t.texParameteri(this.target,t.TEXTURE_MIN_FILTER,gb(t,e.minFilter)),t.texImage2D(this.target,0,n,n,a,i)),t.bindTexture(this.target,null),this.version=e.version}}class _b{constructor(){this.numElements=0,this.vao=null,this.vbos=new Map}}class xb{constructor(t){this.threeRenderer=t,this.gl=this.threeRenderer.getContext(),this.buffers=new Map,this.shaders=new Map,this.textures=new Map,this.glTypeMapping=new Map,this.glTypeMapping.set(Float32Array,this.gl.FLOAT),this.glTypeMapping.set(Uint8Array,this.gl.UNSIGNED_BYTE),this.glTypeMapping.set(Uint16Array,this.gl.UNSIGNED_SHORT),this.toggle=0}createBuffer(t){let e=this.gl,i=new _b;i.vao=e.createVertexArray(),i.numElements=t.attributes.position.count,e.bindVertexArray(i.vao);for(let n in t.attributes){let r=t.attributes[n],s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,r.array,e.STATIC_DRAW);let o=vb[n],a=r.normalized,h=this.glTypeMapping.get(r.array.constructor);e.vertexAttribPointer(o,r.itemSize,h,a,0,0),e.enableVertexAttribArray(o),i.vbos.set(n,{handle:s,name:n,count:r.count,itemSize:r.itemSize,type:t.attributes.position.array.constructor,version:0})}return e.bindBuffer(e.ARRAY_BUFFER,null),e.bindVertexArray(null),i}updateBuffer(t){let e=this.gl,i=this.buffers.get(t);e.bindVertexArray(i.vao);for(let n in t.attributes){let r=t.attributes[n],s=vb[n],o=r.normalized,a=this.glTypeMapping.get(r.array.constructor),h=null;i.vbos.has(n)?(h=i.vbos.get(n).handle,i.vbos.get(n).version=r.version):(h=e.createBuffer(),i.vbos.set(n,{handle:h,name:n,count:r.count,itemSize:r.itemSize,type:t.attributes.position.array.constructor,version:r.version})),e.bindBuffer(e.ARRAY_BUFFER,h),e.bufferData(e.ARRAY_BUFFER,r.array,e.STATIC_DRAW),e.vertexAttribPointer(s,r.itemSize,a,o,0,0),e.enableVertexAttribArray(s)}e.bindBuffer(e.ARRAY_BUFFER,null),e.bindVertexArray(null)}traverse(t){let e=[],i=[t];for(;i.length>0;){let t=i.pop();if(t instanceof nb){e.push(t);continue}let n=t.children.filter((t=>t.visible));i.push(...n)}return{octrees:e}}renderNodes(t,e,i,n,r,s,o){let a=this.gl,h=o.material?o.material:t.material,c=null==o.shadowMaps?[]:o.shadowMaps,l=n.matrixWorldInverse,u=new Le,d=new Float32Array(16),p=0;for(let t of e){let e=t.sceneNode.matrixWorld;if(u.multiplyMatrices(l,e),i){let e=i.offsets.get(t);s.setUniform1f("uVNStart",e)}let n,r=t.getLevel();t.debug?s.setUniform("uDebug",!0):s.setUniform("uDebug",!1),t instanceof ub?n=0===Object.keys(t.children).length:t instanceof mb&&(n=t.geometryNode.isLeaf),s.setUniform("uIsLeafNode",n);const o=s.uniformLocations.modelMatrix;o&&(d.set(e.elements),a.uniformMatrix4fv(o,!1,d));const f=s.uniformLocations.modelViewMatrix;for(let t=0;t<16;t++)d[t]=u.elements[t];if(a.uniformMatrix4fv(f,!1,d),h.clipPolygons&&h.clipPolygons.length>0){let t=[],i=[];for(let n of h.clipPolygons){let r=n.viewMatrix,s=n.projMatrix.clone().multiply(r).multiply(e);t.push(n.markers.length),i.push(s)}let n=[].concat(...i.map((t=>t.elements))),r=new Array(24*h.clipPolygons.length);for(let t=0;t<h.clipPolygons.length;t++){let e=h.clipPolygons[t];for(let i=0;i<e.markers.length;i++)r[24*t+(3*i+0)]=e.markers[i].position.x,r[24*t+(3*i+1)]=e.markers[i].position.y,r[24*t+(3*i+2)]=e.markers[i].position.z}const o=s.uniformLocations["uClipPolygonVCount[0]"];a.uniform1iv(o,t);const c=s.uniformLocations["uClipPolygonWVP[0]"];a.uniformMatrix4fv(c,!1,n);const l=s.uniformLocations["uClipPolygonVertices[0]"];a.uniform3fv(l,r)}if(s.setUniform1f("uLevel",r),s.setUniform1f("uNodeSpacing",t.geometryNode.estimatedSpacing),s.setUniform1f("uPCIndex",p),c.length>0){const t=s.uniformLocations["uShadowMap[0]"];s.setUniform3f("uShadowColor",h.uniforms.uShadowColor.value);let i=5,n=new Array(c.length).fill(i).map(((t,e)=>t+e));a.uniform1iv(t,n);for(let t=0;t<c.length;t++){let e=c[t],i=n[t],r=this.threeRenderer.properties.get(e.target.texture).__webglTexture;a.activeTexture(a[`TEXTURE${i}`]),a.bindTexture(a.TEXTURE_2D,r)}{let t=c.map((t=>t.camera.matrixWorldInverse)).map((t=>(new Le).multiplyMatrices(t,e))),i=[].concat(...t.map((t=>t.elements)));const n=s.uniformLocations["uShadowWorldView[0]"];a.uniformMatrix4fv(n,!1,i)}{let t=[].concat(...c.map((t=>t.camera.projectionMatrix.elements)));const e=s.uniformLocations["uShadowProj[0]"];a.uniformMatrix4fv(e,!1,t)}}let m=t.geometryNode.geometry,g=null;if(this.buffers.has(m)){g=this.buffers.get(m);for(let t in m.attributes){m.attributes[t].version>g.vbos.get(t).version&&this.updateBuffer(m)}}else g=this.createBuffer(m),this.buffers.set(m,g);a.bindVertexArray(g.vao);let v=g.numElements;a.drawArrays(a.POINTS,0,v),p++}a.bindVertexArray(null)}renderOctree(t,e,i,n,r={}){let s=this.gl,o=r.material?r.material:t.material,a=null==r.shadowMaps?[]:r.shadowMaps,h=i.matrixWorldInverse,c=i.matrixWorld,l=i.projectionMatrix,u=(new Le).getInverse(l),d=(new Le,null),p=null,f=0;if(o.pointSizeType>=0&&(o.pointSizeType===Zv.ADAPTIVE||o.pointColorType===Jv.LOD)){let n=null!=r.vnTextureNodes?r.vnTextureNodes:e;p=t.computeVisibilityTextureData(n,i);const s=o.visibleNodesTexture;s.image.data.set(p.data),s.needsUpdate=!0}if(!this.shaders.has(o)){let[t,e]=[o.vertexShader,o.fragmentShader],i=new bb(s,"pointcloud",t,e);this.shaders.set(o,i)}d=this.shaders.get(o);{let[t,e]=[o.vertexShader,o.fragmentShader],i=o.snapEnabled?o.numSnapshots:0,n=o.clipBoxes&&o.clipBoxes.length?o.clipBoxes.length:0,s=r.clipSpheres&&r.clipSpheres.length?r.clipSpheres.length:0,h=o.clipPolygons&&o.clipPolygons.length?o.clipPolygons.length:0,c=[`#define num_shadowmaps ${a.length}`,`#define num_snapshots ${i}`,`#define num_clipboxes ${n}`,`#define num_clipspheres ${s}`,`#define num_clippolygons ${h}`].join("\n");t=`${c}\n${t}`,e=`${c}\n${e}`,d.update(t,e),o.needsUpdate=!1}for(let t of Object.keys(o.uniforms)){let e=o.uniforms[t];if("t"==e.type){let t=e.value;if(!t)continue;if(!this.textures.has(t)){let e=new yb(s,t);this.textures.set(t,e)}this.textures.get(t).update()}}s.useProgram(d.program);let m=!1;m=void 0!==r.transparent?r.transparent&&o.opacity<1:o.opacity<1,m?(s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE),s.depthMask(!1),s.disable(s.DEPTH_TEST)):(s.disable(s.BLEND),s.depthMask(!0),s.enable(s.DEPTH_TEST)),void 0!==r.blendFunc&&(s.enable(s.BLEND),s.blendFunc(...r.blendFunc)),void 0!==r.depthTest&&(!0===r.depthTest?s.enable(s.DEPTH_TEST):s.disable(s.DEPTH_TEST)),void 0!==r.depthWrite&&(!0===r.depthWrite?s.depthMask(!0):s.depthMask(!1));{d.setUniformMatrix4("projectionMatrix",l),d.setUniformMatrix4("viewMatrix",h),d.setUniformMatrix4("uViewInv",c),d.setUniformMatrix4("uProjInv",u);let t=n?n.width:o.screenWidth,e=n?n.height:o.screenHeight;if(d.setUniform1f("uScreenWidth",t),d.setUniform1f("uScreenHeight",e),d.setUniform1f("fov",Math.PI*i.fov/180),d.setUniform1f("near",i.near),d.setUniform1f("far",i.far),d.setUniform1f("logDepthBufFC",2/(Math.log(i.far+1)/Math.LN2)),i instanceof Oc?(d.setUniform("uUseOrthographicCamera",!0),d.setUniform("uOrthoWidth",i.right-i.left),d.setUniform("uOrthoHeight",i.top-i.bottom)):d.setUniform("uUseOrthographicCamera",!1),o.clipBoxes.length+o.clipPolygons.length===0?d.setUniform1i("clipTask",Xv.NONE):d.setUniform1i("clipTask",o.clipTask),d.setUniform1i("clipMethod",o.clipMethod),o.clipBoxes&&o.clipBoxes.length>0){const t=d.uniformLocations["clipBoxes[0]"];s.uniformMatrix4fv(t,!1,o.uniforms.clipBoxes.value)}if(r.clipSpheres&&r.clipSpheres.length>0){let t=r.clipSpheres,e=[];for(let n of t){let t=n.matrixWorld,r=i.matrixWorld,s=(new Le).getInverse(t),o=(new Le).multiplyMatrices(s,r);e.push(o)}let n=[].concat(...e.map((t=>t.elements)));const o=d.uniformLocations["uClipSpheres[0]"];s.uniformMatrix4fv(o,!1,n)}d.setUniform1f("size",o.size),d.setUniform1f("maxSize",o.uniforms.maxSize.value),d.setUniform1f("minSize",o.uniforms.minSize.value),d.setUniform1f("uOctreeSpacing",o.spacing),d.setUniform("uOctreeSize",o.uniforms.octreeSize.value),d.setUniform3f("uColor",o.color.toArray()),d.setUniform1f("uOpacity",o.opacity),d.setUniform2f("elevationRange",o.elevationRange),d.setUniform2f("intensityRange",o.intensityRange),d.setUniform1f("intensityGamma",o.intensityGamma),d.setUniform1f("intensityContrast",o.intensityContrast),d.setUniform1f("intensityBrightness",o.intensityBrightness),d.setUniform1f("rgbGamma",o.rgbGamma),d.setUniform1f("rgbContrast",o.rgbContrast),d.setUniform1f("rgbBrightness",o.rgbBrightness),d.setUniform1f("uTransition",o.transition),d.setUniform1f("wRGB",o.weightRGB),d.setUniform1f("wIntensity",o.weightIntensity),d.setUniform1f("wElevation",o.weightElevation),d.setUniform1f("wClassification",o.weightClassification),d.setUniform1f("wReturnNumber",o.weightReturnNumber),d.setUniform1f("wSourceID",o.weightSourceID);let a=this.textures.get(o.visibleNodesTexture);d.setUniform1i("visibleNodesTexture",f),s.activeTexture(s.TEXTURE0+f),s.bindTexture(a.target,a.id),f++;let p=this.textures.get(o.gradientTexture);d.setUniform1i("gradient",f),s.activeTexture(s.TEXTURE0+f),s.bindTexture(p.target,p.id),f++;let m=this.textures.get(o.classificationTexture);if(d.setUniform1i("classificationLUT",f),s.activeTexture(s.TEXTURE0+f),s.bindTexture(m.target,m.id),f++,!0===o.snapEnabled){{const t=d.uniformLocations["uSnapshot[0]"],e=d.uniformLocations["uSnapshotDepth[0]"];let i=f,n=new Array(5).fill(i).map(((t,e)=>t+e)),r=new Array(5).fill(1+Math.max(...n)).map(((t,e)=>t+e));f=1+Math.max(...r),s.uniform1iv(t,n),s.uniform1iv(e,r);for(let t=0;t<5;t++){let e=o.uniforms.uSnapshot.value[t],i=o.uniforms.uSnapshotDepth.value[t];if(!e)break;let a=this.threeRenderer.properties.get(e).__webglTexture,h=this.threeRenderer.properties.get(i).__webglTexture,c=n[t],l=r[t];s.activeTexture(s[`TEXTURE${c}`]),s.bindTexture(s.TEXTURE_2D,a),s.activeTexture(s[`TEXTURE${l}`]),s.bindTexture(s.TEXTURE_2D,h)}}{let t=[].concat(...o.uniforms.uSnapView.value.map((t=>t.elements)));const e=d.uniformLocations["uSnapView[0]"];s.uniformMatrix4fv(e,!1,t)}{let t=[].concat(...o.uniforms.uSnapProj.value.map((t=>t.elements)));const e=d.uniformLocations["uSnapProj[0]"];s.uniformMatrix4fv(e,!1,t)}{let t=[].concat(...o.uniforms.uSnapProjInv.value.map((t=>t.elements)));const e=d.uniformLocations["uSnapProjInv[0]"];s.uniformMatrix4fv(e,!1,t)}{let t=[].concat(...o.uniforms.uSnapViewInv.value.map((t=>t.elements)));const e=d.uniformLocations["uSnapViewInv[0]"];s.uniformMatrix4fv(e,!1,t)}}}this.renderNodes(t,e,p,i,n,d,r),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,null),s.activeTexture(s.TEXTURE0)}render(t,e,i=null,n={}){const r=this.gl;null!=i&&this.threeRenderer.setRenderTarget(i),e.updateProjectionMatrix();const s=this.traverse(t);for(const t of s.octrees){let r=t.visibleNodes;this.renderOctree(t,r,e,i,n)}r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,null),this.threeRenderer.state.reset()}}class wb{constructor(t){this.version=t;let e=-1===t.indexOf(".")?t.length:t.indexOf(".");this.versionMajor=parseInt(t.substr(0,e)),this.versionMinor=parseInt(t.substr(e+1)),0===this.versionMinor.length&&(this.versionMinor=0)}newerThan(t){let e=new wb(t);return this.versionMajor>e.versionMajor||this.versionMajor===e.versionMajor&&this.versionMinor>e.versionMinor}equalOrHigher(t){let e=new wb(t);return this.versionMajor>e.versionMajor||this.versionMajor===e.versionMajor&&this.versionMinor>=e.versionMinor}upTo(t){return!this.newerThan(t)}}class Mb{constructor(t){this.version="string"==typeof t?new wb(t):t}static progressCB(){}load(t){if(t.loaded)return;let e=t.pcoGeometry.pointAttributes,i=t.getURL();this.version.equalOrHigher("1.4")&&(i+="."+e.toLowerCase());let n=kv.createXMLHttpRequest();n.open("GET",i,!0),n.responseType="arraybuffer",n.overrideMimeType("text/plain; charset=x-user-defined"),n.onreadystatechange=()=>{if(4===n.readyState)if(200===n.status){let e=n.response;this.parse(t,e)}else console.log("Failed to load file! HTTP status: "+n.status+", file: "+i)},n.send(null)}parse(t,e){let i=new LASFile(e),n=new Tb(t);i.open().then((t=>(i.isOpen=!0,i))).catch((t=>{console.log("failed to open file. :(")})).then((t=>t.getHeader().then((function(e){return[t,e]})))).then((t=>{let e=t[0],i=t[1],r=0,s=i.pointsCount,o=function(){return e.readData(1e6,0,1).then((function(t){return n.push(new LASDecoder(t.buffer,i.pointsFormatId,i.pointsStructSize,t.count,i.scale,i.offset,i.mins,i.maxs)),r+=t.count,Mb.progressCB(r/s),t.hasMoreData?o():(i.totalRead=r,i.versionAsString=e.versionAsString,i.isCompressed=e.isCompressed,[e,i,n])}))};return o()})).then((t=>{let e=t[0];return Mb.progressCB(1),e.close().then((function(){return e.isOpen=!1,t.slice(1)})).catch((t=>{if(e.isOpen)return e.close().then((function(){throw e.isOpen=!1,t}));throw t}))}))}handle(t,e){}}class Tb{constructor(t){this.node=t}push(t){let e=Potree.scriptPath+"/workers/LASDecoderWorker.js",i=Potree.workerPool.getWorker(e);this.node;i.onmessage=n=>{let r=new fn,s=t.pointsCount,o=new Float32Array(n.data.position),a=new Uint8Array(n.data.color),h=new Float32Array(n.data.intensity),c=new Uint8Array(n.data.classification),l=new Uint8Array(n.data.returnNumber),u=new Uint8Array(n.data.numberOfReturns),d=new Uint16Array(n.data.pointSourceID),p=new Uint8Array(n.data.indices);r.setAttribute("position",new Yi(o,3)),r.setAttribute("color",new Yi(a,4,!0)),r.setAttribute("intensity",new Yi(h,1)),r.setAttribute("classification",new Yi(c,1)),r.setAttribute("returnNumber",new Yi(l,1)),r.setAttribute("numberOfReturns",new Yi(u,1)),r.setAttribute("pointSourceID",new Yi(d,1)),r.setAttribute("indices",new Yi(p,4)),r.attributes.indices.normalized=!0;let f=new ci((new pe).fromArray(n.data.tightBoundingBox.min),(new pe).fromArray(n.data.tightBoundingBox.max));r.boundingBox=this.node.boundingBox,this.node.tightBoundingBox=f,this.node.geometry=r,this.node.numPoints=s,this.node.loaded=!0,this.node.loading=!1,Potree.numNodesLoading--,this.node.mean=new pe(...n.data.mean),Potree.workerPool.returnWorker(e,i)};let n={buffer:t.arrayb,numPoints:t.pointsCount,pointSize:t.pointSize,pointFormatID:2,scale:t.scale,offset:t.offset,mins:t.mins,maxs:t.maxs};i.postMessage(n,[n.buffer])}}const Sb=0,Eb=1,Pb=4,Ab=5,Cb=6,Lb=7,Rb=8,Ib=9,Ob=10,Fb=11,Bb=12,Db=13,zb=14,Nb=15,Ub={DATA_TYPE_DOUBLE:{ordinal:0,size:8},DATA_TYPE_FLOAT:{ordinal:1,size:4},DATA_TYPE_INT8:{ordinal:2,size:1},DATA_TYPE_UINT8:{ordinal:3,size:1},DATA_TYPE_INT16:{ordinal:4,size:2},DATA_TYPE_UINT16:{ordinal:5,size:2},DATA_TYPE_INT32:{ordinal:6,size:4},DATA_TYPE_UINT32:{ordinal:7,size:4},DATA_TYPE_INT64:{ordinal:8,size:8},DATA_TYPE_UINT64:{ordinal:9,size:8}};let Vb=0;for(let t in Ub)Ub[Vb]=Ub[t],Vb++;class kb{constructor(t,e,i){this.name=t,this.type=e,this.numElements=i,this.byteSize=this.numElements*this.type.size}}kb.POSITION_CARTESIAN=new kb(Sb,Ub.DATA_TYPE_FLOAT,3),kb.RGBA_PACKED=new kb(Eb,Ub.DATA_TYPE_INT8,4),kb.COLOR_PACKED=kb.RGBA_PACKED,kb.RGB_PACKED=new kb(Eb,Ub.DATA_TYPE_INT8,3),kb.NORMAL_FLOATS=new kb(Pb,Ub.DATA_TYPE_FLOAT,3),kb.FILLER_1B=new kb(Ab,Ub.DATA_TYPE_UINT8,1),kb.INTENSITY=new kb(Cb,Ub.DATA_TYPE_UINT16,1),kb.CLASSIFICATION=new kb(Lb,Ub.DATA_TYPE_UINT8,1),kb.NORMAL_SPHEREMAPPED=new kb(Rb,Ub.DATA_TYPE_UINT8,2),kb.NORMAL_OCT16=new kb(Ib,Ub.DATA_TYPE_UINT8,2),kb.NORMAL=new kb(Ob,Ub.DATA_TYPE_FLOAT,3),kb.RETURN_NUMBER=new kb(Fb,Ub.DATA_TYPE_UINT8,1),kb.NUMBER_OF_RETURNS=new kb(Bb,Ub.DATA_TYPE_UINT8,1),kb.SOURCE_ID=new kb(Db,Ub.DATA_TYPE_UINT8,1),kb.INDICES=new kb(zb,Ub.DATA_TYPE_UINT32,1),kb.SPACING=new kb(Nb,Ub.DATA_TYPE_FLOAT,1);class jb{constructor(t){if(this.attributes=[],this.byteSize=0,this.size=0,null!=t)for(let e=0;e<t.length;e++){let i=t[e],n=kb[i];this.attributes.push(n),this.byteSize+=n.byteSize,this.size++}}add(t){this.attributes.push(t),this.byteSize+=t.byteSize,this.size++}hasColors(){for(let t in this.attributes){if(this.attributes[t].name===Eb)return!0}return!1}hasNormals(){for(let t in this.attributes){let e=this.attributes[t];if(e===kb.NORMAL_SPHEREMAPPED||e===kb.NORMAL_FLOATS||e===kb.NORMAL||e===kb.NORMAL_OCT16)return!0}return!1}}class Hb{constructor(t,e,i){this.version="string"==typeof t?new wb(t):t,this.boundingBox=e,this.scale=i}load(t){if(t.loaded)return;let e=t.getURL();this.version.equalOrHigher("1.4")&&(e+=".bin");let i=kv.createXMLHttpRequest();i.open("GET",e,!0),i.responseType="arraybuffer",i.overrideMimeType("text/plain; charset=x-user-defined"),i.onreadystatechange=()=>{if(4===i.readyState){if(200!==i.status&&0!==i.status||null===i.response)throw new Error(`Failed to load file! HTTP status: ${i.status}, file: ${e}`);{let e=i.response;this.parse(t,e)}}};try{i.send(null)}catch(t){console.log("fehler beim laden der punktwolke: "+t)}}parse(t,e){let i=t.pcoGeometry.pointAttributes,n=e.byteLength/t.pcoGeometry.pointAttributes.byteSize;this.version.upTo("1.5")&&(t.numPoints=n);let r=Potree.scriptPath+"/workers/BinaryDecoderWorker.js",s=Potree.workerPool.getWorker(r);s.onmessage=function(e){let n=e.data,o=n.attributeBuffers,a=new ci((new pe).fromArray(n.tightBoundingBox.min),(new pe).fromArray(n.tightBoundingBox.max));Potree.workerPool.returnWorker(r,s);let h=new fn;for(let t in o){let e=o[t].buffer;if(parseInt(t)===Sb)h.setAttribute("position",new Yi(new Float32Array(e),3));else if(parseInt(t)===Eb)h.setAttribute("color",new Yi(new Uint8Array(e),4,!0));else if(parseInt(t)===Cb)h.setAttribute("intensity",new Yi(new Float32Array(e),1));else if(parseInt(t)===Lb)h.setAttribute("classification",new Yi(new Uint8Array(e),1));else if(parseInt(t)===Rb)h.setAttribute("normal",new Yi(new Float32Array(e),3));else if(parseInt(t)===Ib)h.setAttribute("normal",new Yi(new Float32Array(e),3));else if(parseInt(t)===Ob)h.setAttribute("normal",new Yi(new Float32Array(e),3));else if(parseInt(t)===zb){let t=new Yi(new Uint8Array(e),4);t.normalized=!0,h.setAttribute("indices",t)}else if(parseInt(t)===Nb){let t=new Yi(new Float32Array(e),1);h.setAttribute("spacing",t)}}a.max.sub(a.min),a.min.set(0,0,0);let c=e.data.buffer.byteLength/i.byteSize;t.numPoints=c,t.geometry=h,t.mean=new pe(...n.mean),t.tightBoundingBox=a,t.loaded=!0,t.loading=!1,t.estimatedSpacing=n.estimatedSpacing,Potree.numNodesLoading--};let o={buffer:e,pointAttributes:i,version:this.version.version,min:[t.boundingBox.min.x,t.boundingBox.min.y,t.boundingBox.min.z],offset:[t.pcoGeometry.offset.x,t.pcoGeometry.offset.y,t.pcoGeometry.offset.z],scale:this.scale,spacing:t.spacing,hasChildren:t.hasChildren,name:t.name};s.postMessage(o,[o.buffer])}}var Gb=484813681109536e-20,Wb=Math.PI/2,qb=1e-10,Xb=.017453292519943295,Yb=57.29577951308232,Zb=Math.PI/4,$b=2*Math.PI,Jb=3.14159265359,Qb={greenwich:0,lisbon:-9.131906111111,paris:2.337229166667,bogota:-74.080916666667,madrid:-3.687938888889,rome:12.452333333333,bern:7.439583333333,jakarta:106.807719444444,ferro:-17.666666666667,brussels:4.367975,stockholm:18.058277777778,athens:23.7163375,oslo:10.722916666667},Kb={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}},ty=/[\s_\-\/\(\)]/g;function ey(t,e){if(t[e])return t[e];for(var i,n=Object.keys(t),r=e.toLowerCase().replace(ty,""),s=-1;++s<n.length;)if((i=n[s]).toLowerCase().replace(ty,"")===r)return t[i]}var iy=function(t){var e,i,n,r={},s=t.split("+").map((function(t){return t.trim()})).filter((function(t){return t})).reduce((function(t,e){var i=e.split("=");return i.push(!0),t[i[0].toLowerCase()]=i[1],t}),{}),o={proj:"projName",datum:"datumCode",rf:function(t){r.rf=parseFloat(t)},lat_0:function(t){r.lat0=t*Xb},lat_1:function(t){r.lat1=t*Xb},lat_2:function(t){r.lat2=t*Xb},lat_ts:function(t){r.lat_ts=t*Xb},lon_0:function(t){r.long0=t*Xb},lon_1:function(t){r.long1=t*Xb},lon_2:function(t){r.long2=t*Xb},alpha:function(t){r.alpha=parseFloat(t)*Xb},lonc:function(t){r.longc=t*Xb},x_0:function(t){r.x0=parseFloat(t)},y_0:function(t){r.y0=parseFloat(t)},k_0:function(t){r.k0=parseFloat(t)},k:function(t){r.k0=parseFloat(t)},a:function(t){r.a=parseFloat(t)},b:function(t){r.b=parseFloat(t)},r_a:function(){r.R_A=!0},zone:function(t){r.zone=parseInt(t,10)},south:function(){r.utmSouth=!0},towgs84:function(t){r.datum_params=t.split(",").map((function(t){return parseFloat(t)}))},to_meter:function(t){r.to_meter=parseFloat(t)},units:function(t){r.units=t;var e=ey(Kb,t);e&&(r.to_meter=e.to_meter)},from_greenwich:function(t){r.from_greenwich=t*Xb},pm:function(t){var e=ey(Qb,t);r.from_greenwich=(e||parseFloat(t))*Xb},nadgrids:function(t){"@null"===t?r.datumCode="none":r.nadgrids=t},axis:function(t){var e="ewnsud";3===t.length&&-1!==e.indexOf(t.substr(0,1))&&-1!==e.indexOf(t.substr(1,1))&&-1!==e.indexOf(t.substr(2,1))&&(r.axis=t)}};for(e in s)i=s[e],e in o?"function"==typeof(n=o[e])?n(i):r[n]=i:r[e]=i;return"string"==typeof r.datumCode&&"WGS84"!==r.datumCode&&(r.datumCode=r.datumCode.toLowerCase()),r},ny=function(t){return new cy(t).output()},ry=/\s/,sy=/[A-Za-z]/,oy=/[A-Za-z84]/,ay=/[,\]]/,hy=/[\d\.E\-\+]/;function cy(t){if("string"!=typeof t)throw new Error("not a string");this.text=t.trim(),this.level=0,this.place=0,this.root=null,this.stack=[],this.currentObject=null,this.state=1}function ly(t,e,i){Array.isArray(e)&&(i.unshift(e),e=null);var n=e?{}:t,r=i.reduce((function(t,e){return uy(e,t),t}),n);e&&(t[e]=r)}function uy(t,e){if(Array.isArray(t)){var i,n=t.shift();if("PARAMETER"===n&&(n=t.shift()),1===t.length)return Array.isArray(t[0])?(e[n]={},void uy(t[0],e[n])):void(e[n]=t[0]);if(t.length)if("TOWGS84"!==n)switch(Array.isArray(n)||(e[n]={}),n){case"UNIT":case"PRIMEM":case"VERT_DATUM":return e[n]={name:t[0].toLowerCase(),convert:t[1]},void(3===t.length&&uy(t[2],e[n]));case"SPHEROID":case"ELLIPSOID":return e[n]={name:t[0],a:t[1],rf:t[2]},void(4===t.length&&uy(t[3],e[n]));case"PROJECTEDCRS":case"PROJCRS":case"GEOGCS":case"GEOCCS":case"PROJCS":case"LOCAL_CS":case"GEODCRS":case"GEODETICCRS":case"GEODETICDATUM":case"EDATUM":case"ENGINEERINGDATUM":case"VERT_CS":case"VERTCRS":case"VERTICALCRS":case"COMPD_CS":case"COMPOUNDCRS":case"ENGINEERINGCRS":case"ENGCRS":case"FITTED_CS":case"LOCAL_DATUM":case"DATUM":return t[0]=["name",t[0]],void ly(e,n,t);default:for(i=-1;++i<t.length;)if(!Array.isArray(t[i]))return uy(t,e[n]);return ly(e,n,t)}else e[n]=t;else e[n]=!0}else e[t]=!0}cy.prototype.readCharicter=function(){var t=this.text[this.place++];if(4!==this.state)for(;ry.test(t);){if(this.place>=this.text.length)return;t=this.text[this.place++]}switch(this.state){case 1:return this.neutral(t);case 2:return this.keyword(t);case 4:return this.quoted(t);case 5:return this.afterquote(t);case 3:return this.number(t);case-1:return}},cy.prototype.afterquote=function(t){if('"'===t)return this.word+='"',void(this.state=4);if(ay.test(t))return this.word=this.word.trim(),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in afterquote yet, index '+this.place)},cy.prototype.afterItem=function(t){return","===t?(null!==this.word&&this.currentObject.push(this.word),this.word=null,void(this.state=1)):"]"===t?(this.level--,null!==this.word&&(this.currentObject.push(this.word),this.word=null),this.state=1,this.currentObject=this.stack.pop(),void(this.currentObject||(this.state=-1))):void 0},cy.prototype.number=function(t){if(!hy.test(t)){if(ay.test(t))return this.word=parseFloat(this.word),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in number yet, index '+this.place)}this.word+=t},cy.prototype.quoted=function(t){'"'!==t?this.word+=t:this.state=5},cy.prototype.keyword=function(t){if(oy.test(t))this.word+=t;else{if("["===t){var e=[];return e.push(this.word),this.level++,null===this.root?this.root=e:this.currentObject.push(e),this.stack.push(this.currentObject),this.currentObject=e,void(this.state=1)}if(!ay.test(t))throw new Error("havn't handled \""+t+'" in keyword yet, index '+this.place);this.afterItem(t)}},cy.prototype.neutral=function(t){if(sy.test(t))return this.word=t,void(this.state=2);if('"'===t)return this.word="",void(this.state=4);if(hy.test(t))return this.word=t,void(this.state=3);if(!ay.test(t))throw new Error("havn't handled \""+t+'" in neutral yet, index '+this.place);this.afterItem(t)},cy.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(-1===this.state)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function dy(t){return.017453292519943295*t}var py=function(t){var e=ny(t),i=e.shift(),n=e.shift();e.unshift(["name",n]),e.unshift(["type",i]);var r={};return uy(e,r),function(t){"GEOGCS"===t.type?t.projName="longlat":"LOCAL_CS"===t.type?(t.projName="identity",t.local=!0):"object"==typeof t.PROJECTION?t.projName=Object.keys(t.PROJECTION)[0]:t.projName=t.PROJECTION,t.UNIT&&(t.units=t.UNIT.name.toLowerCase(),"metre"===t.units&&(t.units="meter"),t.UNIT.convert&&("GEOGCS"===t.type?t.DATUM&&t.DATUM.SPHEROID&&(t.to_meter=t.UNIT.convert*t.DATUM.SPHEROID.a):t.to_meter=t.UNIT.convert));var e=t.GEOGCS;function i(e){return e*(t.to_meter||1)}"GEOGCS"===t.type&&(e=t),e&&(e.DATUM?t.datumCode=e.DATUM.name.toLowerCase():t.datumCode=e.name.toLowerCase(),"d_"===t.datumCode.slice(0,2)&&(t.datumCode=t.datumCode.slice(2)),"new_zealand_geodetic_datum_1949"!==t.datumCode&&"new_zealand_1949"!==t.datumCode||(t.datumCode="nzgd49"),"wgs_1984"===t.datumCode&&("Mercator_Auxiliary_Sphere"===t.PROJECTION&&(t.sphere=!0),t.datumCode="wgs84"),"_ferro"===t.datumCode.slice(-6)&&(t.datumCode=t.datumCode.slice(0,-6)),"_jakarta"===t.datumCode.slice(-8)&&(t.datumCode=t.datumCode.slice(0,-8)),~t.datumCode.indexOf("belge")&&(t.datumCode="rnb72"),e.DATUM&&e.DATUM.SPHEROID&&(t.ellps=e.DATUM.SPHEROID.name.replace("_19","").replace(/[Cc]larke\_18/,"clrk"),"international"===t.ellps.toLowerCase().slice(0,13)&&(t.ellps="intl"),t.a=e.DATUM.SPHEROID.a,t.rf=parseFloat(e.DATUM.SPHEROID.rf,10)),e.DATUM&&e.DATUM.TOWGS84&&(t.datum_params=e.DATUM.TOWGS84),~t.datumCode.indexOf("osgb_1936")&&(t.datumCode="osgb36"),~t.datumCode.indexOf("osni_1952")&&(t.datumCode="osni52"),(~t.datumCode.indexOf("tm65")||~t.datumCode.indexOf("geodetic_datum_of_1965"))&&(t.datumCode="ire65"),"ch1903+"===t.datumCode&&(t.datumCode="ch1903"),~t.datumCode.indexOf("israel")&&(t.datumCode="isr93")),t.b&&!isFinite(t.b)&&(t.b=t.a),[["standard_parallel_1","Standard_Parallel_1"],["standard_parallel_2","Standard_Parallel_2"],["false_easting","False_Easting"],["false_northing","False_Northing"],["central_meridian","Central_Meridian"],["latitude_of_origin","Latitude_Of_Origin"],["latitude_of_origin","Central_Parallel"],["scale_factor","Scale_Factor"],["k0","scale_factor"],["latitude_of_center","Latitude_Of_Center"],["latitude_of_center","Latitude_of_center"],["lat0","latitude_of_center",dy],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",dy],["x0","false_easting",i],["y0","false_northing",i],["long0","central_meridian",dy],["lat0","latitude_of_origin",dy],["lat0","standard_parallel_1",dy],["lat1","standard_parallel_1",dy],["lat2","standard_parallel_2",dy],["azimuth","Azimuth"],["alpha","azimuth",dy],["srsCode","name"]].forEach((function(e){return i=t,r=(n=e)[0],s=n[1],void(!(r in i)&&s in i&&(i[r]=i[s],3===n.length&&(i[r]=n[2](i[r]))));var i,n,r,s})),t.long0||!t.longc||"Albers_Conic_Equal_Area"!==t.projName&&"Lambert_Azimuthal_Equal_Area"!==t.projName||(t.long0=t.longc),t.lat_ts||!t.lat1||"Stereographic_South_Pole"!==t.projName&&"Polar Stereographic (variant B)"!==t.projName||(t.lat0=dy(t.lat1>0?90:-90),t.lat_ts=t.lat1)}(r),r};function fy(t){var e=this;if(2===arguments.length){var i=arguments[1];"string"==typeof i?"+"===i.charAt(0)?fy[t]=iy(arguments[1]):fy[t]=py(arguments[1]):fy[t]=i}else if(1===arguments.length){if(Array.isArray(t))return t.map((function(t){Array.isArray(t)?fy.apply(e,t):fy(t)}));if("string"==typeof t){if(t in fy)return fy[t]}else"EPSG"in t?fy["EPSG:"+t.EPSG]=t:"ESRI"in t?fy["ESRI:"+t.ESRI]=t:"IAU2000"in t?fy["IAU2000:"+t.IAU2000]=t:console.log(t);return}}!function(t){t("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),t("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),t("EPSG:3857","+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"),t.WGS84=t["EPSG:4326"],t["EPSG:3785"]=t["EPSG:3857"],t.GOOGLE=t["EPSG:3857"],t["EPSG:900913"]=t["EPSG:3857"],t["EPSG:102113"]=t["EPSG:3857"]}(fy);var my=fy;var gy=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];var vy=["3857","900913","3785","102113"];var by=function(t){if(!function(t){return"string"==typeof t}(t))return t;if(function(t){return t in my}(t))return my[t];if(function(t){return gy.some((function(e){return t.indexOf(e)>-1}))}(t)){var e=py(t);if(function(t){var e=ey(t,"authority");if(e){var i=ey(e,"epsg");return i&&vy.indexOf(i)>-1}}(e))return my["EPSG:3857"];var i=function(t){var e=ey(t,"extension");if(e)return ey(e,"proj4")}(e);return i?iy(i):e}return function(t){return"+"===t[0]}(t)?iy(t):void 0},yy=function(t,e){var i,n;if(t=t||{},!e)return t;for(n in e)void 0!==(i=e[n])&&(t[n]=i);return t},_y=function(t,e,i){var n=t*e;return i/Math.sqrt(1-n*n)},xy=function(t){return t<0?-1:1},wy=function(t){return Math.abs(t)<=Jb?t:t-xy(t)*$b},My=function(t,e,i){var n=t*i,r=.5*t;return n=Math.pow((1-n)/(1+n),r),Math.tan(.5*(Wb-e))/n},Ty=function(t,e){for(var i,n,r=.5*t,s=Wb-2*Math.atan(e),o=0;o<=15;o++)if(i=t*Math.sin(s),s+=n=Wb-2*Math.atan(e*Math.pow((1-i)/(1+i),r))-s,Math.abs(n)<=1e-10)return s;return-9999};function Sy(t){return t}var Ey=[{init:function(){var t=this.b/this.a;this.es=1-t*t,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=_y(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)},forward:function(t){var e,i,n=t.x,r=t.y;if(r*Yb>90&&r*Yb<-90&&n*Yb>180&&n*Yb<-180)return null;if(Math.abs(Math.abs(r)-Wb)<=qb)return null;if(this.sphere)e=this.x0+this.a*this.k0*wy(n-this.long0),i=this.y0+this.a*this.k0*Math.log(Math.tan(Zb+.5*r));else{var s=Math.sin(r),o=My(this.e,r,s);e=this.x0+this.a*this.k0*wy(n-this.long0),i=this.y0-this.a*this.k0*Math.log(o)}return t.x=e,t.y=i,t},inverse:function(t){var e,i,n=t.x-this.x0,r=t.y-this.y0;if(this.sphere)i=Wb-2*Math.atan(Math.exp(-r/(this.a*this.k0)));else{var s=Math.exp(-r/(this.a*this.k0));if(-9999===(i=Ty(this.e,s)))return null}return e=wy(this.long0+n/(this.a*this.k0)),t.x=e,t.y=i,t},names:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"]},{init:function(){},forward:Sy,inverse:Sy,names:["longlat","identity"]}],Py={},Ay=[];function Cy(t,e){var i=Ay.length;return t.names?(Ay[i]=t,t.names.forEach((function(t){Py[t.toLowerCase()]=i})),this):(console.log(e),!0)}var Ly={start:function(){Ey.forEach(Cy)},add:Cy,get:function(t){if(!t)return!1;var e=t.toLowerCase();return void 0!==Py[e]&&Ay[Py[e]]?Ay[Py[e]]:void 0}},Ry={MERIT:{a:6378137,rf:298.257,ellipseName:"MERIT 1983"},SGS85:{a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"},GRS80:{a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"},IAU76:{a:6378140,rf:298.257,ellipseName:"IAU 1976"},airy:{a:6377563.396,b:6356256.91,ellipseName:"Airy 1830"},APL4:{a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"},NWL9D:{a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"},mod_airy:{a:6377340.189,b:6356034.446,ellipseName:"Modified Airy"},andrae:{a:6377104.43,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"},aust_SA:{a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"},GRS67:{a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"},bessel:{a:6377397.155,rf:299.1528128,ellipseName:"Bessel 1841"},bess_nam:{a:6377483.865,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"},clrk66:{a:6378206.4,b:6356583.8,ellipseName:"Clarke 1866"},clrk80:{a:6378249.145,rf:293.4663,ellipseName:"Clarke 1880 mod."},clrk58:{a:6378293.645208759,rf:294.2606763692654,ellipseName:"Clarke 1858"},CPM:{a:6375738.7,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"},delmbr:{a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"},engelis:{a:6378136.05,rf:298.2566,ellipseName:"Engelis 1985"},evrst30:{a:6377276.345,rf:300.8017,ellipseName:"Everest 1830"},evrst48:{a:6377304.063,rf:300.8017,ellipseName:"Everest 1948"},evrst56:{a:6377301.243,rf:300.8017,ellipseName:"Everest 1956"},evrst69:{a:6377295.664,rf:300.8017,ellipseName:"Everest 1969"},evrstSS:{a:6377298.556,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"},fschr60:{a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"},fschr60m:{a:6378155,rf:298.3,ellipseName:"Fischer 1960"},fschr68:{a:6378150,rf:298.3,ellipseName:"Fischer 1968"},helmert:{a:6378200,rf:298.3,ellipseName:"Helmert 1906"},hough:{a:6378270,rf:297,ellipseName:"Hough"},intl:{a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"},kaula:{a:6378163,rf:298.24,ellipseName:"Kaula 1961"},lerch:{a:6378139,rf:298.257,ellipseName:"Lerch 1979"},mprts:{a:6397300,rf:191,ellipseName:"Maupertius 1738"},new_intl:{a:6378157.5,b:6356772.2,ellipseName:"New International 1967"},plessis:{a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"},krass:{a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"},SEasia:{a:6378155,b:6356773.3205,ellipseName:"Southeast Asia"},walbeck:{a:6376896,b:6355834.8467,ellipseName:"Walbeck"},WGS60:{a:6378165,rf:298.3,ellipseName:"WGS 60"},WGS66:{a:6378145,rf:298.25,ellipseName:"WGS 66"},WGS7:{a:6378135,rf:298.26,ellipseName:"WGS 72"}},Iy=Ry.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};Ry.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};var Oy={};Oy.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},Oy.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},Oy.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},Oy.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},Oy.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},Oy.potsdam={towgs84:"606.0,23.0,413.0",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},Oy.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},Oy.hermannskogel={towgs84:"653.0,-212.0,449.0",ellipse:"bessel",datumName:"Hermannskogel"},Oy.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},Oy.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},Oy.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},Oy.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},Oy.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"},Oy.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},Oy.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},Oy.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},Oy.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};var Fy=function(t,e,i,n,r,s){var o={};return o.datum_type=void 0===t||"none"===t?5:4,e&&(o.datum_params=e.map(parseFloat),0===o.datum_params[0]&&0===o.datum_params[1]&&0===o.datum_params[2]||(o.datum_type=1),o.datum_params.length>3&&(0===o.datum_params[3]&&0===o.datum_params[4]&&0===o.datum_params[5]&&0===o.datum_params[6]||(o.datum_type=2,o.datum_params[3]*=Gb,o.datum_params[4]*=Gb,o.datum_params[5]*=Gb,o.datum_params[6]=o.datum_params[6]/1e6+1))),o.a=i,o.b=n,o.es=r,o.ep2=s,o};function By(t,e){if(!(this instanceof By))return new By(t);e=e||function(t){if(t)throw t};var i=by(t);if("object"==typeof i){var n=By.projections.get(i.projName);if(n){if(i.datumCode&&"none"!==i.datumCode){var r=ey(Oy,i.datumCode);r&&(i.datum_params=r.towgs84?r.towgs84.split(","):null,i.ellps=r.ellipse,i.datumName=r.datumName?r.datumName:i.datumCode)}i.k0=i.k0||1,i.axis=i.axis||"enu",i.ellps=i.ellps||"wgs84";var s,o,a,h,c,l,u,d=function(t,e,i,n,r){if(!t){var s=ey(Ry,n);s||(s=Iy),t=s.a,e=s.b,i=s.rf}return i&&!e&&(e=(1-1/i)*t),(0===i||Math.abs(t-e)<qb)&&(r=!0,e=t),{a:t,b:e,rf:i,sphere:r}}(i.a,i.b,i.rf,i.ellps,i.sphere),p=(s=d.a,o=d.b,d.rf,a=i.R_A,l=((h=s*s)-(c=o*o))/h,u=0,a?(h=(s*=1-l*(.16666666666666666+l*(.04722222222222222+.022156084656084655*l)))*s,l=0):u=Math.sqrt(l),{es:l,e:u,ep2:(h-c)/c}),f=i.datum||Fy(i.datumCode,i.datum_params,d.a,d.b,p.es,p.ep2);yy(this,i),yy(this,n),this.a=d.a,this.b=d.b,this.rf=d.rf,this.sphere=d.sphere,this.es=p.es,this.e=p.e,this.ep2=p.ep2,this.datum=f,this.init(),e(null,this)}else e(t)}else e(t)}By.projections=Ly,By.projections.start();var Dy=By;my("UTM10N","+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs");class zy{constructor(){this.points=[];let t=zy.getMaterialInstance();t.uniforms.minSize.value=2,t.uniforms.maxSize.value=2,t.pointColorType=Jv.RGB,t.opacity=1,this.material=t,this.sceneNode=new Ye}static releaseMaterialInstance(t){zy.materialPool.add(t)}static getMaterialInstance(){let t=zy.materialPool.values().next().value;return t?zy.materialPool.delete(t):t=new cb,t}dispose(){for(let t of this.sceneNode.children)zy.releaseMaterialInstance(t.material),t.geometry.dispose();this.sceneNode.children=[]}addPoints(t){this.points.push(t);let e=1e4,i=()=>{let t=new fn,i={position:new Float32Array(3e4),color:new Uint8Array(4e4),intensity:new Uint16Array(e),classification:new Uint8Array(e),returnNumber:new Uint8Array(e),numberOfReturns:new Uint8Array(e),pointSourceID:new Uint16Array(e)};t.setAttribute("position",new Yi(i.position,3)),t.setAttribute("color",new Yi(i.color,4,!0)),t.setAttribute("intensity",new Yi(i.intensity,1,!1)),t.setAttribute("classification",new Yi(i.classification,1,!1)),t.setAttribute("returnNumber",new Yi(i.returnNumber,1,!1)),t.setAttribute("numberOfReturns",new Yi(i.numberOfReturns,1,!1)),t.setAttribute("pointSourceID",new Yi(i.pointSourceID,1,!1)),t.drawRange.start=0,t.drawRange.count=0,this.currentBatch=new ta(t,this.material),this.sceneNode.add(this.currentBatch)};this.currentBatch||i();{let n={start:this.currentBatch.geometry.drawRange.count,count:0},r=new ci;for(let s=0;s<t.numPoints;s++){if(n.start+n.count>=e){for(let t of Object.keys(this.currentBatch.geometry.attributes)){let e=this.currentBatch.geometry.attributes[t];e.updateRange.offset=n.start,e.updateRange.count=n.count,e.needsUpdate=!0}this.currentBatch.geometry.computeBoundingBox(),this.currentBatch.geometry.computeBoundingSphere(),i(),n={start:0,count:0}}let o=t.data.mileage[s],a=0,h=t.data.position[3*s+2];r.expandByPoint(new pe(o,a,h));let c=n.start+n.count,l=this.currentBatch.geometry.attributes;l.position.array[3*c+0]=o,l.position.array[3*c+1]=a,l.position.array[3*c+2]=h,t.data.color&&(l.color.array[4*c+0]=t.data.color[4*s+0],l.color.array[4*c+1]=t.data.color[4*s+1],l.color.array[4*c+2]=t.data.color[4*s+2],l.color.array[4*c+3]=255),t.data.intensity&&(l.intensity.array[c]=t.data.intensity[s]),t.data.classification&&(l.classification.array[c]=t.data.classification[s]),t.data.returnNumber&&(l.returnNumber.array[c]=t.data.returnNumber[s]),t.data.numberOfReturns&&(l.numberOfReturns.array[c]=t.data.numberOfReturns[s]),t.data.pointSourceID&&(l.pointSourceID.array[c]=t.data.pointSourceID[s]),n.count++,this.currentBatch.geometry.drawRange.count++}for(let t of Object.keys(this.currentBatch.geometry.attributes)){let e=this.currentBatch.geometry.attributes[t];e.updateRange.offset=n.start,e.updateRange.count=n.count,e.needsUpdate=!0}t.projectedBox=r,this.projectedBox=this.points.reduce(((t,e)=>t.union(e.projectedBox)),new ci)}}}zy.materialPool=new Set;Oc.prototype.zoomTo=function(t,e=1){(t.geometry||t.boundingBox)&&this.updateProjectionMatrix()},Xn.prototype.zoomTo=function(t,e){if(!t.geometry&&!t.boundingSphere&&!t.boundingBox)return;let i;t.geometry&&null===t.geometry.boundingSphere&&t.geometry.computeBoundingSphere(),t.updateMatrixWorld(),i=t.boundingSphere?t.boundingSphere:t.geometry&&t.geometry.boundingSphere?t.geometry.boundingSphere:t.boundingBox.getBoundingSphere(new di);let n=e||1;i=i.clone().applyMatrix4(t.matrixWorld);let r=i.radius,s=this.fov*Math.PI/180;this.aspect<1&&(s*=this.aspect);let o=Math.abs(r/Math.sin(s/2))*n,a=this.getWorldDirection(new pe).multiplyScalar(-o);this.position.copy(i.center.clone().add(a))},_i.prototype.distanceToPlaneWithNegative=function(t){let e=t.normal.dot(this.direction);return 0===e?0===t.distanceToPoint(this.origin)?0:null:-(this.origin.dot(t.normal)+t.constant)/e},window.Potree=window.Potree||function(){};const Ny=new class{constructor(){this.workers={}}getWorker(t){if(this.workers[t]||(this.workers[t]=[]),0===this.workers[t].length){let e=new Worker(t);this.workers[t].push(e)}return this.workers[t].pop()}returnWorker(t,e){this.workers[t].push(e)}},Uy=1,Vy=6,ky="";let jy=new class{constructor(){this.first=null,this.last=null,this.items={},this.elements=0,this.numPoints=0}size(){return this.elements}contains(t){return null==this.items[t.id]}touch(t){if(!t.loaded)return;let e;null==this.items[t.id]?(e=new eb(t),e.previous=this.last,this.last=e,null!==e.previous&&(e.previous.next=e),this.items[t.id]=e,this.elements++,null===this.first&&(this.first=e),this.numPoints+=t.numPoints):(e=this.items[t.id],null===e.previous?null!==e.next&&(this.first=e.next,this.first.previous=null,e.previous=this.last,e.next=null,this.last=e,e.previous.next=e):null===e.next||(e.previous.next=e.next,e.next.previous=e.previous,e.previous=this.last,e.next=null,this.last=e,e.previous.next=e))}remove(t){let e=this.items[t.id];e&&(1===this.elements?(this.first=null,this.last=null):(e.previous||(this.first=e.next,this.first.previous=null),e.next||(this.last=e.previous,this.last.next=null),e.previous&&e.next&&(e.previous.next=e.next,e.next.previous=e.previous)),delete this.items[t.id],this.elements--,this.numPoints-=t.numPoints)}getLRUItem(){if(null===this.first)return null;return this.first.node}toString(){let t="{ ",e=this.first;for(;null!==e;)t+=e.node.id,null!==e.next&&(t+=", "),e=e.next;return t+="}",t+="("+this.size()+")",t}freeMemory(){if(!(this.elements<=1))for(;this.numPoints>Potree.pointLoadLimit;){let t=this.first.node;this.disposeDescendants(t)}}disposeDescendants(t){let e=[];for(e.push(t);e.length>0;){let t=e.pop();t.dispose(),this.remove(t);for(let i in t.children)if(t.children.hasOwnProperty(i)){t.children[i].loaded&&e.push(t.children[i])}}}};console.log("Potree "+Uy+"."+Vy+ky);let Hy="";document.currentScript&&document.currentScript.src?(Hy=new URL(document.currentScript.src+"/..").href,"/"===Hy.slice(-1)&&(Hy=Hy.slice(0,-1))):window.__viewer_baseURL&&(Hy=window.__viewer_baseURL+"dist/build/potree");const Gy=Hy+"/resources";function Wy(t,e,i){let n=function(t){t.name=e,i({type:"pointcloud_loaded",pointcloud:t})};t&&(0===t.indexOf("greyhound://")?GreyhoundLoader.load(t,(function(e){if(e){let t=new db(e);n(t)}else console.error(new Error(`failed to load point cloud from URL: ${t}`))})):t.indexOf("cloud.js")>0?class{static load(t,e){try{let i=new rb;i.url=t;let n=kv.createXMLHttpRequest();n.open("GET",t,!0),n.onreadystatechange=function(){if(4===n.readyState&&(200===n.status||0===n.status)){let r=JSON.parse(n.responseText),s=new wb(r.version);0===r.octreeDir.indexOf("http")?i.octreeDir=r.octreeDir:i.octreeDir=t+"/../"+r.octreeDir,i.spacing=r.spacing,i.hierarchyStepSize=r.hierarchyStepSize,i.pointAttributes=r.pointAttributes;let o=new pe(r.boundingBox.lx,r.boundingBox.ly,r.boundingBox.lz),a=new ci(o,new pe(r.boundingBox.ux,r.boundingBox.uy,r.boundingBox.uz)),h=a.clone();r.tightBoundingBox&&(h.min.copy(new pe(r.tightBoundingBox.lx,r.tightBoundingBox.ly,r.tightBoundingBox.lz)),h.max.copy(new pe(r.tightBoundingBox.ux,r.tightBoundingBox.uy,r.tightBoundingBox.uz)));let c=o.clone();a.min.sub(c),a.max.sub(c),h.min.sub(c),h.max.sub(c),i.projection=r.projection,i.boundingBox=a,i.tightBoundingBox=h,i.boundingSphere=a.getBoundingSphere(new di),i.tightBoundingSphere=h.getBoundingSphere(new di),i.offset=c,"LAS"===r.pointAttributes||"LAZ"===r.pointAttributes?i.loader=new Mb(r.version):(i.loader=new Hb(r.version,a,r.scale),i.pointAttributes=new jb(i.pointAttributes));let l={};{let t="r",e=new sb(t,i,a);e.level=0,e.hasChildren=!0,e.spacing=i.spacing,s.upTo("1.5")?e.numPoints=r.hierarchy[0][1]:e.numPoints=0,i.root=e,i.root.load(),l[t]=e}if(s.upTo("1.4"))for(let t=1;t<r.hierarchy.length;t++){let e=r.hierarchy[t][0],n=r.hierarchy[t][1],s=parseInt(e.charAt(e.length-1)),o=l[e.substring(0,e.length-1)],a=e.length-1,h=tb.createChildAABB(o.boundingBox,s),c=new sb(e,i,h);c.level=a,c.numPoints=n,c.spacing=i.spacing/Math.pow(2,a),o.addChild(c),l[e]=c}i.nodes=l,e(i)}},n.send(null)}catch(i){console.log("loading failed: '"+t+"'"),console.log(i),e()}}loadPointAttributes(t){let e=t.pointAttributes,i=new jb;for(let t=0;t<e.length;t++){let n=kb[e[t]];i.add(n)}return i}createChildAABB(t,e){let i=t.min.clone(),n=t.max.clone(),r=(new pe).subVectors(n,i);return(1&e)>0?i.z+=r.z/2:n.z-=r.z/2,(2&e)>0?i.y+=r.y/2:n.y-=r.y/2,(4&e)>0?i.x+=r.x/2:n.x-=r.x/2,new ci(i,n)}}.load(t,(function(e){if(e){let t=new db(e);n(t)}else console.error(new Error(`failed to load point cloud from URL: ${t}`))})):t.indexOf(".vpc")>0?PointCloudArena4DGeometry.load(t,(function(e){if(e){let t=new PointCloudArena4D(e);n(t)}else console.error(new Error(`failed to load point cloud from URL: ${t}`))})):console.error(new Error(`failed to load point cloud from URL: ${t}`)))}window.Potree.scriptPath=window.Potree.scriptPath||Hy,window.Potree.resourcePath=window.Potree.resourcePath||Gy,window.Potree.lru=jy,window.Potree.workerPool=Ny,window.Potree.PointCloudMaterial=cb,window.Potree.PointColorType=Jv,window.Potree.ClipTask=Xv,window.Potree.pointBudget=1e6,window.Potree.framenumber=0,window.Potree.numNodesLoading=0,window.Potree.maxNodesLoading=4;class qy{constructor(t,e,i){this.radius=1.4,this.strength=.4,this._renderer=t.renderer,this._potreeRenderer=e,this.useFragDepthExtension=!i&&t.isFragDepthAvailable(),this._edlMaterial=new Xy(this.useFragDepthExtension);const n=t.isWebgl2()?Et:St;this.useFragDepthExtension||t.composer.readBuffer.depthTexture||(t.composer.readBuffer.depthTexture=new sa(void 0,void 0,n),t.composer.writeBuffer.depthTexture=t.composer.readBuffer.depthTexture.clone()),this._vec2=new ce;const r=new sa(void 0,void 0,n);this._rtEDL=new xe(t.width,t.height,{minFilter:ft,magFilter:ft,format:Ft,type:t.isHalfFloatTextureTypeAvailable()?Pt:Mt,depthTexture:r})}setSize(t,e){this._rtEDL.setSize(t,e)}render(t,e,i,n){this._renderer.setClearAlpha(0),this._renderer.setRenderTarget(this._rtEDL),this._renderer.clear(!0,!0,!0);const{width:r,height:s}=this._renderer.getSize(this._vec2);for(const e of t.children){e.children[0].material.useEDL=!0}this._potreeRenderer.render(t,e,this._rtEDL);for(const e of t.children){e.children[0].material.useEDL=!1}this._edlMaterial.uniforms.screenWidth.value=r,this._edlMaterial.uniforms.screenHeight.value=s,this._edlMaterial.uniforms.uRegularColor.value=n.texture,this._edlMaterial.uniforms.uEDLColor.value=this._rtEDL.texture,this._edlMaterial.uniforms.uRegularDepth.value=n.depthTexture,this._edlMaterial.uniforms.uEDLDepth.value=this._rtEDL.depthTexture,this._edlMaterial.uniforms.edlStrength.value=this.strength,this._edlMaterial.uniforms.radius.value=this.radius,this._renderer.state.setBlending(0),this._renderer.setRenderTarget(i),tb.screenPass.render(this._renderer,this._edlMaterial)}}class Xy extends Wn{constructor(t){super(),this.fs="\nuniform float screenWidth;\nuniform float screenHeight;\nuniform vec2 neighbours[NEIGHBOUR_COUNT];\nuniform float edlStrength;\nuniform float radius;\n\nuniform sampler2D uRegularColor;\nuniform sampler2D uRegularDepth;\nuniform sampler2D uEDLColor;\nuniform sampler2D uEDLDepth;\n\nvarying vec2 vUv;\n\nfloat response(float depth){\n\tvec2 uvRadius = radius / vec2(screenWidth, screenHeight);\n\t\n\tfloat sum = 0.0;\n\t\n\tfor(int i = 0; i < NEIGHBOUR_COUNT; i++){\n\t\tvec2 uvNeighbor = vUv + uvRadius * neighbours[i];\n\t\t\n\t\tfloat neighbourDepth = texture2D(uEDLColor, uvNeighbor).a;\n\t\tneighbourDepth = (neighbourDepth == 1.0) ? 0.0 : neighbourDepth;\n\n\t\tif(neighbourDepth != 0.0){\n\t\t\tif(depth == 0.0){\n\t\t\t\tsum += 100.0;\n\t\t\t}else{\n\t\t\t\tsum += max(0.0, depth - neighbourDepth);\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn sum / float(NEIGHBOUR_COUNT);\n}\n\nvoid main(){\t\n\tvec4 cEDL = texture2D(uEDLColor, vUv);\n\t\n\tfloat depth = cEDL.a;\n\tdepth = (depth == 1.0) ? 0.0 : depth;\n\tfloat res = response(depth);\n\tfloat shade = exp(-res * 300.0 * edlStrength);\n    \n\tfloat dEDL = texture2D(uEDLDepth, vUv).r;\n    vec4 color = vec4(cEDL.rgb * shade, cEDL.a + 1.0 - shade);\n\n    #ifdef FRAG_DEPTH_EXT\n        gl_FragDepthEXT = dEDL;\n        gl_FragColor = color;\n    #else\n        vec4 cReg = texture2D(uRegularColor, vUv);\n        float dReg = texture2D(uRegularDepth, vUv).r;\n        gl_FragColor = dEDL < dReg ? color : cReg;\n    #endif\n}\n",this.vs="\nvarying vec2 vUv;\n\nvoid main() {\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4(position,1.0);\n\tgl_Position = projectionMatrix * mvPosition;\n}\t\n",this.extensions.fragDepth=t;this.setValues({uniforms:{screenWidth:{type:"f",value:0},screenHeight:{type:"f",value:0},edlStrength:{type:"f",value:1},radius:{type:"f",value:1},neighbours:{type:"2fv",value:[]},depthMap:{type:"t",value:null},uRegularColor:{type:"t",value:null},uRegularDepth:{type:"t",value:null},uEDLColor:{type:"t",value:null},uEDLDepth:{type:"t",value:null}},vertexShader:this.getDefines()+this.vs,fragmentShader:this.getDefines()+this.fs,lights:!1,depthTest:!0,depthWrite:!0,transparent:!0}),this.neighbourCount=8}getDefines(){let t="";return t+="#define NEIGHBOUR_COUNT "+this.neighbourCount+"\n",this.extensions.fragDepth&&(t+="#define FRAG_DEPTH_EXT\n"),t}updateShaderSource(){const t=this.getDefines()+this.vs,e=this.getDefines()+this.fs;this.setValues({vertexShader:t,fragmentShader:e}),this.uniforms.neighbours.value=this._neighbours,this.needsUpdate=!0}get neighbourCount(){return this._neighbourCount}set neighbourCount(t){if(this._neighbourCount!==t){this._neighbourCount=t,this._neighbours=new Float32Array(2*this._neighbourCount);for(let t=0;t<this._neighbourCount;t++)this._neighbours[2*t]=Math.cos(2*t*Math.PI/this._neighbourCount),this._neighbours[2*t+1]=Math.sin(2*t*Math.PI/this._neighbourCount);this.updateShaderSource()}}}class Yy extends nm{constructor(t,e,i){super(),this._scene=t,this._camera=e,this.renderer=i}render(t,e,i){this.renderer.render(this._scene,this._camera.value,this.renderToScreen?null:i,e),t.getContext().enable(t.getContext().BLEND)}setSize(t,e){this.renderer instanceof qy&&this.renderer.setSize(t,e)}}class Zy extends Om{constructor(t,e,i,n,r){super(t),this._api=e,this._pointcloud=i,this._potreeRenderer=r,this.add(i),this.boundingBox.value.copy(n).translate(i.position)}adjustScreenPosition(t){const e=new ce,i=this._api.container.getBoundingClientRect();return e.x=t.x-i.left,e.y=t.y-i.top,e}pick(t){if(!t.ray.intersectsBox(this.boundingBox.value))return;const e={renderer:this._api.renderingManager.renderer,pRenderer:this._potreeRenderer},i=tb.getMousePointCloudIntersection(this.adjustScreenPosition(t.screenPosition),this._api.camera.value,e,[this._pointcloud]);if(i){const e=new pe(i.location.x,i.location.y,i.location.z);return Promise.resolve({id:this.id,model:this,point:e,object:this,normal:new pe,distance:i.distance,caster:t})}}async pickSnapped(t,e){if(!e.includes(2))return;const i=await this.pick(t);return i?(i.snapType=2,[i]):void 0}}class $y extends Bv{constructor(t){super(),this.settings=t,this._pointSize=1,this._pointShape=$v.SQUARE,this._pointSizeType=Zv.ADAPTIVE,this.potreeIdentifier=t=>"string"==typeof t&&t.trim().endsWith("cloud.js"),this.update=()=>{this._pointCloud&&this._camera&&(Potree.pointLoadLimit=2*Potree.pointBudget,fb([this._pointCloud],this._camera.value,this._api.renderingManager.renderer),this._pointCloud.material.screenWidth=this._api.renderingManager.width,this._pointCloud.material.screenHeight=this._api.renderingManager.height,Potree.numNodesLoading>0&&(this._lastLoadingTime=performance.now()),this.isLoading()&&this._api.renderingManager.redraw())}}get name(){return"potree"}set api(t){this._api=t,this._camera=t.camera;let e=this.settings&&this.settings.workerRootUrl?this.settings.workerRootUrl:t.settings.staticRootUrl;if(e||(e=window.DEFAULT_STATIC_ROOT_URL||"/"),Potree.scriptPath=`${e}dist`,setInterval((()=>this.update()),100),t.registry.register(this.potreeIdentifier,((t,e)=>this.loadModel(t,e)),((t,e)=>this.unload(t,e))),!t.renderingManager.isWebgl2()){const e=t.renderingManager.renderer.getContext(),i=e.getExtension("OES_vertex_array_object");i&&(e.createVertexArray=i.createVertexArrayOES.bind(i),e.bindVertexArray=i.bindVertexArrayOES.bind(i))}this._potreeRenderer=new xb(t.renderingManager.renderer),this._scene=new Ze,this._potreePass=new Yy(this._scene,t.camera,this._potreeRenderer),t.renderingManager.composer.insertPass(this._potreePass,1)}set pointBudget(t){Potree.pointBudget=t,this._api.renderingManager.redraw()}get pointBudget(){return Potree.pointBudget}set pointSize(t){this._pointSize=t,this._potreeModel&&(this._potreeModel.children.forEach((e=>e.material.size=t)),this._api.renderingManager.redraw())}get pointSize(){return this._pointSize}set pointShape(t){this._pointShape=t,this._potreeModel&&(this._potreeModel.children.forEach((e=>e.material.shape=t)),this._api.renderingManager.redraw())}get pointShape(){return this._pointShape}set pointSizeType(t){this._pointSizeType=t,this._potreeModel&&(this._potreeModel.children.forEach((e=>e.material.pointSizeType=t)),this._api.renderingManager.redraw())}get pointSizeType(){return this._pointSizeType}set pointColorType(t){if(this._pointColorType=t,!this._potreeModel)return;const e=Jv[t];if(void 0===e)throw new Error("Unknown coloring method.");this._potreeModel.children.forEach((t=>t.material.pointColorType=e)),this._api.renderingManager.redraw()}get pointColorType(){return this._pointColorType}get pointColorTypes(){return Object.keys(Jv)}set elevationRange(t){this._potreeModel&&(this._potreeModel.children.forEach((e=>e.material.elevationRange=t)),this._api.renderingManager.redraw())}get elevationRange(){if(this._potreeModel)return this._potreeModel.children[0].material.elevationRange}set eyeDomeLightingEnabled(t){const e=this._api.renderingManager.composer.passes;this._edlRenderer&&!t&&(this._potreePass.renderer=this._potreeRenderer,e[e.indexOf(this._potreePass)-1].setRenderToScreen(!0),this._edlRenderer=null,this._api.renderingManager.redraw()),!this._edlRenderer&&t&&(this._edlRenderer=new qy(this._api.renderingManager,this._potreeRenderer,this.settings&&this.settings.disableFragDepthExtension),this._potreePass.renderer=this._edlRenderer,this._edlRenderer.useFragDepthExtension||e[e.indexOf(this._potreePass)-1].setRenderToScreen(!1),this._api.renderingManager.redraw())}get eyeDomeLightingEnabled(){return!!this._edlRenderer}set eyeDomeLightingRadius(t){this._edlRenderer&&(this._edlRenderer.radius=t,this._api.renderingManager.redraw())}get eyeDomeLightingRadius(){return this._edlRenderer?this._edlRenderer.radius:0}set eyeDomeLightingStrength(t){this._edlRenderer&&(this._edlRenderer.strength=t,this._api.renderingManager.redraw())}get eyeDomeLightingStrength(){return this._edlRenderer?this._edlRenderer.strength:0}loadModel(t,e){return new Promise((i=>{Wy(t,"",(n=>{this._material=n.pointcloud.material,this._api.renderingManager.logarithmicDepthBuffer&&this._material.setDefine("logDepthBuffer","#define USE_LOGDEPTHBUF_EXT"),this._material.size=this._pointSize,this._material.uniforms.minSize.value=1,this._material.uniforms.maxSize.value=50,this._material.pointSizeType=this._pointSizeType,this._material.shape=this._pointShape,this._material.gradient=ob.VIRIDIS,this._pointCloud=n.pointcloud,this._pointCloud.minimumNodePixelSize=80,Potree.pointBudget=15e5,this._potreeModel=new Zy(t,this._api,this._pointCloud,this._pointCloud.boundingBox.clone(),this._potreeRenderer),e.transform&&fd(this._potreeModel,e.transform),this._api.models.add(this._potreeModel,!1),this._scene.add(this._potreeModel),i(this._potreeModel),this._api.renderingManager.redraw()}))}))}async unload(t,e){this._potreeModel&&(this._api.models.remove(this._potreeModel),this._scene.remove(this._potreeModel),this._pointCloud=null)}isLoading(){return performance.now()-this._lastLoadingTime<4e3}set minimumNodePixelSize(t){this._pointCloud.minimumNodePixelSize=t}get(){return this._pointCloud.minimumNodePixelSize}setClassification(t,e){const i=this._material.classification[t];i?i.set(e.r,e.g,e.b,e.a):this._material.classification[t]=new _e(e.r,e.g,e.b,e.a),this._material.recomputeClassification()}resetClassications(){this._material.classification=Potree.Classification.DEFAULT,this._material.recomputeClassification()}get classifications(){const t=this._material.classification,e={};for(const i of t){const n=t[i];e[i]={r:n.x,g:n.y,b:n.z,a:n.w}}return e}transform(t,e){fd(this._potreeModel,e)}}class Jy extends Om{constructor(){super("markups"),this.isSelectable=!0,this.pick=(()=>t=>{if(!t.ray.intersectsBox(this.boundingBox.value))return;t.linePrecision=.1;const e=t.intersectObjects(this.children,!0)[0];if(e){const i=Qy(e.object),n={caster:t,model:this,object:i,id:i.id,pickPriority:1};return Promise.resolve(Object.assign(n,e))}})()}clearSelection(){this.children.forEach((t=>t.deselect()))}pickFrustum(t){if(!t.frustum.intersectsBox(this.boundingBox.value))return null;const e=[];return this.children.forEach((i=>{t.frustum.intersectsBox(i.boundingBox)&&e.push(i)})),0===e.length?null:Promise.resolve({model:this,object:e[0],id:e[0].id,childrenIds:e.map((t=>t.id))})}updateBoundingBox(){this.boundingBox.value.makeEmpty(),this.children.forEach((t=>{this.boundingBox.value.union(t.boundingBox)})),this.boundingBox.value.expandByScalar(1.1),this.boundingBox.next(this.boundingBox.value)}}const Qy=t=>{for(;t;){if(t.parent instanceof Jy)return t;t=t.parent}};function Ky(t){return Kp(t)&&t.intersection&&t.intersection.object&&t.intersection.object.userData.isMovable}const t_=t=>(!t.intersection||t.intersection.object&&!t.intersection.object.userData.isMovable||(t.intersection=void 0),t),e_=(t,e,i)=>{const n=e;Object.assign(n.userData,{interactive:!0,isMovable:!0});let r=!1,s=!1;const o=t.inputHandler.pointerDown$.pipe(Cp(tf(0,1)),rp(of(t.inputHandler.picker)),Cp((t=>Ky(t)&&t.intersection.object===n)),pp((t=>{Object.assign(t,{origin:n}),i.dragStart(t),r=!0})),Ip((()=>t.inputHandler.pointerMove$.pipe(rp(of(t.inputHandler.picker)),Bp(nf(t.inputHandler,0,1))))),Qd(t_),pp((e=>{r&&(Object.assign(e,{origin:n}),i.dragging(e),s||t.eventDispatcher.dragStart(),s=!0)})),Ip((()=>t.inputHandler.pointerUp$)),pp((t=>{r&&(Object.assign(t,{origin:n}),i.dragEnd(t),r=!1,s=!1)})));return n.unsubscribe=o.subscribe(),n},i_=(t,e,i,n)=>{const r=e;Object.assign(r.userData,{interactive:!0,isMovable:!0});let s=!1,o=!1;const a=!!n;n=n||new Ti;const h=new _i,c=new pe,l=e=>(If(e,t.container,t.camera.value,h),h.intersectPlane(n,c),e.intersection={point:c},e),u=t.inputHandler.pointerDown$.pipe(Cp(tf(0,1)),rp(of(t.inputHandler.picker)),Cp((t=>Ky(t)&&t.intersection.object===r)),pp((t=>{if(t.intersection.object===r){if(Object.assign(t,{origin:r}),!a){const e=t.intersection.caster.ray.direction.clone().negate();n.setFromNormalAndCoplanarPoint(e,t.intersection.point)}i.dragStart(t),s=!0}})),Ip((()=>t.inputHandler.pointerMove$.pipe(Bp(nf(t.inputHandler,0,1))))),Qd(l),pp((e=>{s&&(Object.assign(e,{origin:r}),i.dragging(e),o||t.eventDispatcher.dragStart(),o=!0)})),Ip((()=>t.inputHandler.pointerUp$)),Qd(l),pp((t=>{s&&(Object.assign(t,{origin:r}),i.dragEnd(t),s=!1,o=!1)})));return r.unsubscribe=u.subscribe(),r},n_=(t,e,i=[])=>{const n=()=>dd(e.settings.selectionColor);let r,s=dd(e.settings.color),o=!1,a=!1;const h=()=>o?dd(e.settings.hoverColor):a?n():s,c=t=>{i.forEach((e=>e.color.set(t))),e.renderingManager.redraw()},l=()=>{const t=h();c(t)};let u=Object.assign(t,{color:{}});return u=Object.defineProperties(t.color,{baseColor:{get:()=>s,set:t=>(t=>{s=t,c(t),r&&clearTimeout(r),r=setTimeout((()=>l()),1e3)})(t)},hovered:{get:()=>a,set:t=>(t=>{o=t,l()})(t)},selected:{get:()=>a,set:t=>(t=>{a=t,t?c(n()):l()})(t)},activeColor:{get:()=>h()}}),l(),u};var r_,s_,o_=function(){kc.call(this),this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new nn([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new nn([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))};o_.prototype=Object.assign(Object.create(kc.prototype),{constructor:o_,isLineSegmentsGeometry:!0,applyMatrix:function(t){var e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},setPositions:function(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var i=new Nl(e,6,1);return this.setAttribute("instanceStart",new ho(i,3,0)),this.setAttribute("instanceEnd",new ho(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},setColors:function(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var i=new Nl(e,6,1);return this.setAttribute("instanceColorStart",new ho(i,3,0)),this.setAttribute("instanceColorEnd",new ho(i,3,3)),this},fromWireframeGeometry:function(t){return this.setPositions(t.attributes.position.array),this},fromEdgesGeometry:function(t){return this.setPositions(t.attributes.position.array),this},fromMesh:function(t){return this.fromWireframeGeometry(new oa(t.geometry)),this},fromLineSegements:function(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this},computeBoundingBox:(s_=new ci,function(){null===this.boundingBox&&(this.boundingBox=new ci);var t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),s_.setFromBufferAttribute(e),this.boundingBox.union(s_))}),computeBoundingSphere:(r_=new pe,function(){null===this.boundingSphere&&(this.boundingSphere=new di),null===this.boundingBox&&this.computeBoundingBox();var t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){var i=this.boundingSphere.center;this.boundingBox.getCenter(i);for(var n=0,r=0,s=t.count;r<s;r++)r_.fromBufferAttribute(t,r),n=Math.max(n,i.distanceToSquared(r_)),r_.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(r_));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}),toJSON:function(){}}),ir.line={linewidth:{value:1},resolution:{value:new ce(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},nr.line={uniforms:Gn.merge([ir.common,ir.fog,ir.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};var a_=function(t){Wn.call(this,{type:"LineMaterial",uniforms:Gn.clone(nr.line.uniforms),vertexShader:nr.line.vertexShader,fragmentShader:nr.line.fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}}}),this.setValues(t)};(a_.prototype=Object.create(Wn.prototype)).constructor=a_,a_.prototype.isLineMaterial=!0;var h_,c_,l_=function(t,e){In.call(this),this.type="LineSegments2",this.geometry=void 0!==t?t:new o_,this.material=void 0!==e?e:new a_({color:16777215*Math.random()})};l_.prototype=Object.assign(Object.create(In.prototype),{constructor:l_,isLineSegments2:!0,computeLineDistances:(h_=new pe,c_=new pe,function(){for(var t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*e.data.count),r=0,s=0,o=e.data.count;r<o;r++,s+=2)h_.fromBufferAttribute(e,r),c_.fromBufferAttribute(i,r),n[s]=0===s?0:n[s-1],n[s+1]=n[s]+h_.distanceTo(c_);var a=new Nl(n,2,1);return t.setAttribute("instanceDistanceStart",new ho(a,1,0)),t.setAttribute("instanceDistanceEnd",new ho(a,1,1)),this}),raycast:function(){var t=new _e,e=new _e,i=new _e,n=new pe,r=new Le,s=new ql,o=new pe;return function(a,h){null===a.camera&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');var c=a.ray,l=a.camera,u=l.projectionMatrix,d=this.geometry,p=this.material,f=p.resolution,m=p.linewidth,g=d.attributes.instanceStart,v=d.attributes.instanceEnd;c.at(1,i),i.w=1,i.applyMatrix4(l.matrixWorldInverse),i.applyMatrix4(u),i.multiplyScalar(1/i.w),i.x*=f.x/2,i.y*=f.y/2,i.z=0,n.copy(i);var b=this.matrixWorld;r.multiplyMatrices(l.matrixWorldInverse,b);for(var y=0,_=g.count;y<_;y++){t.fromBufferAttribute(g,y),e.fromBufferAttribute(v,y),t.w=1,e.w=1,t.applyMatrix4(r),e.applyMatrix4(r),t.applyMatrix4(u),e.applyMatrix4(u),t.multiplyScalar(1/t.w),e.multiplyScalar(1/e.w);var x=t.z<-1&&e.z<-1,w=t.z>1&&e.z>1;if(!x&&!w){t.x*=f.x/2,t.y*=f.y/2,e.x*=f.x/2,e.y*=f.y/2,s.start.copy(t),s.start.z=0,s.end.copy(e),s.end.z=0;var M=s.closestPointToPointParameter(n,!0);s.at(M,o);var T=he.lerp(t.z,e.z,M),S=T>=-1&&T<=1,E=n.distanceTo(o)<.5*m;if(S&&E){s.start.fromBufferAttribute(g,y),s.end.fromBufferAttribute(v,y),s.start.applyMatrix4(b),s.end.applyMatrix4(b);var P=new pe,A=new pe;c.distanceSqToSegment(s.start,s.end,A,P),h.push({point:A,pointOnLine:P,distance:c.origin.distanceTo(A),object:this,face:null,faceIndex:y,uv:null,uv2:null})}}}}}()});var u_=function(){o_.call(this),this.type="LineGeometry"};u_.prototype=Object.assign(Object.create(o_.prototype),{constructor:u_,isLineGeometry:!0,setPositions:function(t){for(var e=t.length-3,i=new Float32Array(2*e),n=0;n<e;n+=3)i[2*n]=t[n],i[2*n+1]=t[n+1],i[2*n+2]=t[n+2],i[2*n+3]=t[n+3],i[2*n+4]=t[n+4],i[2*n+5]=t[n+5];return o_.prototype.setPositions.call(this,i),this},setColors:function(t){for(var e=t.length-3,i=new Float32Array(2*e),n=0;n<e;n+=3)i[2*n]=t[n],i[2*n+1]=t[n+1],i[2*n+2]=t[n+2],i[2*n+3]=t[n+3],i[2*n+4]=t[n+4],i[2*n+5]=t[n+5];return o_.prototype.setColors.call(this,i),this},fromLine:function(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this},copy:function(){return this}});var d_=function(t,e){l_.call(this),this.type="Line2",this.geometry=void 0!==t?t:new u_,this.material=void 0!==e?e:new a_({color:16777215*Math.random()})};d_.prototype=Object.assign(Object.create(l_.prototype),{constructor:d_,isLine2:!0});class p_ extends Go{constructor(t){super(new fn,new No({visible:!1,transparent:!0,opacity:0})),this.lineMaterial=t,this.initMeshLine(this.lineMaterial)}set renderOrder(t){this._meshLine&&(this._meshLine.renderOrder=t)}get renderOrder(){return this._meshLine?this._meshLine.renderOrder:0}initMeshLine(t){this._meshLine=new d_(new u_,t),this._meshLine.scale.set(1,1,1);const e=new ce;this._meshLine.onBeforeRender=t=>{const{width:i,height:n}=t.getSize(e);this._meshLine.material.resolution.set(i,n)},this.add(this._meshLine)}update(t){const e=this.geometry,i=this._meshLine.geometry,n=_d(e,"position",t.length,3,Float32Array).array;yd(n,t),e.computeBoundingBox(),e.computeBoundingSphere(),i.setPositions(n),t.length>1&&(this.startPosition=t[0].clone(),this.endPosition=t[t.length-1].clone())}}function f_(t,e,i){t.computeBoundingBox();const n=new In(t,e);return n.renderOrder=1,i&&n.position.add(i),Object.assign(n,$m(Zm(1).orthoScale)),n}class m_ extends Ye{constructor(t){super(),this._api=t,this._api.eventDispatcher.dispatch(new CustomEvent("markupadded"))}dispatchModifiedEvent(){this._api.eventDispatcher.dispatch(new CustomEvent("markupmodified"))}static getHandleSize(t){return t.renderingManager.isMobile()?1:.5}dispose(){this.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})),this._api.eventDispatcher.dispatch(new CustomEvent("markupremoved"))}}class g_ extends m_{constructor(t,e,i=new ih(m_.getHandleSize(t)),n=i){super(t),this._api=t,this._cursor=e,this._startGeometry=i,this._endGeometry=n,this._colorMaterials=[],this._handleMaterial=new qi({depthTest:!1,depthWrite:!1,transparent:!0}),this._lineMaterial=new a_({linewidth:4*m_.getHandleSize(t),depthTest:!1,depthWrite:!1,transparent:!0}),this.boundingBox=new ci,this._colorMaterials=[this._handleMaterial,this._lineMaterial],n_(this,t,this._colorMaterials),this.createLine()}from(t){}makeMovable(){e_(this._api,this.startHandle,this),e_(this._api,this.endHandle,this)}init(t){this.position.copy(t),this.updateMatrixWorld(!1),this.startHandle=f_(this._startGeometry,this._handleMaterial),this.endHandle=f_(this._endGeometry,this._handleMaterial),this.makeMovable(),this.add(this.startHandle),this.add(this.endHandle),this.updateLine(this.startHandle.position,this.endHandle.position)}start(t){this.init(t.point)}update(t){const e=this.worldToLocal(t.point.clone());this.endHandle.position.copy(e),this.updateLine(this.startHandle.position,this.endHandle.position),this.endHandle.visible=!1,this._api.renderingManager.redraw()}end(){this.showHandles(this.active),this.updateBoundingBox()}createLine(){this._line=new p_(this._lineMaterial),this._line.renderOrder=1,this.add(this._line)}updateLine(t,e){this._line.update([t,e])}dragStart(t){this._cursor&&this._cursor.subscribe(),t.origin===this.startHandle?this.startHandle.visible=!1:this.endHandle.visible=!1}dragging(t){if(this.active&&this._cursor.intersection){const e=this.worldToLocal(this._cursor.intersection.point.clone());t.origin===this.startHandle?this.startHandle.position.copy(e):this.endHandle.position.copy(e),this.updateLine(this.startHandle.position,this.endHandle.position),this.updateBoundingBox(),this._api.renderingManager.redraw()}}dragEnd(t){this.updateBoundingBox(),t.origin===this.startHandle?this.startHandle.visible=!0:this.endHandle.visible=!0,this._cursor.unsubscribe(),this.dispatchModifiedEvent()}updateBoundingBox(){const t=[];this.traverse((e=>{e.geometry&&t.push(e.geometry)})),this.boundingBox=md(t),this.boundingBox.applyMatrix4(this.matrix);const e=this.parent;e&&e instanceof Jy&&e.updateBoundingBox()}pointerOver(){this.color.hovered=!0}pointerOut(){this.color.hovered=!1}select(){this.color.selected=!0,this.active=!0,this.activeCallback()}deselect(){this.color.selected=!1,this.active=!1,this.activeCallback()}showHandles(t){this.startHandle.visible=t,this.endHandle.visible=t,this.color.selected=t}activeCallback(){this.showHandles(this.active)}cancel(){this.parent&&this.parent.remove(this),this.dispose()}}class v_ extends g_{from(t){this.color.baseColor=t.color,this.init(t.start);const e=(new pe).copy(t.end);this.worldToLocal(e),this.endHandle.position.copy(e),this.updateLine(this.startHandle.position,this.endHandle.position),this.updateBoundingBox(),this.active=!1}}var b_=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}();function y_(t){return function(e){return 0===t?Gp():e.lift(new __(t))}}var __=function(){function t(t){if(this.total=t,this.total<0)throw new b_}return t.prototype.call=function(t,e){return e.subscribe(new x_(t,this.total))},t}(),x_=function(t){function e(e,i){var n=t.call(this,e)||this;return n.total=i,n.count=0,n}return Md(e,t),e.prototype._next=function(t){var e=this.total,i=++this.count;i<=e&&(this.destination.next(t),i===e&&(this.destination.complete(),this.unsubscribe()))},e}(Bd);class w_{get name(){return this._name}onStart(t){this.finished=!1,this.object=this._createMarkup(),this.object.start(t)}onMove(t){this.object.update(t)}onEnd(){this.finished=!0,this.object.end(),this.onFinished&&this.onFinished()}}class M_ extends w_{constructor(t,e,i){super(),this.inputs=e,this._name=t,this.cursor=i;const n=rf(e,{button:0,touchCount:1});this.observable=n.pipe(y_(1),rp((t=>this.cursor.calculateIntersection(t))),Cp((()=>!!this.cursor.intersection)),pp((()=>this.onStart(this.cursor.intersection))),Ip((()=>this.inputs.pointerMove$.pipe(pp((t=>t.intersection=this.cursor.intersection)),Qd(T_(this.object)),Cp(sf),pp((t=>this.onMove(t.intersection))),Bp(n.pipe(pp((()=>this.onEnd()))))))))}set enabled(t){this.subscription&&(this.subscription.unsubscribe(),this.subscription=null,this.cursor.unsubscribe(),!this.finished&&this.object&&(this.object.cancel(),this.object=null)),t&&(this.subscription=this.observable.subscribe(),this.cursor.subscribe())}get enabled(){return!!this.subscription}}const T_=t=>e=>{if(e.intersection&&e.intersection.object){let i=e.intersection.object.parent;for(;i;){if(i===t)return e.intersection=void 0,e;i=i.parent}}return e};class S_ extends M_{constructor(t,e,i,n){super("lineMarkup",t.inputHandler,n),this.api=t,this._settings=e,this.model=i}_createMarkup(){const t=new v_(this.api,this.cursor);return t.color.baseColor=dd(this._settings.color),t.userData.dataType=this.name,this.model.add(t),t}init(t){const e={type:this.name};return E_(e,t),t.userData.iMarkup=e,e}update(t,e){E_(t,e)}from(t){const e=P_(t),i=this._createMarkup();return i.from(e),i.userData.iMarkup=t,i}}const E_=(t,e)=>{const i=(new pe).copy(e.startHandle.position);e.startHandle.localToWorld(i);const n=(new pe).copy(e.endHandle.position);e.endHandle.localToWorld(n),t.start=i,t.end=n,t.color=pd(e.color.baseColor)},P_=t=>({start:ud(t.start,new pe),end:ud(t.end,new pe),color:dd(t.color)});class A_ extends w_{constructor(t,e,i,n,r){super(),this.inputs=e,this.camera=i,this.model=n,this.plane=new Ti,this.options={button:0,touchCount:1},this.intersectPlane=(()=>{const t=new _i,e=new pe;return i=>(If(i,this.inputs.container,this.camera.value,t),t.intersectPlane(this.plane,e),{id:null,object:null,model:null,point:e})})(),this._name=t,this.cursor=r,this.tap$=rf(e,this.options)}set enabled(t){this.handle&&(this.handle.unsubscribe(),this.handle=null,this.cursor.unsubscribe(),!this.finished&&this.object&&(this.object.cancel(),this.object=null)),t&&(this.handle=this.tap$.pipe(y_(1),Cp((()=>!!this.cursor.intersection)),pp((()=>{this.plane.setFromNormalAndCoplanarPoint(this.cursor.intersection.caster.ray.direction.clone().negate(),this.cursor.intersection.point),this.onStart(this.cursor.intersection)})),Ip((()=>this.inputs.pointerMove$.pipe(rp(of(this.inputs.picker,[this.model])),Qd(this.intersectPlane),pp((t=>this.onMove(t))),Bp(this.tap$.pipe(Qd(this.intersectPlane),pp((()=>this.onEnd())))))))).subscribe(),this.cursor.subscribe())}get enabled(){return!!this.handle}}class C_ extends Un{constructor(t){super(),this.create(t)}create(t){const e=4*t,i=new fh(2*t,e,10,1),n=new ih(.6*t);i.translate(0,-e/2,0),i.rotateX(Math.PI/2),i.rotateZ(Math.PI),i.rotateY(Math.PI);const r=new In(i),s=new In(n);r.updateMatrix(),s.updateMatrix(),this.mergeMesh(r),this.mergeMesh(s)}}class L_ extends v_{constructor(t,e){super(t,e,new C_(m_.getHandleSize(t)),new ih(m_.getHandleSize(t))),this._tmp=new pe}makeMovable(){e_(this._api,this.startHandle,this),i_(this._api,this.endHandle,this)}updateLine(t,e){super.updateLine(t,e),this.startHandle.lookAt(this.endHandle.getWorldPosition(this._tmp))}showHandles(t){super.showHandles(t),this.startHandle.visible=!0,this.endHandle.visible=t}}class R_ extends A_{constructor(t,e,i,n){super("arrowMarkup",t.inputHandler,t.camera,i,n),this.api=t,this._settings=e}_createMarkup(){const t=new L_(this.api,this.cursor);return t.color.baseColor=dd(this._settings.color),t.userData.dataType=this.name,this.model.add(t),t}init(t){const e={type:this.name};return E_(e,t),t.userData.iMarkup=e,e}update(t,e){E_(t,e)}from(t){const e=P_(t),i=this._createMarkup();return i.from(e),i.userData.iMarkup=t,i}}class I_{constructor(t,e,i){this.inputs=e,this.plane=new Ti,this.options={button:0,touchCount:1},this._name=t,this.cursor=i,this.tap$=rf(e,this.options)}get name(){return this._name}tap(t){this._createMarkup().insert(t.intersection),this.onFinished&&this.onFinished()}set enabled(t){this.handle&&(this.handle.unsubscribe(),this.handle=null,this.cursor.unsubscribe()),t&&(this.handle=this.tap$.pipe(Cp(sf),pp((t=>this.tap(t)))).subscribe(),this.cursor.subscribe([0]))}get enabled(){return!!this.handle}}class O_ extends p_{updateShape(t,e){this.update(F_(t,e))}}const F_=(t,e)=>{const i=B_();return((t,e,i)=>{let n=0,r=0;for(let s=0;s<t.length;s++){const o=t[s];n=Math.max(o.x,n),r=Math.max(o.y,r);const a=(o.x-354.40918)/(240/e),h=(o.y-298.338865)/(190/i);o.set(a,h,0)}})(i,t,e),i},B_=()=>[new pe(360.11914,112.91992),new pe(324.158923467,118.111793265),new pe(292.252606325,132.707124564),new pe(266.46070852,155.375163582),new pe(248.84375,184.78516),new pe(225.573005953,187.564686143),new pe(203.992424299,194.006147247),new pe(184.536777636,203.718833168),new pe(167.640838557,216.312033763),new pe(153.739379659,231.395038887),new pe(143.267173536,248.577138397),new pe(136.658992785,267.467622149),new pe(134.34961,287.67578),new pe(137.262200495,310.264888292),new pe(145.703333349,331.510628581),new pe(159.268874528,350.670977081),new pe(177.55469,367.00391),new pe(166.560848824,386.416049052),new pe(162.75977,407.378910004),new pe(164.830013084,423.131271689),new pe(170.767586993,437.803077714),new pe(180.162727123,451.08002049),new pe(192.605668873,462.647792427),new pe(207.686647638,472.192085937),new pe(224.995898816,479.398593429),new pe(244.123657805,483.953007313),new pe(264.66016,485.54102),new pe(302.10156875,480.039840271),new pe(334.28711,464.36914),new pe(368.304774234,480.911489076),new pe(406.58594,486.67773),new pe(429.454321646,484.679781835),new pe(451.235395655,478.834773416),new pe(471.317092719,469.366596533),new pe(489.08734353,456.499142976),new pe(503.657759454,440.805874426),new pe(514.37898362,423.071344558),new pe(520.997494357,403.836083155),new pe(523.25977,383.64062),new pe(522.3125,371.59961),new pe(545.653344192,356.642784942),new pe(563.452733046,336.239434903),new pe(574.808470377,311.777889913),new pe(578.81836,284.64648),new pe(576.928049429,265.837169463),new pe(571.398187577,247.922181565),new pe(562.440589575,231.404935693),new pe(550.267070557,216.788851232),new pe(535.420156425,204.80461725),new pe(518.642075641,195.986323635),new pe(500.444197176,190.54249101),new pe(481.33789,188.68164),new pe(473.00781,189.09375),new pe(465.757398952,172.807193423),new pe(455.985311066,158.074572097),new pe(429.999074056,134.028880594),new pe(397.295037518,118.472166294),new pe(360.11914,112.91992)];class D_ extends m_{constructor(t,e,i=new ih(m_.getHandleSize(t))){super(t),this.cursor=e,this._centerGeometry=i,this._edgeHandlesMap=new Map,this._handleMaterial=new qi({depthTest:!1,depthWrite:!1,transparent:!0}),this._camera=t.camera,this._cloudMaterial=new a_({linewidth:4*m_.getHandleSize(t),depthTest:!1,depthWrite:!1,transparent:!0}),n_(this,t,[this._handleMaterial,this._cloudMaterial])}from(t){this.init(t.position,t.plane,t.width,t.height,t.color)}init(t,e,i,n,r){this.position.copy(t),this.plane=e,this.width=i,this.height=n,r&&(this.color.baseColor=r),this.createEdgeHandles(this.width,this.height),this._cloudShape=new O_(this._cloudMaterial),this._cloudShape.renderOrder=1,this.add(this._cloudShape),this.updateCloud(),this.showHandles(!1);const s=new pe;s.addVectors(e.normal,this.position),this.lookAt(s),this.updateBoundingBox(),this._api.renderingManager.redraw()}insert(t){const e=t.point,i=Cf(e,this._camera.value),n=(new Ti).setFromNormalAndCoplanarPoint(t.normal,e),r=4*i,s=3*i;this.init(e,n,r,s)}createEdgeHandles(t,e){const i=new ih(.6*m_.getHandleSize(this._api));for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const s=new pe(n*t,r*e),o=f_(i,this._handleMaterial,s);this._edgeHandlesMap.set(o,{i:n,j:r}),this.add(o),i_(this._api,o,this),0===n&&0===r&&(o.geometry=this._centerGeometry)}}updateHandlePositions(){for(let t of this._edgeHandlesMap.entries()){const e=t[0],i=t[1];e.position.copy(new pe(i.i*this.width,i.j*this.height))}}updateCloud(){this._cloudShape.updateShape(this.width,this.height),this.updateHandlePositions(),this.updateBoundingBox()}dragStart(t){this.cursor&&this.cursor.subscribe([0]);for(const e of this._edgeHandlesMap.entries())t.origin===e[0]&&(e[0].visible=!1)}dragging(t){const e=this._edgeHandlesMap.get(t.origin),i=this.worldToLocal(t.intersection.point.clone()),n=new pe(Math.abs(e.i*i.x),Math.abs(e.j*i.y));0!==n.x&&(this.width=n.x),0!==n.y&&(this.height=n.y),n.equals(new pe)?this.position.copy(t.intersection.point):this.updateCloud(),this._api.renderingManager.redraw()}dragEnd(t){this.cursor.unsubscribe(),this.updateBoundingBox();for(const e of this._edgeHandlesMap.entries())t.origin===e[0]&&(e[0].visible=!0);this.dispatchModifiedEvent()}updateBoundingBox(){const t=[];this.traverse((e=>{e.geometry&&t.push(e.geometry)})),this.updateMatrix(),this.boundingBox=md(t),this.boundingBox.applyMatrix4(this.matrix);const e=this.parent;e&&e instanceof Jy&&e.updateBoundingBox()}select(){this.color.selected=!0,this.active=!0,this.activeCallback()}deselect(){this.color.selected=!1,this.active=!1,this.activeCallback()}showHandles(t){for(const e of this._edgeHandlesMap.keys())e.visible=t}activeCallback(){this.showHandles(this.active),this.active&&this._api.renderingManager.redraw()}}class z_ extends I_{constructor(t,e,i,n){super("cloudMarkup",t.inputHandler,n),this.api=t,this._settings=e,this.model=i}_createMarkup(){const t=new D_(this.api,this.cursor);return t.color.baseColor=dd(this._settings.color),t.userData.dataType=this.name,this.model.add(t),t}init(t){const e={type:this.name};return N_(e,t),t.userData.iMarkup=e,e}update(t,e){N_(t,e)}from(t){const e=U_(t),i=this._createMarkup();return i.from(e),i.userData.iMarkup=t,i}}const N_=(t,e)=>{t.position=e.position.clone(),t.plane={normal:e.plane.normal,coplanarPoint:e.plane.coplanarPoint(new pe)},t.width=e.width,t.height=e.height,t.color=pd(e.color.baseColor)},U_=t=>({position:ud(t.position,new pe),plane:(new Ti).setFromNormalAndCoplanarPoint(ud(t.plane.normal,new pe),ud(t.plane.coplanarPoint,new pe)),width:t.width,height:t.height,color:dd(t.color)});class V_ extends w_{constructor(t,e,i){super(),this.inputs=e,this.model=i,this.options={filter:()=>!0,button:0,touchCount:1},this._name=t}set enabled(t){this.handle&&(this.handle.unsubscribe(),this.handle=null,this.cursor&&this.cursor.unsubscribe(),!this.finished&&this.object&&(this.object.cancel(),this.object=null)),t&&(this.handle=this.inputs.pointerDown$.pipe(Cp(tf(this.options.button,this.options.touchCount)),rp(of(this.inputs.picker,[this.model])),pp((t=>this.object.dragStart(t.intersection))),Ip((()=>this.inputs.pointerMove$.pipe(Bp(nf(this.inputs,this.options.button,this.options.touchCount))))),rp(of(this.inputs.picker,[this.model])),Cp(sf),pp((t=>this.object.dragging(t.intersection))),Bp(this.inputs.pointerUp$.pipe(pp((()=>this.object.dragEnd(void 0))),pp((()=>this.onEnd()))))).subscribe(),this.onStart(void 0))}get enabled(){return!!this.handle}}class k_ extends Ye{constructor(t,e,i){super(),this.plane=(new Ti).setFromNormalAndCoplanarPoint(e,i),this.normal=this.plane.normal,this._constant=this.plane.constant,this.visible=!0,this.userData.interactive=!0;const n=new pe,r=new pe,s=new pe;this.geometry={boundingBox:new ci,computeBoundingBox(){n.set(-1,-1,1).unproject(t),r.set(1,1,1).unproject(t),s.copy(t.position),this.boundingBox.makeEmpty(),this.boundingBox.setFromPoints([n,r,s])},dispose(){}}}get constant(){return this._constant}set constant(t){this.plane.constant=t,this._constant=t}raycast(t,e){t.ray.intersectsPlane&&e.push({object:this,point:t.ray.intersectPlane(this.plane,new pe)})}}class j_ extends m_{constructor(t){super(t),this.lineMap=new Map,this._camera=t.camera,this.boundingBox=new ci,this._lineMaterial=new No({depthTest:!1,depthWrite:!1,transparent:!0}),n_(this,t,[this._lineMaterial])}from(t){const e=new fn;this.color.baseColor=t.color,this._currentPositions=t.segments,this._currentLine=new Go(e,this._lineMaterial),this._currentLine.renderOrder=1,this.updateGeometry(e,this._currentPositions),this.add(this._currentLine),this.lineMap.set(this._currentLine,this._currentPositions),this.updateBoundingBox()}updateGeometry(t,e){yd(_d(t,"position",e.length,3,Float32Array).array,e),t.computeBoundingBox(),t.computeBoundingSphere()}start(){const t=this._camera.value,e=t.getWorldDirection(new pe),i=(new pe).addVectors(t.position,e.multiplyScalar(100));this.position.copy(i),this._pickablePlane=new k_(t,e.negate(),i),this.add(this._pickablePlane),this.updateBoundingBox()}adjustPickablePlane(t){t&&t.caster.ray&&t.point&&(this.position.copy(t.point),this.remove(this._pickablePlane),this._pickablePlane=new k_(this._camera.value,t.caster.ray.direction.clone().negate(),t.point),this.add(this._pickablePlane),this.updateBoundingBox())}dragStart(t){this.adjustPickablePlane(t),this._currentLine=new Go(new fn,this._lineMaterial),this._currentLine.renderOrder=1,this._currentPositions=[],this.updateGeometry(this._currentLine.geometry,this._currentPositions),this.add(this._currentLine)}dragging(t){const e=this.worldToLocal(t.point);this._currentPositions.push(e),this.updateGeometry(this._currentLine.geometry,this._currentPositions),this._api.renderingManager.redraw()}dragEnd(){this.lineMap.set(this._currentLine,this._currentPositions),this.updateBoundingBox(),this.dispatchModifiedEvent()}end(){this.remove(this._pickablePlane)}pointerOver(){this.color.hovered=!0}pointerOut(){this.color.hovered=!1}select(){this.color.selected=!0,this.active=!0}deselect(){this.color.selected=!1,this.active=!1}cancel(){this.parent.remove(this),this.dispose()}updateBoundingBox(){const t=[];this.traverse((e=>{e.geometry&&t.push(e.geometry)})),this.boundingBox=md(t),this.boundingBox.applyMatrix4(this.matrix);const e=this.parent;e&&e instanceof Jy&&e.updateBoundingBox()}}class H_ extends V_{constructor(t,e,i){super("freelineMarkup",t.inputHandler,i),this.api=t,this._settings=e}_createMarkup(){const t=new j_(this.api);return t.color.baseColor=dd(this._settings.color),t.userData.dataType=this.name,this.model.add(t),t}init(t){const e={type:this.name};return G_(e,t),t.userData.iMarkup=e,e}update(t,e){G_(t,e)}from(t){const e=q_(t),i=this._createMarkup();return i.from(e),i.userData.iMarkup=t,i}}const G_=(t,e)=>{t.segments=(t=>{const e=t.lineMap.values(),i=[];for(let n of e)for(let e=0;e<n.length-1;e++){const r={start:t.localToWorld((new pe).copy(n[e])),end:t.localToWorld((new pe).copy(n[e+1]))};i.push(r)}return i})(e),t.color=pd(e.color.baseColor)},W_=t=>{let e;const i=[];for(const n of t){const t=ud(n.start,new pe),r=ud(n.end,new pe);e&&t.equals(e)||i.push(t),i.push(r),e=r}return i},q_=t=>({segments:W_(t.segments),color:dd(t.color)}),X_=t=>{t.stopImmediatePropagation()};class Y_ extends og{constructor(t,e,i="center",n){super(t,e,i),this.isMeasurementElement=!0,this.spellcheck=!1,this.style.userSelect="none",this.style.webkitUserSelect="none",this.style.pointerEvents="none",this.style.background="white",this.style.borderRadius="2px",this.style.padding="0px 3px",this.style.fontFamily='"Open Sans", sans-serif',this.style.overflow="hidden",this.style.fontSize="1em",this.style.boxShadow="0rem 0rem 0.06rem rgba(54,53,69,0.2), 0.12rem 0.12rem 0.5rem rgba(54,53,69,0.30)",this.hidden=!0,"custom"===n.lengthUnit?this._formatter=n.customLengthFormatter:this._formatter=bd(n.lengthUnit,n.decimals)}static get is(){return"measurement-element"}set borderColor(t){this.style.borderColor=`#${t.getHexString()}`}get text(){return this._text}set text(t){this._text=t,this.innerText=t}update(t,e){const i=t.distanceTo(e);this._distance=i;const n=e.sub(t).normalize().multiplyScalar(i/2),r=t.add(n);this.text=this._formatter(i),this.position.copy(r),this.hidden=!1}updateText(t){"custom"===t.lengthUnit?this._formatter=t.customLengthFormatter:this._formatter=bd(t.lengthUnit,t.decimals),this.text=this._formatter(this._distance)}updatePosition(t){super.updatePosition(t),this.hidden&&(this.style.display="none")}connectedCallback(){this.addEventListener("mousemove",X_),this.addEventListener("mousedown",X_)}disconnectedCallback(){this.removeEventListener("mousemove",X_),this.removeEventListener("mousedown",X_)}}customElements.get(Y_.is)||customElements.define(Y_.is,Y_);class Z_ extends Go{constructor(t,e){super(t,e),this._lineGeometry=t,this._lineGeometry.vertices.push(new pe,new pe(1),new pe(1,0,1)),this._lineGeometry.verticesNeedUpdate=!0}updatePerpendicular(t,e,i,n=new pe(0,0,1)){const r=t.distanceTo(i)/10,s=0===r?.2:Math.min(r,.2),o=new _i(e),a=new _i(e);t.equals(e)?o.lookAt((new pe).addVectors(t,n)):o.lookAt(t),i.equals(e)?a.lookAt((new pe).addVectors(i,n)):a.lookAt(i);const h=(new pe).addVectors(e,a.direction.clone().multiplyScalar(s)),c=(new pe).addVectors(h,o.direction.clone().multiplyScalar(s)),l=(new pe).addVectors(e,o.direction.clone().multiplyScalar(s));this._lineGeometry.vertices=[h,c,l],this._lineGeometry.verticesNeedUpdate=!0,this.visible=!0}update(t,e,i){"Plane"===t.pickType?this.updatePerpendicular(this.worldToLocal(t.position.clone()),e,i):"Edge"===t.pickType?this.updatePerpendicular(this.worldToLocal(t.start.clone()),e,i,(new pe).subVectors(t.end,t.start).normalize()):this.visible=!1}}class $_ extends Ye{constructor(t,e){super(),this._dashedLineGeometry=new Un,this._mainLineGeometry=new Un,this._perpendicularVisulizer=new Z_(new Un,t),this._dashedLine=new Xo(this._dashedLineGeometry,e),this._mainLine=new Go(this._mainLineGeometry,t),this.add(this._perpendicularVisulizer),this.add(this._dashedLine),this.add(this._mainLine)}updatePlaneVisualizer(t,e,i){const n=Math.min(2/e.distanceTo(i),.4);this._mainLine.position.copy(e),this._mainLineGeometry.vertices=[new pe(n,-n),new pe(n,n),new pe(-n,n),new pe(-n,-n),new pe(n,-n)],this._mainLine.lookAt((new pe).addVectors(e,t.normal.clone().multiplyScalar(1))),this._dashedLineGeometry.vertices=[e,i],this._dashedLine.computeLineDistances(),this._mainLineGeometry.verticesNeedUpdate=!0,this._dashedLineGeometry.verticesNeedUpdate=!0,this.visible=!0}updateEdgeVisualizer(t,e,i){this._mainLine.position.copy(new pe),this._mainLineGeometry.vertices=[t,e],this._dashedLineGeometry.vertices=[e,i],this._dashedLine.computeLineDistances(),this._mainLineGeometry.verticesNeedUpdate=!0,this._dashedLineGeometry.verticesNeedUpdate=!0,this.visible=!0}update(t,e,i){"Plane"===t.pickType?this.updatePlaneVisualizer(t.plane,this.worldToLocal(t.position.clone()),e):"Edge"===t.pickType?this.updateEdgeVisualizer(this.worldToLocal(t.start.clone()),this.worldToLocal(t.end.clone()),e):this.visible=!1,this._perpendicularVisulizer.update(t,e,i)}}class J_ extends Ye{constructor(t,e){super(),this._startVisualizer=new $_(t,e),this._endVisualizer=new $_(t,e),this.add(this._startVisualizer),this.add(this._endVisualizer)}update(t,e,i){this._startVisualizer.update(t,i.startPositionLocal,i.endPositionLocal),this._endVisualizer.update(e,i.endPositionLocal,i.startPositionLocal)}}class Q_ extends g_{constructor(t,e){super(t,e),this._update={startPoint:!1,endPoint:!1},this.getPlanePoint=(t,e)=>{const i=new pe;let n=new _i(e,t.normal.clone().negate());return n.intersectPlane(t,i)||(n=new _i(e,t.normal.clone()),n.intersectPlane(t,i)),i},this.getRayPoint=(t,e,i)=>{const n=new pe,r=new _i(e);return r.lookAt(t),r.closestPointToPoint(i,n),n},this.getTargetPosition=(t,e)=>{switch(e.pickType){case"Edge":return this.getRayPoint(e.start,e.end,t);case"Plane":return this.getPlanePoint(e.plane,t);case"Point":return e.position.clone()}},this.getMeasurementWorldPositions=(t,e)=>{let i=t.position,n=e.position;const r="Point"===t.pickType,s="Point"===e.pickType;return!(r||s)&&(t.start?(i=t.start,n=this.getTargetPosition(i,e)):e.start?(n=e.start,i=this.getTargetPosition(n,t)):(n=e.position,i=this.getTargetPosition(n,t))),r&&(n=this.getTargetPosition(i,e)),s&&(i=this.getTargetPosition(n,t)),{startPositionWorld:i,endPositionWorld:n}};const i=new No,n=new Ah({dashSize:.05,gapSize:.05});this._endpointVisualizer=new J_(i,n),this._colorMaterials.push(i,n),this.add(this._endpointVisualizer),this._api.settings.lengthUnitSubject.subscribe((()=>{this.updateAllMeasurementText()})),this._api.settings.decimalsSubject.subscribe((()=>{this.updateAllMeasurementText()})),this._api.settings.customLengthFormatterSubject.subscribe((()=>{this.updateAllMeasurementText()}))}updateStartPoint(t){this.startHandle||(this.startHandle=f_(this._startGeometry,this._handleMaterial),e_(this._api,this.startHandle,this),this.add(this.startHandle)),this._startPickObject=t,this._update.startPoint=!0}updateEndPoint(t){this.endHandle||(this.endHandle=f_(this._endGeometry,this._handleMaterial),e_(this._api,this.endHandle,this),this.endHandle.userData.interactive=!1,this.add(this.endHandle)),this._endPickObject=t,this._update.endPoint=!0}activeCallback(){super.activeCallback(),this.endHandle.userData.interactive=!0}updateMeasurementOptions(){this._measurementElementOptions={color:this.color.baseColor,lengthUnit:this._api.settings.lengthUnit,customLengthFormatter:this._api.settings.customLengthFormatter,decimals:this._api.settings.decimals}}updateMeasurementText({startPositionWorld:t,endPositionWorld:e}){this.updateMeasurementOptions(),this._textElement||(this._textElement=new Y_(this._api.camera,new pe,"center",this._measurementElementOptions),this._api.htmlElementPositioner.addElement(this._textElement)),this._textElement.update(t,e)}updateAllMeasurementText(){this.updateMeasurementOptions(),this._textElement&&this._textElement.updateText(this._measurementElementOptions)}updatePositions({startPositionWorld:t,endPositionWorld:e}){let i=this.startHandle.position.clone(),n=this.endHandle.position.clone();return this.position.equals(new pe)&&(this.position.copy(t.clone()),this.updateMatrixWorld(!0)),this._update.startPoint&&(i=this.worldToLocal(t.clone()),this.startHandle.position.copy(i),this._update.startPoint=!1),this._update.endPoint&&(n=this.worldToLocal(e.clone()),this.endHandle.position.copy(n),this._update.endPoint=!1),{startPositionLocal:i,endPositionLocal:n}}updateMeasurement(){const t=this.getMeasurementWorldPositions(this._startPickObject,this._endPickObject),e=this.updatePositions(t);this._endpointVisualizer.update(this._startPickObject,this._endPickObject,e),this.updateMeasurementText(t),this.updateLine(e.startPositionLocal,e.endPositionLocal),this.updateBoundingBox()}dispose(){super.dispose(),this._textElement&&this._api.htmlElementPositioner.removeElement(this._textElement)}start(t){this.updateStartPoint({pickType:"Point",position:t.point.clone()}),this.startHandle.visible=!1}update(t){const e={pickType:"Point",position:t.point.clone()};this.startHandle.visible=!0,this.updateEndPoint(e),this.endHandle.visible=!1,this.updateMeasurement(),this._api.renderingManager.redraw()}dragging(t){if(this.active&&this._cursor.intersection){const e={pickType:"Point",position:this._cursor.intersection.point.clone()};t.origin===this.startHandle?(this.updateStartPoint(e),this.updateEndPoint({pickType:"Point",position:this.localToWorld(this.endHandle.position.clone())})):(this.updateEndPoint(e),this.updateStartPoint({pickType:"Point",position:this.localToWorld(this.startHandle.position.clone())})),this.updateMeasurement(),this._api.renderingManager.redraw()}}}class K_ extends Q_{from(t){const{color:e,start:i,end:n}=t;this.color.baseColor=e,this.updateStartPoint(i),this.updateEndPoint(n),this.updateMeasurement(),this.active=!1,this.showHandles(!1)}}class tx extends M_{constructor(t,e,i,n){super("measurement",t.inputHandler,n),this.api=t,this._settings=e,this.model=i}_createMarkup(){const t=new K_(this.api,this.cursor);return t.color.baseColor=dd(this._settings.color),t.userData.dataType=this.name,this.model.add(t),t}init(t){const e={type:this.name};return nx(e,t),t.userData.iMarkup=e,e}update(t,e){nx(t,e)}from(t){const e=ix(t),i=this._createMarkup();return i.from(e),i.userData.iMarkup=t,i}}const ex=t=>{switch(t.pickType){case"Edge":return{pickType:"Edge",start:ud(t.start,new pe),end:ud(t.end,new pe)};case"Plane":return{pickType:"Plane",position:ud(t.plane.coplanarPoint,new pe),plane:(new Ti).setFromNormalAndCoplanarPoint(ud(t.plane.normal,new pe),ud(t.plane.coplanarPoint,new pe))};case"Point":return{pickType:"Point",position:ud(t.position,new pe)}}},ix=t=>({start:ex(t.start),end:ex(t.end),color:dd(t.color)}),nx=(t,e)=>{const i=(new pe).copy(e.startHandle.position);e.localToWorld(i);const n=(new pe).copy(e.endHandle.position);e.localToWorld(n),t.start={pickType:"Point",position:i},t.end={pickType:"Point",position:n},t.color=pd(e.color.baseColor)};class rx extends og{constructor(t,e,i="default",n,r,s=new Ui("rgb(0,0,0)")){super(t.camera,e,i),this._api=t,this._color=n,this._text=r,this._textColor=s,this.selectText=()=>{if(this.contentEditable="true",void 0!==window.getSelection&&void 0!==document.createRange){var t=document.createRange();t.selectNodeContents(this);var e=window.getSelection();e.removeAllRanges(),e.addRange(t)}},this.onKeyPress=t=>{13===t.keyCode&&(this.blur(),window.getSelection().removeAllRanges())},this.stopPropagation=t=>t.stopImmediatePropagation(),this.setDefaultBorderColor=()=>{this.style.borderColor=`#${this._color.getHexString()}`},this.spellcheck=!1,this.contentEditable="true",this.style.borderColor=`#${this._color.getHexString()}`,this.style.margin="-1px -1px 0px 0px",this.style.padding="0px 3px 0px 3px",this.style.borderBottom="2px solid black",this.style.fontFamily='"Open Sans", sans-serif',this.style.textShadow="-1px 0 #ffffff,0 1px #ffffff,1px 0 #ffffff,0 -1px #ffffff",this.style.overflow="hidden",this.style.fontSize="1.5em",this.style.letterSpacing="1px",this.style.minHeight="33px",this.style.height="auto",this.style.webkitUserSelect="none",this.style.userSelect="none",this.innerText=""}static get is(){return"text-element"}set borderColor(t){this.style.borderColor=`#${t.getHexString()}`}set textColor(t){this._textColor=t,this.style.color=`#${this._textColor.getHexString()}`}get textColor(){return this._textColor}connectedCallback(){this.addEventListener("touchend",this.setDefaultBorderColor),this.addEventListener("keypress",this.onKeyPress)}disconnectedCallback(){this.removeEventListener("touchend",this.setDefaultBorderColor),this.removeEventListener("keypress",this.onKeyPress),this.removeEventListener("mouseover",this.pointerOver),this.removeEventListener("mouseout",this.pointerOut)}updatePosition(t){super.updatePosition(t),this.hidden&&(this.style.display="none")}}customElements.get(rx.is)||customElements.define(rx.is,rx);class sx extends v_{constructor(t,e){super(t,e),this.api=t,this.onClick=t=>{if(!this.active){const t=this._api.models.getIterable();for(const e of t)e.clearSelection&&e.clearSelection();this.select()}},this.onBlur=()=>{this.active=!1,this.textElement.setDefaultBorderColor(),this.textElement.contentEditable="false"},this.onHtmlDragStart=t=>{t.stopImmediatePropagation(),this.htmlElementIsDragging=!0,this._cursor.subscribe();const e=this.endHandle.getWorldPosition(new pe),i=Ff(e,this._api.camera.value,this._api.container.clientWidth,this._api.container.clientHeight);this._offset=new ce(i.x-t.x,i.y-t.y)},this.onHtmlDrag=t=>{if(this.htmlElementIsDragging&&this.active&&0!==t.x&&0!==t.y){const e=function(t,e,i){const n=new pe,r=new od;n.set(t/window.innerWidth*2-1,-e/window.innerHeight*2+1,.5),n.unproject(i);const s=n.sub(i.position).normalize();return r.set(i.position,s),{id:null,object:null,model:null,caster:r}}(this._offset.x+t.x,this._offset.y+t.y,this.api.camera.value);e.point=function(t,e,i){const n=t.direction,r=e.position.distanceTo(i);return e.position.clone().add(n.multiplyScalar(r))}(e.caster.ray,this.api.camera.value,this.position),this.update(e)}},this.onHtmlDragEnd=t=>{this.htmlElementIsDragging&&(this.textElement.style.pointerEvents="all",this.htmlElementIsDragging=!1,this._cursor.unsubscribe(),this.dispatchModifiedEvent())},this.textElement=new rx(this._api,new pe,"left",this.color.baseColor),this.textElement.hidden=!0,this.textElement.addEventListener("blur",(()=>this.dispatchModifiedEvent())),this._api.htmlElementPositioner.addElement(this.textElement),this.textElement.addEventListener("click",this.onClick),this.textElement.addEventListener("mouseover",(()=>this.pointerOver)),this.textElement.addEventListener("mouseout",(()=>this.pointerOut)),this.textElement.addEventListener("blur",this.onBlur),this.textElement.addEventListener("mousedown",this.onHtmlDragStart),this.textElement.addEventListener("pointerdown",this.onHtmlDragStart),window.addEventListener("mousemove",this.onHtmlDrag),window.addEventListener("pointermove",this.onHtmlDrag),window.addEventListener("mouseup",this.onHtmlDragEnd),window.addEventListener("pointerup",this.onHtmlDragEnd),this.textElement.addEventListener("dblclick",this.textElement.selectText);const i=this.textElement.updatePosition.bind(this.textElement);this.textElement.updatePosition=(()=>{const t=new pe,e=new pe,n=new pe;return r=>{i(r),this.startHandle&&this.endHandle&&(this.startHandle.getWorldPosition(e),this.endHandle.getWorldPosition(n),e.project(this.api.camera.value),n.project(this.api.camera.value),t.subVectors(e,n),this.textElement.align=t.x<0?"left":"right")}})()}from(t){super.from(t),this.textElement.borderColor=t.color,this.textElement.textColor=t.textColor,this.textElement.innerHTML=t.text,this.textElement.hidden=!1}updateTextElement(){const t=this.position.clone().add(this.endHandle.position);this.textElement.position.copy(t)}update(t){super.update(t),this.textElement.hidden=!1,this.textElement.style.pointerEvents="none"}end(){super.end(),this.textElement.style.pointerEvents="all",this.updateTextElement(),this.active=!0,this.color.selected=!0,this.textElement.selectText(),setTimeout((()=>this.textElement.focus()),100),this.api.renderingManager.isMobile()&&(this.textElement.innerHTML=window.prompt())}updateLine(t,e){super.updateLine(t,e),this.updateTextElement()}pointerOver(){super.pointerOver(),this.textElement.borderColor=this.color.activeColor}pointerOut(){super.pointerOut(),this.textElement.borderColor=this.color.activeColor}select(){super.select(),this.textElement.style.pointerEvents="all",this.textElement.borderColor=this.color.activeColor}deselect(){super.deselect(),this.textElement.style.pointerEvents="none",this.textElement.borderColor=this.color.activeColor}showHandles(t){this.startHandle.visible=t,this.endHandle.visible=!1,this.color.selected=t}dispose(){super.dispose(),this._api.htmlElementPositioner.removeElement(this.textElement)}}class ox extends A_{constructor(t,e,i,n){super("textMarkup",t.inputHandler,t.camera,i,n),this.api=t,this._settings=e}_createMarkup(){const t=new sx(this.api,this.cursor);return t.color.baseColor=dd(this._settings.color),t.userData.dataType=this.name,this.model.add(t),t}init(t){const e={type:this.name};return ax(e,t),t.userData.iMarkup=e,e}update(t,e){ax(t,e)}from(t){const e=hx(t),i=this._createMarkup();return i.from(e),i.userData.iMarkup=t,i}}const ax=(t,e)=>{E_(t,e),t.text=e.textElement.innerHTML,t.textColor=pd(e.textElement.textColor)},hx=t=>{const e=P_(t);return e.text=t.text,e.textColor=dd(t.textColor),e};class cx{constructor(){this.color="#ff0000"}}class lx extends Bv{constructor(){super(...arguments),this._markupApis=new Map,this._markupDataMap=new Map,this._settings=new cx,this[Symbol.iterator]=()=>ld(this._model.children,(t=>this._getMarkupData(t)))}get name(){return"markups"}get length(){return this._model.children.length}get color(){return this._settings.color}set color(t){this._settings.color=t}set api(t){this._api=t;const e=t.cursor;this._model=new Jy,this._api.models.add(this._model,!1),this.renderPass=new Gm(new Ze,this._api.camera.value),this._api.camera.subscribe((t=>this.renderPass.camera=t)),this.renderPass.clear=!1,this._api.renderingManager.composer.addPass(this.renderPass),this.renderPass.scene.add(this._model),this._addTool(new S_(this._api,this._settings,this._model,e)),this._addTool(new R_(this._api,this._settings,this._model,e)),this._addTool(new z_(this._api,this._settings,this._model,e)),this._addTool(new H_(this._api,this._settings,this._model)),this._addTool(new tx(this._api,this._settings,this._model,e)),this._addTool(new ox(this._api,this._settings,this._model,e)),this._connectStore()}_addTool(t){this._markupApis.set(t.name,t),this._api.toolManager.addTool(t),t.onFinished=()=>this._api.toolManager.activateDefaultTool()}_getMarkupData(t){const e=this._markupApis.get(t.userData.dataType);let i;return this._markupDataMap.has(t)?(i=this._markupDataMap.get(t),e.update(i,t)):(i=e.init(t),this._markupDataMap.set(t,i)),i}_getSelection(){return(this._api.selection.get(this._model.name)||[]).map((t=>this._model.getObjectById(t)))}_connectStore(){this._api.selection.subscribe((()=>{this._model.clearSelection(),this._getSelection().forEach((t=>t.select()))}))}add(t){(t instanceof Array?t:[t]).forEach((t=>{const e=this._markupApis.get(t.type).from(t);this._model.add(e),this._markupDataMap.set(e,t),this._model.updateBoundingBox()})),this._api.renderingManager.redraw()}removeById(t){const e=t instanceof Array?t:[t];e.forEach((t=>{const i=this._model.children.find((e=>e.id===t));i.dispose(),this._model.remove(i),this._api.selection.subtract(this._model.name,e)})),this._api.renderingManager.redraw()}remove(t){(t instanceof Array?t:[t]).forEach((t=>{this._model.children.forEach((e=>{t===e.userData.iMarkup&&(e.dispose(),this._model.remove(e),this._api.selection.subtract(this._model.name,[e.id]))}))})),this._api.renderingManager.redraw()}clear(){this._model.children.map((t=>(t.dispose(),t))).forEach((t=>this._model.remove(t))),this._api.renderingManager.redraw()}colorSelectedMarkups(t){const e=dd(t);this._getSelection().forEach((t=>t.color.baseColor=e))}}i(3),i(4);const ux=new RegExp("gl_Position.*(?![^]*gl_Position)"),dx=new RegExp("[^\\w]*main[^\\w]*(void)?[^\\w]*{");var px={patchMaterialForLogDepthSupport(t){if(t.vertexShader.includes("USE_LOGDEPTHBUF")||t.vertexShader.includes("logdepthbuf_pars_vertex"))return;t.vertexShader=`#include <logdepthbuf_pars_vertex>\n#define EPSILON 1e-6\n${t.vertexShader}`;let e=ux.exec(t.vertexShader),i=e[0].length+e.index;t.vertexShader=`${t.vertexShader.slice(0,i)}\n#include <logdepthbuf_vertex>\n${t.vertexShader.slice(i)}`,t.fragmentShader=`#include <itowns/precision_qualifier\n${t.fragmentShader}`,t.fragmentShader=`#include <logdepthbuf_pars_fragment>\n${t.fragmentShader}`,e=dx.exec(t.fragmentShader),i=e[0].length+e.index,t.fragmentShader=`${t.fragmentShader.slice(0,i)}\n#include <logdepthbuf_fragment>\n${t.fragmentShader.slice(i)}`,t.defines={USE_LOGDEPTHBUF:1,USE_LOGDEPTHBUF_EXT:1}},unrollLoops:(t,e)=>t.replace(/#pragma unroll_loop\s+for\s*\(\s*int\s+i\s*=\s*([\w\d]+);\s*i\s+<\s+([\w\d]+);\s*i\s*\+\+\s*\)\s*\{\n([^}]*)\}/g,(function(t,i,n,r){var s="";i=i in e?e[i]:parseInt(i,10),n=n in e?e[n]:parseInt(n,10);for(var o=i;o<n;o++)s+=r.replace(/\bi\b/g,` ${o} `);return s}))},fx=i(5),mx=i.n(fx),gx=i(6),vx=i.n(gx);let bx=!1,yx=8,_x=4096;function xx(t,e,i){const n=t.getContext(),r=n.createShader(e);return n.shaderSource(r,i),n.compileShader(r),r}function wx(){return navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox")}var Mx={isLogDepthBufferSupported:()=>bx,isFirefox:wx,isInternetExplorer:()=>!!document.documentMode,getMaxTextureUnitsCount:()=>yx,getMaxTextureSize:()=>_x,updateCapabilities(t){const e=t.getContext();yx=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),_x=e.getParameter(e.MAX_TEXTURE_SIZE);const i=e.createProgram(),n=xx(t,e.VERTEX_SHADER,vx.a);let r=`#define SAMPLE ${yx}\n`;r+=mx.a;const s=xx(t,e.FRAGMENT_SHADER,r);if(e.attachShader(i,n),e.attachShader(i,s),e.linkProgram(i),!1===e.getProgramParameter(i,e.LINK_STATUS)){if(!(yx>16))throw new Error(`The GPU capabilities could not be determined accurately.\n                    Impossible to link a shader with the Maximum texture units ${yx}`);{const t=e.getProgramInfoLog(i);console.warn(`${t}: using a maximum of 16 texture units instead of the reported value (${yx})`),wx()&&console.warn("It can come from a Mesa/Firefox bug;\n                        the shader compiles to an error when using more than 16 sampler uniforms,\n                        see https://bugzilla.mozilla.org/show_bug.cgi?id=777028"),yx=16}}e.deleteProgram(i),e.deleteShader(n),e.deleteShader(s),bx=t.capabilities.logarithmicDepthBuffer}};const Tx={FINAL:0,DEPTH:1,ID:2};var Sx={MODES:Tx,push:function(t,e){const i=void 0!==t.mode?t.mode:Tx.FINAL;if(i==e)return()=>{};const n=t=>e=>{const i=e.material;i&&(i.mode=t)};return t.traverse(n(e)),()=>{t.traverse(n(i))}}};new _e(0,0,1,1);const Ex=255/256,Px=new _e(5.9371814131736755e-8,Ex/65536,.0038909912109375,Ex);function Ax(){const t=Mx.getMaxTextureUnitsCount();return Math.min(t-1,15)}function Cx(t,e,i){var n,r,s,o,a=t.x,h=t.y,c=t.z?t.z:0;if(h<-Wb&&h>-1.001*Wb)h=-Wb;else if(h>Wb&&h<1.001*Wb)h=Wb;else{if(h<-Wb)return{x:-1/0,y:-1/0,z:t.z};if(h>Wb)return{x:1/0,y:1/0,z:t.z}}return a>Math.PI&&(a-=2*Math.PI),r=Math.sin(h),o=Math.cos(h),s=r*r,{x:((n=i/Math.sqrt(1-e*s))+c)*o*Math.cos(a),y:(n+c)*o*Math.sin(a),z:(n*(1-e)+c)*r}}function Lx(t,e,i,n){var r,s,o,a,h,c,l,u,d,p,f,m,g,v,b,y=1e-12,_=t.x,x=t.y,w=t.z?t.z:0;if(r=Math.sqrt(_*_+x*x),s=Math.sqrt(_*_+x*x+w*w),r/i<y){if(v=0,s/i<y)return Wb,b=-n,{x:t.x,y:t.y,z:t.z}}else v=Math.atan2(x,_);o=w/s,u=(a=r/s)*(1-e)*(h=1/Math.sqrt(1-e*(2-e)*a*a)),d=o*h,g=0;do{g++,c=e*(l=i/Math.sqrt(1-e*d*d))/(l+(b=r*u+w*d-l*(1-e*d*d))),m=(f=o*(h=1/Math.sqrt(1-c*(2-c)*a*a)))*u-(p=a*(1-c)*h)*d,u=p,d=f}while(m*m>1e-24&&g<30);return{x:v,y:Math.atan(f/Math.abs(p)),z:b}}function Rx(t){return 1===t||2===t}var Ix=function(t,e,i){return function(t,e){return t.datum_type===e.datum_type&&!(t.a!==e.a||Math.abs(t.es-e.es)>5e-11)&&(1===t.datum_type?t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]:2!==t.datum_type||t.datum_params[0]===e.datum_params[0]&&t.datum_params[1]===e.datum_params[1]&&t.datum_params[2]===e.datum_params[2]&&t.datum_params[3]===e.datum_params[3]&&t.datum_params[4]===e.datum_params[4]&&t.datum_params[5]===e.datum_params[5]&&t.datum_params[6]===e.datum_params[6])}(t,e)||5===t.datum_type||5===e.datum_type?i:t.es!==e.es||t.a!==e.a||Rx(t.datum_type)||Rx(e.datum_type)?(i=Cx(i,t.es,t.a),Rx(t.datum_type)&&(i=function(t,e,i){if(1===e)return{x:t.x+i[0],y:t.y+i[1],z:t.z+i[2]};if(2===e){var n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],h=i[5],c=i[6];return{x:c*(t.x-h*t.y+a*t.z)+n,y:c*(h*t.x+t.y-o*t.z)+r,z:c*(-a*t.x+o*t.y+t.z)+s}}}(i,t.datum_type,t.datum_params)),Rx(e.datum_type)&&(i=function(t,e,i){if(1===e)return{x:t.x-i[0],y:t.y-i[1],z:t.z-i[2]};if(2===e){var n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],h=i[5],c=i[6],l=(t.x-n)/c,u=(t.y-r)/c,d=(t.z-s)/c;return{x:l+h*u-a*d,y:-h*l+u+o*d,z:a*l-o*u+d}}}(i,e.datum_type,e.datum_params)),Lx(i,e.es,e.a,e.b)):i},Ox=function(t,e,i){var n,r,s,o=i.x,a=i.y,h=i.z||0,c={};for(s=0;s<3;s++)if(!e||2!==s||void 0!==i.z)switch(0===s?(n=o,r="x"):1===s?(n=a,r="y"):(n=h,r="z"),t.axis[s]){case"e":c[r]=n;break;case"w":c[r]=-n;break;case"n":c[r]=n;break;case"s":c[r]=-n;break;case"u":void 0!==i[r]&&(c.z=n);break;case"d":void 0!==i[r]&&(c.z=-n);break;default:return null}return c},Fx=function(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e};function Bx(t){if("function"==typeof Number.isFinite){if(Number.isFinite(t))return;throw new TypeError("coordinates must be finite numbers")}if("number"!=typeof t||t!=t||!isFinite(t))throw new TypeError("coordinates must be finite numbers")}function Dx(t,e,i){var n;return Array.isArray(i)&&(i=Fx(i)),function(t){Bx(t.x),Bx(t.y)}(i),t.datum&&e.datum&&function(t,e){return(1===t.datum.datum_type||2===t.datum.datum_type)&&"WGS84"!==e.datumCode||(1===e.datum.datum_type||2===e.datum.datum_type)&&"WGS84"!==t.datumCode}(t,e)&&(i=Dx(t,n=new Dy("WGS84"),i),t=n),"enu"!==t.axis&&(i=Ox(t,!1,i)),"longlat"===t.projName?i={x:i.x*Xb,y:i.y*Xb,z:i.z||0}:(t.to_meter&&(i={x:i.x*t.to_meter,y:i.y*t.to_meter,z:i.z||0}),i=t.inverse(i)),t.from_greenwich&&(i.x+=t.from_greenwich),i=Ix(t.datum,e.datum,i),e.from_greenwich&&(i={x:i.x-e.from_greenwich,y:i.y,z:i.z||0}),"longlat"===e.projName?i={x:i.x*Yb,y:i.y*Yb,z:i.z||0}:(i=e.forward(i),e.to_meter&&(i={x:i.x/e.to_meter,y:i.y/e.to_meter,z:i.z||0})),"enu"!==e.axis?Ox(e,!0,i):i}var zx=Dy("WGS84");function Nx(t,e,i){var n,r,s;return Array.isArray(i)?(n=Dx(t,e,i)||{x:NaN,y:NaN},i.length>2?void 0!==t.name&&"geocent"===t.name||void 0!==e.name&&"geocent"===e.name?"number"==typeof n.z?[n.x,n.y,n.z].concat(i.splice(3)):[n.x,n.y,i[2]].concat(i.splice(3)):[n.x,n.y].concat(i.splice(2)):[n.x,n.y]):(r=Dx(t,e,i),2===(s=Object.keys(i)).length||s.forEach((function(n){if(void 0!==t.name&&"geocent"===t.name||void 0!==e.name&&"geocent"===e.name){if("x"===n||"y"===n||"z"===n)return}else if("x"===n||"y"===n)return;r[n]=i[n]})),r)}function Ux(t){return t instanceof Dy?t:t.oProj?t.oProj:Dy(t)}var Vx=function(t,e,i){t=Ux(t);var n,r=!1;return void 0===e?(e=t,t=zx,r=!0):(void 0!==e.x||Array.isArray(e))&&(i=e,e=t,t=zx,r=!0),e=Ux(e),i?Nx(t,e,i):(n={forward:function(i){return Nx(t,e,i)},inverse:function(i){return Nx(e,t,i)}},r&&(n.oProj=e),n)},kx="AJSAJS",jx="AFAFAF",Hx=65,Gx=73,Wx=79,qx=86,Xx=90,Yx={forward:Zx,inverse:function(t){var e=Kx(iw(t.toUpperCase()));if(e.lat&&e.lon)return[e.lon,e.lat,e.lon,e.lat];return[e.left,e.bottom,e.right,e.top]},toPoint:$x};function Zx(t,e){return e=e||5,function(t,e){var i="00000"+t.easting,n="00000"+t.northing;return t.zoneNumber+t.zoneLetter+(p=t.easting,f=t.northing,m=t.zoneNumber,g=ew(m),v=Math.floor(p/1e5),b=Math.floor(f/1e5)%20,r=v,s=b,o=g,a=o-1,h=kx.charCodeAt(a),c=jx.charCodeAt(a),l=h+r-1,u=c+s,d=!1,l>Xx&&(l=l-Xx+Hx-1,d=!0),(l===Gx||h<Gx&&l>Gx||(l>Gx||h<Gx)&&d)&&l++,(l===Wx||h<Wx&&l>Wx||(l>Wx||h<Wx)&&d)&&++l===Gx&&l++,l>Xx&&(l=l-Xx+Hx-1),u>qx?(u=u-qx+Hx-1,d=!0):d=!1,(u===Gx||c<Gx&&u>Gx||(u>Gx||c<Gx)&&d)&&u++,(u===Wx||c<Wx&&u>Wx||(u>Wx||c<Wx)&&d)&&++u===Gx&&u++,u>qx&&(u=u-qx+Hx-1),String.fromCharCode(l)+String.fromCharCode(u))+i.substr(i.length-5,e)+n.substr(n.length-5,e);var r,s,o,a,h,c,l,u,d;var p,f,m,g,v,b}(function(t){var e,i,n,r,s,o,a,h,c=t.lat,l=t.lon,u=6378137,d=.00669438,p=.9996,f=Jx(c),m=Jx(l);h=Math.floor((l+180)/6)+1,180===l&&(h=60);c>=56&&c<64&&l>=3&&l<12&&(h=32);c>=72&&c<84&&(l>=0&&l<9?h=31:l>=9&&l<21?h=33:l>=21&&l<33?h=35:l>=33&&l<42&&(h=37));a=Jx(6*(h-1)-180+3),e=d/(1-d),i=u/Math.sqrt(1-d*Math.sin(f)*Math.sin(f)),n=Math.tan(f)*Math.tan(f),r=e*Math.cos(f)*Math.cos(f),s=Math.cos(f)*(m-a),o=u*((1-d/4-3*d*d/64-5*d*d*d/256)*f-(3*d/8+3*d*d/32+45*d*d*d/1024)*Math.sin(2*f)+(15*d*d/256+45*d*d*d/1024)*Math.sin(4*f)-35*d*d*d/3072*Math.sin(6*f));var g=p*i*(s+(1-n+r)*s*s*s/6+(5-18*n+n*n+72*r-58*e)*s*s*s*s*s/120)+5e5,v=p*(o+i*Math.tan(f)*(s*s/2+(5-n+9*r+4*r*r)*s*s*s*s/24+(61-58*n+n*n+600*r-330*e)*s*s*s*s*s*s/720));c<0&&(v+=1e7);return{northing:Math.round(v),easting:Math.round(g),zoneNumber:h,zoneLetter:tw(c)}}({lat:t[1],lon:t[0]}),e)}function $x(t){var e=Kx(iw(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function Jx(t){return t*(Math.PI/180)}function Qx(t){return t/Math.PI*180}function Kx(t){var e=t.northing,i=t.easting,n=t.zoneLetter,r=t.zoneNumber;if(r<0||r>60)return null;var s,o,a,h,c,l,u,d,p,f=.9996,m=6378137,g=.00669438,v=(1-Math.sqrt(.99330562))/(1+Math.sqrt(.99330562)),b=i-5e5,y=e;n<"N"&&(y-=1e7),u=6*(r-1)-180+3,s=.006739496752268451,p=(d=y/f/6367449.145945056)+(3*v/2-27*v*v*v/32)*Math.sin(2*d)+(21*v*v/16-55*v*v*v*v/32)*Math.sin(4*d)+151*v*v*v/96*Math.sin(6*d),o=m/Math.sqrt(1-g*Math.sin(p)*Math.sin(p)),a=Math.tan(p)*Math.tan(p),h=s*Math.cos(p)*Math.cos(p),c=.99330562*m/Math.pow(1-g*Math.sin(p)*Math.sin(p),1.5),l=b/(o*f);var _=p-o*Math.tan(p)/c*(l*l/2-(5+3*a+10*h-4*h*h-9*s)*l*l*l*l/24+(61+90*a+298*h+45*a*a-1.6983531815716497-3*h*h)*l*l*l*l*l*l/720);_=Qx(_);var x,w=(l-(1+2*a+h)*l*l*l/6+(5-2*h+28*a-3*h*h+8*s+24*a*a)*l*l*l*l*l/120)/Math.cos(p);if(w=u+Qx(w),t.accuracy){var M=Kx({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});x={top:M.lat,right:M.lon,bottom:_,left:w}}else x={lat:_,lon:w};return x}function tw(t){var e="Z";return 84>=t&&t>=72?e="X":72>t&&t>=64?e="W":64>t&&t>=56?e="V":56>t&&t>=48?e="U":48>t&&t>=40?e="T":40>t&&t>=32?e="S":32>t&&t>=24?e="R":24>t&&t>=16?e="Q":16>t&&t>=8?e="P":8>t&&t>=0?e="N":0>t&&t>=-8?e="M":-8>t&&t>=-16?e="L":-16>t&&t>=-24?e="K":-24>t&&t>=-32?e="J":-32>t&&t>=-40?e="H":-40>t&&t>=-48?e="G":-48>t&&t>=-56?e="F":-56>t&&t>=-64?e="E":-64>t&&t>=-72?e="D":-72>t&&t>=-80&&(e="C"),e}function ew(t){var e=t%6;return 0===e&&(e=6),e}function iw(t){if(t&&0===t.length)throw"MGRSPoint coverting from nothing";for(var e,i=t.length,n=null,r="",s=0;!/[A-Z]/.test(e=t.charAt(s));){if(s>=2)throw"MGRSPoint bad conversion from: "+t;r+=e,s++}var o=parseInt(r,10);if(0===s||s+3>i)throw"MGRSPoint bad conversion from: "+t;var a=t.charAt(s++);if(a<="A"||"B"===a||"Y"===a||a>="Z"||"I"===a||"O"===a)throw"MGRSPoint zone letter "+a+" not handled: "+t;n=t.substring(s,s+=2);for(var h=ew(o),c=function(t,e){var i=kx.charCodeAt(e-1),n=1e5,r=!1;for(;i!==t.charCodeAt(0);){if(++i===Gx&&i++,i===Wx&&i++,i>Xx){if(r)throw"Bad character: "+t;i=Hx,r=!0}n+=1e5}return n}(n.charAt(0),h),l=function(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;var i=jx.charCodeAt(e-1),n=0,r=!1;for(;i!==t.charCodeAt(0);){if(++i===Gx&&i++,i===Wx&&i++,i>qx){if(r)throw"Bad character: "+t;i=Hx,r=!0}n+=1e5}return n}(n.charAt(1),h);l<nw(a);)l+=2e6;var u=i-s;if(u%2!=0)throw"MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters"+t;var d,p,f,m=u/2,g=0,v=0;return m>0&&(d=1e5/Math.pow(10,m),p=t.substring(s,s+m),g=parseFloat(p)*d,f=t.substring(s+m),v=parseFloat(f)*d),{easting:g+c,northing:v+l,zoneLetter:a,zoneNumber:o,accuracy:d}}function nw(t){var e;switch(t){case"C":e=11e5;break;case"D":e=2e6;break;case"E":e=28e5;break;case"F":e=37e5;break;case"G":e=46e5;break;case"H":e=55e5;break;case"J":e=64e5;break;case"K":e=73e5;break;case"L":e=82e5;break;case"M":e=91e5;break;case"N":e=0;break;case"P":e=8e5;break;case"Q":e=17e5;break;case"R":e=26e5;break;case"S":e=35e5;break;case"T":e=44e5;break;case"U":e=53e5;break;case"V":e=62e5;break;case"W":e=7e6;break;case"X":e=79e5;break;default:e=-1}if(e>=0)return e;throw"Invalid zone letter: "+t}function rw(t,e,i){if(!(this instanceof rw))return new rw(t,e,i);if(Array.isArray(t))this.x=t[0],this.y=t[1],this.z=t[2]||0;else if("object"==typeof t)this.x=t.x,this.y=t.y,this.z=t.z||0;else if("string"==typeof t&&void 0===e){var n=t.split(",");this.x=parseFloat(n[0],10),this.y=parseFloat(n[1],10),this.z=parseFloat(n[2],10)||0}else this.x=t,this.y=e,this.z=i||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}rw.fromMGRS=function(t){return new rw($x(t))},rw.prototype.toMGRS=function(t){return Zx([this.x,this.y],t)};var sw=rw,ow=.046875,aw=.01953125,hw=.01068115234375,cw=function(t){var e=[];e[0]=1-t*(.25+t*(ow+t*(aw+t*hw))),e[1]=t*(.75-t*(ow+t*(aw+t*hw)));var i=t*t;return e[2]=i*(.46875-t*(.013020833333333334+.007120768229166667*t)),i*=t,e[3]=i*(.3645833333333333-.005696614583333333*t),e[4]=i*t*.3076171875,e},lw=function(t,e,i,n){return i*=e,e*=e,n[0]*t-i*(n[1]+e*(n[2]+e*(n[3]+e*n[4])))},uw=function(t,e,i){for(var n=1/(1-e),r=t,s=20;s;--s){var o=Math.sin(r),a=1-e*o*o;if(r-=a=(lw(r,o,Math.cos(r),i)-t)*(a*Math.sqrt(a))*n,Math.abs(a)<qb)return r}return r};var dw={init:function(){this.x0=void 0!==this.x0?this.x0:0,this.y0=void 0!==this.y0?this.y0:0,this.long0=void 0!==this.long0?this.long0:0,this.lat0=void 0!==this.lat0?this.lat0:0,this.es&&(this.en=cw(this.es),this.ml0=lw(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))},forward:function(t){var e,i,n,r=t.x,s=t.y,o=wy(r-this.long0),a=Math.sin(s),h=Math.cos(s);if(this.es){var c=h*o,l=Math.pow(c,2),u=this.ep2*Math.pow(h,2),d=Math.pow(u,2),p=Math.abs(h)>qb?Math.tan(s):0,f=Math.pow(p,2),m=Math.pow(f,2);e=1-this.es*Math.pow(a,2),c/=Math.sqrt(e);var g=lw(s,a,h,this.en);i=this.a*(this.k0*c*(1+l/6*(1-f+u+l/20*(5-18*f+m+14*u-58*f*u+l/42*(61+179*m-m*f-479*f)))))+this.x0,n=this.a*(this.k0*(g-this.ml0+a*o*c/2*(1+l/12*(5-f+9*u+4*d+l/30*(61+m-58*f+270*u-330*f*u+l/56*(1385+543*m-m*f-3111*f))))))+this.y0}else{var v=h*Math.sin(o);if(Math.abs(Math.abs(v)-1)<qb)return 93;if(i=.5*this.a*this.k0*Math.log((1+v)/(1-v))+this.x0,n=h*Math.cos(o)/Math.sqrt(1-Math.pow(v,2)),(v=Math.abs(n))>=1){if(v-1>qb)return 93;n=0}else n=Math.acos(n);s<0&&(n=-n),n=this.a*this.k0*(n-this.lat0)+this.y0}return t.x=i,t.y=n,t},inverse:function(t){var e,i,n,r,s=(t.x-this.x0)*(1/this.a),o=(t.y-this.y0)*(1/this.a);if(this.es)if(e=this.ml0+o/this.k0,i=uw(e,this.es,this.en),Math.abs(i)<Wb){var a=Math.sin(i),h=Math.cos(i),c=Math.abs(h)>qb?Math.tan(i):0,l=this.ep2*Math.pow(h,2),u=Math.pow(l,2),d=Math.pow(c,2),p=Math.pow(d,2);e=1-this.es*Math.pow(a,2);var f=s*Math.sqrt(e)/this.k0,m=Math.pow(f,2);n=i-(e*=c)*m/(1-this.es)*.5*(1-m/12*(5+3*d-9*l*d+l-4*u-m/30*(61+90*d-252*l*d+45*p+46*l-m/56*(1385+3633*d+4095*p+1574*p*d)))),r=wy(this.long0+f*(1-m/6*(1+2*d+l-m/20*(5+28*d+24*p+8*l*d+6*l-m/42*(61+662*d+1320*p+720*p*d))))/h)}else n=Wb*xy(o),r=0;else{var g=Math.exp(s/this.k0),v=.5*(g-1/g),b=this.lat0+o/this.k0,y=Math.cos(b);e=Math.sqrt((1-Math.pow(y,2))/(1+Math.pow(v,2))),n=Math.asin(e),o<0&&(n=-n),r=0===v&&0===y?0:wy(Math.atan2(v,y)+this.long0)}return t.x=r,t.y=n,t},names:["Transverse_Mercator","Transverse Mercator","tmerc"]},pw=function(t){var e=Math.exp(t);return e=(e-1/e)/2},fw=function(t,e){t=Math.abs(t),e=Math.abs(e);var i=Math.max(t,e),n=Math.min(t,e)/(i||1);return i*Math.sqrt(1+Math.pow(n,2))},mw=function(t){var e=Math.abs(t);return e=function(t){var e=1+t,i=e-1;return 0===i?t:t*Math.log(e)/i}(e*(1+e/(fw(1,e)+1))),t<0?-e:e},gw=function(t,e){for(var i,n=2*Math.cos(2*e),r=t.length-1,s=t[r],o=0;--r>=0;)i=n*s-o+t[r],o=s,s=i;return e+i*Math.sin(2*e)},vw=function(t,e,i){for(var n,r,s=Math.sin(e),o=Math.cos(e),a=pw(i),h=function(t){var e=Math.exp(t);return(e+1/e)/2}(i),c=2*o*h,l=-2*s*a,u=t.length-1,d=t[u],p=0,f=0,m=0;--u>=0;)n=f,r=p,d=c*(f=d)-n-l*(p=m)+t[u],m=l*f-r+c*p;return[(c=s*h)*d-(l=o*a)*m,c*m+l*d]};var bw={init:function(){if(void 0===this.es||this.es<=0)throw new Error("incorrect elliptical usage");this.x0=void 0!==this.x0?this.x0:0,this.y0=void 0!==this.y0?this.y0:0,this.long0=void 0!==this.long0?this.long0:0,this.lat0=void 0!==this.lat0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var t=this.es/(1+Math.sqrt(1-this.es)),e=t/(2-t),i=e;this.cgb[0]=e*(2+e*(-2/3+e*(e*(116/45+e*(26/45+e*(-2854/675)))-2))),this.cbg[0]=e*(e*(2/3+e*(4/3+e*(-82/45+e*(32/45+e*(4642/4725)))))-2),i*=e,this.cgb[1]=i*(7/3+e*(e*(-227/45+e*(2704/315+e*(2323/945)))-1.6)),this.cbg[1]=i*(5/3+e*(-16/15+e*(-13/9+e*(904/315+e*(-1522/945))))),i*=e,this.cgb[2]=i*(56/15+e*(-136/35+e*(-1262/105+e*(73814/2835)))),this.cbg[2]=i*(-26/15+e*(34/21+e*(1.6+e*(-12686/2835)))),i*=e,this.cgb[3]=i*(4279/630+e*(-332/35+e*(-399572/14175))),this.cbg[3]=i*(1237/630+e*(e*(-24832/14175)-2.4)),i*=e,this.cgb[4]=i*(4174/315+e*(-144838/6237)),this.cbg[4]=i*(-734/315+e*(109598/31185)),i*=e,this.cgb[5]=i*(601676/22275),this.cbg[5]=i*(444337/155925),i=Math.pow(e,2),this.Qn=this.k0/(1+e)*(1+i*(1/4+i*(1/64+i/256))),this.utg[0]=e*(e*(2/3+e*(-37/96+e*(1/360+e*(81/512+e*(-96199/604800)))))-.5),this.gtu[0]=e*(.5+e*(-2/3+e*(5/16+e*(41/180+e*(-127/288+e*(7891/37800)))))),this.utg[1]=i*(-1/48+e*(-1/15+e*(437/1440+e*(-46/105+e*(1118711/3870720))))),this.gtu[1]=i*(13/48+e*(e*(557/1440+e*(281/630+e*(-1983433/1935360)))-.6)),i*=e,this.utg[2]=i*(-17/480+e*(37/840+e*(209/4480+e*(-5569/90720)))),this.gtu[2]=i*(61/240+e*(-103/140+e*(15061/26880+e*(167603/181440)))),i*=e,this.utg[3]=i*(-4397/161280+e*(11/504+e*(830251/7257600))),this.gtu[3]=i*(49561/161280+e*(-179/168+e*(6601661/7257600))),i*=e,this.utg[4]=i*(-4583/161280+e*(108847/3991680)),this.gtu[4]=i*(34729/80640+e*(-3418889/1995840)),i*=e,this.utg[5]=i*(-20648693/638668800),this.gtu[5]=.6650675310896665*i;var n=gw(this.cbg,this.lat0);this.Zb=-this.Qn*(n+function(t,e){for(var i,n=2*Math.cos(e),r=t.length-1,s=t[r],o=0;--r>=0;)i=n*s-o+t[r],o=s,s=i;return Math.sin(e)*i}(this.gtu,2*n))},forward:function(t){var e=wy(t.x-this.long0),i=t.y;i=gw(this.cbg,i);var n=Math.sin(i),r=Math.cos(i),s=Math.sin(e),o=Math.cos(e);i=Math.atan2(n,o*r),e=Math.atan2(s*r,fw(n,r*o)),e=mw(Math.tan(e));var a,h,c=vw(this.gtu,2*i,2*e);return i+=c[0],e+=c[1],Math.abs(e)<=2.623395162778?(a=this.a*(this.Qn*e)+this.x0,h=this.a*(this.Qn*i+this.Zb)+this.y0):(a=1/0,h=1/0),t.x=a,t.y=h,t},inverse:function(t){var e,i,n=(t.x-this.x0)*(1/this.a),r=(t.y-this.y0)*(1/this.a);if(r=(r-this.Zb)/this.Qn,n/=this.Qn,Math.abs(n)<=2.623395162778){var s=vw(this.utg,2*r,2*n);r+=s[0],n+=s[1],n=Math.atan(pw(n));var o=Math.sin(r),a=Math.cos(r),h=Math.sin(n),c=Math.cos(n);r=Math.atan2(o*c,fw(h,c*a)),n=Math.atan2(h,c*a),e=wy(n+this.long0),i=gw(this.cgb,r)}else e=1/0,i=1/0;return t.x=e,t.y=i,t},names:["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc"]};var yw={init:function(){var t=function(t,e){if(void 0===t){if((t=Math.floor(30*(wy(e)+Math.PI)/Math.PI)+1)<0)return 0;if(t>60)return 60}return t}(this.zone,this.long0);if(void 0===t)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(t)-183)*Xb,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,bw.init.apply(this),this.forward=bw.forward,this.inverse=bw.inverse},names:["Universal Transverse Mercator System","utm"],dependsOn:"etmerc"},_w=function(t,e){return Math.pow((1-t)/(1+t),e)};var xw={init:function(){var t=Math.sin(this.lat0),e=Math.cos(this.lat0);e*=e,this.rc=Math.sqrt(1-this.es)/(1-this.es*t*t),this.C=Math.sqrt(1+this.es*e*e/(1-this.es)),this.phic0=Math.asin(t/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+Zb)/(Math.pow(Math.tan(.5*this.lat0+Zb),this.C)*_w(this.e*t,this.ratexp))},forward:function(t){var e=t.x,i=t.y;return t.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*i+Zb),this.C)*_w(this.e*Math.sin(i),this.ratexp))-Wb,t.x=this.C*e,t},inverse:function(t){for(var e=t.x/this.C,i=t.y,n=Math.pow(Math.tan(.5*i+Zb)/this.K,1/this.C),r=20;r>0&&(i=2*Math.atan(n*_w(this.e*Math.sin(t.y),-.5*this.e))-Wb,!(Math.abs(i-t.y)<1e-14));--r)t.y=i;return r?(t.x=e,t.y=i,t):null},names:["gauss"]};var ww={init:function(){xw.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))},forward:function(t){var e,i,n,r;return t.x=wy(t.x-this.long0),xw.forward.apply(this,[t]),e=Math.sin(t.y),i=Math.cos(t.y),n=Math.cos(t.x),r=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*i*n),t.x=r*i*Math.sin(t.x),t.y=r*(this.cosc0*e-this.sinc0*i*n),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t},inverse:function(t){var e,i,n,r,s;if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,s=Math.sqrt(t.x*t.x+t.y*t.y)){var o=2*Math.atan2(s,this.R2);e=Math.sin(o),i=Math.cos(o),r=Math.asin(i*this.sinc0+t.y*e*this.cosc0/s),n=Math.atan2(t.x*e,s*this.cosc0*i-t.y*this.sinc0*e)}else r=this.phic0,n=0;return t.x=n,t.y=r,xw.inverse.apply(this,[t]),t.x=wy(t.x+this.long0),t},names:["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"]};var Mw={init:function(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=qb&&(this.k0=.5*(1+xy(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=qb&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=qb&&(this.k0=.5*this.cons*_y(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/My(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=_y(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-Wb,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))},forward:function(t){var e,i,n,r,s,o,a=t.x,h=t.y,c=Math.sin(h),l=Math.cos(h),u=wy(a-this.long0);return Math.abs(Math.abs(a-this.long0)-Math.PI)<=qb&&Math.abs(h+this.lat0)<=qb?(t.x=NaN,t.y=NaN,t):this.sphere?(e=2*this.k0/(1+this.sinlat0*c+this.coslat0*l*Math.cos(u)),t.x=this.a*e*l*Math.sin(u)+this.x0,t.y=this.a*e*(this.coslat0*c-this.sinlat0*l*Math.cos(u))+this.y0,t):(i=2*Math.atan(this.ssfn_(h,c,this.e))-Wb,r=Math.cos(i),n=Math.sin(i),Math.abs(this.coslat0)<=qb?(s=My(this.e,h*this.con,this.con*c),o=2*this.a*this.k0*s/this.cons,t.x=this.x0+o*Math.sin(a-this.long0),t.y=this.y0-this.con*o*Math.cos(a-this.long0),t):(Math.abs(this.sinlat0)<qb?(e=2*this.a*this.k0/(1+r*Math.cos(u)),t.y=e*n):(e=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*n+this.cosX0*r*Math.cos(u))),t.y=e*(this.cosX0*n-this.sinX0*r*Math.cos(u))+this.y0),t.x=e*r*Math.sin(u)+this.x0,t))},inverse:function(t){var e,i,n,r,s;t.x-=this.x0,t.y-=this.y0;var o=Math.sqrt(t.x*t.x+t.y*t.y);if(this.sphere){var a=2*Math.atan(o/(2*this.a*this.k0));return e=this.long0,i=this.lat0,o<=qb?(t.x=e,t.y=i,t):(i=Math.asin(Math.cos(a)*this.sinlat0+t.y*Math.sin(a)*this.coslat0/o),e=Math.abs(this.coslat0)<qb?this.lat0>0?wy(this.long0+Math.atan2(t.x,-1*t.y)):wy(this.long0+Math.atan2(t.x,t.y)):wy(this.long0+Math.atan2(t.x*Math.sin(a),o*this.coslat0*Math.cos(a)-t.y*this.sinlat0*Math.sin(a))),t.x=e,t.y=i,t)}if(Math.abs(this.coslat0)<=qb){if(o<=qb)return i=this.lat0,e=this.long0,t.x=e,t.y=i,t;t.x*=this.con,t.y*=this.con,n=o*this.cons/(2*this.a*this.k0),i=this.con*Ty(this.e,n),e=this.con*wy(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else r=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),e=this.long0,o<=qb?s=this.X0:(s=Math.asin(Math.cos(r)*this.sinX0+t.y*Math.sin(r)*this.cosX0/o),e=wy(this.long0+Math.atan2(t.x*Math.sin(r),o*this.cosX0*Math.cos(r)-t.y*this.sinX0*Math.sin(r)))),i=-1*Ty(this.e,Math.tan(.5*(Wb+s)));return t.x=e,t.y=i,t},names:["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],ssfn_:function(t,e,i){return e*=i,Math.tan(.5*(Wb+t))*Math.pow((1-e)/(1+e),.5*i)}};var Tw={init:function(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),i=this.a,n=1/this.rf,r=2*n-Math.pow(n,2),s=this.e=Math.sqrt(r);this.R=this.k0*i*Math.sqrt(1-r)/(1-r*Math.pow(e,2)),this.alpha=Math.sqrt(1+r/(1-r)*Math.pow(Math.cos(t),4)),this.b0=Math.asin(e/this.alpha);var o=Math.log(Math.tan(Math.PI/4+this.b0/2)),a=Math.log(Math.tan(Math.PI/4+t/2)),h=Math.log((1+s*e)/(1-s*e));this.K=o-this.alpha*a+this.alpha*s/2*h},forward:function(t){var e=Math.log(Math.tan(Math.PI/4-t.y/2)),i=this.e/2*Math.log((1+this.e*Math.sin(t.y))/(1-this.e*Math.sin(t.y))),n=-this.alpha*(e+i)+this.K,r=2*(Math.atan(Math.exp(n))-Math.PI/4),s=this.alpha*(t.x-this.lambda0),o=Math.atan(Math.sin(s)/(Math.sin(this.b0)*Math.tan(r)+Math.cos(this.b0)*Math.cos(s))),a=Math.asin(Math.cos(this.b0)*Math.sin(r)-Math.sin(this.b0)*Math.cos(r)*Math.cos(s));return t.y=this.R/2*Math.log((1+Math.sin(a))/(1-Math.sin(a)))+this.y0,t.x=this.R*o+this.x0,t},inverse:function(t){for(var e=t.x-this.x0,i=t.y-this.y0,n=e/this.R,r=2*(Math.atan(Math.exp(i/this.R))-Math.PI/4),s=Math.asin(Math.cos(this.b0)*Math.sin(r)+Math.sin(this.b0)*Math.cos(r)*Math.cos(n)),o=Math.atan(Math.sin(n)/(Math.cos(this.b0)*Math.cos(n)-Math.sin(this.b0)*Math.tan(r))),a=this.lambda0+o/this.alpha,h=0,c=s,l=-1e3,u=0;Math.abs(c-l)>1e-7;){if(++u>20)return;h=1/this.alpha*(Math.log(Math.tan(Math.PI/4+s/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(c))/2)),l=c,c=2*Math.atan(Math.exp(h))-Math.PI/2}return t.x=a,t.y=c,t},names:["somerc"]};var Sw={init:function(){this.no_off=this.no_off||!1,this.no_rot=this.no_rot||!1,isNaN(this.k0)&&(this.k0=1);var t=Math.sin(this.lat0),e=Math.cos(this.lat0),i=this.e*t;this.bl=Math.sqrt(1+this.es/(1-this.es)*Math.pow(e,4)),this.al=this.a*this.bl*this.k0*Math.sqrt(1-this.es)/(1-i*i);var n,r,s=My(this.e,this.lat0,t),o=this.bl/e*Math.sqrt((1-this.es)/(1-i*i));if(o*o<1&&(o=1),isNaN(this.longc)){var a=My(this.e,this.lat1,Math.sin(this.lat1)),h=My(this.e,this.lat2,Math.sin(this.lat2));this.lat0>=0?this.el=(o+Math.sqrt(o*o-1))*Math.pow(s,this.bl):this.el=(o-Math.sqrt(o*o-1))*Math.pow(s,this.bl);var c=Math.pow(a,this.bl),l=Math.pow(h,this.bl);r=.5*((n=this.el/c)-1/n);var u=(this.el*this.el-l*c)/(this.el*this.el+l*c),d=(l-c)/(l+c),p=wy(this.long1-this.long2);this.long0=.5*(this.long1+this.long2)-Math.atan(u*Math.tan(.5*this.bl*p)/d)/this.bl,this.long0=wy(this.long0);var f=wy(this.long1-this.long0);this.gamma0=Math.atan(Math.sin(this.bl*f)/r),this.alpha=Math.asin(o*Math.sin(this.gamma0))}else n=this.lat0>=0?o+Math.sqrt(o*o-1):o-Math.sqrt(o*o-1),this.el=n*Math.pow(s,this.bl),r=.5*(n-1/n),this.gamma0=Math.asin(Math.sin(this.alpha)/o),this.long0=this.longc-Math.asin(r*Math.tan(this.gamma0))/this.bl;this.no_off?this.uc=0:this.lat0>=0?this.uc=this.al/this.bl*Math.atan2(Math.sqrt(o*o-1),Math.cos(this.alpha)):this.uc=-1*this.al/this.bl*Math.atan2(Math.sqrt(o*o-1),Math.cos(this.alpha))},forward:function(t){var e,i,n,r=t.x,s=t.y,o=wy(r-this.long0);if(Math.abs(Math.abs(s)-Wb)<=qb)n=s>0?-1:1,i=this.al/this.bl*Math.log(Math.tan(Zb+n*this.gamma0*.5)),e=-1*n*Wb*this.al/this.bl;else{var a=My(this.e,s,Math.sin(s)),h=this.el/Math.pow(a,this.bl),c=.5*(h-1/h),l=.5*(h+1/h),u=Math.sin(this.bl*o),d=(c*Math.sin(this.gamma0)-u*Math.cos(this.gamma0))/l;i=Math.abs(Math.abs(d)-1)<=qb?Number.POSITIVE_INFINITY:.5*this.al*Math.log((1-d)/(1+d))/this.bl,e=Math.abs(Math.cos(this.bl*o))<=qb?this.al*this.bl*o:this.al*Math.atan2(c*Math.cos(this.gamma0)+u*Math.sin(this.gamma0),Math.cos(this.bl*o))/this.bl}return this.no_rot?(t.x=this.x0+e,t.y=this.y0+i):(e-=this.uc,t.x=this.x0+i*Math.cos(this.alpha)+e*Math.sin(this.alpha),t.y=this.y0+e*Math.cos(this.alpha)-i*Math.sin(this.alpha)),t},inverse:function(t){var e,i;this.no_rot?(i=t.y-this.y0,e=t.x-this.x0):(i=(t.x-this.x0)*Math.cos(this.alpha)-(t.y-this.y0)*Math.sin(this.alpha),e=(t.y-this.y0)*Math.cos(this.alpha)+(t.x-this.x0)*Math.sin(this.alpha),e+=this.uc);var n=Math.exp(-1*this.bl*i/this.al),r=.5*(n-1/n),s=.5*(n+1/n),o=Math.sin(this.bl*e/this.al),a=(o*Math.cos(this.gamma0)+r*Math.sin(this.gamma0))/s,h=Math.pow(this.el/Math.sqrt((1+a)/(1-a)),1/this.bl);return Math.abs(a-1)<qb?(t.x=this.long0,t.y=Wb):Math.abs(a+1)<qb?(t.x=this.long0,t.y=-1*Wb):(t.y=Ty(this.e,h),t.x=wy(this.long0-Math.atan2(r*Math.cos(this.gamma0)-o*Math.sin(this.gamma0),Math.cos(this.bl*e/this.al))/this.bl)),t},names:["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","omerc"]};var Ew={init:function(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<qb)){var t=this.b/this.a;this.e=Math.sqrt(1-t*t);var e=Math.sin(this.lat1),i=Math.cos(this.lat1),n=_y(this.e,e,i),r=My(this.e,this.lat1,e),s=Math.sin(this.lat2),o=Math.cos(this.lat2),a=_y(this.e,s,o),h=My(this.e,this.lat2,s),c=My(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>qb?this.ns=Math.log(n/a)/Math.log(r/h):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=n/(this.ns*Math.pow(r,this.ns)),this.rh=this.a*this.f0*Math.pow(c,this.ns),this.title||(this.title="Lambert Conformal Conic")}},forward:function(t){var e=t.x,i=t.y;Math.abs(2*Math.abs(i)-Math.PI)<=qb&&(i=xy(i)*(Wb-2e-10));var n,r,s=Math.abs(Math.abs(i)-Wb);if(s>qb)n=My(this.e,i,Math.sin(i)),r=this.a*this.f0*Math.pow(n,this.ns);else{if((s=i*this.ns)<=0)return null;r=0}var o=this.ns*wy(e-this.long0);return t.x=this.k0*(r*Math.sin(o))+this.x0,t.y=this.k0*(this.rh-r*Math.cos(o))+this.y0,t},inverse:function(t){var e,i,n,r,s,o=(t.x-this.x0)/this.k0,a=this.rh-(t.y-this.y0)/this.k0;this.ns>0?(e=Math.sqrt(o*o+a*a),i=1):(e=-Math.sqrt(o*o+a*a),i=-1);var h=0;if(0!==e&&(h=Math.atan2(i*o,i*a)),0!==e||this.ns>0){if(i=1/this.ns,n=Math.pow(e/(this.a*this.f0),i),-9999===(r=Ty(this.e,n)))return null}else r=-Wb;return s=wy(h/this.ns+this.long0),t.x=s,t.y=r,t},names:["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_2SP","lcc"]};var Pw={init:function(){this.a=6377397.155,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.4334234309119251),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq},forward:function(t){var e,i,n,r,s,o,a,h=t.x,c=t.y,l=wy(h-this.long0);return e=Math.pow((1+this.e*Math.sin(c))/(1-this.e*Math.sin(c)),this.alfa*this.e/2),i=2*(Math.atan(this.k*Math.pow(Math.tan(c/2+this.s45),this.alfa)/e)-this.s45),n=-l*this.alfa,r=Math.asin(Math.cos(this.ad)*Math.sin(i)+Math.sin(this.ad)*Math.cos(i)*Math.cos(n)),s=Math.asin(Math.cos(i)*Math.sin(n)/Math.cos(r)),o=this.n*s,a=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(r/2+this.s45),this.n),t.y=a*Math.cos(o)/1,t.x=a*Math.sin(o)/1,this.czech||(t.y*=-1,t.x*=-1),t},inverse:function(t){var e,i,n,r,s,o,a,h=t.x;t.x=t.y,t.y=h,this.czech||(t.y*=-1,t.x*=-1),s=Math.sqrt(t.x*t.x+t.y*t.y),r=Math.atan2(t.y,t.x)/Math.sin(this.s0),n=2*(Math.atan(Math.pow(this.ro0/s,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),e=Math.asin(Math.cos(this.ad)*Math.sin(n)-Math.sin(this.ad)*Math.cos(n)*Math.cos(r)),i=Math.asin(Math.cos(n)*Math.sin(r)/Math.cos(e)),t.x=this.long0-i/this.alfa,o=e,a=0;var c=0;do{t.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(e/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(o))/(1-this.e*Math.sin(o)),this.e/2))-this.s45),Math.abs(o-t.y)<1e-10&&(a=1),o=t.y,c+=1}while(0===a&&c<15);return c>=15?null:t},names:["Krovak","krovak"]},Aw=function(t,e,i,n,r){return t*r-e*Math.sin(2*r)+i*Math.sin(4*r)-n*Math.sin(6*r)},Cw=function(t){return 1-.25*t*(1+t/16*(3+1.25*t))},Lw=function(t){return.375*t*(1+.25*t*(1+.46875*t))},Rw=function(t){return.05859375*t*t*(1+.75*t)},Iw=function(t){return t*t*t*(35/3072)},Ow=function(t,e,i){var n=e*i;return t/Math.sqrt(1-n*n)},Fw=function(t){return Math.abs(t)<Wb?t:t-xy(t)*Math.PI},Bw=function(t,e,i,n,r){var s,o;s=t/e;for(var a=0;a<15;a++)if(s+=o=(t-(e*s-i*Math.sin(2*s)+n*Math.sin(4*s)-r*Math.sin(6*s)))/(e-2*i*Math.cos(2*s)+4*n*Math.cos(4*s)-6*r*Math.cos(6*s)),Math.abs(o)<=1e-10)return s;return NaN};var Dw={init:function(){this.sphere||(this.e0=Cw(this.es),this.e1=Lw(this.es),this.e2=Rw(this.es),this.e3=Iw(this.es),this.ml0=this.a*Aw(this.e0,this.e1,this.e2,this.e3,this.lat0))},forward:function(t){var e,i,n=t.x,r=t.y;if(n=wy(n-this.long0),this.sphere)e=this.a*Math.asin(Math.cos(r)*Math.sin(n)),i=this.a*(Math.atan2(Math.tan(r),Math.cos(n))-this.lat0);else{var s=Math.sin(r),o=Math.cos(r),a=Ow(this.a,this.e,s),h=Math.tan(r)*Math.tan(r),c=n*Math.cos(r),l=c*c,u=this.es*o*o/(1-this.es);e=a*c*(1-l*h*(1/6-(8-h+8*u)*l/120)),i=this.a*Aw(this.e0,this.e1,this.e2,this.e3,r)-this.ml0+a*s/o*l*(.5+(5-h+6*u)*l/24)}return t.x=e+this.x0,t.y=i+this.y0,t},inverse:function(t){t.x-=this.x0,t.y-=this.y0;var e,i,n=t.x/this.a,r=t.y/this.a;if(this.sphere){var s=r+this.lat0;e=Math.asin(Math.sin(s)*Math.cos(n)),i=Math.atan2(Math.tan(n),Math.cos(s))}else{var o=this.ml0/this.a+r,a=Bw(o,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(a)-Wb)<=qb)return t.x=this.long0,t.y=Wb,r<0&&(t.y*=-1),t;var h=Ow(this.a,this.e,Math.sin(a)),c=h*h*h/this.a/this.a*(1-this.es),l=Math.pow(Math.tan(a),2),u=n*this.a/h,d=u*u;e=a-h*Math.tan(a)/c*u*u*(.5-(1+3*l)*u*u/24),i=u*(1-d*(l/3+(1+3*l)*l*d/15))/Math.cos(a)}return t.x=wy(i+this.long0),t.y=Fw(e),t},names:["Cassini","Cassini_Soldner","cass"]},zw=function(t,e){var i;return t>1e-7?(1-t*t)*(e/(1-(i=t*e)*i)-.5/t*Math.log((1-i)/(1+i))):2*e};var Nw=.3333333333333333,Uw=.17222222222222222,Vw=.10257936507936508,kw=.06388888888888888,jw=.0664021164021164,Hw=.016415012942191543;var Gw={init:function(){var t,e=Math.abs(this.lat0);if(Math.abs(e-Wb)<qb?this.mode=this.lat0<0?this.S_POLE:this.N_POLE:Math.abs(e)<qb?this.mode=this.EQUIT:this.mode=this.OBLIQ,this.es>0)switch(this.qp=zw(this.e,1),this.mmf=.5/(1-this.es),this.apa=function(t){var e,i=[];return i[0]=t*Nw,e=t*t,i[0]+=e*Uw,i[1]=e*kw,e*=t,i[0]+=e*Vw,i[1]+=e*jw,i[2]=e*Hw,i}(this.es),this.mode){case this.N_POLE:case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=zw(this.e,t)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*t*t)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))},forward:function(t){var e,i,n,r,s,o,a,h,c,l,u=t.x,d=t.y;if(u=wy(u-this.long0),this.sphere){if(s=Math.sin(d),l=Math.cos(d),n=Math.cos(u),this.mode===this.OBLIQ||this.mode===this.EQUIT){if((i=this.mode===this.EQUIT?1+l*n:1+this.sinph0*s+this.cosph0*l*n)<=qb)return null;e=(i=Math.sqrt(2/i))*l*Math.sin(u),i*=this.mode===this.EQUIT?s:this.cosph0*s-this.sinph0*l*n}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(n=-n),Math.abs(d+this.phi0)<qb)return null;i=Zb-.5*d,e=(i=2*(this.mode===this.S_POLE?Math.cos(i):Math.sin(i)))*Math.sin(u),i*=n}}else{switch(a=0,h=0,c=0,n=Math.cos(u),r=Math.sin(u),s=Math.sin(d),o=zw(this.e,s),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(a=o/this.qp,h=Math.sqrt(1-a*a)),this.mode){case this.OBLIQ:c=1+this.sinb1*a+this.cosb1*h*n;break;case this.EQUIT:c=1+h*n;break;case this.N_POLE:c=Wb+d,o=this.qp-o;break;case this.S_POLE:c=d-Wb,o=this.qp+o}if(Math.abs(c)<qb)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:c=Math.sqrt(2/c),i=this.mode===this.OBLIQ?this.ymf*c*(this.cosb1*a-this.sinb1*h*n):(c=Math.sqrt(2/(1+h*n)))*a*this.ymf,e=this.xmf*c*h*r;break;case this.N_POLE:case this.S_POLE:o>=0?(e=(c=Math.sqrt(o))*r,i=n*(this.mode===this.S_POLE?c:-c)):e=i=0}}return t.x=this.a*e+this.x0,t.y=this.a*i+this.y0,t},inverse:function(t){t.x-=this.x0,t.y-=this.y0;var e,i,n,r,s,o,a,h,c,l,u=t.x/this.a,d=t.y/this.a;if(this.sphere){var p,f=0,m=0;if((i=.5*(p=Math.sqrt(u*u+d*d)))>1)return null;switch(i=2*Math.asin(i),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(m=Math.sin(i),f=Math.cos(i)),this.mode){case this.EQUIT:i=Math.abs(p)<=qb?0:Math.asin(d*m/p),u*=m,d=f*p;break;case this.OBLIQ:i=Math.abs(p)<=qb?this.phi0:Math.asin(f*this.sinph0+d*m*this.cosph0/p),u*=m*this.cosph0,d=(f-Math.sin(i)*this.sinph0)*p;break;case this.N_POLE:d=-d,i=Wb-i;break;case this.S_POLE:i-=Wb}e=0!==d||this.mode!==this.EQUIT&&this.mode!==this.OBLIQ?Math.atan2(u,d):0}else{if(a=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(u/=this.dd,d*=this.dd,(o=Math.sqrt(u*u+d*d))<qb)return t.x=0,t.y=this.phi0,t;r=2*Math.asin(.5*o/this.rq),n=Math.cos(r),u*=r=Math.sin(r),this.mode===this.OBLIQ?(a=n*this.sinb1+d*r*this.cosb1/o,s=this.qp*a,d=o*this.cosb1*n-d*this.sinb1*r):(a=d*r/o,s=this.qp*a,d=o*n)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(d=-d),!(s=u*u+d*d))return t.x=0,t.y=this.phi0,t;a=1-s/this.qp,this.mode===this.S_POLE&&(a=-a)}e=Math.atan2(u,d),h=Math.asin(a),c=this.apa,l=h+h,i=h+c[0]*Math.sin(l)+c[1]*Math.sin(l+l)+c[2]*Math.sin(l+l+l)}return t.x=wy(this.long0+e),t.y=i,t},names:["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],S_POLE:1,N_POLE:2,EQUIT:3,OBLIQ:4},Ww=function(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)};var qw={init:function(){Math.abs(this.lat1+this.lat2)<qb||(this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=_y(this.e3,this.sin_po,this.cos_po),this.qs1=zw(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=_y(this.e3,this.sin_po,this.cos_po),this.qs2=zw(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=zw(this.e3,this.sin_po,this.cos_po),Math.abs(this.lat1-this.lat2)>qb?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)},forward:function(t){var e=t.x,i=t.y;this.sin_phi=Math.sin(i),this.cos_phi=Math.cos(i);var n=zw(this.e3,this.sin_phi,this.cos_phi),r=this.a*Math.sqrt(this.c-this.ns0*n)/this.ns0,s=this.ns0*wy(e-this.long0),o=r*Math.sin(s)+this.x0,a=this.rh-r*Math.cos(s)+this.y0;return t.x=o,t.y=a,t},inverse:function(t){var e,i,n,r,s,o;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns0>=0?(e=Math.sqrt(t.x*t.x+t.y*t.y),n=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),n=-1),r=0,0!==e&&(r=Math.atan2(n*t.x,n*t.y)),n=e*this.ns0/this.a,this.sphere?o=Math.asin((this.c-n*n)/(2*this.ns0)):(i=(this.c-n*n)/this.ns0,o=this.phi1z(this.e3,i)),s=wy(r/this.ns0+this.long0),t.x=s,t.y=o,t},names:["Albers_Conic_Equal_Area","Albers","aea"],phi1z:function(t,e){var i,n,r,s,o=Ww(.5*e);if(t<qb)return o;for(var a=t*t,h=1;h<=25;h++)if(o+=s=.5*(r=1-(n=t*(i=Math.sin(o)))*n)*r/Math.cos(o)*(e/(1-a)-i/r+.5/t*Math.log((1-n)/(1+n))),Math.abs(s)<=1e-7)return o;return null}};var Xw={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1},forward:function(t){var e,i,n,r,s,o,a,h=t.x,c=t.y;return n=wy(h-this.long0),e=Math.sin(c),i=Math.cos(c),r=Math.cos(n),1,(s=this.sin_p14*e+this.cos_p14*i*r)>0||Math.abs(s)<=qb?(o=this.x0+1*this.a*i*Math.sin(n)/s,a=this.y0+1*this.a*(this.cos_p14*e-this.sin_p14*i*r)/s):(o=this.x0+this.infinity_dist*i*Math.sin(n),a=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*i*r)),t.x=o,t.y=a,t},inverse:function(t){var e,i,n,r,s,o;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,(e=Math.sqrt(t.x*t.x+t.y*t.y))?(r=Math.atan2(e,this.rc),i=Math.sin(r),n=Math.cos(r),o=Ww(n*this.sin_p14+t.y*i*this.cos_p14/e),s=Math.atan2(t.x*i,e*this.cos_p14*n-t.y*this.sin_p14*i),s=wy(this.long0+s)):(o=this.phic0,s=0),t.x=s,t.y=o,t},names:["gnom"]};var Yw={init:function(){this.sphere||(this.k0=_y(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))},forward:function(t){var e,i,n=t.x,r=t.y,s=wy(n-this.long0);if(this.sphere)e=this.x0+this.a*s*Math.cos(this.lat_ts),i=this.y0+this.a*Math.sin(r)/Math.cos(this.lat_ts);else{var o=zw(this.e,Math.sin(r));e=this.x0+this.a*this.k0*s,i=this.y0+this.a*o*.5/this.k0}return t.x=e,t.y=i,t},inverse:function(t){var e,i;return t.x-=this.x0,t.y-=this.y0,this.sphere?(e=wy(this.long0+t.x/this.a/Math.cos(this.lat_ts)),i=Math.asin(t.y/this.a*Math.cos(this.lat_ts))):(i=function(t,e){var i=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));if(Math.abs(Math.abs(e)-i)<1e-6)return e<0?-1*Wb:Wb;for(var n,r,s,o,a=Math.asin(.5*e),h=0;h<30;h++)if(r=Math.sin(a),s=Math.cos(a),o=t*r,a+=n=Math.pow(1-o*o,2)/(2*s)*(e/(1-t*t)-r/(1-o*o)+.5/t*Math.log((1-o)/(1+o))),Math.abs(n)<=1e-10)return a;return NaN}(this.e,2*t.y*this.k0/this.a),e=wy(this.long0+t.x/(this.a*this.k0))),t.x=e,t.y=i,t},names:["cea"]};var Zw={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)},forward:function(t){var e=t.x,i=t.y,n=wy(e-this.long0),r=Fw(i-this.lat0);return t.x=this.x0+this.a*n*this.rc,t.y=this.y0+this.a*r,t},inverse:function(t){var e=t.x,i=t.y;return t.x=wy(this.long0+(e-this.x0)/(this.a*this.rc)),t.y=Fw(this.lat0+(i-this.y0)/this.a),t},names:["Equirectangular","Equidistant_Cylindrical","eqc"]};var $w={init:function(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Cw(this.es),this.e1=Lw(this.es),this.e2=Rw(this.es),this.e3=Iw(this.es),this.ml0=this.a*Aw(this.e0,this.e1,this.e2,this.e3,this.lat0)},forward:function(t){var e,i,n,r=t.x,s=t.y,o=wy(r-this.long0);if(n=o*Math.sin(s),this.sphere)Math.abs(s)<=qb?(e=this.a*o,i=-1*this.a*this.lat0):(e=this.a*Math.sin(n)/Math.tan(s),i=this.a*(Fw(s-this.lat0)+(1-Math.cos(n))/Math.tan(s)));else if(Math.abs(s)<=qb)e=this.a*o,i=-1*this.ml0;else{var a=Ow(this.a,this.e,Math.sin(s))/Math.tan(s);e=a*Math.sin(n),i=this.a*Aw(this.e0,this.e1,this.e2,this.e3,s)-this.ml0+a*(1-Math.cos(n))}return t.x=e+this.x0,t.y=i+this.y0,t},inverse:function(t){var e,i,n,r,s,o,a,h,c;if(n=t.x-this.x0,r=t.y-this.y0,this.sphere)if(Math.abs(r+this.a*this.lat0)<=qb)e=wy(n/this.a+this.long0),i=0;else{var l;for(o=this.lat0+r/this.a,a=n*n/this.a/this.a+o*o,h=o,s=20;s;--s)if(h+=c=-1*(o*(h*(l=Math.tan(h))+1)-h-.5*(h*h+a)*l)/((h-o)/l-1),Math.abs(c)<=qb){i=h;break}e=wy(this.long0+Math.asin(n*Math.tan(h)/this.a)/Math.sin(i))}else if(Math.abs(r+this.ml0)<=qb)i=0,e=wy(this.long0+n/this.a);else{var u,d,p,f,m;for(o=(this.ml0+r)/this.a,a=n*n/this.a/this.a+o*o,h=o,s=20;s;--s)if(m=this.e*Math.sin(h),u=Math.sqrt(1-m*m)*Math.tan(h),d=this.a*Aw(this.e0,this.e1,this.e2,this.e3,h),p=this.e0-2*this.e1*Math.cos(2*h)+4*this.e2*Math.cos(4*h)-6*this.e3*Math.cos(6*h),h-=c=(o*(u*(f=d/this.a)+1)-f-.5*u*(f*f+a))/(this.es*Math.sin(2*h)*(f*f+a-2*o*f)/(4*u)+(o-f)*(u*p-2/Math.sin(2*h))-p),Math.abs(c)<=qb){i=h;break}u=Math.sqrt(1-this.es*Math.pow(Math.sin(i),2))*Math.tan(i),e=wy(this.long0+Math.asin(n*u/this.a)/Math.sin(i))}return t.x=e,t.y=i,t},names:["Polyconic","poly"]};var Jw={init:function(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013},forward:function(t){var e,i=t.x,n=t.y-this.lat0,r=i-this.long0,s=n/Gb*1e-5,o=r,a=1,h=0;for(e=1;e<=10;e++)a*=s,h+=this.A[e]*a;var c,l=h,u=o,d=1,p=0,f=0,m=0;for(e=1;e<=6;e++)c=p*l+d*u,d=d*l-p*u,p=c,f=f+this.B_re[e]*d-this.B_im[e]*p,m=m+this.B_im[e]*d+this.B_re[e]*p;return t.x=m*this.a+this.x0,t.y=f*this.a+this.y0,t},inverse:function(t){var e,i,n=t.x,r=t.y,s=n-this.x0,o=(r-this.y0)/this.a,a=s/this.a,h=1,c=0,l=0,u=0;for(e=1;e<=6;e++)i=c*o+h*a,h=h*o-c*a,c=i,l=l+this.C_re[e]*h-this.C_im[e]*c,u=u+this.C_im[e]*h+this.C_re[e]*c;for(var d=0;d<this.iterations;d++){var p,f=l,m=u,g=o,v=a;for(e=2;e<=6;e++)p=m*l+f*u,f=f*l-m*u,m=p,g+=(e-1)*(this.B_re[e]*f-this.B_im[e]*m),v+=(e-1)*(this.B_im[e]*f+this.B_re[e]*m);f=1,m=0;var b=this.B_re[1],y=this.B_im[1];for(e=2;e<=6;e++)p=m*l+f*u,f=f*l-m*u,m=p,b+=e*(this.B_re[e]*f-this.B_im[e]*m),y+=e*(this.B_im[e]*f+this.B_re[e]*m);var _=b*b+y*y;l=(g*b+v*y)/_,u=(v*b-g*y)/_}var x=l,w=u,M=1,T=0;for(e=1;e<=9;e++)M*=x,T+=this.D[e]*M;var S=this.lat0+T*Gb*1e5,E=this.long0+w;return t.x=E,t.y=S,t},names:["New_Zealand_Map_Grid","nzmg"]};var Qw={init:function(){},forward:function(t){var e=t.x,i=t.y,n=wy(e-this.long0),r=this.x0+this.a*n,s=this.y0+this.a*Math.log(Math.tan(Math.PI/4+i/2.5))*1.25;return t.x=r,t.y=s,t},inverse:function(t){t.x-=this.x0,t.y-=this.y0;var e=wy(this.long0+t.x/this.a),i=2.5*(Math.atan(Math.exp(.8*t.y/this.a))-Math.PI/4);return t.x=e,t.y=i,t},names:["Miller_Cylindrical","mill"]};var Kw={init:function(){this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=cw(this.es)},forward:function(t){var e,i,n=t.x,r=t.y;if(n=wy(n-this.long0),this.sphere){if(this.m)for(var s=this.n*Math.sin(r),o=20;o;--o){var a=(this.m*r+Math.sin(r)-s)/(this.m+Math.cos(r));if(r-=a,Math.abs(a)<qb)break}else r=1!==this.n?Math.asin(this.n*Math.sin(r)):r;e=this.a*this.C_x*n*(this.m+Math.cos(r)),i=this.a*this.C_y*r}else{var h=Math.sin(r),c=Math.cos(r);i=this.a*lw(r,h,c,this.en),e=this.a*n*c/Math.sqrt(1-this.es*h*h)}return t.x=e,t.y=i,t},inverse:function(t){var e,i,n,r;return t.x-=this.x0,n=t.x/this.a,t.y-=this.y0,e=t.y/this.a,this.sphere?(e/=this.C_y,n/=this.C_x*(this.m+Math.cos(e)),this.m?e=Ww((this.m*e+Math.sin(e))/this.n):1!==this.n&&(e=Ww(Math.sin(e)/this.n)),n=wy(n+this.long0),e=Fw(e)):(e=uw(t.y/this.a,this.es,this.en),(r=Math.abs(e))<Wb?(r=Math.sin(e),i=this.long0+t.x*Math.sqrt(1-this.es*r*r)/(this.a*Math.cos(e)),n=wy(i)):r-qb<Wb&&(n=this.long0)),t.x=n,t.y=e,t},names:["Sinusoidal","sinu"]};var tM={init:function(){},forward:function(t){for(var e=t.x,i=t.y,n=wy(e-this.long0),r=i,s=Math.PI*Math.sin(i);;){var o=-(r+Math.sin(r)-s)/(1+Math.cos(r));if(r+=o,Math.abs(o)<qb)break}r/=2,Math.PI/2-Math.abs(i)<qb&&(n=0);var a=.900316316158*this.a*n*Math.cos(r)+this.x0,h=1.4142135623731*this.a*Math.sin(r)+this.y0;return t.x=a,t.y=h,t},inverse:function(t){var e,i;t.x-=this.x0,t.y-=this.y0,i=t.y/(1.4142135623731*this.a),Math.abs(i)>.999999999999&&(i=.999999999999),e=Math.asin(i);var n=wy(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));n<-Math.PI&&(n=-Math.PI),n>Math.PI&&(n=Math.PI),i=(2*e+Math.sin(2*e))/Math.PI,Math.abs(i)>1&&(i=1);var r=Math.asin(i);return t.x=n,t.y=r,t},names:["Mollweide","moll"]};var eM={init:function(){Math.abs(this.lat1+this.lat2)<qb||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Cw(this.es),this.e1=Lw(this.es),this.e2=Rw(this.es),this.e3=Iw(this.es),this.sinphi=Math.sin(this.lat1),this.cosphi=Math.cos(this.lat1),this.ms1=_y(this.e,this.sinphi,this.cosphi),this.ml1=Aw(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<qb?this.ns=this.sinphi:(this.sinphi=Math.sin(this.lat2),this.cosphi=Math.cos(this.lat2),this.ms2=_y(this.e,this.sinphi,this.cosphi),this.ml2=Aw(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=Aw(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))},forward:function(t){var e,i=t.x,n=t.y;if(this.sphere)e=this.a*(this.g-n);else{var r=Aw(this.e0,this.e1,this.e2,this.e3,n);e=this.a*(this.g-r)}var s=this.ns*wy(i-this.long0),o=this.x0+e*Math.sin(s),a=this.y0+this.rh-e*Math.cos(s);return t.x=o,t.y=a,t},inverse:function(t){var e,i,n,r;t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns>=0?(i=Math.sqrt(t.x*t.x+t.y*t.y),e=1):(i=-Math.sqrt(t.x*t.x+t.y*t.y),e=-1);var s=0;if(0!==i&&(s=Math.atan2(e*t.x,e*t.y)),this.sphere)return r=wy(this.long0+s/this.ns),n=Fw(this.g-i/this.a),t.x=r,t.y=n,t;var o=this.g-i/this.a;return n=Bw(o,this.e0,this.e1,this.e2,this.e3),r=wy(this.long0+s/this.ns),t.x=r,t.y=n,t},names:["Equidistant_Conic","eqdc"]};var iM={init:function(){this.R=this.a},forward:function(t){var e,i,n=t.x,r=t.y,s=wy(n-this.long0);Math.abs(r)<=qb&&(e=this.x0+this.R*s,i=this.y0);var o=Ww(2*Math.abs(r/Math.PI));(Math.abs(s)<=qb||Math.abs(Math.abs(r)-Wb)<=qb)&&(e=this.x0,i=r>=0?this.y0+Math.PI*this.R*Math.tan(.5*o):this.y0+Math.PI*this.R*-Math.tan(.5*o));var a=.5*Math.abs(Math.PI/s-s/Math.PI),h=a*a,c=Math.sin(o),l=Math.cos(o),u=l/(c+l-1),d=u*u,p=u*(2/c-1),f=p*p,m=Math.PI*this.R*(a*(u-f)+Math.sqrt(h*(u-f)*(u-f)-(f+h)*(d-f)))/(f+h);s<0&&(m=-m),e=this.x0+m;var g=h+u;return m=Math.PI*this.R*(p*g-a*Math.sqrt((f+h)*(h+1)-g*g))/(f+h),i=r>=0?this.y0+m:this.y0-m,t.x=e,t.y=i,t},inverse:function(t){var e,i,n,r,s,o,a,h,c,l,u,d;return t.x-=this.x0,t.y-=this.y0,u=Math.PI*this.R,s=(n=t.x/u)*n+(r=t.y/u)*r,u=3*(r*r/(h=-2*(o=-Math.abs(r)*(1+s))+1+2*r*r+s*s)+(2*(a=o-2*r*r+n*n)*a*a/h/h/h-9*o*a/h/h)/27)/(c=(o-a*a/3/h)/h)/(l=2*Math.sqrt(-c/3)),Math.abs(u)>1&&(u=u>=0?1:-1),d=Math.acos(u)/3,i=t.y>=0?(-l*Math.cos(d+Math.PI/3)-a/3/h)*Math.PI:-(-l*Math.cos(d+Math.PI/3)-a/3/h)*Math.PI,e=Math.abs(n)<qb?this.long0:wy(this.long0+Math.PI*(s-1+Math.sqrt(1+2*(n*n-r*r)+s*s))/2/n),t.x=e,t.y=i,t},names:["Van_der_Grinten_I","VanDerGrinten","vandg"]};var nM={init:function(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)},forward:function(t){var e,i,n,r,s,o,a,h,c,l,u,d,p,f,m,g,v,b,y,_,x,w,M=t.x,T=t.y,S=Math.sin(t.y),E=Math.cos(t.y),P=wy(M-this.long0);return this.sphere?Math.abs(this.sin_p12-1)<=qb?(t.x=this.x0+this.a*(Wb-T)*Math.sin(P),t.y=this.y0-this.a*(Wb-T)*Math.cos(P),t):Math.abs(this.sin_p12+1)<=qb?(t.x=this.x0+this.a*(Wb+T)*Math.sin(P),t.y=this.y0+this.a*(Wb+T)*Math.cos(P),t):(b=this.sin_p12*S+this.cos_p12*E*Math.cos(P),v=(g=Math.acos(b))/Math.sin(g),t.x=this.x0+this.a*v*E*Math.sin(P),t.y=this.y0+this.a*v*(this.cos_p12*S-this.sin_p12*E*Math.cos(P)),t):(e=Cw(this.es),i=Lw(this.es),n=Rw(this.es),r=Iw(this.es),Math.abs(this.sin_p12-1)<=qb?(s=this.a*Aw(e,i,n,r,Wb),o=this.a*Aw(e,i,n,r,T),t.x=this.x0+(s-o)*Math.sin(P),t.y=this.y0-(s-o)*Math.cos(P),t):Math.abs(this.sin_p12+1)<=qb?(s=this.a*Aw(e,i,n,r,Wb),o=this.a*Aw(e,i,n,r,T),t.x=this.x0+(s+o)*Math.sin(P),t.y=this.y0+(s+o)*Math.cos(P),t):(a=S/E,h=Ow(this.a,this.e,this.sin_p12),c=Ow(this.a,this.e,S),l=Math.atan((1-this.es)*a+this.es*h*this.sin_p12/(c*E)),y=0===(u=Math.atan2(Math.sin(P),this.cos_p12*Math.tan(l)-this.sin_p12*Math.cos(P)))?Math.asin(this.cos_p12*Math.sin(l)-this.sin_p12*Math.cos(l)):Math.abs(Math.abs(u)-Math.PI)<=qb?-Math.asin(this.cos_p12*Math.sin(l)-this.sin_p12*Math.cos(l)):Math.asin(Math.sin(P)*Math.cos(l)/Math.sin(u)),d=this.e*this.sin_p12/Math.sqrt(1-this.es),g=h*y*(1-(_=y*y)*(m=(p=this.e*this.cos_p12*Math.cos(u)/Math.sqrt(1-this.es))*p)*(1-m)/6+(x=_*y)/8*(f=d*p)*(1-2*m)+(w=x*y)/120*(m*(4-7*m)-3*d*d*(1-7*m))-w*y/48*f),t.x=this.x0+g*Math.sin(u),t.y=this.y0+g*Math.cos(u),t))},inverse:function(t){var e,i,n,r,s,o,a,h,c,l,u,d,p,f,m,g,v,b,y,_,x,w;if(t.x-=this.x0,t.y-=this.y0,this.sphere){if((e=Math.sqrt(t.x*t.x+t.y*t.y))>2*Wb*this.a)return;return i=e/this.a,n=Math.sin(i),r=Math.cos(i),s=this.long0,Math.abs(e)<=qb?o=this.lat0:(o=Ww(r*this.sin_p12+t.y*n*this.cos_p12/e),a=Math.abs(this.lat0)-Wb,s=Math.abs(a)<=qb?this.lat0>=0?wy(this.long0+Math.atan2(t.x,-t.y)):wy(this.long0-Math.atan2(-t.x,t.y)):wy(this.long0+Math.atan2(t.x*n,e*this.cos_p12*r-t.y*this.sin_p12*n))),t.x=s,t.y=o,t}return h=Cw(this.es),c=Lw(this.es),l=Rw(this.es),u=Iw(this.es),Math.abs(this.sin_p12-1)<=qb?(d=this.a*Aw(h,c,l,u,Wb),e=Math.sqrt(t.x*t.x+t.y*t.y),o=Bw((d-e)/this.a,h,c,l,u),s=wy(this.long0+Math.atan2(t.x,-1*t.y)),t.x=s,t.y=o,t):Math.abs(this.sin_p12+1)<=qb?(d=this.a*Aw(h,c,l,u,Wb),e=Math.sqrt(t.x*t.x+t.y*t.y),o=Bw((e-d)/this.a,h,c,l,u),s=wy(this.long0+Math.atan2(t.x,t.y)),t.x=s,t.y=o,t):(e=Math.sqrt(t.x*t.x+t.y*t.y),m=Math.atan2(t.x,t.y),p=Ow(this.a,this.e,this.sin_p12),g=Math.cos(m),b=-(v=this.e*this.cos_p12*g)*v/(1-this.es),y=3*this.es*(1-b)*this.sin_p12*this.cos_p12*g/(1-this.es),w=1-b*(x=(_=e/p)-b*(1+b)*Math.pow(_,3)/6-y*(1+3*b)*Math.pow(_,4)/24)*x/2-_*x*x*x/6,f=Math.asin(this.sin_p12*Math.cos(x)+this.cos_p12*Math.sin(x)*g),s=wy(this.long0+Math.asin(Math.sin(m)*Math.sin(x)/Math.cos(f))),o=Math.atan((1-this.es*w*this.sin_p12/Math.sin(f))*Math.tan(f)/(1-this.es)),t.x=s,t.y=o,t)},names:["Azimuthal_Equidistant","aeqd"]};var rM={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)},forward:function(t){var e,i,n,r,s,o,a,h=t.x,c=t.y;return n=wy(h-this.long0),e=Math.sin(c),i=Math.cos(c),r=Math.cos(n),1,((s=this.sin_p14*e+this.cos_p14*i*r)>0||Math.abs(s)<=qb)&&(o=1*this.a*i*Math.sin(n),a=this.y0+1*this.a*(this.cos_p14*e-this.sin_p14*i*r)),t.x=o,t.y=a,t},inverse:function(t){var e,i,n,r,s,o,a;return t.x-=this.x0,t.y-=this.y0,e=Math.sqrt(t.x*t.x+t.y*t.y),i=Ww(e/this.a),n=Math.sin(i),r=Math.cos(i),o=this.long0,Math.abs(e)<=qb?(a=this.lat0,t.x=o,t.y=a,t):(a=Ww(r*this.sin_p14+t.y*n*this.cos_p14/e),s=Math.abs(this.lat0)-Wb,Math.abs(s)<=qb?(o=this.lat0>=0?wy(this.long0+Math.atan2(t.x,-t.y)):wy(this.long0-Math.atan2(-t.x,t.y)),t.x=o,t.y=a,t):(o=wy(this.long0+Math.atan2(t.x*n,e*this.cos_p14*r-t.y*this.sin_p14*n)),t.x=o,t.y=a,t))},names:["ortho"]},sM=1,oM=2,aM=3,hM=4,cM=5,lM=6,uM=1,dM=2,pM=3,fM=4;function mM(t,e,i,n){var r;return t<qb?(n.value=uM,r=0):(r=Math.atan2(e,i),Math.abs(r)<=Zb?n.value=uM:r>Zb&&r<=Wb+Zb?(n.value=dM,r-=Wb):r>Wb+Zb||r<=-(Wb+Zb)?(n.value=pM,r=r>=0?r-Jb:r+Jb):(n.value=fM,r+=Wb)),r}function gM(t,e){var i=t+e;return i<-Jb?i+=$b:i>+Jb&&(i-=$b),i}var vM={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.lat0>=Wb-Zb/2?this.face=cM:this.lat0<=-(Wb-Zb/2)?this.face=lM:Math.abs(this.long0)<=Zb?this.face=sM:Math.abs(this.long0)<=Wb+Zb?this.face=this.long0>0?oM:hM:this.face=aM,0!==this.es&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)},forward:function(t){var e,i,n,r,s,o,a={x:0,y:0},h={value:0};if(t.x-=this.long0,e=0!==this.es?Math.atan(this.one_minus_f_squared*Math.tan(t.y)):t.y,i=t.x,this.face===cM)r=Wb-e,i>=Zb&&i<=Wb+Zb?(h.value=uM,n=i-Wb):i>Wb+Zb||i<=-(Wb+Zb)?(h.value=dM,n=i>0?i-Jb:i+Jb):i>-(Wb+Zb)&&i<=-Zb?(h.value=pM,n=i+Wb):(h.value=fM,n=i);else if(this.face===lM)r=Wb+e,i>=Zb&&i<=Wb+Zb?(h.value=uM,n=-i+Wb):i<Zb&&i>=-Zb?(h.value=dM,n=-i):i<-Zb&&i>=-(Wb+Zb)?(h.value=pM,n=-i-Wb):(h.value=fM,n=i>0?-i+Jb:-i-Jb);else{var c,l,u,d,p,f;this.face===oM?i=gM(i,+Wb):this.face===aM?i=gM(i,+Jb):this.face===hM&&(i=gM(i,-Wb)),d=Math.sin(e),p=Math.cos(e),f=Math.sin(i),c=p*Math.cos(i),l=p*f,u=d,this.face===sM?n=mM(r=Math.acos(c),u,l,h):this.face===oM?n=mM(r=Math.acos(l),u,-c,h):this.face===aM?n=mM(r=Math.acos(-c),u,-l,h):this.face===hM?n=mM(r=Math.acos(-l),u,c,h):(r=n=0,h.value=uM)}return o=Math.atan(12/Jb*(n+Math.acos(Math.sin(n)*Math.cos(Zb))-Wb)),s=Math.sqrt((1-Math.cos(r))/(Math.cos(o)*Math.cos(o))/(1-Math.cos(Math.atan(1/Math.cos(n))))),h.value===dM?o+=Wb:h.value===pM?o+=Jb:h.value===fM&&(o+=1.5*Jb),a.x=s*Math.cos(o),a.y=s*Math.sin(o),a.x=a.x*this.a+this.x0,a.y=a.y*this.a+this.y0,t.x=a.x,t.y=a.y,t},inverse:function(t){var e,i,n,r,s,o,a,h,c,l,u,d,p={lam:0,phi:0},f={value:0};if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,i=Math.atan(Math.sqrt(t.x*t.x+t.y*t.y)),e=Math.atan2(t.y,t.x),t.x>=0&&t.x>=Math.abs(t.y)?f.value=uM:t.y>=0&&t.y>=Math.abs(t.x)?(f.value=dM,e-=Wb):t.x<0&&-t.x>=Math.abs(t.y)?(f.value=pM,e=e<0?e+Jb:e-Jb):(f.value=fM,e+=Wb),c=Jb/12*Math.tan(e),s=Math.sin(c)/(Math.cos(c)-1/Math.sqrt(2)),o=Math.atan(s),(a=1-(n=Math.cos(e))*n*(r=Math.tan(i))*r*(1-Math.cos(Math.atan(1/Math.cos(o)))))<-1?a=-1:a>1&&(a=1),this.face===cM)h=Math.acos(a),p.phi=Wb-h,f.value===uM?p.lam=o+Wb:f.value===dM?p.lam=o<0?o+Jb:o-Jb:f.value===pM?p.lam=o-Wb:p.lam=o;else if(this.face===lM)h=Math.acos(a),p.phi=h-Wb,f.value===uM?p.lam=-o+Wb:f.value===dM?p.lam=-o:f.value===pM?p.lam=-o-Wb:p.lam=o<0?-o-Jb:-o+Jb;else{var m,g,v;c=(m=a)*m,g=(c+=(v=c>=1?0:Math.sqrt(1-c)*Math.sin(o))*v)>=1?0:Math.sqrt(1-c),f.value===dM?(c=g,g=-v,v=c):f.value===pM?(g=-g,v=-v):f.value===fM&&(c=g,g=v,v=-c),this.face===oM?(c=m,m=-g,g=c):this.face===aM?(m=-m,g=-g):this.face===hM&&(c=m,m=g,g=-c),p.phi=Math.acos(-v)-Wb,p.lam=Math.atan2(g,m),this.face===oM?p.lam=gM(p.lam,-Wb):this.face===aM?p.lam=gM(p.lam,-Jb):this.face===hM&&(p.lam=gM(p.lam,+Wb))}return 0!==this.es&&(l=p.phi<0?1:0,u=Math.tan(p.phi),d=this.b/Math.sqrt(u*u+this.one_minus_f_squared),p.phi=Math.atan(Math.sqrt(this.a*this.a-d*d)/(this.one_minus_f*d)),l&&(p.phi=-p.phi)),p.lam+=this.long0,t.x=p.lam,t.y=p.phi,t},names:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"]},bM=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-9.86701e-7],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,1.8736e-8],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,9.34959e-7],[.7986,-.00755338,-500009e-10,9.35324e-7],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],yM=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,4.22642e-10],[.124,.0124,5.07171e-9,-1.60604e-9],[.186,.0123999,-1.90189e-8,6.00152e-9],[.248,.0124002,7.10039e-8,-2.24e-8],[.31,.0123992,-2.64997e-7,8.35986e-8],[.372,.0124029,9.88983e-7,-3.11994e-7],[.434,.0123893,-369093e-11,-4.35621e-7],[.4958,.0123198,-102252e-10,-3.45523e-7],[.5571,.0121916,-154081e-10,-5.82288e-7],[.6176,.0119938,-241424e-10,-5.25327e-7],[.6769,.011713,-320223e-10,-5.16405e-7],[.7346,.0113541,-397684e-10,-6.09052e-7],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-1.40374e-9],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],_M=.8487,xM=1.3523,wM=Yb/5,MM=18,TM=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))};var SM={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"},forward:function(t){var e=wy(t.x-this.long0),i=Math.abs(t.y),n=Math.floor(i*wM);n<0?n=0:n>=MM&&(n=17);var r={x:TM(bM[n],i=Yb*(i-.08726646259971647*n))*e,y:TM(yM[n],i)};return t.y<0&&(r.y=-r.y),r.x=r.x*this.a*_M+this.x0,r.y=r.y*this.a*xM+this.y0,r},inverse:function(t){var e={x:(t.x-this.x0)/(this.a*_M),y:Math.abs(t.y-this.y0)/(this.a*xM)};if(e.y>=1)e.x/=bM[18][0],e.y=t.y<0?-Wb:Wb;else{var i=Math.floor(e.y*MM);for(i<0?i=0:i>=MM&&(i=17);;)if(yM[i][0]>e.y)--i;else{if(!(yM[i+1][0]<=e.y))break;++i}var n=yM[i],r=5*(e.y-n[0])/(yM[i+1][0]-n[0]);r=function(t,e,i,n){for(var r=e;n;--n){var s=t(r);if(r-=s,Math.abs(s)<i)break}return r}((function(t){return(TM(n,t)-e.y)/function(t,e){return t[1]+e*(2*t[2]+3*e*t[3])}(n,t)}),r,qb,100),e.x/=TM(bM[i],r),e.y=(5*i+r)*Xb,t.y<0&&(e.y=-e.y)}return e.x=wy(e.x+this.long0),e},names:["Robinson","robin"]};var EM={init:function(){this.name="geocent"},forward:function(t){return Cx(t,this.es,this.a)},inverse:function(t){return Lx(t,this.es,this.a,this.b)},names:["Geocentric","geocentric","geocent","Geocent"]};Vx.defaultDatum="WGS84",Vx.Proj=Dy,Vx.WGS84=new Vx.Proj("WGS84"),Vx.Point=sw,Vx.toPoint=Fx,Vx.defs=my,Vx.transform=Dx,Vx.mgrs=Yx,Vx.version="__VERSION__",function(t){t.Proj.projections.add(dw),t.Proj.projections.add(bw),t.Proj.projections.add(yw),t.Proj.projections.add(ww),t.Proj.projections.add(Mw),t.Proj.projections.add(Tw),t.Proj.projections.add(Sw),t.Proj.projections.add(Ew),t.Proj.projections.add(Pw),t.Proj.projections.add(Dw),t.Proj.projections.add(Gw),t.Proj.projections.add(qw),t.Proj.projections.add(Xw),t.Proj.projections.add(Yw),t.Proj.projections.add(Zw),t.Proj.projections.add($w),t.Proj.projections.add(Jw),t.Proj.projections.add(Qw),t.Proj.projections.add(Kw),t.Proj.projections.add(tM),t.Proj.projections.add(eM),t.Proj.projections.add(iM),t.Proj.projections.add(nM),t.Proj.projections.add(rM),t.Proj.projections.add(vM),t.Proj.projections.add(SM),t.Proj.projections.add(EM)}(Vx);var PM=Vx;PM.defs("EPSG:4978","+proj=geocent +datum=WGS84 +units=m +no_defs");const AM=["WMTS:WGS84","WMTS:PM"],CM=["EPSG:4326","EPSG:3857"];function LM(t){if(t)return t.includes("EPSG")?t:CM[AM.indexOf(t)]?CM[AM.indexOf(t)]:`EPSG:${t.match(/\d+/)[0]}`}const RM={DEGREE:1,METER:2};function IM(t){return 0==t.indexOf("EPSG:4326")}function OM(t){switch(t){case"EPSG:4326":return RM.DEGREE;case"EPSG:4978":return RM.METER;default:{const i=PM.defs(LM(t));if(!i)return;return"degrees"===(e=i.units)?RM.DEGREE:"m"===e?RM.METER:void 0}}var e}function FM(t){const e=OM(t);if(void 0===t||void 0===e)throw new Error(`Invalid crs parameter value '${t}'`);return e}var BM={UNIT:RM,isValid(t){FM(t)},isGeographic:t=>FM(t)==RM.DEGREE,isMetricUnit:t=>OM(t)==RM.METER,toUnit:OM,is4326:IM,reasonnableEpsilon:t=>IM(t)?.01:.001,formatToEPSG:LM,formatToTms:function(t){if(t){if(t.includes("WMTS"))return t;const e=CM.indexOf(t);if(e>-1)return AM[e];if(t.includes("EPSG"))return`WMTS:TMS:${t.replace("EPSG:","")}`}}};new _e;const DM=new pe(PM.WGS84.a,PM.WGS84.a,PM.WGS84.b),zM=new pe;var NM=class{constructor(t=DM){this.size=new pe,this._radiiSquared=new pe,this._invRadiiSquared=new pe,this.setSize(t)}geodeticSurfaceNormal(t,e=new pe){return t.toVector3(e).multiply(this._invRadiiSquared).normalize()}geodeticSurfaceNormalCartographic(t,e=new pe){const i=he.degToRad(t.longitude),n=he.degToRad(t.latitude),r=Math.cos(n);return e.set(r*Math.cos(i),r*Math.sin(i),Math.sin(n))}setSize(t){this.size.set(t.x,t.y,t.z),this._radiiSquared.multiplyVectors(t,t),this._invRadiiSquared.x=0==t.x?0:1/this._radiiSquared.x,this._invRadiiSquared.y=0==t.y?0:1/this._radiiSquared.y,this._invRadiiSquared.z=0==t.z?0:1/this._radiiSquared.z}cartographicToCartesian(t,e=new pe){zM.copy(t.geodesicNormal),e.multiplyVectors(this._radiiSquared,zM);const i=Math.sqrt(zM.dot(e));return e.divideScalar(i),zM.multiplyScalar(t.altitude),e.add(zM)}cartesianToCartographic(t,e=new qM("EPSG:4326",0,0,0)){const i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z),n=this.size.x,r=this.size.z,s=Math.abs((n*n-r*r)/(n*n)),o=1-Math.sqrt(1-s),a=Math.sqrt(t.x*t.x+t.y*t.y),h=Math.atan2(t.y,t.x),c=Math.atan(t.z/a*(1-o+s*n/i)),l=Math.sin(c),u=Math.cos(c),d=Math.atan((t.z*(1-o)+s*n*l*l*l)/((1-o)*(a-s*n*u*u*u))),p=a*Math.cos(d)+t.z*Math.sin(d)-n*Math.sqrt(1-s*Math.sin(d)*Math.sin(d));return e.setFromValues(he.radToDeg(h),he.radToDeg(d),p)}cartographicToCartesianArray(t){for(var e=[],i=0;i<t.length;i++)e.push(this.cartographicToCartesian(t[i]));return e}intersection(t){var e=1e-4,i=t.origin,n=t.direction,r=n.x*n.x*this._invRadiiSquared.x+n.y*n.y*this._invRadiiSquared.y+n.z*n.z*this._invRadiiSquared.z,s=2*i.x*n.x*this._invRadiiSquared.x+2*i.y*n.y*this._invRadiiSquared.y+2*i.z*n.z*this._invRadiiSquared.z,o=i.x*i.x*this._invRadiiSquared.x+i.y*i.y*this._invRadiiSquared.y+i.z*i.z*this._invRadiiSquared.z-1,a=s*s-4*r*o;if(a<0||0===r||0===s||0===o)return!1;var h=(-s+(a=Math.sqrt(a)))/(2*r),c=(-s-a)/(2*r);if(h<=e&&c<=e)return!1;var l=0;if((l=h<=e?c:c<=e||h<c?h:c)<e)return!1;var u=new pe;return u.addVectors(t.origin,n.clone().setLength(l)),u}computeDistance(t,e){var i=he.degToRad(t.longitude),n=he.degToRad(t.latitude),r=he.degToRad(e.longitude),s=he.degToRad(e.latitude),o=Math.acos(Math.sin(n)*Math.sin(s)+Math.cos(n)*Math.cos(s)*Math.cos(r-i)),a=this.size.x,h=this.size.z,c=Math.sqrt((a*a-h*h)/(a*a)),l=(n+s)/2,u=a*(1-c*c)/Math.sqrt(1-c*c*Math.sin(l)*Math.sin(l)),d=a/Math.sqrt(1-c*c*Math.sin(l)*Math.sin(l));return o*Math.sqrt(u*d)}};PM.defs("EPSG:4978","+proj=geocent +datum=WGS84 +units=m +no_defs");const UM=new NM,VM=new pe;let kM;const jM={};function HM(t,e){return jM[t]||(jM[t]={}),jM[t][e]||(jM[t][e]=PM(t,e)),jM[t][e]}function GM(t,e,i){return t.setFromValues(e[0],e[1],i)}class WM{constructor(t,e=0,i=0,n=0){this.isCoordinates=!0,BM.isValid(t),this.crs=t,this.x=0,this.y=0,this.z=0,this._normal=new pe,e.length>0?this.setFromArray(e):e.isVector3||e.isCoordinates?this.setFromVector3(e):this.setFromValues(e,i,n),this._normalNeedsUpdate=!0}setFromValues(t=0,e=0,i=0){return this.x=null==t?0:t,this.y=null==e?0:e,this.z=null==i?0:i,this._normalNeedsUpdate=!0,this}setFromArray(t,e=0){return this.setFromValues(t[e],t[e+1],t[e+2])}setFromVector3(t){return this.setFromValues(t.x,t.y,t.z)}clone(){return new WM(this.crs,this)}copy(t){return this.crs=t.crs,this.setFromVector3(t)}get longitude(){return this.x}get latitude(){return this.y}get altitude(){return this.z}set altitude(t){this.z=t}get geodesicNormal(){return this._normalNeedsUpdate&&(this._normalNeedsUpdate=!1,BM.is4326(this.crs)?UM.geodeticSurfaceNormalCartographic(this,this._normal):"EPSG:4978"==this.crs?UM.geodeticSurfaceNormal(this,this._normal):this._normal.set(0,0,1)),this._normal}toVector3(t=new pe){return t.copy(this)}as(t,e=new WM(t)){return this.crs==t?e.copy(this):"EPSG:4978"==t?BM.is4326(this.crs)?(UM.cartographicToCartesian(this,VM),e.setFromVector3(VM)):(GM(kM,HM(this.crs,"EPSG:4326").forward([this.x,this.y]),this.z),kM.as("EPSG:4978",e)):"EPSG:4978"==this.crs?BM.is4326(t)?UM.cartesianToCartographic(this,e):(this.as("EPSG:4326",kM),GM(e,HM("EPSG:4326",t).forward([kM.x,kM.y]),kM.z)):BM.is4326(this.crs)&&"EPSG:3857"==t?(this.y=he.clamp(this.y,-89.999999,89.999999),GM(e,HM(this.crs,t).forward([this.x,this.y]),this.z)):GM(e,HM(this.crs,t).forward([this.x,this.y]),this.z),e.crs=t,e}}kM=new WM("EPSG:4326");var qM=WM;const XM=new ce,YM=new ce,ZM=new ce,$M=new ce,JM=new ce,QM=new ce(2,2),KM={row:0,col:0,invDiff:0};function tT(t,e){const i=2**(t.zoom-e);return KM.invDiff=1/i,KM.row=(t.row-t.row%i)*KM.invDiff,KM.col=(t.col-t.col%i)*KM.invDiff,KM}let eT,iT;const nT=new Array(8);for(var rT=nT.length-1;rT>=0;rT--)nT[rT]=new qM("EPSG:4326",0,0,0,0);const sT=new qM("EPSG:4326",0,0),oT=new Map,aT=new Map;function hT(t){const e=BM.formatToEPSG(t),i=oT.get(e),n=i.dimensions(YM),r=BM.formatToTms(t);return{epsg:e,globalExtent:i,globalDimension:n,sTs:aT.get(r)||aT.get("default"),isInverted:!r.includes(":NI")}}function cT(t,e){const i=aT.get(BM.formatToTms(t))||aT.get("default"),n=2**e;return ZM.set(n,n).multiply(i),ZM}class lT{constructor(t,e,i,n,r){this.isExtent=!0,this.crs=t,this.zoom=0,this.isTiledCrs()?(this.row=0,this.col=0):(this.west=0,this.east=0,this.south=0,this.north=0),this.set(e,i,n,r)}clone(){return this.isTiledCrs()?new lT(this.crs,this.zoom,this.row,this.col):new lT(this.crs,this.west,this.east,this.south,this.north)}isTiledCrs(){return 0==this.crs.indexOf("WMTS:")}tiledCovering(t){if("EPSG:4326"==this.crs&&"WMTS:PM"==t){const e=[],i=eT.copy(this).as(BM.formatToEPSG(t),iT),{globalExtent:n,globalDimension:r,sTs:s}=hT(BM.formatToEPSG(t));i.clampByExtent(n),i.dimensions(JM);const o=this.zoom+1||Math.floor(Math.log2(Math.round(r.x/(JM.x*s.x)))),a=cT(t,o),h=i.center(sT);$M.x=h.x-n.west,$M.y=n.north-i.north,$M.divide(r).multiply(a).floor();for(let s=Math.ceil((n.north-i.south)/r.x*a.y)-1;s>=$M.y;s--)e.push(new lT(t,o,s,$M.x));return e}{const e=new lT("WMTS:PM",0,0,0),{globalExtent:i,globalDimension:n,sTs:r,isInverted:s}=hT(this.crs),o=this.center(sT);this.dimensions(JM);const a=Math.floor(Math.log2(Math.round(n.x/(JM.x*r.x)))),h=cT(t,a);return $M.x=o.x-i.west,$M.y=s?i.north-o.y:o.y-i.south,$M.divide(n).multiply(h).floor(),e.crs=t,e.set(a,$M.y,$M.x),[e]}}as(t,e){if(BM.isValid(t),e=e||new lT("EPSG:4326",[0,0,0,0]),this.isTiledCrs()){const{epsg:i,globalExtent:n,globalDimension:r}=hT(this.crs),s=cT(this.crs,this.zoom);return JM.set(1,1).divide(s).multiply(r),e.west=n.west+(r.x-JM.x*(s.x-this.col)),e.east=e.west+JM.x,e.south=n.south+JM.y*(s.y-this.row-1),e.north=e.south+JM.y,e.crs=i,e.zoom=this.zoom,t==i?e:e.as(t,e)}if(!t.includes("WMTS:")){if(this.crs!=t){const i=this.center(sT);nT[0].setFromValues(this.west,this.north),nT[1].setFromValues(i.x,this.north),nT[2].setFromValues(this.east,this.north),nT[3].setFromValues(this.east,i.y),nT[4].setFromValues(this.east,this.south),nT[5].setFromValues(i.x,this.south),nT[6].setFromValues(this.west,this.south),nT[7].setFromValues(this.west,i.y),e.set(1/0,-1/0,1/0,-1/0);for(let i=0;i<nT.length;i++)nT[i].crs=this.crs,nT[i].as(t,sT),e.north=Math.max(e.north,sT.y),e.south=Math.min(e.south,sT.y),e.east=Math.max(e.east,sT.x),e.west=Math.min(e.west,sT.x);return e.zoom=this.zoom,e.crs=t,e}return e.crs=t,e.set(this.west,this.east,this.south,this.north),e}}center(t=new qM(this.crs)){if(this.isTiledCrs())throw new Error("Invalid operation for WMTS bbox");return this.dimensions(XM),t.crs=this.crs,t.setFromValues(this.west+.5*XM.x,this.south+.5*XM.y),t}dimensions(t=new ce){return t.x=Math.abs(this.east-this.west),t.y=Math.abs(this.north-this.south),t}isPointInside(t,e=0){const i=this.crs==t.crs?t:t.as(this.crs,sT);return i.x<=this.east+e&&i.x>=this.west-e&&i.y<=this.north+e&&i.y>=this.south-e}isInside(t,e){return this.isTiledCrs()?this.zoom==t.zoom?this.row==t.row&&this.col==t.col:!(this.zoom<t.zoom)&&(tT(this,t.zoom),KM.row==t.row&&KM.col==t.col):(t.as(this.crs,eT),e=null==e?BM.reasonnableEpsilon(this.crs):e,this.east-eT.east<=e&&eT.west-this.west<=e&&this.north-eT.north<=e&&eT.south-this.south<=e)}offsetToParent(t,e=new _e){if(this.crs!=t.crs)throw new Error("unsupported mix");if(this.isTiledCrs())return tT(this,t.zoom),e.set(this.col*KM.invDiff-KM.col,this.row*KM.invDiff-KM.row,KM.invDiff,KM.invDiff);t.dimensions(XM),this.dimensions(YM);const i=(this.west-t.west)/XM.x,n=(t.north-this.north)/XM.y,r=YM.x/XM.x,s=YM.y/XM.y;return e.set(i,n,r,s)}tiledExtentParent(t){return t&&t<this.zoom?(tT(this,t),new lT(this.crs,t,KM.row,KM.col)):this}intersectsExtent(t){const e=t.crs==this.crs?t:t.as(this.crs,eT);return!(this.west>=e.east||this.east<=e.west||this.south>=e.north||this.north<=e.south)}intersect(t){return this.intersectsExtent(t)?(t.crs!=this.crs&&(t=t.as(this.crs,eT)),new lT(this.crs,Math.max(this.west,t.west),Math.min(this.east,t.east),Math.max(this.south,t.south),Math.min(this.north,t.north))):new lT(this.crs,0,0,0,0)}set(t,e,i,n){if(t.isExtent&&(t.isTiledCrs()?(e=t.row,i=t.col,t=t.zoom):(e=t.east,i=t.south,n=t.north,t=t.west)),this.isTiledCrs()){if(void 0===t)throw new Error("Invalid values to set");if(this.zoom<0)throw new Error("Invalid zoom value for tiled extent");this.zoom=t,this.row=e,this.col=i}else if(t.isCoordinates)this.west=t.x,this.east=e.x,this.south=t.y,this.north=e.y;else if(t&&void 0!==t.west)this.west=t.west,this.east=t.east,this.south=t.south,this.north=t.north;else if(t&&4==t.length)this.west=t[0],this.east=t[1],this.south=t[2],this.north=t[3];else{if(void 0===t)throw new Error("No values to set in the extent");this.west=t,this.east=e,this.south=i,this.north=n}return this}copy(t){return this.crs=t.crs,this.set(t)}union(t){if(t.crs!=this.crs)throw new Error("unsupported union between 2 diff crs");if(this.west===1/0)this.copy(t);else{const e=t.west;e<this.west&&(this.west=e);const i=t.east;i>this.east&&(this.east=i);const n=t.south;n<this.south&&(this.south=n);const r=t.north;r>this.north&&(this.north=r)}}expandByCoordinates(t){const e=t.crs==this.crs?t:t.as(this.crs,sT);this.expandByValuesCoordinates(e.x,e.y)}expandByValuesCoordinates(t,e){t<this.west&&(this.west=t),t>this.east&&(this.east=t),e<this.south&&(this.south=e),e>this.north&&(this.north=e)}static fromBox3(t,e){return new lT(t,{west:e.min.x,east:e.max.x,south:e.min.y,north:e.max.y})}toString(t=""){return this.isTiledCrs()?`${this.zoom}${t}${this.row}${t}${this.col}`:`${this.east}${t}${this.north}${t}${this.west}${t}${this.south}`}subdivision(){return this.subdivisionByScheme()}subdivisionByScheme(t=QM){const e=[],i=this.dimensions(XM).divide(t);for(let n=t.x-1;n>=0;n--)for(let r=t.y-1;r>=0;r--){const t=this.west+n*i.x,s=this.south+r*i.y;e.push(new lT(this.crs,t,t+i.x,s,s+i.y))}return e}transformedCopy(t,e,i){if(!i.isTiledCrs()){if(this.crs=i.crs,this.west=(i.west+t.x)*e.x,this.east=(i.east+t.x)*e.x,this.west>this.east){const t=this.west;this.west=this.east,this.east=t}if(this.south=(i.south+t.y)*e.y,this.north=(i.north+t.y)*e.y,this.south>this.north){const t=this.south;this.south=this.north,this.north=t}}}clampSouthNorth(t=this.south,e=this.north){return this.south=Math.max(this.south,t),this.north=Math.min(this.north,e),this}clampWestEast(t=this.west,e=this.east){return this.west=Math.max(this.west,t),this.east=Math.min(this.east,e),this}clampByExtent(t){return this.clampSouthNorth(t.south,t.north),this.clampWestEast(t.west,t.east)}}eT=new lT("EPSG:4326",[0,0,0,0]),iT=new lT("EPSG:4326",[0,0,0,0]),oT.set("EPSG:4326",new lT("EPSG:4326",-180,180,-90,90));const uT=oT.get("EPSG:4326").as("EPSG:3857");uT.clampSouthNorth(uT.west,uT.east),oT.set("EPSG:3857",uT),aT.set("default",new ce(1,1)),aT.set("WMTS:PM",aT.get("default")),aT.set("WMTS:WGS84",new ce(2,1));var dT=lT;class pT{constructor(t){this.layer=t}clear(){}update(){}}var fT=class extends se{constructor(t,e={}){super(),this.isLayer=!0,Object.assign(this,e),Object.defineProperty(this,"id",{value:t,writable:!1}),this.options=e.options||{},this.updateStrategy||(this.updateStrategy={type:0,options:{}}),this.defineLayerProperty("frozen",!1),this.info=new pT(this)}defineLayerProperty(t,e,i){const n=Object.getOwnPropertyDescriptor(this,t);if(!n||!n.set){let n=null==this[t]?e:this[t];Object.defineProperty(this,t,{get:()=>n,set:e=>{if(n!==e){const r={type:`${t}-property-changed`,previous:{},new:{}};r.previous[t]=n,r.new[t]=e,n=e,i&&i(this,t),this.dispatchEvent(r)}}})}}convert(t){return t}delete(){console.warn("Function delete doesn't exist for this layer")}};function mT(t,e,i=0){const n=t.camera.camera3D.layers.mask;return t.camera.camera3D.layers.mask=1<<i,()=>{t.camera.camera3D.layers.mask=n}}const gT=new _e;function vT(t,e,i,n=0){const r=t.mainLoop.gfxEngine.getWindowSize();i=i||new ce(Math.floor(r.x/2),Math.floor(r.y/2));const s=e.level0Nodes.map((t=>Sx.push(t,Sx.MODES.ID))),o=mT(t,e.object3d,e.threejsLayer),a=t.mainLoop.gfxEngine.renderViewToBuffer({camera:t.camera,scene:e.object3d},{x:i.x-n,y:i.y-n,width:1+2*n,height:1+2*n});o(),s.forEach((t=>t()));const h=[];return bT(n,((t,e)=>{const i=4*(2*e*n+t),r=a.slice(i,i+4||void 0);gT.fromArray(r).divideScalar(255);const s=(o=gT,(c=256**3)?Px.dot(o)*c:Px.dot(o));var o,c;const l=Math.round(s);h.includes(l)||h.push(l)})),h}function bT(t,e){let i;for(let n=0;n<=t;n++){const t=n*n;for(let r=-n;r<=n;r++){const s=r*r;for(let o=-n;o<=n;o++){const n=s+o*o;if(!(n>t)&&(!(n<=i)&&!1===e(r,o)))return}}i=t}}function yT(t){return t.layer?t.layer:t.parent?yT(t.parent):void 0}const _T=new Ul;var xT={pickTilesAt(t,e,i,n){const r=[],s=vT(t,n,e,i),o=t=>{s.includes(t.id)&&t.isTileMesh&&r.push({object:t,layer:n})};for(const t of n.level0Nodes)t.traverse(o);return r},pickPointsAt(t,e,i,n){if(!n.root)return;n.object3d.traverse((t=>{t.isPoints&&t.baseId&&t.material.enablePicking(!0)}));const r=mT(t,n.object3d,n.threejsLayer),s=t.mainLoop.gfxEngine.renderViewToBuffer({camera:t.camera,scene:n.object3d},{x:e.x-i,y:e.y-i,width:1+2*i,height:1+2*i});r();const o=[];bT(i,((t,e)=>{const n=4*(2*e*i+t),r=s.slice(n,n+4),a={objId:r[0]<<8|r[1],index:r[2]<<8|r[3]};for(let t=0;t<o.length;t++)if(o[t].objId==a.objId&&o[t].index==a.index)return;o.push(a)}));const a=[];return n.object3d.traverse((t=>{if(t.isPoints&&t.baseId){t.material.enablePicking(!1);for(let e=0;e<o.length;e++)o[e].objId==t.baseId&&a.push({object:t,index:o[e].index,layer:n})}})),a},pickObjectsAt(t,e,i,n,r=[]){if(i<0){const i=t.viewToNormalizedCoords(e);_T.setFromCamera(i,t.camera.camera3D);const s=_T.intersectObject(n,!0);for(const t of s)t.layer=yT(t.object),r.push(t);return r}const s={x:e.x-i,y:e.y-i,width:1+2*i,height:1+2*i},o=t.mainLoop.gfxEngine.renderViewToBuffer({scene:n,camera:t.camera},s),a=t.mainLoop.gfxEngine.renderer.getClearColor(),h=Math.round(255*a.r),c=Math.round(255*a.g),l=Math.round(255*a.b),u=t.viewToNormalizedCoords(e),d=u.clone();return bT(i,((e,s)=>{const a=4*((s+i)*(2*i+1)+(e+i)),p=o[a],f=o[a+1],m=o[a+2];if(Math.abs(h-p)<=1&&Math.abs(c-f)<=1&&Math.abs(l-m)<=1)return;d.setX(u.x+e/t.camera.width).setY(u.y+s/t.camera.height),_T.setFromCamera(d,t.camera.camera3D);const g=_T.intersectObject(n,!0);for(const t of g)t.layer=yT(t.object),r.push(t);return 0==r.length})),r}};function wT(t){if(t.dispose)t.dispose();else if(t.geometry&&t.geometry.dispose(),t.material)if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose()}function MT(t,e){for(const i of t.children)MT(i,e);e(t)}var TT=class extends fT{constructor(t,e,i={}){if(super(t,i),this.isGeometryLayer=!0,!e||!e.isObject3D)throw new Error("Missing/Invalid object3d parameter (must be a\n                three.js Object3D instance)");"Group"===e.type&&""===e.name&&(e.name=t),Object.defineProperty(this,"object3d",{value:e,writable:!1,configurable:!0}),this.defineLayerProperty("opacity",1,(()=>{(this.parent?this.parent.object3d:this.object3d).traverse((t=>{t.layer==this?this.changeOpacity(t):t.content&&t.content.layer==this&&t.content.traverse(this.changeOpacity)}))})),this.defineLayerProperty("wireframe",!1,(()=>{(this.parent?this.parent.object3d:this.object3d).traverse((t=>{t.layer==this&&t.material?t.material.wireframe=this.wireframe:t.content&&t.content.layer==this&&t.content.traverse((t=>{t.material&&t.layer==this&&(t.material.wireframe=this.wireframe)}))}))})),this.attachedLayers=[],this.visible=null==i.visible||i.visible,this.getObjectToUpdateForAttachedLayers=t=>{if(t.parent&&t.material)return{element:t,parent:t.parent}}}postUpdate(){}culling(){return!0}attach(t){if(!t.update)throw new Error(`Missing 'update' function -> can't attach layer\n                ${t.id}`);this.attachedLayers.push(t),t.parent=this}detach(t){const e=this.attachedLayers.length;return this.attachedLayers=this.attachedLayers.filter((e=>e.id!=t.id)),t.parent=void 0,this.attachedLayers.length<e}delete(){this.parent?MT(this.parent.object3d,(t=>{t.layer&&t.layer.id==this.id&&(t.parent.remove(t),wT(t))})):(this.object3d.parent&&this.object3d.parent.remove(this.object3d),this.object3d.traverse(wT))}pickObjectsAt(t,e,i=this.options.defaultPickingRadius){return xT.pickObjectsAt(t,e,i,this.object3d)}changeOpacity(t){t.material&&(null!=t.material.opacity&&(t.material.transparent=this.opacity<1,t.material.opacity=this.opacity),t.material.uniforms&&null!=t.material.uniforms.opacity&&(t.material.transparent=this.opacity<1,t.material.uniforms.opacity.value=this.opacity))}};var ST={getElevationValueAt(t,e,i=0,n){const r=BT(t,i,e,n||t.level0Nodes);if(r)return{z:r.coord.z,texture:r.texture,tile:r.tile}},placeObjectOnGround(t,e,i,n={},r){let s;if(s=r?r.concat(t.level0Nodes):t.level0Nodes,n.modifyGeometry){const r={worldFromLocal:i.matrixWorld,localFromWorld:(new Le).getInverse(i.matrixWorld)},o=i.geometry;if(o.vertices){n.cache&&(n.cache.length=o.vertices.length);let i=!0;const a=new qM(e);for(let h=0;h<o.vertices.length;h++){const c=n.cache?n.cache[h]:void 0,l=DT(t,n.method||0,s,e,o.vertices[h],n.offset||0,r,a,c);n.cache&&(n.cache[h]=l),l||(i=!1)}return o.verticesNeedUpdate=!0,i}if(o.isBufferGeometry){n.cache&&(n.cache.length=o.attributes.position.count);let i=!0;const a=new pe,h=new qM(e);for(let c=0;c<o.attributes.position.count;c++){const l=n.cache?n.cache[c]:void 0;a.fromBufferAttribute(o.attributes.position,c);const u=a.z,d=DT(t,n.method||0,s,e,a,n.offset||0,r,h,l);n.cache&&(n.cache[c]=d),d||(i=!1),u!=a.z&&(o.attributes.position.needsUpdate=!0),o.attributes.position.setXYZ(c,a.x,a.y,a.z)}return i}}else{n.cache&&(n.cache.length=1);const r={worldFromLocal:i.parent?i.parent.matrixWorld:void 0,localFromWorld:i.parent?(new Le).getInverse(i.parent.matrixWorld):void 0},o=DT(t,n.method||0,s,e,i.position,n.offset||0,r,void 0,n.cache?n.cache[0]:void 0);if(o)return n.cache&&(n.cache[0]=o),i.updateMatrix(),i.updateMatrixWorld(),!0}},FAST_READ_Z:0,PRECISE_READ_Z:1};function ET(t,e){if(e.extent){if(!e.extent.isPointInside(t))return;for(let i=0;i<e.children.length;i++){const n=ET(t,e.children[i]);if(n)return n}const i=e.material.getElevationLayer();return i&&i.level>=0?e:void 0}}let PT;function AT(t,e,...i){for(let t=0;t<i.length;t+=2)i[t]=he.clamp(i[t],0,e.image.width-1),i[t+1]=he.clamp(i[t+1],0,e.image.height-1);if(e.image.data){if(2===i.length)return e.image.data[i[1]*e.image.width+i[0]];const t=[];for(let n=0;n<i.length;n+=2)t.push(e.image.data[i[n+1]*e.image.width+i[n]]);return t}{PT||(PT=document.createElement("canvas"),PT.width=2,PT.height=2);let n=1/0,r=1/0,s=-1/0,o=-1/0;for(let t=0;t<i.length;t+=2)n=Math.min(i[t],n),r=Math.min(i[t+1],r),s=Math.max(i[t],s),o=Math.max(i[t+1],o);const a=s-n+1,h=o-r+1;PT.width=Math.max(PT.width,a),PT.height=Math.max(PT.height,h);const c=PT.getContext("2d");c.drawImage(e.image,n,r,a,h,0,0,a,h);const l=c.getImageData(0,0,a,h),u=t.attachedLayers.filter((t=>t.isElevationLayer))[0],d=[];for(let t=0;t<i.length;t+=2){const e=i[t]-n,s=i[t+1]-r;d.push(he.lerp(u.colorTextureElevationMinZ,u.colorTextureElevationMaxZ,l.data[4*s*a+4*e]/255))}return 2===i.length?d[0]:d}}function CT(t,e,i){const n=t.image.width,r=t.image.height,s=Math.max(0,e*n-.5),o=Math.max(0,i*r-.5),a=Math.floor(s),h=Math.ceil(s),c=Math.floor(o);return{u1:a,u2:h,v1:c,v2:Math.ceil(o),wu:s-a,wv:o-c}}function LT(t,e,i,n){const r=CT(e,i,n),[s,o,a,h]=AT(t,e,r.u1,r.v1,r.u2,r.v1,r.u1,r.v2,r.u2,r.v2),c=he.lerp(s,o,r.wu),l=he.lerp(a,h,r.wu);return he.lerp(c,l,r.wv)}function RT(t,e,i){return function(t,e,i,n){const r=CT(e,i,n);return AT(t,e,r.wu<=0?r.u1:r.u2,r.wv<=0?r.v1:r.v2)}(t,e,i.x,i.y)}const IT=new pe;const OT={v:new pe,coord1:new qM("EPSG:4978"),coord2:new qM("EPSG:4978"),offset:new ce},FT=new ce;function BT(t,e,i,n,r){const s=i.as(t.extent.crs,OT.coord1);let o=null;r&&r.tile&&r.tile.material&&(o=ET(s,r.tile));for(let t=0;!o&&t<n.length;t++)o=ET(s,n[t]);if(!o)return;const a=o,h=a.material.getElevationLayer(),c=h.textures[0];if(r&&r.id===c.id&&r.version===c.version)return{coord:s,texture:c,tile:a};const l=Math.round(Math.log2(1/h.offsetScales[0].z));for(let t=0;t<l;t++)o=o.parent;return function(t,e,i=new ce){if(t.crs!=e.crs)throw new Error(`Unsupported mix: ${t.crs} and ${e.crs}`);e.dimensions(FT);const n=(t.x-e.west)/FT.x,r=(e.north-t.y)/FT.y;i.set(n,r)}(s,o.extent,OT.offset),s.z=1==e?function(t,e,i,n,r){const s=n.x/r.x/16;let o=Math.floor(i.x/s)*s,a=Math.floor(i.y/s)*s;1==o&&(o-=s),1==a&&(a-=s);const h=o,c=o+s,l=a,u=a+s,d=(i.x-o)/s,p=(i.y-a)/s,f=1==p||d/(1-p)>=1,m=new Bi(new pe(h,u),new pe(c,l),f?new pe(c,u):new pe(h,l));m.getBarycoord(new pe(i.x,i.y),IT);const g=LT(t,e,m.a.x,m.a.y),v=LT(t,e,m.b.x,m.b.y),b=LT(t,e,m.c.x,m.c.y);return g*IT.x+v*IT.y+b*IT.z}(t,c,OT.offset,a.extent.dimensions(),o.extent.dimensions()):RT(t,c,OT.offset),{coord:s,texture:c,tile:a}}function DT(t,e,i,n,r,s,o={},a,h){const c=a||new qM(n);o.worldFromLocal?c.setFromVector3(OT.v.copy(r).applyMatrix4(o.worldFromLocal)):c.setFromVector3(r);const l=BT(t,e,c,i,h);if(l)return l.coord.z+=s,l.coord.as(n,OT.coord2).toVector3(r),o.localFromWorld&&r.applyMatrix4(o.localFromWorld),{id:l.texture.id,version:l.texture.version,tile:l.tile}}function zT(t,e,i){const n=he.degToRad(i),r=e/(2*Math.tan(.5*n));t._preSSE=r}function NT(t,e,i,n={}){if(Object.defineProperty(this,"crs",{get:()=>t}),this.camera3D=n.camera?n.camera:new Xn(30,e/i),this._viewMatrix=new Le,this.width=e,this.height=i,this._viewMatrixNeedsUpdate=!0,this.resize(e,i),this._preSSE=1/0,this.camera3D.isPerspectiveCamera){let t=this.camera3D.fov;Object.defineProperty(this.camera3D,"fov",{get:()=>t,set:e=>{t=e,zT(this,this.height,t)}})}}NT.prototype.resize=function(t,e){},NT.prototype.update=function(){this.camera3D.updateMatrixWorld(),this._viewMatrixNeedsUpdate=!0},NT.prototype.position=function(t){return new qM(this.crs,this.camera3D.position).as(t||this.crs)},NT.prototype.setPosition=function(t){this.camera3D.position.copy(t.as(this.crs))};const UT={frustum:new tr,matrix:new Le,box3:new ci},VT=[new pe,new pe,new pe,new pe,new pe,new pe,new pe,new pe];const kT=new ci(new pe(-1,-1,-1),new pe(1,1,1));NT.prototype.isBox3Visible=function(t,e){return this.box3SizeOnScreen(t,e).intersectsBox(kT)},NT.prototype.isSphereVisible=function(t,e){return this._viewMatrixNeedsUpdate&&(this._viewMatrix.multiplyMatrices(this.camera3D.projectionMatrix,this.camera3D.matrixWorldInverse),this._viewMatrixNeedsUpdate=!1),e?(UT.matrix.multiplyMatrices(this._viewMatrix,e),UT.frustum.setFromMatrix(UT.matrix)):UT.frustum.setFromMatrix(this._viewMatrix),UT.frustum.intersectsSphere(t)},NT.prototype.box3SizeOnScreen=function(t,e){const i=function(t,e,i){let n=t.camera3D.matrixWorldInverse;i&&(n=UT.matrix.multiplyMatrices(t.camera3D.matrixWorldInverse,i)),VT[0].set(e.min.x,e.min.y,e.min.z).applyMatrix4(n),VT[1].set(e.min.x,e.min.y,e.max.z).applyMatrix4(n),VT[2].set(e.min.x,e.max.y,e.min.z).applyMatrix4(n),VT[3].set(e.min.x,e.max.y,e.max.z).applyMatrix4(n),VT[4].set(e.max.x,e.min.y,e.min.z).applyMatrix4(n),VT[5].set(e.max.x,e.min.y,e.max.z).applyMatrix4(n),VT[6].set(e.max.x,e.max.y,e.min.z).applyMatrix4(n),VT[7].set(e.max.x,e.max.y,e.max.z).applyMatrix4(n);let r=!1;for(let e=0;e<8;e++)VT[e].z<=-t.camera3D.near?r=!0:VT[e].z=-t.camera3D.near;return r?VT:void 0}(this,t,e);if(!i)return UT.box3.makeEmpty();for(let t=0;t<8;t++)i[t].applyMatrix4(this.camera3D.projectionMatrix);return UT.box3.setFromPoints(i)},NT.prototype.adjustAltitudeToAvoidCollisionWithLayer=function(t,e,i){const n=t.camera.position().as("EPSG:4326");if(void 0!==e){const r=ST.getElevationValueAt(e,n);if(null!=r){n.altitude-(r.z+i)<0&&(n.altitude=r.z+i,t.camera.camera3D.position.copy(n.as(t.referenceCrs)),t.notifyChange(this.camera3D))}}};var jT=NT;let HT,GT={};const WT={POLICIES:{INFINITE:1/0,TEXTURE:9e5,ELEVATION:9e5},get:(t,e,i)=>{if(null!=GT[t])return HT=null==GT[t][e]?GT[t]:null==GT[t][e][i]?GT[t][e]:GT[t][e][i],HT.value?(HT.lastTimeUsed=Date.now(),HT.value):void 0},set:(t,e,i,n,r)=>(HT={value:t,lastTimeUsed:Date.now(),lifetime:e},null==n?(GT[i]=HT,t):(GT[i]||(GT[i]={}),null==r?(GT[i][n]=HT,t):(GT[i][n]||(GT[i][n]={}),GT[i][n][r]=HT,t))),delete:(t,e,i)=>{if(null==GT[t])throw Error("Please specify at least a key of something to delete");null==GT[t][e]?delete GT[t]:null==GT[t][e][i]?delete GT[t][e]:delete GT[t][e][i]},clear:()=>{GT={}},flush:(t=Date.now())=>{for(const e in GT)if(GT[e].lifetime<t-GT[e].lastTimeUsed)delete GT[e];else for(const i in GT[e])if(GT[e][i].lifetime<t-GT[e][i].lastTimeUsed)delete GT[e][i];else for(const n in GT[e][i])GT[e][i][n].lifetime<t-GT[e][i][n].lastTimeUsed&&delete GT[e][i][n]}};Object.freeze(WT);var qT=WT;const XT="update_start",YT="before_camera_update",ZT="after_camera_update",$T="before_layer_update",JT="after_layer_update",QT="before_render",KT="after_render",tS="update_end";function eS(t,e){this.renderingState=0,this.needsRedraw=!1,this.scheduler=t,this.gfxEngine=e,this._updateLoopRestarted=!0}function iS(t,e,i){if(i)for(const n of i){const i=e.update(t,e,n),r=e.getObjectToUpdateForAttachedLayers(n);if(r)if(r.element){0;for(const i of e.attachedLayers)i.ready&&i.update(t,i,r.element,r.parent)}else if(r.elements)for(let i=0;i<r.elements.length;i++){if(!r.elements[i].isObject3D)throw new Error("\n                            Invalid object for attached layer to update.\n                            Must be a THREE.Object and have a THREE.Material");for(const n of e.attachedLayers)n.ready&&n.update(t,n,r.elements[i],r.parent)}iS(t,e,i)}}function nS(t,e){let i=!1;const n=new Set;return t.forEach((t=>{t===e||t.isCamera?(e.info.clear(),i=!0):t.layer===e&&n.add(t)})),i?new Set([e]):n}eS.prototype=Object.create(se.prototype),eS.prototype.constructor=eS,eS.prototype.scheduleViewUpdate=function(t,e){this.needsRedraw|=e,1!==this.renderingState&&(this.renderingState=1,requestAnimationFrame((e=>{this._step(t,e)})))},eS.prototype._update=function(t,e,i){const n={camera:t.camera,engine:this.gfxEngine,scheduler:this.scheduler,view:t};e.forEach((i=>{const n=i.layer||i;if(n.isLayer){const i=t.getParentLayer(n);i&&e.add(i)}}));for(const r of t.getLayers(((t,e)=>!e)))if(n.geometryLayer=r,r.ready&&r.visible&&!r.frozen){t.execFrameRequesters($T,i,this._updateLoopRestarted,r);const s=nS(e,r);if(s.size>0){for(const t of r.attachedLayers)t.ready&&t.preUpdate&&t.preUpdate(n,s);const t=r.preUpdate(n,s);iS(n,r,t),r.postUpdate(n,r,e)}t.execFrameRequesters(JT,i,this._updateLoopRestarted,r)}},eS.prototype._step=function(t,e){const i=e-this._lastTimestamp;t._executeFrameRequestersRemovals(),t.execFrameRequesters(XT,i,this._updateLoopRestarted);const n=this.needsRedraw;this._lastTimestamp=e,this.needsRedraw=!1,this.renderingState=0;const r=new Set(t._changeSources);t._changeSources.clear(),t.execFrameRequesters(YT,i,this._updateLoopRestarted),t.execFrameRequesters(ZT,i,this._updateLoopRestarted);const s=t.camera.camera3D.matrixAutoUpdate;t.camera.camera3D.matrixAutoUpdate=!1,this._update(t,r,i),0==this.scheduler.commandsWaitingExecutionCount()&&this.dispatchEvent({type:"command-queue-empty"}),n&&this._renderView(t,i),this._updateLoopRestarted=0===this.renderingState,t.camera.camera3D.matrixAutoUpdate=s,qT.flush(),t.execFrameRequesters(tS,i,this._updateLoopRestarted)},eS.prototype._renderView=function(t,e){t.execFrameRequesters(QT,e,this._updateLoopRestarted),t.render?t.render():this.gfxEngine.renderView(t),t.execFrameRequesters(KT,e,this._updateLoopRestarted)};var rS=eS;function sS(t,e,i){if(t&&(!i||i(t,e)))return t}const oS=(t,e)=>{throw e.handlingError(t),t};function aS(t,e,i){const n=i.source,r={buildExtent:n.isFileSource||!i.isGeometryLayer,crsIn:n.projection,crsOut:i.projection,sprites:i.sprites||n.sprites,filteringExtent:!n.isFileSource&&i.isGeometryLayer?e.as(n.projection):void 0,overrideAltitudeInToZero:i.overrideAltitudeInToZero,filter:i.filter||n.filter,isInverted:n.isInverted,mergeFeatures:void 0===i.mergeFeatures||i.mergeFeatures,withNormal:i.isGeometryLayer,withAltitude:i.isGeometryLayer};return n.parser(t,r).then((t=>n.onParsedFile(t)))}function hS(t,e){const i=e.source,n=i.urlFromExtent(t);return i.fetcher(n,i.networkOptions).then((e=>(e.extent=t,e)))}var cS={executeCommand(t){const e=[],i=t.layer,n=i.source,r=t.extentsSource,s=t.extentsDestination||r,o=t.parsedData||[];for(let t=0,a=r.length;t<a;t++){const a=r[t],h=n.isVectorSource?s[t]:a;let c=qT.get(n.uid,i.id,h.toString("-"));if(!c){const e=s[t],r=sS(o[t],e,i.isValidData)||n.parsedData;c=r?i.convert(r,e,i):n.fetchedData?aS(n.fetchedData,e,i).then((t=>i.convert(t,e,i)),(t=>oS(t,n))):hS(a,i).then((t=>aS(t,e,i)),(t=>oS(t,n))).then((t=>i.convert(t,e,i)),(t=>oS(t,n))),qT.set(c,qT.POLICIES.TEXTURE,n.uid,i.id,h.toString("-"))}e.push(c)}return Promise.all(e)}};var lS=class{constructor(t){this.command=t,this.isCancelledCommandException=!0}toString(){return`Cancelled command ${this.command.requester.id}/${this.command.layer.id}`}},uS={executeCommand(t){const e=[],i=t.layer,n=t.requester,r=t.extentsSource;if(n&&!n.material)return Promise.reject(new lS(t));for(let t=0,s=r.length;t<s;t++)e.push(i.convert(n,r[t]));return Promise.all(e)}};function dS(t){Yh.call(this,t),this.dracoLoader=null,this.ddsLoader=null}function pS(){var t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}dS.prototype=Object.assign(Object.create(Yh.prototype),{constructor:dS,load:function(t,e,i,n){var r,s=this;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Vc(t),s.manager.itemStart(t);var o=function(e){n?n(e):console.error(e),s.manager.itemError(t),s.manager.itemEnd(t)},a=new $h(s.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),"use-credentials"===s.crossOrigin&&a.setWithCredentials(!0),a.load(t,(function(i){try{s.parse(i,r,(function(i){e(i),s.manager.itemEnd(t)}),o)}catch(t){o(t)}}),i,o)},setDRACOLoader:function(t){return this.dracoLoader=t,this},setDDSLoader:function(t){return this.ddsLoader=t,this},parse:function(t,e,i,n){var r,s={};if("string"==typeof t)r=t;else if(Uc(new Uint8Array(t,0,4))===bS){try{s[fS.KHR_BINARY_GLTF]=new xS(t)}catch(t){return void(n&&n(t))}r=s[fS.KHR_BINARY_GLTF].content}else r=Uc(new Uint8Array(t));var o=JSON.parse(r);if(void 0===o.asset||o.asset.version[0]<2)n&&n(new Error("threeExamples.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead."));else{if(o.extensionsUsed)for(var a=0;a<o.extensionsUsed.length;++a){var h=o.extensionsUsed[a],c=o.extensionsRequired||[];switch(h){case fS.KHR_LIGHTS_PUNCTUAL:s[h]=new gS(o);break;case fS.KHR_MATERIALS_UNLIT:s[h]=new vS;break;case fS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[h]=new TS;break;case fS.KHR_DRACO_MESH_COMPRESSION:s[h]=new wS(o,this.dracoLoader);break;case fS.MSFT_TEXTURE_DDS:s[h]=new mS(this.ddsLoader);break;case fS.KHR_TEXTURE_TRANSFORM:s[h]=new MS;break;default:c.indexOf(h)>=0&&console.warn('threeExamples.GLTFLoader: Unknown extension "'+h+'".')}}new JS(o,s,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager}).parse(i,n)}}});var fS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function mS(t){if(!t)throw new Error("threeExamples.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=fS.MSFT_TEXTURE_DDS,this.ddsLoader=t}function gS(t){this.name=fS.KHR_LIGHTS_PUNCTUAL;var e=t.extensions&&t.extensions[fS.KHR_LIGHTS_PUNCTUAL]||{};this.lightDefs=e.lights||[]}function vS(){this.name=fS.KHR_MATERIALS_UNLIT}gS.prototype.loadLight=function(t){var e,i=this.lightDefs[t],n=new Ui(16777215);void 0!==i.color&&n.fromArray(i.color);var r=void 0!==i.range?i.range:0;switch(i.type){case"directional":(e=new Bc(n)).target.position.set(0,0,-1),e.add(e.target);break;case"point":(e=new Ic(n)).distance=r;break;case"spot":(e=new Lc(n)).distance=r,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,e.angle=i.spot.outerConeAngle,e.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,e.target.position.set(0,0,-1),e.add(e.target);break;default:throw new Error('threeExamples.GLTFLoader: Unexpected light type, "'+i.type+'".')}return e.position.set(0,0,0),e.decay=2,void 0!==i.intensity&&(e.intensity=i.intensity),e.name=i.name||"light_"+t,Promise.resolve(e)},vS.prototype.getMaterialType=function(){return qi},vS.prototype.extendParams=function(t,e,i){var n=[];t.color=new Ui(1,1,1),t.opacity=1;var r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){var s=r.baseColorFactor;t.color.fromArray(s),t.opacity=s[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(t,"map",r.baseColorTexture))}return Promise.all(n)};var bS="glTF",yS=1313821514,_S=5130562;function xS(t){this.name=fS.KHR_BINARY_GLTF,this.content=null,this.body=null;var e=new DataView(t,0,12);if(this.header={magic:Uc(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==bS)throw new Error("threeExamples.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("threeExamples.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.");for(var i=new DataView(t,12),n=0;n<i.byteLength;){var r=i.getUint32(n,!0);n+=4;var s=i.getUint32(n,!0);if(n+=4,s===yS){var o=new Uint8Array(t,12+n,r);this.content=Uc(o)}else if(s===_S){var a=12+n;this.body=t.slice(a,a+r)}n+=r}if(null===this.content)throw new Error("threeExamples.GLTFLoader: JSON content not found.")}function wS(t,e){if(!e)throw new Error("threeExamples.GLTFLoader: No DRACOLoader instance provided.");this.name=fS.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e}function MS(){this.name=fS.KHR_TEXTURE_TRANSFORM}function TS(){return{name:fS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return Wn},extendParams:function(t,e,i){var n=e.extensions[this.name],r=nr.standard,s=Gn.clone(r.uniforms),o=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),a=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),h=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),c=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),l=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb;","material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );","material.specularColor = specularFactor.rgb;"].join("\n"),u=r.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",o).replace("#include <metalnessmap_pars_fragment>",a).replace("#include <roughnessmap_fragment>",h).replace("#include <metalnessmap_fragment>",c).replace("#include <lights_physical_fragment>",l);delete s.roughness,delete s.metalness,delete s.roughnessMap,delete s.metalnessMap,s.specular={value:(new Ui).setHex(1118481)},s.glossiness={value:.5},s.specularMap={value:null},s.glossinessMap={value:null},t.vertexShader=r.vertexShader,t.fragmentShader=u,t.uniforms=s,t.defines={STANDARD:""},t.color=new Ui(1,1,1),t.opacity=1;var d=[];if(Array.isArray(n.diffuseFactor)){var p=n.diffuseFactor;t.color.fromArray(p),t.opacity=p[3]}if(void 0!==n.diffuseTexture&&d.push(i.assignTexture(t,"map",n.diffuseTexture)),t.emissive=new Ui(0,0,0),t.glossiness=void 0!==n.glossinessFactor?n.glossinessFactor:1,t.specular=new Ui(1,1,1),Array.isArray(n.specularFactor)&&t.specular.fromArray(n.specularFactor),void 0!==n.specularGlossinessTexture){var f=n.specularGlossinessTexture;d.push(i.assignTexture(t,"glossinessMap",f)),d.push(i.assignTexture(t,"specularMap",f))}return Promise.all(d)},createMaterial:function(t){var e=new Wn({defines:t.defines,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms,fog:!0,lights:!0,opacity:t.opacity,transparent:t.transparent});return e.isGLTFSpecularGlossinessMaterial=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e.extensions.derivatives=!0,e},cloneMaterial:function(t){var e=t.clone();e.isGLTFSpecularGlossinessMaterial=!0;for(var i=this.specularGlossinessParams,n=0,r=i.length;n<r;n++){var s=t[i[n]];e[i[n]]=s&&s.isColor?s.clone():s}return e},refreshUniforms:function(t,e,i,n,r){if(!0===r.isGLTFSpecularGlossinessMaterial){var s,o=r.uniforms,a=r.defines;o.opacity.value=r.opacity,o.diffuse.value.copy(r.color),o.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),o.map.value=r.map,o.specularMap.value=r.specularMap,o.alphaMap.value=r.alphaMap,o.lightMap.value=r.lightMap,o.lightMapIntensity.value=r.lightMapIntensity,o.aoMap.value=r.aoMap,o.aoMapIntensity.value=r.aoMapIntensity,r.map?s=r.map:r.specularMap?s=r.specularMap:r.displacementMap?s=r.displacementMap:r.normalMap?s=r.normalMap:r.bumpMap?s=r.bumpMap:r.glossinessMap?s=r.glossinessMap:r.alphaMap?s=r.alphaMap:r.emissiveMap&&(s=r.emissiveMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),o.uvTransform.value.copy(s.matrix)),r.envMap&&(o.envMap.value=r.envMap,o.envMapIntensity.value=r.envMapIntensity,o.flipEnvMap.value=r.envMap.isCubeTexture?-1:1,o.reflectivity.value=r.reflectivity,o.refractionRatio.value=r.refractionRatio,o.maxMipLevel.value=t.properties.get(r.envMap).__maxMipLevel),o.specular.value.copy(r.specular),o.glossiness.value=r.glossiness,o.glossinessMap.value=r.glossinessMap,o.emissiveMap.value=r.emissiveMap,o.bumpMap.value=r.bumpMap,o.normalMap.value=r.normalMap,o.displacementMap.value=r.displacementMap,o.displacementScale.value=r.displacementScale,o.displacementBias.value=r.displacementBias,null!==o.glossinessMap.value&&void 0===a.USE_GLOSSINESSMAP&&(a.USE_GLOSSINESSMAP="",a.USE_ROUGHNESSMAP=""),null===o.glossinessMap.value&&void 0!==a.USE_GLOSSINESSMAP&&(delete a.USE_GLOSSINESSMAP,delete a.USE_ROUGHNESSMAP)}}}}function SS(t,e,i,n){Rh.call(this,t,e,i,n)}wS.prototype.decodePrimitive=function(t,e){var i=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,o={},a={},h={};for(var c in s){var l=NS[c]||c.toLowerCase();o[l]=s[c]}for(c in t.attributes){l=NS[c]||c.toLowerCase();if(void 0!==s[c]){var u=i.accessors[t.attributes[c]],d=FS[u.componentType];h[l]=d,a[l]=!0===u.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e){n.decodeDracoFile(t,(function(t){for(var i in t.attributes){var n=t.attributes[i],r=a[i];void 0!==r&&(n.normalized=r)}e(t)}),o,h)}))}))},MS.prototype.extendTexture=function(t,e){return t=t.clone(),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),void 0!==e.texCoord&&console.warn('threeExamples.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),t.needsUpdate=!0,t},SS.prototype=Object.create(Rh.prototype),SS.prototype.constructor=SS,SS.prototype.copySampleValue_=function(t){for(var e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n*3+n,s=0;s!==n;s++)e[s]=i[r+s];return e},SS.prototype.beforeStart_=SS.prototype.copySampleValue_,SS.prototype.afterEnd_=SS.prototype.copySampleValue_,SS.prototype.interpolate_=function(t,e,i,n){for(var r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,h=3*o,c=n-e,l=(i-e)/c,u=l*l,d=u*l,p=t*h,f=p-h,m=-2*d+3*u,g=d-u,v=1-m,b=g-u+l,y=0;y!==o;y++){var _=s[f+y+o],x=s[f+y+a]*c,w=s[p+y+o],M=s[p+y]*c;r[y]=v*_+b*x+m*w+g*M}return r};var ES,PS=0,AS=1,CS=2,LS=3,RS=4,IS=5,OS=6,FS={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},BS={9728:ft,9729:yt,9984:gt,9985:_t,9986:bt,9987:wt},DS={33071:dt,33648:pt,10497:ut},zS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},NS={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex",_BATCHID:"_BATCHID"},US={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},VS={CUBICSPLINE:void 0,LINEAR:Yt,STEP:Xt},kS="OPAQUE",jS="MASK",HS="BLEND",GS={"image/png":Ft,"image/jpeg":Ot};function WS(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}function qS(t,e,i){for(var n in i.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=i.extensions[n])}function XS(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("threeExamples.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function YS(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(var i=0,n=e.weights.length;i<n;i++)t.morphTargetInfluences[i]=e.weights[i];if(e.extras&&Array.isArray(e.extras.targetNames)){var r=e.extras.targetNames;if(t.morphTargetInfluences.length===r.length){t.morphTargetDictionary={};for(i=0,n=r.length;i<n;i++)t.morphTargetDictionary[r[i]]=i}else console.warn("threeExamples.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ZS(t){for(var e="",i=Object.keys(t).sort(),n=0,r=i.length;n<r;n++)e+=i[n]+":"+t[i[n]]+";";return e}function $S(t){if(t.isInterleavedBufferAttribute){for(var e=t.count,i=t.itemSize,n=t.array.slice(0,e*i),r=0,s=0;r<e;++r)n[s++]=t.getX(r),i>=2&&(n[s++]=t.getY(r)),i>=3&&(n[s++]=t.getZ(r)),i>=4&&(n[s++]=t.getW(r));return new Yi(n,i,t.normalized)}return t.clone()}function JS(t,e,i){this.json=t||{},this.extensions=e||{},this.options=i||{},this.cache=new pS,this.primitiveCache={},this.textureLoader=new ic(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new $h(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}function QS(t,e,i){var n=e.attributes,r=[];function s(e,n){return i.getDependency("accessor",e).then((function(e){t.setAttribute(n,e)}))}for(var o in n){var a=NS[o]||o.toLowerCase();a in t.attributes||r.push(s(n[o],a))}if(void 0!==e.indices&&!t.index){var h=i.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(h)}return XS(t,e),Promise.all(r).then((function(){return void 0!==e.targets?function(t,e,i){for(var n=!1,r=!1,s=0,o=e.length;s<o&&(void 0!==(c=e[s]).POSITION&&(n=!0),void 0!==c.NORMAL&&(r=!0),!n||!r);s++);if(!n&&!r)return Promise.resolve(t);var a=[],h=[];for(s=0,o=e.length;s<o;s++){var c=e[s];if(n){var l=void 0!==c.POSITION?i.getDependency("accessor",c.POSITION):t.attributes.position;a.push(l)}r&&(l=void 0!==c.NORMAL?i.getDependency("accessor",c.NORMAL):t.attributes.normal,h.push(l))}return Promise.all([Promise.all(a),Promise.all(h)]).then((function(i){for(var s=i[0],o=i[1],a=0,h=s.length;a<h;a++)t.attributes.position!==s[a]&&(s[a]=$S(s[a]));for(a=0,h=o.length;a<h;a++)t.attributes.normal!==o[a]&&(o[a]=$S(o[a]));for(a=0,h=e.length;a<h;a++){var c=e[a],l="morphTarget"+a;if(n&&void 0!==c.POSITION){var u=s[a];u.name=l;for(var d=t.attributes.position,p=0,f=u.count;p<f;p++)u.setXYZ(p,u.getX(p)+d.getX(p),u.getY(p)+d.getY(p),u.getZ(p)+d.getZ(p))}if(r&&void 0!==c.NORMAL){var m=o[a];m.name=l;var g=t.attributes.normal;for(p=0,f=m.count;p<f;p++)m.setXYZ(p,m.getX(p)+g.getX(p),m.getY(p)+g.getY(p),m.getZ(p)+g.getZ(p))}}return n&&(t.morphAttributes.position=s),r&&(t.morphAttributes.normal=o),t}))}(t,e.targets,i):t}))}JS.prototype.parse=function(t,e){var i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.markDefs(),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then((function(e){var s={scene:e[0][n.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:n.asset,parser:i,userData:{}};qS(r,s,n),XS(s,n),t(s)})).catch(e)},JS.prototype.markDefs=function(){for(var t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[],n={},r={},s=0,o=e.length;s<o;s++)for(var a=e[s].joints,h=0,c=a.length;h<c;h++)t[a[h]].isBone=!0;for(var l=0,u=t.length;l<u;l++){var d=t[l];void 0!==d.mesh&&(void 0===n[d.mesh]&&(n[d.mesh]=r[d.mesh]=0),n[d.mesh]++,void 0!==d.skin&&(i[d.mesh].isSkinnedMesh=!0))}this.json.meshReferences=n,this.json.meshUses=r},JS.prototype.getDependency=function(t,e){var i=t+":"+e,n=this.cache.get(i);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this.loadNode(e);break;case"mesh":n=this.loadMesh(e);break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this.loadBufferView(e);break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this.loadMaterial(e);break;case"texture":n=this.loadTexture(e);break;case"skin":n=this.loadSkin(e);break;case"animation":n=this.loadAnimation(e);break;case"camera":n=this.loadCamera(e);break;case"light":n=this.extensions[fS.KHR_LIGHTS_PUNCTUAL].loadLight(e);break;default:throw new Error("Unknown type: "+t)}this.cache.add(i,n)}return n},JS.prototype.getDependencies=function(t){var e=this.cache.get(t);if(!e){var i=this,n=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(n.map((function(e,n){return i.getDependency(t,n)}))),this.cache.add(t,e)}return e},JS.prototype.loadBuffer=function(t){var e=this.json.buffers[t],i=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("threeExamples.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[fS.KHR_BINARY_GLTF].body);var n=this.options;return new Promise((function(t,r){i.load(WS(e.uri,n.path),t,void 0,(function(){r(new Error('threeExamples.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))},JS.prototype.loadBufferView=function(t){var e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){var i=e.byteLength||0,n=e.byteOffset||0;return t.slice(n,n+i)}))},JS.prototype.loadAccessor=function(t){var e=this,i=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse)return Promise.resolve(null);var r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(t){var r,s=t[0],o=zS[n.type],a=FS[n.componentType],h=a.BYTES_PER_ELEMENT,c=h*o,l=n.byteOffset||0,u=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,d=!0===n.normalized;if(u&&u!==c){var p=Math.floor(l/u),f="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+p+":"+n.count,m=e.cache.get(f);m||(m=new so(new a(s,p*u,n.count*u/h),u/h),e.cache.add(f,m)),r=new ho(m,o,l%u/h,d)}else r=new Yi(null===s?new a(n.count*o):new a(s,l,n.count*o),o,d);if(void 0!==n.sparse){var g=zS.SCALAR,v=FS[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,y=n.sparse.values.byteOffset||0,_=new v(t[1],b,n.sparse.count*g),x=new a(t[2],y,n.sparse.count*o);null!==s&&(r=new Yi(r.array.slice(),r.itemSize,r.normalized));for(var w=0,M=_.length;w<M;w++){var T=_[w];if(r.setX(T,x[w*o]),o>=2&&r.setY(T,x[w*o+1]),o>=3&&r.setZ(T,x[w*o+2]),o>=4&&r.setW(T,x[w*o+3]),o>=5)throw new Error("threeExamples.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return r}))},JS.prototype.loadTexture=function(t){var e,i=this,n=this.json,r=this.options,s=this.textureLoader,o=window.URL||window.webkitURL,a=n.textures[t],h=a.extensions||{},c=(e=h[fS.MSFT_TEXTURE_DDS]?n.images[h[fS.MSFT_TEXTURE_DDS].source]:n.images[a.source]).uri,l=!1;return void 0!==e.bufferView&&(c=i.getDependency("bufferView",e.bufferView).then((function(t){l=!0;var i=new Blob([t],{type:e.mimeType});return c=o.createObjectURL(i)}))),Promise.resolve(c).then((function(t){var e=r.manager.getHandler(t);return e||(e=h[fS.MSFT_TEXTURE_DDS]?i.extensions[fS.MSFT_TEXTURE_DDS].ddsLoader:s),new Promise((function(i,n){e.load(WS(t,r.path),i,void 0,n)}))})).then((function(t){!0===l&&o.revokeObjectURL(c),t.flipY=!1,void 0!==a.name&&(t.name=a.name),e.mimeType in GS&&(t.format=GS[e.mimeType]);var i=(n.samplers||{})[a.sampler]||{};return t.magFilter=BS[i.magFilter]||yt,t.minFilter=BS[i.minFilter]||wt,t.wrapS=DS[i.wrapS]||ut,t.wrapT=DS[i.wrapT]||ut,t}))},JS.prototype.assignTexture=function(t,e,i){var n=this;return this.getDependency("texture",i.index).then((function(r){if(!r.isCompressedTexture)switch(e){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":r.format=Ot}if(n.extensions[fS.KHR_TEXTURE_TRANSFORM]){var s=void 0!==i.extensions?i.extensions[fS.KHR_TEXTURE_TRANSFORM]:void 0;s&&(r=n.extensions[fS.KHR_TEXTURE_TRANSFORM].extendTexture(r,s))}t[e]=r}))},JS.prototype.assignFinalMaterial=function(t){var e=t.geometry,i=t.material,n=this.extensions,r=void 0!==e.attributes.tangent,s=void 0!==e.attributes.color,o=void 0===e.attributes.normal,a=!0===t.isSkinnedMesh,h=Object.keys(e.morphAttributes).length>0,c=h&&void 0!==e.morphAttributes.normal;if(t.isPoints){var l="PointsMaterial:"+i.uuid,u=this.cache.get(l);u||(u=new Zo,Wi.prototype.copy.call(u,i),u.color.copy(i.color),u.map=i.map,u.sizeAttenuation=!1,this.cache.add(l,u)),i=u}else if(t.isLine){l="LineBasicMaterial:"+i.uuid;var d=this.cache.get(l);d||(d=new No,Wi.prototype.copy.call(d,i),d.color.copy(i.color),this.cache.add(l,d)),i=d}if(r||s||o||a||h){l="ClonedMaterial:"+i.uuid+":";i.isGLTFSpecularGlossinessMaterial&&(l+="specular-glossiness:"),a&&(l+="skinning:"),r&&(l+="vertex-tangents:"),s&&(l+="vertex-colors:"),o&&(l+="flat-shading:"),h&&(l+="morph-targets:"),c&&(l+="morph-normals:");var p=this.cache.get(l);p||(p=i.isGLTFSpecularGlossinessMaterial?n[fS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].cloneMaterial(i):i.clone(),a&&(p.skinning=!0),r&&(p.vertexTangents=!0),s&&(p.vertexColors=2),o&&(p.flatShading=!0),h&&(p.morphTargets=!0),c&&(p.morphNormals=!0),this.cache.add(l,p)),i=p}i.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&(console.log("threeExamples.GLTFLoader: Duplicating UVs to support aoMap."),e.setAttribute("uv2",new Yi(e.attributes.uv.array,2))),i.isGLTFSpecularGlossinessMaterial&&(t.onBeforeRender=n[fS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].refreshUniforms),t.material=i},JS.prototype.loadMaterial=function(t){var e,i=this,n=this.json,r=this.extensions,s=n.materials[t],o={},a=s.extensions||{},h=[];if(a[fS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var c=r[fS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];e=c.getMaterialType(),h.push(c.extendParams(o,s,i))}else if(a[fS.KHR_MATERIALS_UNLIT]){var l=r[fS.KHR_MATERIALS_UNLIT];e=l.getMaterialType(),h.push(l.extendParams(o,s,i))}else{e=eg;var u=s.pbrMetallicRoughness||{};if(o.color=new Ui(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){var d=u.baseColorFactor;o.color.fromArray(d),o.opacity=d[3]}void 0!==u.baseColorTexture&&h.push(i.assignTexture(o,"map",u.baseColorTexture)),void 0!==u.metallicRoughnessTexture&&(h.push(i.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),h.push(i.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture)))}!0===s.doubleSided&&(o.side=2);var p=s.alphaMode||kS;return p===HS?o.transparent=!0:(o.transparent=!1,p===jS&&(o.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&e!==qi&&(h.push(i.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new ce(1,1),void 0!==s.normalTexture.scale&&o.normalScale.set(s.normalTexture.scale,s.normalTexture.scale)),void 0!==s.occlusionTexture&&e!==qi&&(h.push(i.assignTexture(o,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(o.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&e!==qi&&(o.emissive=(new Ui).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&e!==qi&&h.push(i.assignTexture(o,"emissiveMap",s.emissiveTexture)),Promise.all(h).then((function(){var t;return t=e===Wn?r[fS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new e(o),void 0!==s.name&&(t.name=s.name),t.map&&(t.map.encoding=te),t.emissiveMap&&(t.emissiveMap.encoding=te),t.specularMap&&(t.specularMap.encoding=te),XS(t,s),s.extensions&&qS(r,t,s),t}))},JS.prototype.loadGeometries=function(t){var e=this,i=this.extensions,n=this.primitiveCache;function r(t){return i[fS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(i){return QS(i,t,e)}))}for(var s,o,a=[],h=0,c=t.length;h<c;h++){var l,u=t[h],d=(o=void 0,(o=(s=u).extensions&&s.extensions[fS.KHR_DRACO_MESH_COMPRESSION])?"draco:"+o.bufferView+":"+o.indices+":"+ZS(o.attributes):s.indices+":"+ZS(s.attributes)+":"+s.mode),p=n[d];if(p)a.push(p.promise);else l=u.extensions&&u.extensions[fS.KHR_DRACO_MESH_COMPRESSION]?r(u):QS(new fn,u,e),n[d]={primitive:u,promise:l},a.push(l)}return Promise.all(a)},JS.prototype.loadMesh=function(t){for(var e=this,i=this.json.meshes[t],n=i.primitives,r=[],s=0,o=n.length;s<o;s++){var a=void 0===n[s].material?ES=ES||new qi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0}):this.getDependency("material",n[s].material);r.push(a)}return Promise.all(r).then((function(r){return e.loadGeometries(n).then((function(s){for(var o=[],a=0,h=s.length;a<h;a++){var c,l=s[a],u=n[a],d=r[a];if(u.mode===RS||u.mode===IS||u.mode===OS||void 0===u.mode)!0!==(c=!0===i.isSkinnedMesh?new Ao(l,d):new In(l,d)).isSkinnedMesh||c.geometry.attributes.skinWeight.normalized||c.normalizeSkinWeights(),u.mode===IS?c.drawMode=1:u.mode===OS&&(c.drawMode=2);else if(u.mode===AS)c=new Xo(l,d);else if(u.mode===LS)c=new Go(l,d);else if(u.mode===CS)c=new Yo(l,d);else{if(u.mode!==PS)throw new Error("threeExamples.GLTFLoader: Primitive mode unsupported: "+u.mode);c=new ta(l,d)}Object.keys(c.geometry.morphAttributes).length>0&&YS(c,i),c.name=i.name||"mesh_"+t,s.length>1&&(c.name+="_"+a),XS(c,i),e.assignFinalMaterial(c),o.push(c)}if(1===o.length)return o[0];var p=new to;for(a=0,h=o.length;a<h;a++)p.add(o[a]);return p}))}))},JS.prototype.loadCamera=function(t){var e,i=this.json.cameras[t],n=i[i.type];if(n)return"perspective"===i.type?e=new Xn(he.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(e=new Oc(n.xmag/-2,n.xmag/2,n.ymag/2,n.ymag/-2,n.znear,n.zfar)),void 0!==i.name&&(e.name=i.name),XS(e,i),Promise.resolve(e);console.warn("threeExamples.GLTFLoader: Missing camera parameters.")},JS.prototype.loadSkin=function(t){var e=this.json.skins[t],i={joints:e.joints};return void 0===e.inverseBindMatrices?Promise.resolve(i):this.getDependency("accessor",e.inverseBindMatrices).then((function(t){return i.inverseBindMatrices=t,i}))},JS.prototype.loadAnimation=function(t){for(var e=this.json.animations[t],i=[],n=[],r=[],s=[],o=[],a=0,h=e.channels.length;a<h;a++){var c=e.channels[a],l=e.samplers[c.sampler],u=c.target,d=void 0!==u.node?u.node:u.id,p=void 0!==e.parameters?e.parameters[l.input]:l.input,f=void 0!==e.parameters?e.parameters[l.output]:l.output;i.push(this.getDependency("node",d)),n.push(this.getDependency("accessor",p)),r.push(this.getDependency("accessor",f)),s.push(l),o.push(u)}return Promise.all([Promise.all(i),Promise.all(n),Promise.all(r),Promise.all(s),Promise.all(o)]).then((function(i){for(var n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],h=[],c=0,l=n.length;c<l;c++){var u=n[c],d=r[c],p=s[c],f=o[c],m=a[c];if(void 0!==u){var g;switch(u.updateMatrix(),u.matrixAutoUpdate=!0,US[m.path]){case US.weights:g=Nh;break;case US.rotation:g=Vh;break;case US.position:case US.scale:default:g=jh}var v=u.name?u.name:u.uuid,b=void 0!==f.interpolation?VS[f.interpolation]:Yt,y=[];US[m.path]===US.weights?u.traverse((function(t){!0===t.isMesh&&t.morphTargetInfluences&&y.push(t.name?t.name:t.uuid)})):y.push(v);var _=p.array;if(p.normalized){var x;if(_.constructor===Int8Array)x=1/127;else if(_.constructor===Uint8Array)x=1/255;else if(_.constructor==Int16Array)x=1/32767;else{if(_.constructor!==Uint16Array)throw new Error("threeExamples.GLTFLoader: Unsupported output accessor component type.");x=1/65535}for(var w=new Float32Array(_.length),M=0,T=_.length;M<T;M++)w[M]=_[M]*x;_=w}for(M=0,T=y.length;M<T;M++){var S=new g(y[M]+"."+US[m.path],d.array,_,b);"CUBICSPLINE"===f.interpolation&&(S.createInterpolant=function(t){return new SS(this.times,this.values,this.getValueSize()/3,t)},S.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),h.push(S)}}}return new Hh(void 0!==e.name?e.name:"animation_"+t,void 0,h)}))},JS.prototype.loadNode=function(t){var e,i=this.json,n=this.extensions,r=this,s=i.meshReferences,o=i.meshUses,a=i.nodes[t];return(e=[],void 0!==a.mesh&&e.push(r.getDependency("mesh",a.mesh).then((function(t){var e;if(s[a.mesh]>1){var i=o[a.mesh]++;(e=t.clone()).name+="_instance_"+i,e.onBeforeRender=t.onBeforeRender;for(var n=0,r=e.children.length;n<r;n++)e.children[n].name+="_instance_"+i,e.children[n].onBeforeRender=t.children[n].onBeforeRender}else e=t;return void 0!==a.weights&&e.traverse((function(t){if(t.isMesh)for(var e=0,i=a.weights.length;e<i;e++)t.morphTargetInfluences[e]=a.weights[e]})),e}))),void 0!==a.camera&&e.push(r.getDependency("camera",a.camera)),a.extensions&&a.extensions[fS.KHR_LIGHTS_PUNCTUAL]&&void 0!==a.extensions[fS.KHR_LIGHTS_PUNCTUAL].light&&e.push(r.getDependency("light",a.extensions[fS.KHR_LIGHTS_PUNCTUAL].light)),Promise.all(e)).then((function(t){var e;if((e=!0===a.isBone?new Io:t.length>1?new to:1===t.length?t[0]:new Ye)!==t[0])for(var i=0,r=t.length;i<r;i++)e.add(t[i]);if(void 0!==a.name&&(e.userData.name=a.name,e.name=Fl.sanitizeNodeName(a.name)),XS(e,a),a.extensions&&qS(n,e,a),void 0!==a.matrix){var s=new Le;s.fromArray(a.matrix),e.applyMatrix(s)}else void 0!==a.translation&&e.position.fromArray(a.translation),void 0!==a.rotation&&e.quaternion.fromArray(a.rotation),void 0!==a.scale&&e.scale.fromArray(a.scale);return e}))},JS.prototype.loadScene=function(){function t(e,i,n,r){var s=n.nodes[e];return r.getDependency("node",e).then((function(t){return void 0===s.skin?t:r.getDependency("skin",s.skin).then((function(t){for(var i=[],n=0,s=(e=t).joints.length;n<s;n++)i.push(r.getDependency("node",e.joints[n]));return Promise.all(i)})).then((function(i){return t.traverse((function(t){if(t.isMesh){for(var n=[],r=[],s=0,o=i.length;s<o;s++){var a=i[s];if(a){n.push(a);var h=new Le;void 0!==e.inverseBindMatrices&&h.fromArray(e.inverseBindMatrices.array,16*s),r.push(h)}else console.warn('threeExamples.GLTFLoader: Joint "%s" could not be found.',e.joints[s])}t.bind(new Ro(n,r),t.matrixWorld)}})),t}));var e})).then((function(e){i.add(e);var o=[];if(s.children)for(var a=s.children,h=0,c=a.length;h<c;h++){var l=a[h];o.push(t(l,e,n,r))}return Promise.all(o)}))}return function(e){var i=this.json,n=this.extensions,r=this.json.scenes[e],s=new Ze;void 0!==r.name&&(s.name=r.name),XS(s,r),r.extensions&&qS(n,s,r);for(var o=r.nodes||[],a=[],h=0,c=o.length;h<c;h++)a.push(t(o[h],s,i,this));return Promise.all(a).then((function(){return s}))}}();var KS=dS;const tE={DRACOLoader:function(t){Yh.call(this,t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}};tE.DRACOLoader.prototype=Object.assign(Object.create(Yh.prototype),{constructor:tE.DRACOLoader,setDecoderPath:function(t){return this.decoderPath=t,this},setDecoderConfig:function(t){return this.decoderConfig=t,this},setWorkerLimit:function(t){return this.workerLimit=t,this},setVerbosity:function(){console.warn("threeExamples.DRACOLoader: The .setVerbosity() method has been removed.")},setDrawMode:function(){console.warn("threeExamples.DRACOLoader: The .setDrawMode() method has been removed.")},setSkipDequantization:function(){console.warn("threeExamples.DRACOLoader: The .setSkipDequantization() method has been removed.")},load:function(t,e,i,n){var r=new $h(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),"use-credentials"===this.crossOrigin&&r.setWithCredentials(!0),r.load(t,(t=>{var i={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(t,i).then(e).catch(n)}),i,n)},decodeDracoFile:function(t,e,i,n){var r={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i};this.decodeGeometry(t,r).then(e)},decodeGeometry:function(t,e){var i,n=this.workerNextTaskID++,r=t.byteLength;for(var s in e.attributeTypes){var o=e.attributeTypes[s];void 0!==o.BYTES_PER_ELEMENT&&(e.attributeTypes[s]=o.name)}var a=this._getWorker(n,r).then((r=>(i=r,new Promise(((r,s)=>{i._callbacks[n]={resolve:r,reject:s},i.postMessage({type:"decode",id:n,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.finally((()=>{i&&n&&this._releaseTask(i,n)})),a},_createGeometry:function(t){var e=new fn;t.index&&e.setIndex(new Yi(t.index.array,1));for(var i=0;i<t.attributes.length;i++){var n=t.attributes[i],r=n.name,s=n.array,o=n.itemSize;e.setAttribute(r,new Yi(s,o))}return e},_loadLibrary:function(t,e){var i=new $h(this.manager);return i.setPath(this.decoderPath),i.setResponseType(e),new Promise(((e,n)=>{i.load(t,e,void 0,n)}))},_initDecoder:function(){if(this.decoderPending)return this.decoderPending;var t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{var i=e[0];t||(this.decoderConfig.wasmBinary=e[1]);var n=tE.DRACOLoader.DRACOWorker.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending},_getWorker:function(t,e){return this._initDecoder().then((()=>{var i;this.workerPool.length<this.workerLimit?((i=new Worker(this.workerSourceURL))._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(t){var e=t.data;switch(e.type){case"decode":i._callbacks[e.id].resolve(e);break;case"error":i._callbacks[e.id].reject(e);break;default:console.error('threeExamples.DRACOLoader: Unexpected message, "'+e.type+'"')}},this.workerPool.push(i)):this.workerPool.sort((function(t,e){return t._taskLoad>e._taskLoad?-1:1}));return(i=this.workerPool[this.workerPool.length-1])._taskCosts[t]=e,i._taskLoad+=e,i}))},_releaseTask:function(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]},debug:function(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))},dispose:function(){for(var t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this}}),tE.DRACOLoader.DRACOWorker=function(){var t,e;function i(t,e,i,n,r,s){var o,a,h=s.num_components(),c=i.num_points()*h;switch(r){case Float32Array:o=new t.DracoFloat32Array,e.GetAttributeFloatForAllPoints(i,s,o),a=new Float32Array(c);break;case Int8Array:o=new t.DracoInt8Array,e.GetAttributeInt8ForAllPoints(i,s,o),a=new Int8Array(c);break;case Int16Array:o=new t.DracoInt16Array,e.GetAttributeInt16ForAllPoints(i,s,o),a=new Int16Array(c);break;case Int32Array:o=new t.DracoInt32Array,e.GetAttributeInt32ForAllPoints(i,s,o),a=new Int32Array(c);break;case Uint8Array:o=new t.DracoUInt8Array,e.GetAttributeUInt8ForAllPoints(i,s,o),a=new Uint8Array(c);break;case Uint16Array:o=new t.DracoUInt16Array,e.GetAttributeUInt16ForAllPoints(i,s,o),a=new Uint16Array(c);break;case Uint32Array:o=new t.DracoUInt32Array,e.GetAttributeUInt32ForAllPoints(i,s,o),a=new Uint32Array(c);break;default:throw new Error("threeExamples.DRACOLoader: Unexpected attribute type.")}for(var l=0;l<c;l++)a[l]=o.GetValue(l);return t.destroy(o),{name:n,array:a,itemSize:h}}onmessage=function(n){var r=n.data;switch(r.type){case"init":t=r.decoderConfig,e=new Promise((function(e){t.onModuleLoaded=function(t){e({draco:t})},DracoDecoderModule(t)}));break;case"decode":var s=r.buffer,o=r.taskConfig;e.then((t=>{var e=t.draco,n=new e.Decoder,a=new e.DecoderBuffer;a.Init(new Int8Array(s),s.byteLength);try{var h=function(t,e,n,r){var s,o,a=r.attributeIDs,h=r.attributeTypes,c=e.GetEncodedGeometryType(n);if(c===t.TRIANGULAR_MESH)s=new t.Mesh,o=e.DecodeBufferToMesh(n,s);else{if(c!==t.POINT_CLOUD)throw new Error("threeExamples.DRACOLoader: Unexpected geometry type.");s=new t.PointCloud,o=e.DecodeBufferToPointCloud(n,s)}if(!o.ok()||0===s.ptr)throw new Error("threeExamples.DRACOLoader: Decoding failed: "+o.error_msg());var l={index:null,attributes:[]};for(var u in a){var d,p,f=self[h[u]];if(r.useUniqueIDs)p=a[u],d=e.GetAttributeByUniqueId(s,p);else{if(-1===(p=e.GetAttributeId(s,t[a[u]])))continue;d=e.GetAttribute(s,p)}l.attributes.push(i(t,e,s,u,f,d))}if(c===t.TRIANGULAR_MESH){for(var m=s.num_faces(),g=new Uint32Array(3*m),v=new t.DracoInt32Array,b=0;b<m;++b){e.GetFaceFromMesh(s,b,v);for(var y=0;y<3;++y)g[3*b+y]=v.GetValue(y)}l.index={array:g,itemSize:1},t.destroy(v)}return t.destroy(s),l}(e,n,a,o),c=h.attributes.map((t=>t.array.buffer));h.index&&c.push(h.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:h},c)}catch(t){console.error(t),self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(a),e.destroy(n)}}))}}},tE.DRACOLoader.setDecoderPath=function(){console.warn("threeExamples.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.")},tE.DRACOLoader.setDecoderConfig=function(){console.warn("threeExamples.DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.")},tE.DRACOLoader.releaseDecoderModule=function(){console.warn("threeExamples.DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.")},tE.DRACOLoader.getDecoderModule=function(){console.warn("threeExamples.DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.")};tE.DRACOLoader;const eE={};eE.LegacyGLTFLoader=function(){function t(t){Yh.call(this,t)}function e(){var t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}},update:function(e,i){for(var n in t){var r=t[n];r.update&&r.update(e,i)}}}}function i(t,e){var i={},n=t.material.uniforms;for(var r in n){var s=n[r];if(s.semantic){var o=s.node,a=t;o&&(a=e[o]),i[r]={semantic:s.semantic,sourceNode:a,targetNode:t,uniform:s}}}this.boundUniforms=i,this._m4=new Le}t.prototype=Object.assign(Object.create(Yh.prototype),{constructor:t,load:function(t,e,i,n){var r,s=this;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Vc(t);var o=new $h(s.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.load(t,(function(t){s.parse(t,r,e)}),i,n)},parse:function(t,e,i){var a,h={};Uc(new Uint8Array(t,0,4))===s.magic?(h[n.KHR_BINARY_GLTF]=new o(t),a=h[n.KHR_BINARY_GLTF].content):a=Uc(new Uint8Array(t));var c=JSON.parse(a);c.extensionsUsed&&c.extensionsUsed.indexOf(n.KHR_MATERIALS_COMMON)>=0&&(h[n.KHR_MATERIALS_COMMON]=new r(c)),new S(c,h,{crossOrigin:this.crossOrigin,manager:this.manager,path:e||this.resourcePath||""}).parse((function(t,e,n,r){i({scene:t,scenes:e,cameras:n,animations:r})}))}}),t.Shaders={update:function(){console.warn("threeExamples.LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.")}},i.prototype.update=function(t,e){var i=this.boundUniforms;for(var n in i){var r=i[n];switch(r.semantic){case"MODELVIEW":r.uniform.value.multiplyMatrices(e.matrixWorldInverse,r.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var s=r.uniform.value;this._m4.multiplyMatrices(e.matrixWorldInverse,r.sourceNode.matrixWorld),s.getNormalMatrix(this._m4);break;case"PROJECTION":r.uniform.value.copy(e.projectionMatrix);break;case"JOINTMATRIX":for(var o=r.uniform.value,a=0;a<o.length;a++)o[a].getInverse(r.sourceNode.matrixWorld).multiply(r.targetNode.skeleton.bones[a].matrixWorld).multiply(r.targetNode.skeleton.boneInverses[a]).multiply(r.targetNode.bindMatrix);break;default:console.warn("Unhandled shader semantic: "+r.semantic)}}},t.Animations={update:function(){console.warn("threeExamples.LegacyGLTFLoader.Animation has been deprecated. Use THREE.AnimationMixer instead.")}};var n={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_MATERIALS_COMMON:"KHR_materials_common"};function r(t){this.name=n.KHR_MATERIALS_COMMON,this.lights={};var e=(t.extensions&&t.extensions[n.KHR_MATERIALS_COMMON]||{}).lights||{};for(var i in e){var r,s=e[i],o=s[s.type],a=(new Ui).fromArray(o.color);switch(s.type){case"directional":(r=new Bc(a)).position.set(0,0,1);break;case"point":r=new Ic(a);break;case"spot":(r=new Lc(a)).position.set(0,0,1);break;case"ambient":r=new Dc(a)}r&&(this.lights[i]=r)}}var s={magic:"glTF",version:1,contentFormat:0};function o(t){this.name=n.KHR_BINARY_GLTF;var e=new DataView(t,0,20),i={magic:Uc(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0),contentLength:e.getUint32(12,!0),contentFormat:e.getUint32(16,!0)};for(var r in s){var o=s[r];if(i[r]!==o)throw new Error('Unsupported glTF-Binary header: Expected "%s" to be "%s".',r,o)}var a=new Uint8Array(t,20,i.contentLength);this.header=i,this.content=Uc(a),this.body=t.slice(20+i.contentLength,i.length)}o.prototype.loadShader=function(t,e){var i=e[t.extensions[n.KHR_BINARY_GLTF].bufferView],r=new Uint8Array(i);return Uc(r)};var a={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,TRIANGLES:4,LINES:1,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,VERTEX_SHADER:35633,FRAGMENT_SHADER:35632},h={5126:Number,35675:ge,35676:Le,35664:ce,35665:pe,35666:_e,35678:ye},c={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},l={9728:ft,9729:yt,9984:gt,9985:_t,9986:bt,9987:wt},u={33071:dt,33648:pt,10497:ut},d={6406:It,6407:Ot,6408:Ft,6409:Bt,6410:Dt},p={5121:Mt,32819:At,32820:Ct,33635:Lt},f={1028:1,1029:0},m={512:0,513:2,514:4,515:3,516:5,517:7,518:5,519:1},g={32774:nt,32778:101,32779:102},v={0:ot,1:at,768:202,769:203,770:ht,771:ct,772:206,773:207,774:208,775:209,776:210},b={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},y={scale:"scale",translation:"position",rotation:"quaternion"},_={LINEAR:Yt,STEP:Xt},x={2884:"CULL_FACE",2929:"DEPTH_TEST",3042:"BLEND",3089:"SCISSOR_TEST",32823:"POLYGON_OFFSET_FILL",32926:"SAMPLE_ALPHA_TO_COVERAGE"};function w(t,e,i){if(!t)return Promise.resolve();var n,r=[];if("[object Array]"===Object.prototype.toString.call(t)){n=[];for(var s=t.length,o=0;o<s;o++){(h=e.call(i||this,t[o],o))&&(r.push(h),h instanceof Promise?h.then(function(t,e){n[t]=e}.bind(this,o)):n[o]=h)}}else for(var a in n={},t){var h;if(t.hasOwnProperty(a))(h=e.call(i||this,t[a],a))&&(r.push(h),h instanceof Promise?h.then(function(t,e){n[t]=e}.bind(this,a)):n[a]=h)}return Promise.all(r).then((function(){return n}))}function M(t,e){return"string"!=typeof t||""===t?"":/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:(e||"")+t}function T(t){this.isDeferredShaderMaterial=!0,this.params=t}function S(t,i,n){this.json=t||{},this.extensions=i||{},this.options=n||{},this.cache=new e}return T.prototype.create=function(){var t=Gn.clone(this.params.uniforms);for(var e in this.params.uniforms){var i=this.params.uniforms[e];i.value instanceof ye&&(t[e].value=i.value,t[e].value.needsUpdate=!0),t[e].semantic=i.semantic,t[e].node=i.node}return this.params.uniforms=t,new _h(this.params)},S.prototype._withDependencies=function(t){for(var e={},i=0;i<t.length;i++){var n=t[i],r="load"+n.charAt(0).toUpperCase()+n.slice(1),s=this.cache.get(n);if(void 0!==s)e[n]=s;else if(this[r]){var o=this[r]();this.cache.add(n,o),e[n]=o}}return w(e,(function(t){return t}))},S.prototype.parse=function(t){var e=this.json;this.cache.removeAll(),this._withDependencies(["scenes","cameras","animations"]).then((function(i){var n=[];for(var r in i.scenes)n.push(i.scenes[r]);var s=void 0!==e.scene?i.scenes[e.scene]:n[0],o=[];for(var r in i.cameras){var a=i.cameras[r];o.push(a)}var h=[];for(var r in i.animations)h.push(i.animations[r]);t(s,n,o,h)}))},S.prototype.loadShaders=function(){var t=this.json,e=this.extensions,i=this.options;return this._withDependencies(["bufferViews"]).then((function(r){return w(t.shaders,(function(t){return t.extensions&&t.extensions[n.KHR_BINARY_GLTF]?e[n.KHR_BINARY_GLTF].loadShader(t,r.bufferViews):new Promise((function(e){var n=new $h(i.manager);n.setResponseType("text"),n.load(M(t.uri,i.path),(function(t){e(t)}))}))}))}))},S.prototype.loadBuffers=function(){var t=this.json,e=this.extensions,i=this.options;return w(t.buffers,(function(t,r){return"binary_glTF"===r?e[n.KHR_BINARY_GLTF].body:"arraybuffer"===t.type||void 0===t.type?new Promise((function(e){var n=new $h(i.manager);n.setResponseType("arraybuffer"),n.load(M(t.uri,i.path),(function(t){e(t)}))})):void console.warn("threeExamples.LegacyGLTFLoader: "+t.type+" buffer type is not supported")}))},S.prototype.loadBufferViews=function(){var t=this.json;return this._withDependencies(["buffers"]).then((function(e){return w(t.bufferViews,(function(t){var i=e.buffers[t.buffer],n=void 0!==t.byteLength?t.byteLength:0;return i.slice(t.byteOffset,t.byteOffset+n)}))}))},S.prototype.loadAccessors=function(){var t=this.json;return this._withDependencies(["bufferViews"]).then((function(e){return w(t.accessors,(function(t){var i=e.bufferViews[t.bufferView],n=b[t.type],r=c[t.componentType],s=r.BYTES_PER_ELEMENT,o=s*n;if(t.byteStride&&t.byteStride!==o){var a=new r(i);return new ho(new so(a,t.byteStride/s),n,t.byteOffset/s)}return new Yi(a=new r(i,t.byteOffset,t.count*n),n)}))}))},S.prototype.loadTextures=function(){var t=this.json,e=this.options;return this._withDependencies(["bufferViews"]).then((function(i){return w(t.textures,(function(r){if(r.source)return new Promise((function(s){var o=t.images[r.source],a=o.uri,h=!1;if(o.extensions&&o.extensions[n.KHR_BINARY_GLTF]){var c=o.extensions[n.KHR_BINARY_GLTF],f=i.bufferViews[c.bufferView],m=new Blob([f],{type:c.mimeType});a=URL.createObjectURL(m),h=!0}var g=e.manager.getHandler(a);null===g&&(g=new ic(e.manager)),g.setCrossOrigin(e.crossOrigin),g.load(M(a,e.path),(function(e){if(h&&URL.revokeObjectURL(a),e.flipY=!1,void 0!==r.name&&(e.name=r.name),e.format=void 0!==r.format?d[r.format]:Ft,void 0!==r.internalFormat&&e.format!==d[r.internalFormat]&&console.warn("threeExamples.LegacyGLTFLoader: Three.js doesn't support texture internalFormat which is different from texture format. internalFormat will be forced to be the same value as format."),e.type=void 0!==r.type?p[r.type]:Mt,r.sampler){var i=t.samplers[r.sampler];e.magFilter=l[i.magFilter]||yt,e.minFilter=l[i.minFilter]||bt,e.wrapS=u[i.wrapS]||ut,e.wrapT=u[i.wrapT]||ut}s(e)}),void 0,(function(){h&&URL.revokeObjectURL(a),s()}))}))}))}))},S.prototype.loadMaterials=function(){var t=this.json;return this._withDependencies(["shaders","textures"]).then((function(e){return w(t.materials,(function(i){var r,s,o={},c={};if(i.extensions&&i.extensions[n.KHR_MATERIALS_COMMON]&&(s=i.extensions[n.KHR_MATERIALS_COMMON]),s){var l=["ambient","emission","transparent","transparency","doubleSided"];switch(s.technique){case"BLINN":case"PHONG":r=Mh,l.push("diffuse","specular","shininess");break;case"LAMBERT":r=Eh,l.push("diffuse");break;case"CONSTANT":default:r=qi}l.forEach((function(t){void 0!==s.values[t]&&(o[t]=s.values[t])})),(s.doubleSided||o.doubleSided)&&(c.side=2),(s.transparent||o.transparent)&&(c.transparent=!0,c.opacity=void 0!==o.transparency?o.transparency:1)}else if(void 0===i.technique)r=Mh,Object.assign(o,i.values);else{r=T;var u=t.techniques[i.technique];c.uniforms={};var d=t.programs[u.program];if(d){c.fragmentShader=e.shaders[d.fragmentShader],c.fragmentShader||(console.warn("ERROR: Missing fragment shader definition:",d.fragmentShader),r=Mh);var p=e.shaders[d.vertexShader];p||(console.warn("ERROR: Missing vertex shader definition:",d.vertexShader),r=Mh),c.vertexShader=function(t,e){var i={};for(var n in e.attributes){var r=e.attributes[n],s=(u=e.parameters[r]).type,o=u.semantic;i[n]={type:s,semantic:o}}var a=e.parameters,h=e.attributes,c={};for(var n in i){var l=a[r=h[n]];(o=l.semantic)&&(c[n]=l)}for(var r in c){o=(u=c[r]).semantic;var u,d=new RegExp("\\b"+r+"\\b","g");switch(o){case"POSITION":t=t.replace(d,"position");break;case"NORMAL":t=t.replace(d,"normal");break;case"TEXCOORD_0":case"TEXCOORD0":case"TEXCOORD":t=t.replace(d,"uv");break;case"TEXCOORD_1":t=t.replace(d,"uv2");break;case"COLOR_0":case"COLOR0":case"COLOR":t=t.replace(d,"color");break;case"WEIGHT":t=t.replace(d,"skinWeight");break;case"JOINT":t=t.replace(d,"skinIndex")}}return t}(p,u);var b=u.uniforms;for(var y in b){var _=b[y],w=u.parameters[_],M=w.type;if(!h[M])throw new Error("Unknown shader uniform param type: "+M);var S,E=w.count;void 0!==i.values&&(S=i.values[_]);var P=new h[M],A=w.semantic,C=w.node;switch(M){case a.FLOAT:P=w.value,"transparency"==_&&(c.transparent=!0),void 0!==S&&(P=S);break;case a.FLOAT_VEC2:case a.FLOAT_VEC3:case a.FLOAT_VEC4:case a.FLOAT_MAT3:w&&w.value&&P.fromArray(w.value),S&&P.fromArray(S);break;case a.FLOAT_MAT2:console.warn("FLOAT_MAT2 is not a supported uniform type");break;case a.FLOAT_MAT4:if(E){P=new Array(E);for(var L=0;L<E;L++)P[L]=new h[M];if(w&&w.value){var R=w.value;P.fromArray(R)}S&&P.fromArray(S)}else{if(w&&w.value){var I=w.value;P.fromArray(I)}S&&P.fromArray(S)}break;case a.SAMPLER_2D:P=void 0!==S?e.textures[S]:void 0!==w.value?e.textures[w.value]:null}c.uniforms[y]={value:P,semantic:A,node:C}}for(var O=u.states||{},F=O.enable||[],B=O.functions||{},D=!1,z=!1,N=!1,U=0,V=F.length;U<V;U++){var k=F[U];switch(x[k]){case"CULL_FACE":D=!0;break;case"DEPTH_TEST":z=!0;break;case"BLEND":N=!0;break;case"SCISSOR_TEST":case"POLYGON_OFFSET_FILL":case"SAMPLE_ALPHA_TO_COVERAGE":break;default:throw new Error("Unknown technique.states.enable: "+k)}}c.side=D?void 0!==B.cullFace?f[B.cullFace]:0:2,c.depthTest=z,c.depthFunc=void 0!==B.depthFunc?m[B.depthFunc]:2,c.depthWrite=void 0===B.depthMask||B.depthMask[0],c.blending=N?5:0,c.transparent=N;var j=B.blendEquationSeparate;void 0!==j?(c.blendEquation=g[j[0]],c.blendEquationAlpha=g[j[1]]):(c.blendEquation=nt,c.blendEquationAlpha=nt);var H=B.blendFuncSeparate;void 0!==H?(c.blendSrc=v[H[0]],c.blendDst=v[H[1]],c.blendSrcAlpha=v[H[2]],c.blendDstAlpha=v[H[3]]):(c.blendSrc=at,c.blendDst=ot,c.blendSrcAlpha=at,c.blendDstAlpha=ot)}}Array.isArray(o.diffuse)?c.color=(new Ui).fromArray(o.diffuse):"string"==typeof o.diffuse&&(c.map=e.textures[o.diffuse]),delete c.diffuse,"string"==typeof o.reflective&&(c.envMap=e.textures[o.reflective]),"string"==typeof o.bump&&(c.bumpMap=e.textures[o.bump]),Array.isArray(o.emission)?r===qi?c.color=(new Ui).fromArray(o.emission):c.emissive=(new Ui).fromArray(o.emission):"string"==typeof o.emission&&(r===qi?c.map=e.textures[o.emission]:c.emissiveMap=e.textures[o.emission]),Array.isArray(o.specular)?c.specular=(new Ui).fromArray(o.specular):"string"==typeof o.specular&&(c.specularMap=e.textures[o.specular]),void 0!==o.shininess&&(c.shininess=o.shininess);var G=new r(c);return void 0!==i.name&&(G.name=i.name),G}))}))},S.prototype.loadMeshes=function(){var t=this.json;return this._withDependencies(["accessors","materials"]).then((function(e){return w(t.meshes,(function(i){var n=new to;void 0!==i.name&&(n.name=i.name),i.extras&&(n.userData=i.extras);var r=i.primitives||[];for(var s in r){var o=r[s];if(o.mode===a.TRIANGLES||void 0===o.mode){var h=new fn,c=o.attributes;for(var l in c){if(!(f=c[l]))return;var u=e.accessors[f];switch(l){case"POSITION":h.setAttribute("position",u);break;case"NORMAL":h.setAttribute("normal",u);break;case"TEXCOORD_0":case"TEXCOORD0":case"TEXCOORD":h.setAttribute("uv",u);break;case"TEXCOORD_1":h.setAttribute("uv2",u);break;case"COLOR_0":case"COLOR0":case"COLOR":h.setAttribute("color",u);break;case"WEIGHT":h.setAttribute("skinWeight",u);break;case"JOINT":h.setAttribute("skinIndex",u);break;default:if(!o.material)break;if(!(g=t.materials[o.material]).technique)break;var d=t.techniques[g.technique].parameters||{};for(var p in d)d[p].semantic===l&&h.setAttribute(p,u)}}o.indices&&h.setIndex(e.accessors[o.indices]),(m=new In(h,g=void 0!==e.materials?e.materials[o.material]:new Mh({color:0,emissive:8947848,specular:0,shininess:0,transparent:!1,depthTest:!0,side:0}))).castShadow=!0,m.name="0"===s?n.name:n.name+s,o.extras&&(m.userData=o.extras),n.add(m)}else if(o.mode===a.LINES){h=new fn,c=o.attributes;for(var l in c){var f;if(!(f=c[l]))return;u=e.accessors[f];switch(l){case"POSITION":h.setAttribute("position",u);break;case"COLOR_0":case"COLOR0":case"COLOR":h.setAttribute("color",u)}}var m,g=e.materials[o.material];o.indices?(h.setIndex(e.accessors[o.indices]),m=new Xo(h,g)):m=new Go(h,g),m.name="0"===s?n.name:n.name+s,o.extras&&(m.userData=o.extras),n.add(m)}else console.warn("Only triangular and line primitives are supported")}return n}))}))},S.prototype.loadCameras=function(){return w(this.json.cameras,(function(t){if("perspective"==t.type&&t.perspective){var e=t.perspective.yfov,i=void 0!==t.perspective.aspectRatio?t.perspective.aspectRatio:1,n=e*i,r=new Xn(he.radToDeg(n),i,t.perspective.znear||1,t.perspective.zfar||2e6);return void 0!==t.name&&(r.name=t.name),t.extras&&(r.userData=t.extras),r}if("orthographic"==t.type&&t.orthographic){r=new Oc(window.innerWidth/-2,window.innerWidth/2,window.innerHeight/2,window.innerHeight/-2,t.orthographic.znear,t.orthographic.zfar);return void 0!==t.name&&(r.name=t.name),t.extras&&(r.userData=t.extras),r}}))},S.prototype.loadSkins=function(){var t=this.json;return this._withDependencies(["accessors"]).then((function(e){return w(t.skins,(function(t){var i=new Le;return void 0!==t.bindShapeMatrix&&i.fromArray(t.bindShapeMatrix),{bindShapeMatrix:i,jointNames:t.jointNames,inverseBindMatrices:e.accessors[t.inverseBindMatrices]}}))}))},S.prototype.loadAnimations=function(){var t=this.json;return this._withDependencies(["accessors","nodes"]).then((function(e){return w(t.animations,(function(t,i){var n=[];for(var r in t.channels){var s=t.channels[r],o=t.samplers[s.sampler];if(o){var a=s.target,h=a.id,c=void 0!==t.parameters?t.parameters[o.input]:o.input,l=void 0!==t.parameters?t.parameters[o.output]:o.output,u=e.accessors[c],d=e.accessors[l],p=e.nodes[h];if(p){p.updateMatrix(),p.matrixAutoUpdate=!0;var f=y[a.path]===y.rotation?Vh:jh,m=p.name?p.name:p.uuid,g=void 0!==o.interpolation?_[o.interpolation]:Yt;n.push(new f(m+"."+y[a.path],Lh.arraySlice(u.array,0),Lh.arraySlice(d.array,0),g))}}}return new Hh(h=void 0!==t.name?t.name:"animation_"+i,void 0,n)}))}))},S.prototype.loadNodes=function(){var t=this.json,e=this.extensions,i=this;return w(t.nodes,(function(t){var e,i=new Le;return t.jointName?((e=new Io).name=void 0!==t.name?t.name:t.jointName,e.jointName=t.jointName):(e=new Ye,void 0!==t.name&&(e.name=t.name)),t.extras&&(e.userData=t.extras),void 0!==t.matrix?(i.fromArray(t.matrix),e.applyMatrix(i)):(void 0!==t.translation&&e.position.fromArray(t.translation),void 0!==t.rotation&&e.quaternion.fromArray(t.rotation),void 0!==t.scale&&e.scale.fromArray(t.scale)),e})).then((function(r){return i._withDependencies(["meshes","skins","cameras"]).then((function(i){return w(r,(function(s,o){var a=t.nodes[o];if(void 0!==a.meshes)for(var h in a.meshes){var c=a.meshes[h],l=i.meshes[c];if(void 0!==l)for(var u in l.children){var d,p=l.children[u],f=p.material,m=p.geometry,g=p.userData,v=p.name;switch(f.isDeferredShaderMaterial?f=b=f.create():b=f,p.type){case"LineSegments":p=new Xo(m,b);break;case"LineLoop":p=new Yo(m,b);break;case"Line":p=new Go(m,b);break;default:p=new In(m,b)}if(p.castShadow=!0,p.userData=g,p.name=v,a.skin&&(d=i.skins[a.skin]),d){var b,y=function(t){for(var e=Object.keys(r),i=0,n=e.length;i<n;i++){var s=r[e[i]];if(s.jointName===t)return s}return null},_=m;(b=f).skinning=!0,(p=new Ao(_,b)).castShadow=!0,p.userData=g,p.name=v;for(var x=[],w=[],M=0,T=d.jointNames.length;M<T;M++){var S=d.jointNames[M],E=y(S);if(E){x.push(E);var P=d.inverseBindMatrices.array,A=(new Le).fromArray(P,16*M);w.push(A)}else console.warn("WARNING: joint: '"+S+"' could not be found")}p.bind(new Ro(x,w),d.bindShapeMatrix);var C=function(e,i,n){var s=e[n];if(void 0!==s)for(var o=0,a=s.length;o<a;o++){var h=s[o],c=r[h],l=t.nodes[h];void 0!==c&&!0===c.isBone&&void 0!==l&&(i.add(c),C(l,c,"children"))}};C(a,p,"skeletons")}s.add(p)}else console.warn("LegacyGLTFLoader: Couldn't find node \""+c+'".')}if(void 0!==a.camera){var L=i.cameras[a.camera];s.add(L)}if(a.extensions&&a.extensions[n.KHR_MATERIALS_COMMON]&&a.extensions[n.KHR_MATERIALS_COMMON].light){var R=e[n.KHR_MATERIALS_COMMON].lights[a.extensions[n.KHR_MATERIALS_COMMON].light];s.add(R)}return s}))}))}))},S.prototype.loadScenes=function(){var t=this.json;function e(i,n,r){var s=r[i];n.add(s);var o=t.nodes[i];if(o.children)for(var a=o.children,h=0,c=a.length;h<c;h++){e(a[h],s,r)}}return this._withDependencies(["nodes"]).then((function(n){return w(t.scenes,(function(t){var r=new Ze;void 0!==t.name&&(r.name=t.name),t.extras&&(r.userData=t.extras);for(var s=t.nodes||[],o=0,a=s.length;o<a;o++){e(s[o],r,n.nodes)}return r.traverse((function(t){t.material&&t.material.isRawShaderMaterial&&(t.gltfShader=new i(t,n.nodes),t.onBeforeRender=function(t,e,i){this.gltfShader.update(e,i)})})),r}))}))},t}();var iE=eE.LegacyGLTFLoader,nE=i(7);var rE=new("function"==typeof TextDecoder?TextDecoder:nE.TextDecoder)("utf-8");class sE{constructor(t,e,i){void 0!==e&&console.warn("Binary batch table content not supported yet."),this.content=t,null!=i?this.batchLength=i:0===Object.keys(this.content).length?(console.warn("Batch table is empty."),this.batchLength=0):this.batchLength=this.content[Object.keys(this.content)[0]].length,this.extensions={}}getPickingInfo(t){const e={};if(0===this.batchLength)return;if(t<0)throw new Error(`Batch Id (${t}) must be positive to access\n            feature properties from the batch table.`);if(!(t<this.batchLength))throw new Error(`Batch Id (${t}) must be inferior to batch length \n                (${this.batchLength}) to access feature properties in batch \n                table.`);Object.keys(this.content).forEach((i=>{e[i]=this.content[i][t]}));const i={BatchTable:e};return this.extensions&&Object.keys(this.extensions).forEach((e=>{const n={[e]:this.extensions[e].getPickingInfo(t)};Object.assign(i,n)})),i}removeExtensionFromContent(t){this.content.extensions[t]&&delete this.content.extensions[t],0===Object.keys(this.content.extensions).length&&delete this.content.extensions}}var oE={parse(t,e,i){let n,r=t;e>0&&(n=t.slice(t.byteLength-e),r=t.slice(0,t.byteLength-e));const s=rE.decode(new Uint8Array(r)),o=JSON.parse(s),a=new sE(o,n,i),h=[];return o.extensions&&Object.keys(o.extensions).forEach((t=>{if(QE.isExtensionRegistered(t)){const e=QE.getParser(t);h.push(e(o.extensions[t]).then((e=>{a.extensions[t]=e,a.removeExtensionFromContent(t)})))}})),Promise.all(h).then((()=>a))}};const aE=(new Le).makeRotationX(Math.PI/2),hE=(new Le).makeRotationZ(-Math.PI/2),cE=new KS,lE=new iE;function uE(t){const e=["MODELVIEW","MODELVIEWINVERSETRANSPOSE","PROJECTION","JOINTMATRIX"];if(t.gltfShader){const i=[];for(const e in t.gltfShader.boundUniforms)i.push(e);for(const n of i){const i=t.gltfShader.boundUniforms[n].semantic;e.includes(i)||delete t.gltfShader.boundUniforms[n]}}}var dE={parse(t,e){const i=e.gltfUpAxis,n=e.urlBase;if(!t)throw new Error("No array buffer provided.");const r=new DataView(t,4);let s=0;const o={};if(o.magic=rE.decode(new Uint8Array(t,0,4)),o.magic){o.version=r.getUint32(s,!0),s+=Uint32Array.BYTES_PER_ELEMENT,o.byteLength=r.getUint32(s,!0),s+=Uint32Array.BYTES_PER_ELEMENT,o.FTJSONLength=r.getUint32(s,!0),s+=Uint32Array.BYTES_PER_ELEMENT,o.FTBinaryLength=r.getUint32(s,!0),s+=Uint32Array.BYTES_PER_ELEMENT,o.BTJSONLength=r.getUint32(s,!0),s+=Uint32Array.BYTES_PER_ELEMENT,o.BTBinaryLength=r.getUint32(s,!0),s+=Uint32Array.BYTES_PER_ELEMENT;const a=s+4,h=[];let c={};const l=new pe;if(o.FTJSONLength>0){const e=a,i=t.slice(e,o.FTJSONLength+e),n=rE.decode(new Uint8Array(i));c=JSON.parse(n),c.RTC_CENTER?l.fromArray(c.RTC_CENTER):l.set(0,0,0)}if(o.FTBinaryLength>0&&console.warn("3D Tiles feature table binary not supported yet."),o.BTJSONLength>0){const e=a+o.FTJSONLength+o.FTBinaryLength;h.push(oE.parse(t.slice(e,o.BTJSONLength+e),o.BTBinaryLength,c.BATCH_LENGTH))}else h.push(Promise.resolve({}));const u=a+o.FTJSONLength+o.FTBinaryLength+o.BTJSONLength+o.BTBinaryLength,d=t.slice(u),p=new DataView(d,0,20);return h.push(new Promise((t=>{const r=n=>{for(const t of n.scenes)t.traverse(uE);void 0===i||"Y"===i?n.scene.applyMatrix(aE):"X"===i&&n.scene.applyMatrix(hE),n.scene.position.copy(l);const r=new Uint8Array(d,20,p.getUint32(12,!0)),s=rE.decode(new Uint8Array(r)),o=JSON.parse(s);o.extensions&&o.extensions.CESIUM_RTC&&(n.scene.position.fromArray(o.extensions.CESIUM_RTC.center),n.scene.updateMatrixWorld(!0));n.scene.traverse((function(t){if(t.frustumCulled=!1,t.material){if(e.overrideMaterials){if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose();"object"==typeof e.overrideMaterials&&e.overrideMaterials.isMaterial?t.material=e.overrideMaterials:t.material=new Eh({color:16777215})}else Mx.isLogDepthBufferSupported()&&t.material.isRawShaderMaterial&&!e.doNotPatchMaterial&&(px.patchMaterialForLogDepthSupport(t.material),console.warn("b3dm shader has been patched to add log depth buffer support"));t.material.transparent=e.opacity<1,t.material.opacity=e.opacity}})),t(n)};1===p.getUint32(4,!0)?lE.parse(d,n,r):cE.parse(d,n,r)}))),Promise.all(h).then((t=>({gltf:t[1],batchTable:t[0]})))}throw new Error("Invalid b3dm file.")}},pE=function(t){if(!t)throw new Error("No array buffer provided.");const e=new DataView(t);let i=0;const n={};let r={},s={};if(n.magic=rE.decode(new Uint8Array(t,i,4)),i+=4,n.magic){if(n.version=e.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,n.byteLength=e.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,n.FTJSONLength=e.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,n.FTBinaryLength=e.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,n.BTJSONLength=e.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,n.BTBinaryLength=e.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,n.FTBinaryLength>0&&(s=function(t,e,i){const n=new fn,r=rE.decode(new Uint8Array(t,e,i)),s=JSON.parse(r);let o;s.POINTS_LENGTH&&(o=s.POINTS_LENGTH);if(s.POSITION){const i=s.POSITION.byteOffset+r.length+e,a=new Float32Array(t,i,3*o);n.setAttribute("position",new Yi(a,3))}if(s.RGB){const i=s.RGB.byteOffset+r.length+e,a=new Uint8Array(t,i,3*o);n.setAttribute("color",new Yi(a,3,!0))}if(s.POSITION_QUANTIZED)throw new Error("For pnts loader, POSITION_QUANTIZED: not yet managed");if(s.RGBA)throw new Error("For pnts loader, RGBA: not yet managed");if(s.RGB565)throw new Error("For pnts loader, RGB565: not yet managed");if(s.NORMAL)throw new Error("For pnts loader, NORMAL: not yet managed");if(s.NORMAL_OCT16P)throw new Error("For pnts loader, NORMAL_OCT16P: not yet managed");if(s.BATCH_ID)throw new Error("For pnts loader, BATCH_ID: not yet managed");const a=s.RTC_CENTER?(new pe).fromArray(s.RTC_CENTER):void 0;return{geometry:n,offset:a}}(t,i,n.FTJSONLength)),n.BTJSONLength>0){const e=28+n.FTJSONLength+n.FTBinaryLength;r=oE.parse(t.slice(e,n.BTJSONLength+e))}const o={point:s,batchTable:r};return Promise.resolve(o)}throw new Error("Invalid pnts file.")};const fE=new ic;function mE(t){if(!t.ok){var e=new Error(`Error loading ${t.url}: status ${t.status}`);throw e.response=t,e}}const gE=(t,e={})=>fetch(t,e).then((t=>(mE(t),t.arrayBuffer())));var vE={text:(t,e={})=>fetch(t,e).then((t=>(mE(t),t.text()))),json:(t,e={})=>fetch(t,e).then((t=>(mE(t),t.json()))),xml:(t,e={})=>fetch(t,e).then((t=>(mE(t),t.text()))).then((t=>(new window.DOMParser).parseFromString(t,"text/xml"))),texture(t,e={}){let i,n;fE.crossOrigin=e.crossOrigin;const r=new Promise(((t,e)=>{i=t,n=e}));return fE.load(t,i,(()=>{}),n),r},arrayBuffer:gE,textureFloat:(t,e={})=>gE(t,e).then((t=>function(t){return new Jn(t,256,256,It,Et)}(new Float32Array(t)))),multiple(t,e,i={}){const n=[];let r;for(const s in e){if(!this[s])throw new Error(`${s} is not a valid Fetcher method.`);for(const o of e[s])r=`${t}.${o}`,n.push(this[s](r,i).then((t=>({type:o,result:t}))))}return Promise.all(n).then((t=>{const e={};for(const i of t)e[i.type]=i.result;return Promise.resolve(e)}))}};function bE(t){t.buildIndexAndUv_0=!0,t.center=t.builder.center(t.extent).clone();const e=function(t){const e={index:null,position:null,normal:null,uvs:[]},i=[],n=t.builder,r=t.segment,s=(r+1)*(r+1)+(t.disableSkirt?0:4*r),o=r*r*2+(t.disableSkirt?0:4*r*2);e.position=new Float32Array(3*s),e.normal=new Float32Array(3*s);const a=t.builder.uvCount;a>1&&(e.uvs[1]=new Float32Array(s)),i[0]=()=>{},t.buildIndexAndUv_0&&(e.index=new Uint32Array(3*o),e.uvs[0]=new Float32Array(2*s),i[0]=(t,i,n)=>{e.uvs[0][2*t+0]=i,e.uvs[0][2*t+1]=n});const h=Math.max(2,Math.floor(r)||2),c=Math.max(2,Math.floor(r)||2);let l=0;const u=[];let d=[];const p=[];n.prepare(t);for(let r=0;r<=c;r++){const s=[],o=r/c;if(n.vProjecte(o,t),a>1){const r=n.computeUvs[1](t);i[1]=t=>{e.uvs[1][t]=r}}for(let a=0;a<=h;a++){const u=a/h,f=3*l;n.uProjecte(u,t);const m=n.vertexPosition(t,t.projected),g=n.vertexNormal(t);m.sub(t.center),t.quatNormalToZ&&(m.applyQuaternion(t.quatNormalToZ),g.applyQuaternion(t.quatNormalToZ)),m.toArray(e.position,f),g.toArray(e.normal,f);for(const t of i)t(l,u,o);t.disableSkirt||0!==r&&r!==c&&(a===h?d.push(l):0===a&&p.push(l)),s.push(l),l++}u.push(s),0===r?d=d.concat(s):r===c&&(d=d.concat(s.slice().reverse()))}function f(t,i,n,r){return e.index[r+0]=t,e.index[r+1]=i,e.index[r+2]=n,r+3}t.disableSkirt||(d=d.concat(p.reverse()));let m=0;if(t.buildIndexAndUv_0)for(let t=0;t<c;t++)for(let e=0;e<h;e++){const i=u[t][e+1],n=u[t][e],r=u[t+1][e],s=u[t+1][e+1];m=f(s,n,i,m),m=f(s,r,n,m)}const g=l;if(!t.disableSkirt){const i=(new pe).fromArray(e.position).distanceTo((new pe).fromArray(e.position,3));let n=function(){},r=function(){};t.buildIndexAndUv_0&&(n=function(t,e,i,n,r){return t=f(e,i,n,t),f(e,n,r,t)},r=function(t){e.uvs[0][2*l+0]=e.uvs[0][2*t+0],e.uvs[0][2*l+1]=e.uvs[0][2*t+1]});for(let t=0;t<d.length;t++){const s=d[t],o=3*l,h=3*s;e.position[o+0]=e.position[h+0]-e.normal[h+0]*i,e.position[o+1]=e.position[h+1]-e.normal[h+1]*i,e.position[o+2]=e.position[h+2]-e.normal[h+2]*i,e.normal[o+0]=e.normal[h+0],e.normal[o+1]=e.normal[h+1],e.normal[o+2]=e.normal[h+2],r(s),a>1&&(e.uvs[1][l]=e.uvs[1][s]);const c=(t+1)%d.length;m=n(m,s,l,0===c?g:l+1,d[c]),l++}}return e}(t);e.index=new Yi(e.index,1),e.uvs[0]=new Yi(e.uvs[0],2),e.position=new Yi(e.position,3),e.normal=new Yi(e.normal,3);for(let i=1;i<t.builder.uvCount;i++)e.uvs[1]=new Yi(e.uvs[1],1);return e}var yE=class extends fn{constructor(t,e=bE(t)){super(),this.center=t.center,this.extent=t.extent,this.setIndex(e.index),this.setAttribute("position",e.position),this.setAttribute("normal",e.normal);for(let t=0;t<e.uvs.length;t++)this.setAttribute(`uv_${t}`,e.uvs[t]);this.computeBoundingBox(),this.OBB={}}};const _E=Math.PI/4,xE=1/(2*Math.PI),wE=new pe(0,0,1),ME=new pe(0,1,0),TE=new le,SE=new le,EE=new le;function PE(t){return 1-(.5-Math.log(Math.tan(_E+.5*he.degToRad(t)))*xE)}const AE=new class{constructor(t={}){this.tmp={coords:[new qM("EPSG:4326",0,0),new qM("EPSG:4326",0,0)],position:new pe,dimension:new ce},this.projection=t.projection,this.uvCount=t.uvCount,this.computeUvs=[()=>{},t=>{const e=PE(t.projected.latitude)*t.nbRow;return(isFinite(e)?e:0)-t.deltaUV1}]}prepare(t){t.nbRow=2**(t.level+1);var e=PE(t.extent.south);isFinite(e)||(e=0);var i=e%(1/t.nbRow);t.deltaUV1=(e-i)*t.nbRow,t.quatNormalToZ=EE.setFromAxisAngle(ME,-(.5*Math.PI-he.degToRad(t.extent.center().latitude))),t.projected={longitude:0,latitude:0},t.extent.dimensions(this.tmp.dimension)}center(t){return t.center(this.tmp.coords[0]).as(this.projection,this.tmp.coords[1]).toVector3()}vertexPosition(t){return this.tmp.coords[0].setFromValues(t.projected.longitude,t.projected.latitude),this.tmp.coords[0].as(this.projection,this.tmp.coords[1]).toVector3(this.tmp.position),this.tmp.position}vertexNormal(){return this.tmp.coords[1].geodesicNormal}uProjecte(t,e){e.projected.longitude=e.extent.west+t*this.tmp.dimension.x}vProjecte(t,e){e.projected.latitude=e.extent.south+t*this.tmp.dimension.y}computeSharableExtent(t){const e=Math.abs(t.west-t.east)/2,i=new dT(t.crs,-e,e,t.south,t.north),n=he.degToRad(t.west-i.west),r=he.degToRad(90-t.center(this.tmp.coords[0]).latitude);return TE.setFromAxisAngle(wE,n),SE.setFromAxisAngle(ME,r),TE.multiply(SE),{sharableExtent:i,quaternion:TE.clone(),position:this.center(t)}}OBB(t){return new FE(t.min,t.max)}}({projection:"EPSG:4978",uvCount:1}),CE=new pe,LE=new ce,RE=new pe,IE=new qM("EPSG:4326",0,0,0);class OE extends Ye{constructor(t=new pe(1/0,1/0,1/0),e=new pe(-1/0,-1/0,-1/0)){return super(),this.box3D=new ci(t.clone(),e.clone()),this.natBox=this.box3D.clone(),this.z={min:0,max:0,scale:1},this}clone(){return(new OE).copy(this)}copy(t){return super.copy(t),this.box3D.copy(t.box3D),this.natBox.copy(t.natBox),this.z.min=t.z.min,this.z.max=t.z.max,this.z.scale=t.z.scale,this}update(){this.updateMatrixWorld(!0)}updateZ(t,e,i=this.z.scale){this.z={min:t,max:e,scale:i,delta:Math.abs(e-t)*i},this.box3D.min.z=this.natBox.min.z+t*i,this.box3D.max.z=this.natBox.max.z+e*i}updateScaleZ(t){t>0&&this.updateZ(this.z.min,this.z.max,t)}toPoints(t){return t[0].set(this.box3D.max.x,this.box3D.max.y,this.box3D.max.z),t[1].set(this.box3D.min.x,this.box3D.max.y,this.box3D.max.z),t[2].set(this.box3D.min.x,this.box3D.min.y,this.box3D.max.z),t[3].set(this.box3D.max.x,this.box3D.min.y,this.box3D.max.z),t[4].set(this.box3D.max.x,this.box3D.max.y,this.box3D.min.z),t[5].set(this.box3D.min.x,this.box3D.max.y,this.box3D.min.z),t[6].set(this.box3D.min.x,this.box3D.min.y,this.box3D.min.z),t[7].set(this.box3D.max.x,this.box3D.min.y,this.box3D.min.z),t}isSphereAboveXYBox(t){const e=this.worldToLocal(t.position),i=Math.max(this.box3D.min.x,Math.min(e.x,this.box3D.max.x)),n=Math.max(this.box3D.min.y,Math.min(e.y,this.box3D.max.y));return Math.sqrt((i-e.x)*(i-e.x)+(n-e.y)*(n-e.y))<t.radius}setFromExtent(t,e=t.min||0,i=t.max||0){if("EPSG:4326"==t.crs){const{sharableExtent:n,quaternion:r,position:s}=AE.computeSharableExtent(t),o=Math.max(Math.floor(n.dimensions(LE).x/90+1),2),a=new yE({extent:n,level:0,segment:o,disableSkirt:!0,builder:AE});this.copy(AE.OBB(a.boundingBox)),this.updateZ(e,i),this.position.copy(s),this.quaternion.copy(r),this.updateMatrixWorld(!0)}else{if(t.isTiledCrs()||!BM.isMetricUnit(t.crs))throw new Error("Unsupported extent crs");t.center(IE).toVector3(this.position),t.dimensions(LE),CE.set(LE.x,LE.y,Math.abs(i-e)),this.box3D.setFromCenterAndSize(RE,CE),this.updateMatrixWorld(!0)}return this}}var FE=OE;function BE(t,e,i,n,r,s){const o={view:t,requester:r,layer:i,priority:r?1/(r.distance+1):100,metadata:n,redraw:s};return e.execute(o)}function DE(t){return t.children.filter((e=>e.layer==t.layer&&e.tileId))}function zE(t,e,i,n){i.additiveRefinement?function(t,e,i,n){for(const r of e.tileIndex.index[i.tileId].children){if(r.promise||r.loaded)continue;let s=i.matrixWorld;r.transform&&(s=kE.multiplyMatrices(i.matrixWorld,r.transform));(!n||!n(t.camera,r,s))&&(r.promise=BE(t.view,t.scheduler,e,r,i,!0).then((n=>{i.add(n),n.updateMatrixWorld();const s=VE(e.extent.crs,n.boundingVolume,n.matrixWorld);n.traverse((t=>{t.extent=s})),t.view.notifyChange(r),r.loaded=!0,delete r.promise})))}}(t,e,i,n):function(t,e,i){if(!i.pendingSubdivision&&0==DE(i).length){const n=e.tileIndex.index[i.tileId].children;if(void 0===n||0===n.length)return;i.pendingSubdivision=!0;const r=[];for(let s=0;s<n.length;s++)r.push(BE(t.view,t.scheduler,e,n[s],i,!1).then((r=>{n[s].loaded=!0,i.add(r),r.updateMatrixWorld(),i.additiveRefinement&&t.view.notifyChange(i),e.tileIndex.index[r.tileId].loaded=!0})));Promise.all(r).then((()=>{i.pendingSubdivision=!1,t.view.notifyChange(i)}))}}(t,e,i)}const NE=new ci,UE=new di;function VE(t,e,i){if(e.region){const i=NE.copy(e.region.box3D).applyMatrix4(e.region.matrixWorld);return dT.fromBox3(t,i)}if(e.box){const n=NE.copy(e.box).applyMatrix4(i);return dT.fromBox3(t,n)}{const n=UE.copy(e.sphere).applyMatrix4(i);return new dT(t,{west:n.center.x-n.radius,east:n.center.x+n.radius,south:n.center.y-n.radius,north:n.center.y+n.radius})}}const kE=new Le;function jE(t,e,i){if(e.viewerRequestVolume){const n=e.viewerRequestVolume;if(n.region)return!0;if(n.box)return!0;if(n.sphere){const e=n.sphere.center.clone();if(e.applyMatrix4(i),!(t.camera3D.position.distanceTo(e)<=n.sphere.radius))return!0}}if(e.boundingVolume){const n=e.boundingVolume;if(n.region)return!t.isBox3Visible(n.region.box3D,i.clone().multiply(n.region.matrix));if(n.box)return!t.isBox3Visible(n.box,i);if(n.sphere)return!t.isSphereVisible(n.sphere,i)}return!1}function HE(t,e,i=0){const n=e.additiveRefinement||i>0;for(let r=0;r<e.children.length;r++)e.children[r].content?HE(t,e.children[r],i+1):n&&e.children[r].traverse(GE);if(n)e.dispose&&e.dispose(),delete e.content,t.tileIndex.index[e.tileId].loaded=!1,e.remove(...e.children),0==i&&e.parent&&e.parent.remove(e);else{const t=DE(e);e.remove(...t)}}function GE(t){for(const e of t.children)GE(e);if(t.material)if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose();t.geometry&&t.geometry.dispose(),t.remove(...t.children)}function WE(){if(!this.visible)return[];const t=Date.now();if(this._cleanableTiles.length&&t-this._cleanableTiles[0].cleanableSince>this.cleanupDelay){this.root.cleanableSince=void 0;let e=0;for(;e<this._cleanableTiles.length;e++){const i=this._cleanableTiles[e];if(!(t-i.cleanableSince>this.cleanupDelay))break;HE(this,i)}this._cleanableTiles.splice(0,e)}return[this.root]}const qE=new ci,XE=new di;function YE(t,e){t.content&&(t.content.visible=e)}function ZE(t,e){e.cleanableSince||(e.cleanableSince=Date.now(),t._cleanableTiles.push(e))}function $E(t=jE,e=JE){return function(i,n,r){if(r.parent.pendingSubdivision&&!r.parent.additiveRefinement)return void(r.visible=!1);const s=!t||!t(i.camera,r,r.matrixWorld);if(r.visible=s,s){let s;if(r.cleanableSince&&(n._cleanableTiles.splice(n._cleanableTiles.indexOf(r),1),r.cleanableSince=void 0),r.pendingSubdivision||e(i,n,r))zE(i,n,r,t),YE(r,r.pendingSubdivision||r.additiveRefinement),s=DE(r);else{YE(r,!0);for(const t of DE(r))t.visible=!1,ZE(n,t)}return s}ZE(n,r)}}function JE(t,e,i){if(void 0===e.tileIndex.index[i.tileId].children)return!1;if(e.tileIndex.index[i.tileId].isTileset)return!0;return function(t,e){if(e.distance=0,e.boundingVolume.region)qE.copy(e.boundingVolume.region.box3D),qE.applyMatrix4(e.boundingVolume.region.matrixWorld),e.distance=qE.distanceToPoint(t.camera3D.position);else if(e.boundingVolume.box)qE.copy(e.boundingVolume.box),qE.applyMatrix4(e.matrixWorld),e.distance=qE.distanceToPoint(t.camera3D.position);else{if(!e.boundingVolume.sphere)return 1/0;XE.copy(e.boundingVolume.sphere),XE.applyMatrix4(e.matrixWorld),e.distance=Math.max(0,XE.distanceToPoint(t.camera3D.position))}return 0===e.distance?1/0:t._preSSE*(e.geometricError/e.distance)}(t.camera,i)>e.sseThreshold}const QE=new class{constructor(){this.extensionsMap=new Map}registerExtension(t,e){this.extensionsMap.set(t,e)}getParser(t){return this.extensionsMap.get(t)}isExtensionRegistered(t){return this.extensionsMap.has(t)}};function KE(t,e){let i=1;this.index={};const n=new Le,r=function(t,e,s){if(t.transform=t.transform?(new Le).fromArray(t.transform):void 0,t._worldFromLocalTransform=t.transform,s&&s._worldFromLocalTransform&&(t.transform?t._worldFromLocalTransform=(new Le).multiplyMatrices(s._worldFromLocalTransform,t.transform):t._worldFromLocalTransform=s._worldFromLocalTransform),(t.viewerRequestVolume&&t.viewerRequestVolume.region||t.boundingVolume.region)&&(t._worldFromLocalTransform?n.getInverse(t._worldFromLocalTransform):n.identity()),t.viewerRequestVolume=t.viewerRequestVolume?iP(t.viewerRequestVolume,n):void 0,t.boundingVolume=iP(t.boundingVolume,n),this.index[i]=t,t.tileId=i,t.baseURL=e,i++,t.children)for(const i of t.children)r(i,e,t)}.bind(this);r(t.root,e),this.extendTileset=function(t,e,i){r(t.root,i,this.index[e]),this.index[e].children=[t.root],this.index[e].isTileset=!0}}function tP(t){if(t.content){const e=[];t.content.traverse((i=>{i.isObject3D&&i.material&&i.layer==t.layer&&e.push(i)}));const i=t.parent;return i&&i.content?{elements:e,parent:i.content}:{elements:e}}}const eP=new dT("EPSG:4326",0,0,0,0);function iP(t,e){if(t.region){const i=t.region;eP.set(he.radToDeg(i[0]),he.radToDeg(i[2]),he.radToDeg(i[1]),he.radToDeg(i[3]));const n=(new FE).setFromExtent(eP);return n.matrix.premultiply(e),n.matrix.decompose(n.position,n.quaternion,n.scale),{region:n}}if(t.box){const e=t.box,i=new pe(e[0],e[1],e[2]),n=i.x-e[3],r=i.x+e[3],s=i.y-e[7],o=i.y+e[7],a=i.z-e[11],h=i.z+e[11];return{box:new ci(new pe(n,s,a),new pe(r,o,h))}}if(t.sphere){return{sphere:new di(new pe(t.sphere[0],t.sphere[1],t.sphere[2]),t.sphere[3])}}}function nP(t,e,i){const n=Vc(i),r={gltfUpAxis:e.asset.gltfUpAxis,urlBase:n,overrideMaterials:e.overrideMaterials,doNotPatchMaterial:e.doNotPatchMaterial,opacity:e.opacity};return dE.parse(t,r).then((t=>({batchTable:t.batchTable,object3d:t.gltf.scene})))}function rP(t,e){return pE(t).then((t=>{const i=e.material?e.material.clone():new Zo({size:.05,vertexColors:2}),n=new ta(t.point.geometry,i);return t.point.offset&&n.position.copy(t.point.offset),{object3d:n}}))}var sP={preprocessDataLayer:function(t,e,i){return t.preUpdate=t.preUpdate||WE,t.update=t.update||$E(),t.sseThreshold=t.sseThreshold||16,t.cleanupDelay=t.cleanupDelay||1e3,t.onTileContentLoaded=t.onTileContentLoaded||(()=>{}),t.getObjectToUpdateForAttachedLayers=tP,t._cleanableTiles=[],vE.json(t.url,t.networkOptions).then((n=>{if(t.tileset=n,n.extensionsUsed)for(const t of n.extensionsUsed)QE.isExtensionRegistered(t)||(n.extensionsRequired&&n.extensionsRequired.includes(t)?console.error(`3D Tiles tileset required extension "${t}" must be registered to $3dTilesExtensions global object of iTowns to be parsed and used.`):console.warn(`3D Tiles tileset used extension "${t}" must be registered to $3dTilesExtensions global object of iTowns to be parsed and used.`));const r=t.url.slice(0,t.url.lastIndexOf("/")+1);return t.tileIndex=new KE(n,r),t.asset=n.asset,function(t,e,i){return BE(t,e,i,i.tileset.root,void 0,!0).then((e=>{delete i.tileset,i.object3d.add(e),e.updateMatrixWorld(),i.tileIndex.index[e.tileId].loaded=!0,i.root=e,i.extent=VE(i.projection||t.referenceCrs,e.boundingVolume,e.matrixWorld)}))}(e,i,t,n.root)}))},executeCommand:function(t){const e=t.layer,i=t.metadata,n=new Ye;!function(t,e,i,n){t.frustumCulled=!1,t.layer=e,i.transform&&t.applyMatrix(i.transform),t.geometricError=i.geometricError,t.tileId=i.tileId,i.refine?t.additiveRefinement="ADD"===i.refine.toUpperCase():t.additiveRefinement=!!n&&n.additiveRefinement,t.viewerRequestVolume=i.viewerRequestVolume,t.boundingVolume=i.boundingVolume,t.boundingVolume.region&&t.add(t.boundingVolume.region),t.updateMatrixWorld()}(n,e,i,t.requester);const r=i.content&&(i.content.url||i.content.uri),s=t=>{t.layers.set(e.threejsLayer),t.userData.metadata=i,t.layer=e,t.material&&(t.material.transparent=e.opacity<1,t.material.opacity=e.opacity,t.material.wireframe=e.wireframe)};if(r){const t=r.startsWith("http")?r:i.baseURL+r,o={b3dm:nP,pnts:rP};return vE.arrayBuffer(t,e.networkOptions).then((r=>{if(void 0!==r){let a;const h=rE.decode(new Uint8Array(r,0,4));if("{"===h[0]){r=JSON.parse(rE.decode(new Uint8Array(r)));const n=t.slice(0,t.lastIndexOf("/")+1);e.tileIndex.extendTileset(r,i.tileId,n)}else if("b3dm"==h)a=o.b3dm;else{if("pnts"!=h)return Promise.reject(`Unsupported magic code ${h}`);a=o.pnts}if(a)return a(r,e,t).then((t=>(e.onTileContentLoaded(t),n.content=t.object3d,t.batchTable&&(n.batchTable=t.batchTable),n.add(t.object3d),n.traverse(s),n)))}return n.traverse(s),n}))}return n.traverse(s),Promise.resolve(n)}};const oP=new pe;function aP(t,e,i,n){if(n<=0)return 1/0;const r=e.metadata.spacing/2**i.name.length,s=t.camera.preSSE*r/n;return Math.max(0,s-e.pointSize)}function hP(t){t.obj&&(t.obj.material.visible=!1),t.notVisibleSince||(t.notVisibleSince=Date.now(),t.sse=-1);for(const e of t.children)hP(e)}var cP={preUpdate(t,e){if(!this.root)return[];let i;t.camera.preSSE=t.camera.height/(2*Math.tan(.5*he.degToRad(t.camera.camera3D.fov))),this.material&&(this.material.visible=this.visible,this.material.opacity=this.opacity,this.material.transparent=this.opacity<1,this.material.size=this.pointSize);for(const t of e.values()){if(t.isCamera||t==this)return[this.root];if(void 0!==t.obj&&(t.obj.isPoints&&t.obj.layer==this))if(i){let e;for(e=0;e<Math.min(t.name.length,i.length)&&t.name[e]==i[e];e++);if(i=i.substr(0,e),0==i.length)break}else i=t.name}return i?[this.root.findChildrenByName(i)]:[this.root]},update(t,e,i){if(i.visible=!1,e.octreeDepthLimit>=0&&e.octreeDepthLimit<i.name.length)return void hP(i);const n=i.tightbbox?i.tightbbox:i.bbox;if(i.visible=t.camera.isBox3Visible(n,e.object3d.matrixWorld),i.visible){if(i.notVisibleSince=void 0,oP.copy(t.camera.camera3D.position).sub(e.object3d.position),i.numPoints>0)if(i.obj)i.obj.material.update?i.obj.material.update(e.material):i.obj.material.copy(e.material);else if(!i.promise){const r=Math.max(.001,n.distanceToPoint(oP)),s=aP(t,e,i,r)/r;i.promise=t.scheduler.execute({layer:e,requester:i,view:t.view,priority:s,redraw:!0,isLeaf:0==i.childrenBitField,earlyDropFunction:t=>!t.requester.visible||!e.visible}).then((t=>{e.onPointsCreated&&e.onPointsCreated(e,t),i.obj=t,i.tightbbox=t.tightbbox,e.group.add(i.obj),i.obj.updateMatrixWorld(!0),i.promise=null}),(t=>{t instanceof lS&&(i.promise=null)}))}if(i.children&&i.children.length){const r=n.distanceToPoint(oP);if(i.sse=aP(t,e,i,r)/e.sseThreshold,i.sse>=1)return i.children;for(const t of i.children)hP(t)}}else hP(i)},postUpdate(t,e){if(!e.group)return;e.displayedCount=0;for(const t of e.group.children)if(t.material.visible){const i=t.geometry.attributes.position.count;t.geometry.setDrawRange(0,i),e.displayedCount+=i}if(e.displayedCount>e.pointBudget)if(e.supportsProgressiveDisplay){const t=e.pointBudget/e.displayedCount;for(const i of e.group.children)if(i.material.visible){const e=Math.floor(i.geometry.drawRange.count*t);e>0?i.geometry.setDrawRange(0,e):i.material.visible=!1}e.displayedCount*=t}else{e.group.children.sort(((t,e)=>e.userData.metadata.sse-t.userData.metadata.sse));let t=!1;e.displayedCount=0;for(const i of e.group.children){const n=i.geometry.attributes.position.count;t||e.displayedCount+n>e.pointBudget?(i.material.visible=!1,t=!0):e.displayedCount+=n}}const i=Date.now();for(let t=e.group.children.length-1;t>=0;t--){const n=e.group.children[t];if(!n.material.visible&&i-n.userData.metadata.notVisibleSince>1e4){if(e.group.children.splice(t,1),Array.isArray(n.material))for(const t of n.material)t.dispose();else n.material.dispose();n.geometry.dispose(),n.material=null,n.geometry=null,n.userData.metadata.obj=null}}}};const lP={POSITION_CARTESIAN:{numElements:3,arrayType:Float32Array,attributeName:"position"},COLOR_PACKED:{numElements:4,arrayType:Uint8Array,attributeName:"color",normalized:!0},INTENSITY:{numElements:1,numByte:2,arrayType:Float32Array,attributeName:"intensity",normalized:!0},CLASSIFICATION:{numElements:1,arrayType:Uint8Array,attributeName:"classification"},NORMAL_SPHEREMAPPED:{numElements:2,arrayType:Uint8Array,attributeName:"sphereMappedNormal"},NORMAL_OCT16:{numElements:2,arrayType:Uint8Array,attributeName:"oct16Normal"},NORMAL:{numElements:3,arrayType:Float32Array,attributeName:"normal"}};for(const t of Object.keys(lP)){const e=lP[t];e.potreeName=t,e.numByte=e.numByte||e.arrayType.BYTES_PER_ELEMENT,e.byteSize=e.numElements*e.numByte,e.normalized=e.normalized||!1;const i="getUint"+8*e.numByte;e.getValue=1===e.numByte?function(t,e){return t[i](e)}:function(t,e){return t[i](e,!0)}}var uP={parse:function(t,e){if(!t)throw new Error("No array buffer provided.");const i=new DataView(t);let n=0;for(const t of e)n+=lP[t].byteSize;const r=Math.floor(t.byteLength/n),s=new fn;let o=0,a=0;for(const t of e){const e=lP[t],h=e.numElements*r,c=new e.arrayType(h);for(let t=0;t<h;t+=e.numElements){for(let n=0;n<e.numElements;n++)c[t+n]=e.getValue(i,a+n*e.numByte);a+=n}o+=e.byteSize,a=o,s.setAttribute(e.attributeName,new Yi(c,e.numElements,e.normalized))}return s.computeBoundingBox(),Promise.resolve(s)}},dP={parse:function(t){if(!t)throw new Error("No array buffer provided.");const e=new DataView(t,0,24),i=new ci(new pe(e.getFloat32(0,!0),e.getFloat32(4,!0),e.getFloat32(8,!0)),new pe(e.getFloat32(12,!0),e.getFloat32(16,!0),e.getFloat32(20,!0))),n=Math.floor((t.byteLength-24)/16),r=new Float32Array(t,24,3*n),s=new Uint8Array(t,24+12*n,4*n),o=new fn;return o.setAttribute("position",new Yi(r,3)),o.setAttribute("color",new Yi(s,4,!0)),o.boundingBox=i,Promise.resolve(o)}},pP=i(8),fP=i.n(pP),mP=i(2),gP=i.n(mP);const vP={COLOR:0,INTENSITY:1,CLASSIFICATION:2,NORMAL:3};var bP=class extends _h{constructor(t={}){const e=t.orientedImageMaterial;delete t.orientedImageMaterial,super(t),this.vertexShader=fP.a,this.size=t.size||0,this.scale=t.scale||.025/Math.tan(.5),this.overlayColor=t.overlayColor||new _e(0,0,0,0),this.mode=t.mode||vP.COLOR,this.picking=!1;for(const t in vP)Object.prototype.hasOwnProperty.call(vP,t)&&(this.defines[`MODE_${t}`]=vP[t]);this.uniforms.size=new zl(this.size),this.uniforms.mode=new zl(this.mode),this.uniforms.pickingMode=new zl(this.picking),this.uniforms.opacity=new zl(this.opacity),this.uniforms.overlayColor=new zl(this.overlayColor),e?(this.uniforms.projectiveTextureAlphaBorder=e.uniforms.projectiveTextureAlphaBorder,this.uniforms.projectiveTextureDistortion=e.uniforms.projectiveTextureDistortion,this.uniforms.projectiveTextureMatrix=e.uniforms.projectiveTextureMatrix,this.uniforms.projectiveTexture=e.uniforms.projectiveTexture,this.uniforms.mask=e.uniforms.mask,this.uniforms.boostLight=e.uniforms.boostLight,this.defines.ORIENTED_IMAGES_COUNT=e.defines.ORIENTED_IMAGES_COUNT,this.defines.USE_DISTORTION=e.defines.USE_DISTORTION,this.defines.DEBUG_ALPHA_BORDER=e.defines.DEBUG_ALPHA_BORDER,this.defines.USE_TEXTURES_PROJECTIVE=!0,this.defines.USE_BASE_MATERIAL=!0,this.fragmentShader=px.unrollLoops(gP.a,this.defines)):this.fragmentShader=gP.a,Mx.isLogDepthBufferSupported()&&(this.defines.USE_LOGDEPTHBUF=1,this.defines.USE_LOGDEPTHBUF_EXT=1),this.updateUniforms()}copy(t){return super.copy(t),t.uniforms.projectiveTextureAlphaBorder&&(this.uniforms.projectiveTextureAlphaBorder=t.uniforms.projectiveTextureAlphaBorder,this.uniforms.projectiveTextureDistortion=t.uniforms.projectiveTextureDistortion,this.uniforms.projectiveTextureMatrix=t.uniforms.projectiveTextureMatrix,this.uniforms.projectiveTexture=t.uniforms.projectiveTexture,this.uniforms.mask=t.uniforms.mask,this.uniforms.boostLight=t.uniforms.boostLight),this}enablePicking(t){this.picking=t,this.blending=t?0:1,this.updateUniforms()}updateUniforms(){this.uniforms.size.value=this.size>0?this.size:-this.scale*window.innerHeight,this.uniforms.mode.value=this.mode,this.uniforms.pickingMode.value=this.picking,this.uniforms.opacity.value=this.opacity,this.uniforms.overlayColor.value=this.overlayColor}update(t){return this.visible=t.visible,this.opacity=t.opacity,this.transparent=t.transparent,this.size=t.size,this.mode=t.mode,this.picking=t.picking,this.scale=t.scale,this.overlayColor.copy(t.overlayColor),this.updateUniforms(),Object.assign(this.defines,t.defines),this}};function yP(t,e,i){return vE.arrayBuffer(`${i.baseurl}/r${i.name}.hrc`,t.fetchOptions).then((n=>{const r=new DataView(n),s=[];let o=0;for(i.childrenBitField=r.getUint8(0),o+=1,i.numPoints=r.getUint32(1,!0),o+=4,i.children=[],s.push(i);s.length&&o<n.byteLength;){const v=s.shift();for(let b=0;b<8;b++)if(v.childrenBitField&1<<b&&o+5<=n.byteLength){const n=r.getUint8(o);o+=1;let y=r.getUint32(o,!0);o+=4,0==y&&(y=i.numPoints);const _=v.name+b,x=(a=v.bbox,h=b,c=void 0,l=void 0,u=void 0,d=void 0,p=void 0,f=void 0,m=void 0,g=void 0,c=a.min,l=a.max,u=(new pe).copy(l).sub(c).multiplyScalar(.5),d=new pe(u.x,0,0),p=new pe(0,u.y,0),f=new pe(0,0,u.z),m=c,g=(new pe).add(c).add(u),1===h?(c=(new pe).copy(m).add(f),l=(new pe).copy(g).add(f)):3===h?(c=(new pe).copy(m).add(f).add(p),l=(new pe).copy(g).add(f).add(p)):0===h?(c=m,l=g):2===h?(c=(new pe).copy(m).add(p),l=(new pe).copy(g).add(p)):5===h?(c=(new pe).copy(m).add(f).add(d),l=(new pe).copy(g).add(f).add(d)):7===h?(c=(new pe).copy(m).add(u),l=(new pe).copy(g).add(u)):4===h?(c=(new pe).copy(m).add(d),l=(new pe).copy(g).add(d)):6===h&&(c=(new pe).copy(m).add(d).add(p),l=(new pe).copy(g).add(d).add(p)),new ci(c,l));let w=i.baseurl;if(_.length%e==0){const t=_.substr(i.name.length);w=`${i.baseurl}/${t}`}const M={numPoints:y,childrenBitField:n,children:[],name:_,baseurl:w,bbox:x,layer:t,parent:v};v.children.push(M),s.push(M)}}var a,h,c,l,u,d,p,f,m,g;return i}))}function _P(t,e){if(t.name===e)return t;const i=t.name.length;for(let n=0;n<t.children.length;n++)if(t.children[n].name[i]==e[i])return _P(t.children[n],e);throw new Error(`Cannot find node with name '${e}'`)}let xP=1;function wP(t,e){e.metadata=t;var i=!0;if(null!=e.metadata.scale){e.isFromPotreeConverter=!0,i="CIN"===e.metadata.pointAttributes;const t=Array.isArray(e.metadata.pointAttributes)&&e.metadata.pointAttributes.find((t=>t.startsWith("NORMAL")));t&&(e.material.defines[t]=1)}else e.metadata.scale=1,e.metadata.octreeDir=`itowns/${e.table}.points`,e.metadata.hierarchyStepSize=1e6,i=!0;e.parse=i?dP.parse:uP.parse,e.extension=i?"cin":"bin",e.supportsProgressiveDisplay=i}function MP(t){if(t.obj){const e=t.parent;return e&&e.obj?{element:t.obj,parent:e.obj}:{element:t.obj}}}var TP={preprocessDataLayer:(t,e)=>(t.file||(t.file="cloud.js"),t.group||(t.group=new to,t.object3d.add(t.group),t.group.updateMatrixWorld()),t.bboxes||(t.bboxes=new to,t.object3d.add(t.bboxes),t.bboxes.updateMatrixWorld(),t.bboxes.visible=!1),t.fetchOptions=t.fetchOptions||{},t.octreeDepthLimit=t.octreeDepthLimit||-1,t.pointBudget=t.pointBudget||2e6,t.pointSize=0!==t.pointSize&&isNaN(t.pointSize)?4:t.pointSize,t.sseThreshold=t.sseThreshold||2,t.material=t.material||{},t.material=t.material.isMaterial?t.material:new bP(t.material),t.material.defines=t.material.defines||{},t.mode=vP.COLOR,t.preUpdate=cP.preUpdate,t.update=cP.update,t.postUpdate=cP.postUpdate,t.getObjectToUpdateForAttachedLayers=MP,t.pickObjectsAt=(e,i,n)=>xT.pickPointsAt(e,i,n,t),vE.json(`${t.url}/${t.file}`,t.fetchOptions).then((e=>{wP(e,t);const i=function(t){let e;if(t.isFromPotreeConverter)e=new ci(new pe(t.metadata.boundingBox.lx,t.metadata.boundingBox.ly,t.metadata.boundingBox.lz),new pe(t.metadata.boundingBox.ux,t.metadata.boundingBox.uy,t.metadata.boundingBox.uz));else{let i=0;for(const e of t.metadata){if(e.table==t.table)break;i++}e=new ci(new pe(t.metadata[i].bbox.xmin,t.metadata[i].bbox.ymin,t.metadata[i].bbox.zmin),new pe(t.metadata[i].bbox.xmax,t.metadata[i].bbox.ymax,t.metadata[i].bbox.zmax))}return e}(t);return yP(t,t.metadata.hierarchyStepSize,{baseurl:`${t.url}/${t.metadata.octreeDir}/r`,name:"",bbox:i})})).then((i=>(t.root=i,i.findChildrenByName=_P.bind(i,i),t.extent=dT.fromBox3(e.referenceCrs,i.bbox),t)))),executeCommand(t){const e=t.layer,i=t.requester;i.childrenBitField&&0===i.children.length&&yP(e,e.metadata.hierarchyStepSize,i).then((()=>t.view.notifyChange(e,!1)));const n=`${i.baseurl}/r${i.name}.${e.extension}?isleaf=${t.isLeaf?1:0}`;return vE.arrayBuffer(n,e.fetchOptions).then((t=>e.parse(t,e.metadata.pointAttributes))).then((n=>{const r=new ta(n,e.material.clone());return function(t){const e=t.geometry.attributes.position.count,i=new Uint8Array(4*e),n=xP++;if(e>65535||n>65535)return console.warn("Currently picking is limited to Points with less than 65535 elements and less than 65535 Points instances"),t;for(let t=0;t<e;t++){const e=n<<16|t;i[4*t+0]=(4278190080&e)>>24,i[4*t+1]=(16711680&e)>>16,i[4*t+2]=(65280&e)>>8,i[4*t+3]=(255&e)>>0}t.baseId=n,t.geometry.setAttribute("unique_id",new Yi(i,4,!0))}(r),r.frustumCulled=!1,r.matrixAutoUpdate=!1,r.position.copy(i.bbox.min),r.scale.set(e.metadata.scale,e.metadata.scale,e.metadata.scale),r.updateMatrix(),r.tightbbox=n.boundingBox.applyMatrix4(r.matrix),r.layers.set(e.threejsLayer),r.layer=e,r.extent=dT.fromBox3(t.view.referenceCrs,i.bbox),r.userData.metadata=i,r}))}};class SP{constructor(){this.data=[]}queue(t){return this.data.push(t)}dequeue(){let t=0,e=1/0,i=1/0;for(let n=0;n<this.data.length;n++){let r=this.data[n].priority,s=this.data[n].timestamp;(e>r||e===r&&i>s)&&(e=r,i=s,t=n)}return this.data.splice(t,1)[0]}get length(){return this.data.length}}function EP(t,e){const i=e.priority-t.priority;return 0===i?e.timestamp-t.timestamp:i}function PP(){return{queue(t){const e=t.layer;let i=this.storages.get(e.id);i||(i={q:new SP({comparator:EP}),priority:1,accumulator:0},this.storages.set(e.id,i)),i.priority=e.priority||1,i.q.queue(t),this.counters.pending++},storages:new Map,counters:{executing:0,executed:0,failed:0,cancelled:0,pending:0},execute(t,e){return this.counters.pending--,this.counters.executing++,e.executeCommand(t).then((e=>{this.counters.executing--,t.resolve(e),this.counters.executed++}),(e=>{this.counters.executing--,t.reject(e),this.counters.failed++}))}}}function AP(){this.defaultQueue=PP(),this.hostQueues=new Map,this.providers={},this.maxCommandsPerHost=6,this.initDefaultProviders()}AP.prototype.constructor=AP,AP.prototype.initDefaultProviders=function(){this.addProtocolProvider("tile",uS),this.addProtocolProvider("3d-tiles",sP),this.addProtocolProvider("potreeconverter",TP)},AP.prototype.runCommand=function(t,e,i){const n=t.layer.protocol||t.layer.source.protocol,r=this.getProtocolProvider(n);if(!r)throw new Error(`No known provider for layer ${t.layer.id}`);e.execute(t,r,i).then((()=>{if(e.counters.executing<this.maxCommandsPerHost){const t=this.deQueue(e);t&&this.runCommand(t,e)}}))},AP.prototype.execute=function(t){const e=t.layer,i=e.source&&e.source.url?new URL(e.source.url,document.location).host:void 0;t.promise=new Promise(((e,i)=>{t.resolve=e,t.reject=i})),i&&!this.hostQueues.has(i)&&this.hostQueues.set(i,PP());const n=i?this.hostQueues.get(i):this.defaultQueue;return t.timestamp=Date.now(),n.queue(t),n.counters.executing<this.maxCommandsPerHost&&Promise.resolve().then((()=>{if(n.counters.executing<this.maxCommandsPerHost){const t=this.deQueue(n);t&&this.runCommand(t,n)}})),t.promise},AP.prototype.addProtocolProvider=function(t,e){if("function"!=typeof e.executeCommand)throw new Error(`Can't add provider for ${t}: missing a executeCommand function.`);this.providers[t]=e},AP.prototype.getProtocolProvider=function(t){return this.providers[t]||cS},AP.prototype.commandsWaitingExecutionCount=function(){let t=this.defaultQueue.counters.pending+this.defaultQueue.counters.executing;for(var e of this.hostQueues)t+=e[1].counters.pending+e[1].counters.executing;return t},AP.prototype.commandsRunningCount=function(){let t=this.defaultQueue.counters.executing;for(var e of this.hostQueues)t+=e[1].counters.executing;return t},AP.prototype.resetCommandsCount=function(t){let e=this.defaultQueue.counters[t];for(var i of(this.defaultQueue.counters[t]=0,this.hostQueues))e+=i[1].counters[t],i[1].counters[t]=0;return e},AP.prototype.deQueue=function(t){for(var e=function(t){let e,i,n=0;for(const r of t){const t=r[1];t.q.length>0&&(n+=t.priority,t.accumulator+=t.priority,(!e||t.accumulator>i)&&(e=t,i=t.accumulator))}if(e)return e.accumulator-=n,e.q}(t.storages);e&&e.length>0;){var i=e.dequeue();if(!i.earlyDropFunction||!i.earlyDropFunction(i))return i;t.counters.pending--,t.counters.cancelled++,i.reject(new lS(i))}};var CP=AP;const LP="layers-initialized",RP="layer-removed",IP="layer-added",OP="initialized",FP=function(t,e){t.object3d&&(t.object3d.visible=t.visible),t.threejsLayer&&(t.visible?e.camera.camera3D.layers.enable(t.threejsLayer):e.camera.camera3D.layers.disable(t.threejsLayer))};new ce,new Le,new ce,new _i,new pe,new pe;const BP=new qM("EPSG:4326");var DP=class extends se{constructor(t,e,i={}){super(),this.referenceCrs=t,BP.crs=t,this.mainLoop=i.mainLoop||new rS(new CP,undefined),this.camera=new jT(this.referenceCrs,1e3,1e3,i),zT(this.camera,this.camera.height,45),this._frameRequesters={},this._layers=[],this._changeSources=new Set,this._delayedFrameRequesterRemoval=[],this._allLayersAreReadyCallback=()=>{this.getLayers().every((t=>t.ready))&&0==this.mainLoop.scheduler.commandsWaitingExecutionCount()&&0==this.mainLoop.renderingState&&(this.dispatchEvent({type:LP}),this.removeFrameRequester(tS,this._allLayersAreReadyCallback))};const n=()=>{this.removeEventListener(LP,n),this.dispatchEvent({type:OP})};this.addEventListener(LP,n),this._fullSizeDepthBuffer=null,this.addFrameRequester(QT,(()=>{null!=this._fullSizeDepthBuffer&&this._fullSizeDepthBuffer.needsUpdate&&(this._fullSizeDepthBuffer=null)}))}render(){}addLayer(t,e){return new Promise(((i,n)=>{if(!t)return void n(new Error("layer is undefined"));if(this.getLayerById(t.id))return void n(new Error(`Invalid id '${t.id}': id already used`));const r=t.source?t.source.protocol:t.protocol,s=this.mainLoop.scheduler.getProtocolProvider(r);if(!t.protocol||s){if(t=function(t,e,i,n){const r=e.source;return n&&!e.extent&&(e.extent=n.extent,r&&!r.extent&&(r.extent=n.extent)),e.isGeometryLayer?(e.defineLayerProperty("visible",!0,(()=>FP(e,t))),FP(e,t),e.projection=t.referenceCrs):n.tileMatrixSets.includes(BM.formatToTms(r.projection))?e.projection=r.projection:e.projection=n.extent.crs,e.whenReady||(i&&i.preprocessDataLayer?e.whenReady=i.preprocessDataLayer(e,t,t.mainLoop.scheduler,n):r&&r.whenReady?e.whenReady=r.whenReady:e.whenReady=Promise.resolve()),e.whenReady=e.whenReady.then((()=>(e.ready=!0,e))),e}(this,t,s,e),e)if(t.isColorLayer){const i=this.getLayers((t=>t.isColorLayer));if(!(e.countColorLayersTextures(...i,t)<=Ax()))return void n(new Error(`Cant add color layer ${t.id}: the maximum layer is reached`));e.attach(t)}else e.attach(t);else{if("function"!=typeof t.update)return void n(new Error("Cant add GeometryLayer: missing a update function"));if("function"!=typeof t.preUpdate)return void n(new Error("Cant add GeometryLayer: missing a preUpdate function"));this._layers.push(t)}t.whenReady.then((t=>{this.notifyChange(e||t,!1),this._frameRequesters[tS]&&this._frameRequesters[tS].includes(this._allLayersAreReadyCallback)||this.addFrameRequester(tS,this._allLayersAreReadyCallback),i(t)})),this.dispatchEvent({type:IP,layerId:t.id})}else n(new Error(`${t.protocol} is not a recognized protocol name.`))}))}removeLayer(t){const e=this.getLayerById(t);if(e){const i=e.parent;if(e.delete(),i&&!i.detach(e))throw new Error(`Error to detach ${t} from ${i.id}`);if(null==i&&this._layers.splice(this._layers.findIndex((e=>e.id==t)),1),e.isColorLayer){const t=this.getLayers((t=>t.isColorLayer));for(const i of t)i.sequence>e.sequence&&i.sequence--}return this.notifyChange(this.camera),this.dispatchEvent({type:RP,layerId:t}),!0}throw new Error(`${t} doesn't exist`)}notifyChange(t,e=!0){t&&(this._changeSources.add(t),(t.isTileMesh||t.isCamera)&&this._fullSizeDepthBuffer&&(this._fullSizeDepthBuffer.needsUpdate=!0)),this.mainLoop.scheduleViewUpdate(this,e),this.onChange&&this.onChange()}getLayers(t){const e=[];for(const i of this._layers){t&&!t(i)||e.push(i);for(const n of i.attachedLayers)t&&!t(n,i)||e.push(n)}return e}getLayerById(t){const e=this.getLayers((e=>e.id===t));if(e.length)return e[0]}getParentLayer(t){for(const e of this._layers)for(const i of e.attachedLayers)if(i===t)return e}addFrameRequester(t,e){if("function"!=typeof e)throw new Error("frameRequester must be a function");this._frameRequesters[t]?this._frameRequesters[t].push(e):this._frameRequesters[t]=[e]}removeFrameRequester(t,e){this._frameRequesters[t].includes(e)?this._delayedFrameRequesterRemoval.push({when:t,frameRequester:e}):console.error("Invalid call to removeFrameRequester: frameRequester isn't registered")}_executeFrameRequestersRemovals(){for(const t of this._delayedFrameRequesterRemoval){const e=this._frameRequesters[t.when].indexOf(t.frameRequester);e>=0?this._frameRequesters[t.when].splice(e,1):console.warn("FrameReq has already been removed")}this._delayedFrameRequesterRemoval.length=0}execFrameRequesters(t,e,i,...n){if(this._frameRequesters[t]){this._delayedFrameRequesterRemoval.length>0&&this._executeFrameRequestersRemovals();for(const r of this._frameRequesters[t])r.update?r.update(e,i,n):r(e,i,n)}}};class zP extends Om{constructor(t,e){super(t),this._api=e}loadTileset(t){const e={url:t,protocol:"3d-tiles",sseThreshold:1};return this._geometryLayer=new TT("3d-tiles",this,{source:e}),Object.assign(this._geometryLayer,e),this._view=new DP("EPSG:4978",void 0,{camera:this._api.camera}),DP.prototype.addLayer.call(this._view,this._geometryLayer),new Promise((t=>{this._view.onChange=()=>{if(this._geometryLayer.tileIndex){const e=this._geometryLayer.tileIndex.index[1],i=this.boundingBox.value.isEmpty();this.boundingBox.value.copy(e.boundingVolume.box),e.transform&&this.boundingBox.value.applyMatrix4(e.transform),this.boundingBox.next(this.boundingBox.value),i&&t()}}}))}get sseThreshold(){return this._geometryLayer.sseThreshold}set sseThreshold(t){this._geometryLayer.sseThreshold=t}getBatchTable(t,e){const i=this.getObjectById(t),n=i.geometry.attributes;if(n&&n._BATCHID){const t=n._BATCHID.array[e];return this.findBatchTable(i).getPickingInfo(t)}}findBatchTable(t){return t.batchTable?t.batchTable:t.parent?this.findBatchTable(t.parent):void 0}pick(t){if(!t.ray.intersectsBox(this.boundingBox.value))return;const e=this.intersectModel(t);return 0!==e.length?Promise.resolve(e[0]):void 0}pickSnapped(t,e){if(!e.includes(0)||!t.ray.intersectsBox(this.boundingBox.value))return;const i=this.intersectModel(t);return Promise.resolve(i)}intersectModel(t){const e=t.intersectObject(this,!0);return e.forEach((t=>{t.snapType=0,t.normal=t.face.normal,t.id=t.object.id,t.model=this})),e}updateCamera(){this._view.notifyChange(this._api.camera,!1)}}class NP extends Bv{constructor(){super(...arguments),this.isTilesetUrl=(t,e)=>"string"==typeof t&&t.endsWith(".json")&&t.includes("tileset")}get name(){return"itowns"}set api(t){this._api=t,t.registry.register(this.isTilesetUrl,((t,e)=>this.loadTilesetUrl(t,e)),(t=>this.unload(t))),t.camera.subscribe((()=>this.updateCamera()))}async loadTilesetUrl(t,e){if(void 0===e.modelId&&(e.modelId=t),this._api.models.get(e.modelId))throw new Error("A model with the same id is already loaded.");const i=new zP(e.modelId,this._api);return await i.loadTileset(t),this._api.models.add(i),i}updateCamera(){for(const t of this._api.models.getIterable())t instanceof zP&&t.updateCamera()}unload(t){const e=this._api.models.get(t);e.dispose(),this._api.models.remove(e)}}var UP={},VP={},kP=/{{ *?(?:(?:([\w$]+) *?\((.*?)\) *?([\w$]*))|(?:([\w$]+) *?\((.*?)\) *?\/)|(?:([\w$@].*?) *?((?:\| *?[\w$]+ *)*))|(?:\/ *?([\w$]+))|(?:# *?([\w$]+))|(?:!\-\-[^]+?\-\-)) *?}}\n?/g,jP={s:"{{",e:"}}"},HP=/@(?:((?:\.\.\/)+)|([\w$]+):)?/g,GP=kP,WP=jP;function qP(t,e){var i=t+GP.source.slice(WP.s.length,0-(WP.e.length+3))+e+"\\n?",n=GP.lastIndex;WP={s:t,e:e},(GP=RegExp(i,"g")).lastIndex=n}function XP(t,e,i){return t.replace(HP,(function(t,n,r){return"hvals"+(n&&n.length?e[i-n.length/3-1].id:r||"")+"."}))}var YP={if:{helperStart:function(t){return"if("+t+"){"},helperEnd:function(){return"}"},blocks:{else:function(){return"}else{"}}},each:{helperStart:function(t,e){return"for(var i=0;i<"+t+".length; i++){tR+=(function(hvals){var tR='';var hvals"+e+"=hvals;"},helperEnd:function(t){return"return tR})({this:"+t+"[i],index:i})};"}},foreach:{helperStart:function(t,e){return"for(var key in "+t+"){if(!"+t+".hasOwnProperty(key)) continue;tR+=(function(hvals){var tR='';var hvals"+e+"=hvals;"},helperEnd:function(t){return"return tR})({this:"+t+"[key], key: key})};"}},log:{selfClosing:function(t){return"console.log("+t+");"}},tags:{selfClosing:function(t){return qP(t.slice(0,t.indexOf(",")).trim(),t.slice(t.indexOf(",")+1).trim()),""}},js:{selfClosing:function(t){return t+";"}}},ZP={"&":"&amp;","<":"&lt;",'"':"&quot;","'":"&#39;"};function $P(t){return ZP[t]}var JP=/[&<"']/g,QP=/[&<"']/,KP={e:function(t){var e=String(t);return QP.test(e)?e.replace(JP,$P):e}},tA={start:"",end:""};var eA=!0;function iA(t,e){var i,n=!1,r="",s="";if(e&&""!==e){i=e.split("|");for(var o=0;o<i.length;o++)i[o]=i[o].trim(),""!==i[o]&&("safe"!==i[o]?(r="Sqrl.F."+i[o]+"("+r,s+=")"):n=!0)}return r+=tA.start,s+=tA.end,!n&&eA&&(r+="Sqrl.F.e(",s+=")"),r+t+s}function nA(t){var e,i=0,n="var tR='';",r=[],s=-1,o=0,a={};function h(e){i!==e&&(n+="tR+='"+t.slice(i,e).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"';")}function c(t,e){var i=XP(t,r,s);return"@"===t[0]?iA(i,e):iA("options."+i,e)}for(WP=jP,(GP=kP).lastIndex=0;null!==(e=GP.exec(t));)if(h(e.index),i=e[0].length+e.index,e[1]){var l=e[3];""!==l&&null!==l||(l=o,o++);var u=YP.hasOwnProperty(e[1]);s+=1;var d=e[2]||"";d=XP(d,r,s),u||(d="["+d+"]");var p={name:e[1],id:l,params:d,native:u};r[s]=p,u?(n+=YP[e[1]].helperStart(d,l),i=GP.lastIndex):n+="tR+=Sqrl.H."+e[1]+"("+d+",function(hvals){var hvals"+l+"=hvals;var tR='';"}else if(e[4]){var f=e[5]||"";if(f=XP(f,r,s),"include"===e[4]){var m=t.slice(0,e.index),g=t.slice(e.index+e[0].length),v=f.replace(/'|"/g,""),b=VP[v];t=m+b+g,i=GP.lastIndex=e.index}else YP.hasOwnProperty(e[4])&&YP[e[4]].hasOwnProperty("selfClosing")?(n+=YP[e[4]].selfClosing(f),i=GP.lastIndex):n+="tR+=Sqrl.H."+e[4]+"("+f+");"}else if(e[6])n+="tR+="+c(e[6],e[7])+";";else if(e[8]){var y=r[s];y&&y.name===e[8]?(s-=1,!0===y.native?n+=YP[y.name].helperEnd(y.params,y.id):a[y.id]?n+="return tR}});":n+="return tR});"):console.error("Helper beginning & end don't match.")}else if(e[9]){var _=r[s];if(_.native){var x=YP[_.name];x.blocks&&x.blocks[e[9]]?(n+=x.blocks[e[9]](_.id),i=GP.lastIndex):console.warn("Native helper '%s' doesn't accept that block.",_.name)}else a[_.id]?n+="return tR},"+e[9]+":function(hvals){var hvals"+_.id+"=hvals;var tR='';":(n+="return tR},{"+e[9]+":function(hvals){var hvals"+_.id+"=hvals;var tR='';",a[_.id]=!0)}return h(t.length),n+="return tR",new Function("options","Sqrl",n.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))}var rA={};function sA(t,e){var n=t.$file,r=t.$name,s=t.$cache;if(n){var o=i(11);return!1!==s?(rA.hasOwnProperty(n)||(rA[n]=nA(o.readFileSync(n,"utf8"))),rA[n]):nA(o.readFileSync(n,"utf8"))}return"string"==typeof e?r&&!1!==s?(rA.hasOwnProperty(r)||(rA[r]=nA(e)),rA[r]):!0===s?(rA.hasOwnProperty(e)||(rA[e]=nA(e)),rA[e]):nA(e):r&&!1!==s&&rA.hasOwnProperty(r)?rA[r]:"No template"}window.Tekla.ThreeD||(window.Tekla.ThreeD={_baseUrl:"",_newItemTitle:"",_getUrl:function(t){let e=this._baseUrl;return"/"!==e.substr(-1)&&(e+="/"),e+t},init:function(t,e,i){const n=document.getElementById("webglViewerWrapper");if(n){this._baseUrl=t;const r={staticRootUrl:this._getUrl("Scripts/"),hoverColor:"yellow",selectionColor:"blue",analyticsEnabled:!1,useWebgl2:!0},s=new Km(r).addPlugin(new Uv).addPlugin(new $y).addPlugin(new NP).addPlugin(new lx);window.teklaMap3=window.teklaMap3||{},window.teklaMap3.threeDViewer=s,this._newItemTitle=e&&e.pointname,n.appendChild(s),s.plugins.potree.eyeDomeLightingEnabled=!0,s.plugins.potree.pointSizeType=Zv.FIXED,s.plugins.potree.pointSize=5,s.plugins.potree.pointBudget=i&&i>15e5&&i<2e7?i:5e6,s._api.renderingManager._nearPlaneMin=1.7,s.addEventListener("selection",(t=>{t&&t.detail&&t.detail.count>0&&this.showTrimBimProperties()})),s.addEventListener("pick",(t=>{if(t.detail&&t.detail.face){const e=s.getModel(t.detail.modelId).getBatchTable(t.detail.id,t.detail.face.a);if(e&&e.BatchTable){const t=e.BatchTable.LocusId;if(t){const e=t.split(".");e&&e.length>1&&this.showDWProperties(+e[0],+e[1])}}}})),s.addEventListener("active-tool-changed",(t=>{"selection"===s.activeTool&&(clearToolstate(),startPan())})),s.addEventListener("navigationend",(t=>{window.Tekla.MapLink&&window.Tekla.MapLink.update()})),s.addEventListener("markupadded",(()=>{this.updateMarkUps()})),s.addEventListener("markupremoved",(()=>{this.updateMarkUps()})),s.addEventListener("markupmodified",(()=>{this.updateMarkUps()})),this.loadPointCloudSettings()}},_viewer:()=>window.teklaMap3.threeDViewer,setViewAngle:function(t){this._viewer().viewPreset=t},deleteMarkUp:function(t){this._viewer().plugins.markups.removeById(t)},updateMarkUps:function(){const t=this._viewer();let e=!1;const i=[...t.plugins.markups];i.length>0&&i.forEach((t=>{if("textMarkup"==t.type){const i=window.teklaMap,n=[[t.start.x,t.start.y,t.start.z],[t.end.x,t.end.y,t.end.z]];if(t.id){const i=MySitesDB.Select(t.id);i&&(i.Explanation!==t.text&&(i.set_Explanation(t.text),e=!0),i.set_ThreedDLine(n))}else{const e=i.AddPolyline({name:this._newItemTitle,explanation:t.text,editable:!1,CanDelete:!0,coordinates:n});t.id=e}}})),e&&$_CallEventHandler(tekla.Map.EVENT.DRAWINGREADY,void 0)},addMarkUps:function(t,e){const i=this._viewer();e&&i.plugins.markups.clear();const n=t.GetThreeDItems();n&&n.length&&n.forEach((t=>{var e={type:"textMarkup",start:t.start,end:t.end,color:{r:1,g:0,b:0},text:t.text,textColor:{r:0,g:0,b:0},id:t.id};i.plugins.markups.add(e)}))},updateCamera:function(t){const e=this._viewer();if(e&&t){const i=e.getCamera();i&&(i.position={x:t.east,y:t.north-100,z:100},i.lookAt={x:t.east,y:t.north+0,z:25},e.setCamera(i).catch((()=>{})))}},zoomTo:function(t){const e=this._viewer();e&&e.fitToView({modelIds:[t]})},setView:function(t,e){const i=this._viewer(),n=new pe(e,t-300,100),r={position:n,quaternion:(new le).setFromRotationMatrix((new Le).lookAt(new pe(e,t,0),n,new pe(0,1,0)))};i.setCamera(r)},getView:function(){const t=this._viewer().getCamera().position;return{north:t.y,east:t.x}},setActiveTool:function(t){this._viewer().activeTool=t},clearMarkUps:function(){this._viewer().plugins.markups.clear()},showTrimBimProperties:function(){const t=this._viewer();t.plugins.trimbim.getSelectedEntities().then((e=>{if(1===e.length&&1===e[0].entities.length){const i=e[0].modelId,n=e[0].entities[0].id;t.plugins.trimbim.getEntityInfo(i,n).then((t=>{const e=[],i=t.properties;if(i)for(let t=0;t<i.length;t++){const n=i[t];if(Object.keys(n.properties).length>0)for(let t=0;t<n.properties.length;t++){const i=n.properties[t];e.push({key:i.name,value:i.value})}}const n=$("#trimbim\\/properties\\.html").html(),r=(o={Properties:e},"function"==typeof(s=n)?s(o,{H:UP,F:KP,P:VP}):"string"==typeof s?sA(o,s)(o,{H:UP,F:KP,P:VP}):void 0);var s,o;$_CallEventHandler(tekla.Map.EVENT.SHOWPROPERTIES,r,"sw")}))}}))},showDWProperties:function(t,e){const i=`properties/get/${t}/${e}`;$.ajax({async:!0,type:"GET",url:this._getUrl(i),success:function(t){$_CallEventHandler(tekla.Map.EVENT.SHOWPROPERTIES,t,"sw")}})},showPointCloudSettings(){const t=document.getElementById("pointcloud-settings");t&&(angular.element(t).scope().show(),angular.element(t).scope().$apply())},loadPointCloudSettings(){const t=document.getElementById("pointcloud-settings");t&&angular.element(t).scope().loadClassifications(options.pointCloudClassificationsURL)},presetView:function(t){const e=this._viewer();e&&e.fitToView({viewPreset:t})}}),window.Tekla.ThreeDMaterial||(window.Tekla.ThreeDMaterial={_materials:[],_pointCloudsInView:[],_gltfModels:[],_trbs:[],_baseMapMaterials:[],_viewer:function(){return window.teklaMap3.threeDViewer},setSse:function(t){const e=this._viewer();(this._gltfModels||[]).forEach((i=>{e.getModel(i).sseThreshold=t}))},_setDefaultSse:function(){this.setSse(6)},_removeModel:function(t,e){const i=t.indexOf(e);i>-1&&t.splice(i,1)},init:function(t){this._materials=t},find:function(t){return this._materials?this._materials.find((e=>e.name===t)):null},removePointClouds:function(){const t=[];return this._pointCloudsInView.forEach((e=>t.push(this._viewer().unload(e,{fitToView:!1})))),this._pointCloudsInView=[],t},removeTrimBims:function(){const t=[];return this._trbs.forEach((e=>t.push(this._viewer().unload(e,{fitToView:!1})))),this._trbs=[],t},removeTrimBim:function(t){const e=[],i=this._trbs.find((e=>e===t));return i&&(e.push(this._viewer().unload(i,{fitToView:!1})),this._removeModel(this._trbs,t)),e},affineParamsToMatrix4:function(t,e){const i=Math.sqrt(t[2]*t[2]+t[3]*t[3]);let n=t[2]/i,r=-t[3]/i;n>1&&(n=1),n<-1&&(n=-1);let s=Math.acos(n);r<0&&(s=-s);const o=Math.cos(-s),a=Math.sin(-s),h=0,c=-Math.sin(-s),l=Math.cos(-s),u=0,d=0,p=0,f=1,m=Math.abs(i)<1e-6?1:i;return{elements:[o*m,a*m,h*m,0,c*m,l*m,u*m,0,d*m,p*m,f*m,0,t[1],t[0],e||0,1]}},setState:function(t,e,i){const n=[],r=[];if(e&&i&&((this._baseMapMaterials||[]).forEach((t=>{const e=this.find(t);e&&n.push.apply(n,this._hide(e))})),this._baseMapMaterials=[]),(t||[]).forEach((t=>{const s=this.find(t);if(s)if(e){const e=this._activate(s,i);n.push.apply(n,e.promises),r.push.apply(r,e.fitToIds),i&&this._baseMapMaterials.push(t)}else!i&&this._baseMapMaterials.find((e=>e===t))||n.push.apply(n,this._hide(s));else console.error("Material "+t+" not found")})),n.length>0){const t=this._pointCloudsInView;Promise.all(n).then((function(){if(t.length>0&&(window.Tekla.ThreeD.showPointCloudSettings(),"undefined"!=typeof angular)){const t=document.getElementById("pointcloud-settings");t&&(angular.element(t).scope().refresh(),angular.element(t).scope().$apply())}window.Tekla.ThreeDMaterial._setDefaultSse()}))}},fitToMaterials:function(t){const e=[];if((t||[]).forEach((t=>{const i=this.find(t);i&&(i.mainMaterial&&i.mainMaterial.uri&&("PointCloud"===i.mainMaterial.type?i.mainMaterial.uri&&this._pointCloudsInView.find((t=>t==i.mainMaterial.uri))&&e.push(i.mainMaterial.uri):e.push(i.mainMaterial.uri)),i.files&&i.files.forEach((t=>{this._trbs.find((e=>e===t.uri))&&e.push(t.uri)})))})),e.length>0){this._viewer().fitToView({modelIds:e})}},_hide:function(t){const e=this._viewer(),i=[];if(t.mainMaterial&&t.mainMaterial.uri){const n=t.mainMaterial.uri;"PointCloud"===t.mainMaterial.type?(i.push(e.unload(n,{fitToView:!1})),this._removeModel(this._pointCloudsInView,n)):(i.push(e.unload(n,{fitToView:!1})),this._removeModel(this._gltfModels,n))}if(t.files)for(let n=0;n<t.files.length;n++){const r=t.files[n].uri;i.push(e.unload(r,{fitToView:!1})),this._removeModel(this._trbs,r)}return i},_activate:function(t,e){const i=this._viewer(),n=[],r=[];if(t.mainMaterial&&("PointCloud"===t.mainMaterial.type?i&&t.mainMaterial.uri&&(n.push.apply(n,this.removePointClouds()),n.push(i.load(t.mainMaterial.uri,{fitToView:!1})),this._pointCloudsInView.push(t.mainMaterial.uri)):i&&t.mainMaterial.uri&&(n.push(i.load(t.mainMaterial.uri,{fitToView:!1})),this._gltfModels.push(t.mainMaterial.uri))),t.files)for(let e=0;e<t.files.length;e++)if(this._trbs.find((i=>i===t.files[e].uri)))r.push(t.files[e].uri);else{const s=t.files[e].transformation;let o=null;const a=[s&&!isNaN(s.a)?s.a:0,s&&!isNaN(s.b)?s.b:0,s&&!isNaN(s.c)?s.c:1,s&&!isNaN(s.d)?s.d:0,s&&!isNaN(s.e)?s.e:0,s&&!isNaN(s.f)?s.f:1],h=s&&!isNaN(s.zoffset)?s.zoffset:0;o=this.affineParamsToMatrix4(a,h);const c=i.load(t.files[e].uri,{transform:o,fitToView:!1});n.push(c),r.push(t.files[e].uri),this._trbs.push(t.files[e].uri)}return{promises:n,fitToIds:r}}})}]);
