@luma.gl/core 8.5.15 → 8.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=29)}([function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){var r=n(27);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},function(e,t,n){var r=n(7),i=n(9);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},function(e,t,n){var r=n(32),i=n(33),a=n(26),o=n(34);e.exports=function(e){return r(e)||i(e)||a(e)||o()}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t,n){var r=n(36),i=n(37),a=n(26),o=n(38);e.exports=function(e,t){return r(e)||i(e,t)||a(e,t)||o()}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},,function(e,t,n){"use strict";(function(e,r){n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return s}));var i=n(7),a={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document,process:"object"===(void 0===r?"undefined":n.n(i)()(r))&&r},o=a.window||a.self||a.global,s=a.process||{};console}).call(this,n(24),n(12))},function(e,t){var n,r,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&d())}function d(){if(!l){var e=s(h);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new v(e,t)),1!==c.length||l||s(d)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){var r=n(40);function i(t,n,a){return"undefined"!=typeof Reflect&&Reflect.get?e.exports=i=Reflect.get:e.exports=i=function(e,t,n){var i=r(e,t);if(i){var a=Object.getOwnPropertyDescriptor(i,t);return a.get?a.get.call(n):a.value}},i(t,n,a||t)}e.exports=i},function(e,t,n){e.exports=n(41)},function(e,t,n){"use strict";(function(e){function r(){var t;if("undefined"!=typeof window&&window.performance)t=window.performance.now();else if(void 0!==e&&e.hrtime){var n=e.hrtime();t=1e3*n[0]+n[1]/1e6}else t=Date.now();return t}n.d(t,"a",(function(){return r}))}).call(this,n(12))},,,function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return o}));var r=n(7),i=n.n(r),a=n(19);function o(){return!("object"===(void 0===e?"undefined":i()(e))&&"[object process]"===String(e)&&!e.browser)||Object(a.a)()}}).call(this,n(12))},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return a}));var r=n(7),i=n.n(r);function a(t){if("undefined"!=typeof window&&"object"===i()(window.process)&&"renderer"===window.process.type)return!0;if(void 0!==e&&"object"===i()(e.versions)&&Boolean(e.versions.electron))return!0;var n="object"===("undefined"==typeof navigator?"undefined":i()(navigator))&&"string"==typeof navigator.userAgent&&navigator.userAgent,r=t||n;return!!(r&&r.indexOf("Electron")>=0)}}).call(this,n(12))},function(e,t,n){var r=n(27),i=n(39);function a(t,n,o){return i()?e.exports=a=Reflect.construct:e.exports=a=function(e,t,n){var i=[null];i.push.apply(i,t);var a=new(Function.bind.apply(e,i));return n&&r(a,n.prototype),a},a.apply(null,arguments)}e.exports=a},function(e,t){function n(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,u,"next",e)}function u(e){n(o,i,a,s,u,"throw",e)}s(void 0)}))}}},,,function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}},function(e,t,n){var r=n(25);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return a}));var r=n(7),i=n.n(r);function a(t){if("undefined"!=typeof window&&"object"===i()(window.process)&&"renderer"===window.process.type)return!0;if(void 0!==e&&"object"===i()(e.versions)&&Boolean(e.versions.electron))return!0;var n="object"===("undefined"==typeof navigator?"undefined":i()(navigator))&&"string"==typeof navigator.userAgent&&navigator.userAgent,r=t||n;return!!(r&&r.indexOf("Electron")>=0)}}).call(this,n(12))},function(e,t,n){(function(t){var r=n(42),i="undefined"==typeof window?t:window;i.luma=i.luma||{},e.exports=Object.assign(i.luma,r)}).call(this,n(24))},,,function(e,t,n){var r=n(25);e.exports=function(e){if(Array.isArray(e))return r(e)}},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t){},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}},function(e,t,n){var r=n(3);e.exports=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=r(e)););return e}},function(e,t,n){var r=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,a=Object.create(i.prototype),o=new E(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return k()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=b(o,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=c(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,o),a}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function h(){}function d(){}var v={};v[i]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(T([])));p&&p!==t&&n.call(p,i)&&(v=p);var m=d.prototype=f.prototype=Object.create(v);function y(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){var r;this._invoke=function(i,a){function o(){return new t((function(r,o){!function r(i,a,o,s){var u=c(e[i],e,a);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){l.value=e,o(l)}),(function(e){return r("throw",e,o,s)}))}s(u.arg)}(i,a,r,o)}))}return r=r?r.then(o,o):o()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:k}}function k(){return{value:void 0,done:!0}}return h.prototype=m.constructor=d,d.constructor=h,h.displayName=s(d,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,o,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},y(_.prototype),_.prototype[a]=function(){return this},e.AsyncIterator=_,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new _(u(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},y(m),s(m,o,"Generator"),m[i]=function(){return this},m.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}},function(e,t,n){"use strict";n.r(t),n.d(t,"createGLContext",(function(){return Ve})),n.d(t,"instrumentGLContext",(function(){return Ge})),n.d(t,"isWebGL",(function(){return B})),n.d(t,"isWebGL2",(function(){return j})),n.d(t,"getParameters",(function(){return Se})),n.d(t,"setParameters",(function(){return Oe})),n.d(t,"withParameters",(function(){return Ie})),n.d(t,"resetParameters",(function(){return Le})),n.d(t,"cssToDeviceRatio",(function(){return Re})),n.d(t,"cssToDevicePixels",(function(){return Fe})),n.d(t,"lumaStats",(function(){return Ze})),n.d(t,"FEATURES",(function(){return Nn})),n.d(t,"hasFeature",(function(){return Sn})),n.d(t,"hasFeatures",(function(){return Ln})),n.d(t,"Buffer",(function(){return Bt})),n.d(t,"Program",(function(){return Ar})),n.d(t,"Framebuffer",(function(){return Cn})),n.d(t,"Renderbuffer",(function(){return on})),n.d(t,"Texture2D",(function(){return en})),n.d(t,"TextureCube",(function(){return pn})),n.d(t,"clear",(function(){return sn})),n.d(t,"readPixelsToArray",(function(){return bn})),n.d(t,"readPixelsToBuffer",(function(){return An})),n.d(t,"cloneTextureFrom",(function(){return _n})),n.d(t,"copyToTexture",(function(){return En})),n.d(t,"Texture3D",(function(){return yn})),n.d(t,"TransformFeedback",(function(){return Er})),n.d(t,"AnimationLoop",(function(){return Ir})),n.d(t,"Model",(function(){return ea})),n.d(t,"Transform",(function(){return ba})),n.d(t,"ProgramManager",(function(){return ki})),n.d(t,"Timeline",(function(){return ka})),n.d(t,"Geometry",(function(){return Sa})),n.d(t,"ClipSpace",(function(){return Pa})),n.d(t,"ConeGeometry",(function(){return Va})),n.d(t,"CubeGeometry",(function(){return Qa})),n.d(t,"CylinderGeometry",(function(){return eo})),n.d(t,"IcoSphereGeometry",(function(){return Ro})),n.d(t,"PlaneGeometry",(function(){return Do})),n.d(t,"SphereGeometry",(function(){return Go})),n.d(t,"TruncatedConeGeometry",(function(){return Na})),n.d(t,"normalizeShaderModule",(function(){return Nr})),n.d(t,"fp32",(function(){return Ho})),n.d(t,"fp64",(function(){return Yo})),n.d(t,"project",(function(){return fs})),n.d(t,"dirlight",(function(){return ds})),n.d(t,"picking",(function(){return gs})),n.d(t,"gouraudLighting",(function(){return Os})),n.d(t,"phongLighting",(function(){return Ss})),n.d(t,"pbr",(function(){return Ls})),n.d(t,"log",(function(){return N})),n.d(t,"assert",(function(){return ct})),n.d(t,"uid",(function(){return dt}));var r=n(7),i=n.n(r),a=n(6),o=n.n(a),s=n(0),u=n.n(s),c=n(2),l=n.n(c),f=n(1),h=n.n(f),d=n(18),v=Object(d.a)();function g(e){try{var t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch(e){return null}}var p=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";l()(this,e),this.storage=g(r),this.id=t,this.config={},Object.assign(this.config,n),this._loadConfiguration()}return h()(e,[{key:"getConfiguration",value:function(){return this.config}},{key:"setConfiguration",value:function(e){return this.config={},this.updateConfiguration(e)}},{key:"updateConfiguration",value:function(e){if(Object.assign(this.config,e),this.storage){var t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}},{key:"_loadConfiguration",value:function(){var e={};if(this.storage){var t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}]),e}();function m(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600,i=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>r&&(n=Math.min(n,r/e.width));var a=e.width*n,o=e.height*n,s=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(a/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(i,");"),"background-size:".concat(a,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),s]}var y={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function _(e){return"string"==typeof e?y[e.toUpperCase()]||y.WHITE:e}function b(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function x(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"],r=Object.getPrototypeOf(e),i=Object.getOwnPropertyNames(r),a=b(i);try{var o=function(){var r=t.value;"function"==typeof e[r]&&(n.find((function(e){return r===e}))||(e[r]=e[r].bind(e)))};for(a.s();!(t=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}}function E(e,t){if(!e)throw new Error(t||"Assertion failed")}var T=n(11);function k(){var e;if(v&&T.b.performance)e=T.b.performance.now();else if(T.a.hrtime){var t=T.a.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}var w={debug:v&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},O={enabled:!0,level:0};function S(){}var L={},I={once:!0};function P(e){for(var t in e)for(var n in e[t])return n||"untitled";return"empty"}var R=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""},n=t.id;l()(this,e),this.id=n,this.VERSION="8.5.14",this._startTs=k(),this._deltaTs=k(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new p("__probe-".concat(this.id,"__"),O),this.userData={},this.timeStamp("".concat(this.id," started")),x(this),Object.seal(this)}return h()(e,[{key:"isEnabled",value:function(){return this._storage.config.enabled}},{key:"getLevel",value:function(){return this._storage.config.level}},{key:"getTotal",value:function(){return Number((k()-this._startTs).toPrecision(10))}},{key:"getDelta",value:function(){return Number((k()-this._deltaTs).toPrecision(10))}},{key:"getPriority",value:function(){return this.level}},{key:"enable",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}},{key:"setLevel",value:function(e){return this._storage.updateConfiguration({level:e}),this}},{key:"assert",value:function(e,t){E(e,t)}},{key:"warn",value:function(e){return this._getLogFunction(0,e,w.warn,arguments,I)}},{key:"error",value:function(e){return this._getLogFunction(0,e,w.error,arguments)}},{key:"deprecated",value:function(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}},{key:"removed",value:function(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}},{key:"probe",value:function(e,t){return this._getLogFunction(e,t,w.log,arguments,{time:!0,once:!0})}},{key:"log",value:function(e,t){return this._getLogFunction(e,t,w.debug,arguments)}},{key:"info",value:function(e,t){return this._getLogFunction(e,t,console.info,arguments)}},{key:"once",value:function(e,t){return this._getLogFunction(e,t,w.debug||w.info,arguments,I)}},{key:"table",value:function(e,t,n){return t?this._getLogFunction(e,t,console.table||S,n&&[n],{tag:P(t)}):S}},{key:"image",value:function(e){var t=e.logLevel,r=e.priority,i=e.image,a=e.message,s=void 0===a?"":a,u=e.scale,c=void 0===u?1:u;return this._shouldLog(t||r)?v?function(e){var t=e.image,n=e.message,r=void 0===n?"":n,i=e.scale,a=void 0===i?1:i;if("string"==typeof t){var s=new Image;return s.onload=function(){var e,t=m(s,r,a);(e=console).log.apply(e,o()(t))},s.src=t,S}var u=t.nodeName||"";if("img"===u.toLowerCase()){var c;return(c=console).log.apply(c,o()(m(t,r,a))),S}if("canvas"===u.toLowerCase()){var l=new Image;return l.onload=function(){var e;return(e=console).log.apply(e,o()(m(l,r,a)))},l.src=t.toDataURL(),S}return S}({image:i,message:s,scale:c}):function(e){var t=e.image,r=(e.message,e.scale),i=void 0===r?1:r,a=null;try{a=n(35)}catch(e){}if(a)return function(){return a(t,{fit:"box",width:"".concat(Math.round(80*i),"%")}).then((function(e){return console.log(e)}))};return S}({image:i,message:s,scale:c}):S}},{key:"settings",value:function(){console.table?console.table(this._storage.config):console.log(this._storage.config)}},{key:"get",value:function(e){return this._storage.config[e]}},{key:"set",value:function(e,t){this._storage.updateConfiguration(u()({},e,t))}},{key:"time",value:function(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}},{key:"timeEnd",value:function(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}},{key:"timeStamp",value:function(e,t){return this._getLogFunction(e,t,console.timeStamp||S)}},{key:"group",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1},r=n=C({logLevel:e,message:t,opts:n}),i=r.collapsed;return n.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}},{key:"groupCollapsed",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},n,{collapsed:!0}))}},{key:"groupEnd",value:function(e){return this._getLogFunction(e,"",console.groupEnd||S)}},{key:"withGroup",value:function(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}},{key:"trace",value:function(){console.trace&&console.trace()}},{key:"_shouldLog",value:function(e){return this.isEnabled()&&this.getLevel()>=F(e)}},{key:"_getLogFunction",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4?arguments[4]:void 0;if(this._shouldLog(e)){var a;i=C({logLevel:e,message:t,args:r,opts:i}),E(n=n||i.method),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=k();var s=i.tag||i.message;if(i.once){if(L[s])return S;L[s]=k()}return t=M(this.id,i.message,i),(a=n).bind.apply(a,[console,t].concat(o()(i.args)))}return S}},{key:"level",set:function(e){this.setLevel(e)},get:function(){return this.getLevel()}},{key:"priority",set:function(e){this.level=e},get:function(){return this.level}}]),e}();function F(e){if(!e)return 0;var t;switch(i()(e)){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return E(Number.isFinite(t)&&t>=0),t}function C(e){var t=e.logLevel,n=e.message;e.logLevel=F(t);for(var r=e.args?Array.from(e.args):[];r.length&&r.shift()!==n;);switch(e.args=r,i()(t)){case"string":case"function":void 0!==n&&r.unshift(n),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());var a=i()(e.message);return E("string"===a||"object"===a),Object.assign(e,e.opts)}function M(e,t,n){if("string"==typeof t){var r=n.time?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,n=Math.max(t-e.length,0);return"".concat(" ".repeat(n)).concat(e)}((s=n.total)<10?"".concat(s.toFixed(2),"ms"):s<100?"".concat(s.toFixed(1),"ms"):s<1e3?"".concat(s.toFixed(0),"ms"):"".concat((s/1e3).toFixed(2),"s")):"";t=n.time?"".concat(e,": ").concat(r," ").concat(t):"".concat(e,": ").concat(t),i=t,a=n.color,o=n.background,v||"string"!=typeof i||(a&&(a=_(a),i="[".concat(a,"m").concat(i,"")),o&&(a=_(o),i="[".concat(o+10,"m").concat(i,""))),t=i}var i,a,o,s;return t}R.VERSION="8.5.14";var N=new R({id:"luma.gl"});function D(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function B(e){return"undefined"!=typeof WebGLRenderingContext&&e instanceof WebGLRenderingContext||("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&Number.isFinite(e._version)))}function j(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&2===e._version)}function U(e){return D(B(e),"Invalid WebGLRenderingContext"),e}function V(e){return D(j(e),"Requires WebGL2"),e}var G={};function z(e,t){var n;G[e]=!0,void 0!==t&&(n=t,globalThis.console&&globalThis.console.error&&globalThis.console.error(n))}var H=function e(t){var n=t.gl;this.ext=t,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(t.maxVertexAttribs);for(var r=0;r<this.attribs.length;r++){var i=new e.VertexAttrib(n);this.attribs[r]=i}this.maxAttrib=0};(H.VertexAttrib=function(e){this.enabled=!1,this.buffer=null,this.size=4,this.type=5126,this.normalized=!1,this.stride=16,this.offset=0,this.cached="",this.recache()}).prototype.recache=function(){this.cached=[this.size,this.type,this.normalized,this.stride,this.offset].join(":")};var W,X=function(e){var t=this;this.gl=e,function(e){var t=e.getError;e.getError=function(){var n;do{0!==(n=t.apply(e))&&(G[n]=!0)}while(0!==n);for(n in G)if(G[n])return delete G[n],parseInt(n,10);return 0}}(e);var n=this.original={getParameter:e.getParameter,enableVertexAttribArray:e.enableVertexAttribArray,disableVertexAttribArray:e.disableVertexAttribArray,bindBuffer:e.bindBuffer,getVertexAttrib:e.getVertexAttrib,vertexAttribPointer:e.vertexAttribPointer};e.getParameter=function(e){return e===t.VERTEX_ARRAY_BINDING_OES?t.currentVertexArrayObject===t.defaultVertexArrayObject?null:t.currentVertexArrayObject:n.getParameter.apply(this,arguments)},e.enableVertexAttribArray=function(e){var r=t.currentVertexArrayObject;r.maxAttrib=Math.max(r.maxAttrib,e);var i=r.attribs[e];return i.enabled=!0,n.enableVertexAttribArray.apply(this,arguments)},e.disableVertexAttribArray=function(e){var r=t.currentVertexArrayObject;r.maxAttrib=Math.max(r.maxAttrib,e);var i=r.attribs[e];return i.enabled=!1,n.disableVertexAttribArray.apply(this,arguments)},e.bindBuffer=function(e,r){switch(e){case 34962:t.currentArrayBuffer=r;break;case 34963:t.currentVertexArrayObject.elementArrayBuffer=r}return n.bindBuffer.apply(this,arguments)},e.getVertexAttrib=function(e,r){var i=t.currentVertexArrayObject,a=i.attribs[e];switch(r){case 34975:return a.buffer;case 34338:return a.enabled;case 34339:return a.size;case 34340:return a.stride;case 34341:return a.type;case 34922:return a.normalized;default:return n.getVertexAttrib.apply(this,arguments)}},e.vertexAttribPointer=function(e,r,i,a,o,s){var u=t.currentVertexArrayObject;u.maxAttrib=Math.max(u.maxAttrib,e);var c=u.attribs[e];return c.buffer=t.currentArrayBuffer,c.size=r,c.type=i,c.normalized=a,c.stride=o,c.offset=s,c.recache(),n.vertexAttribPointer.apply(this,arguments)},e.instrumentExtension&&e.instrumentExtension(this,"OES_vertex_array_object"),e.canvas&&e.canvas.addEventListener("webglcontextrestored",(function(){var e;e="OESVertexArrayObject emulation library context restored",globalThis.console&&globalThis.console.log&&globalThis.console.log(e),t.reset_()}),!0),this.reset_()};X.prototype.VERTEX_ARRAY_BINDING_OES=34229,X.prototype.reset_=function(){if(void 0!==this.vertexArrayObjects)for(var e=0;e<this.vertexArrayObjects.length;++e)this.vertexArrayObjects.isAlive=!1;var t=this.gl;this.maxVertexAttribs=t.getParameter(34921),this.defaultVertexArrayObject=new H(this),this.currentVertexArrayObject=null,this.currentArrayBuffer=null,this.vertexArrayObjects=[this.defaultVertexArrayObject],this.bindVertexArrayOES(null)},X.prototype.createVertexArrayOES=function(){var e=new H(this);return this.vertexArrayObjects.push(e),e},X.prototype.deleteVertexArrayOES=function(e){e.isAlive=!1,this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(e),1),this.currentVertexArrayObject===e&&this.bindVertexArrayOES(null)},X.prototype.isVertexArrayOES=function(e){return!!(e&&e instanceof H&&e.hasBeenBound&&e.ext===this)},X.prototype.bindVertexArrayOES=function(e){var t=this.gl;if(!e||e.isAlive){var n=this.original,r=this.currentVertexArrayObject;this.currentVertexArrayObject=e||this.defaultVertexArrayObject,this.currentVertexArrayObject.hasBeenBound=!0;var i=this.currentVertexArrayObject;if(r!==i){r&&i.elementArrayBuffer===r.elementArrayBuffer||n.bindBuffer.call(t,34963,i.elementArrayBuffer);for(var a=this.currentArrayBuffer,o=Math.max(r?r.maxAttrib:0,i.maxAttrib),s=0;s<=o;s++){var u=i.attribs[s],c=r?r.attribs[s]:null;if(r&&u.enabled===c.enabled||(u.enabled?n.enableVertexAttribArray.call(t,s):n.disableVertexAttribArray.call(t,s)),u.enabled){var l=!1;r&&u.buffer===c.buffer||(a!==u.buffer&&(n.bindBuffer.call(t,34962,u.buffer),a=u.buffer),l=!0),(l||u.cached!==c.cached)&&n.vertexAttribPointer.call(t,s,u.size,u.type,u.normalized,u.stride,u.offset)}}this.currentArrayBuffer!==a&&n.bindBuffer.call(t,34962,this.currentArrayBuffer)}}else z(1282,"bindVertexArrayOES: attempt to bind deleted arrayObject")};var q,K=function(e){return j(e)?void 0:0},Y=(W={},u()(W,3074,(function(e){return j(e)?void 0:36064})),u()(W,35723,(function(e){return j(e)?void 0:4352})),u()(W,35977,K),u()(W,32937,K),u()(W,36795,(function(e,t){var n=j(e)?e.getExtension("EXT_disjoint_timer_query_webgl2"):e.getExtension("EXT_disjoint_timer_query");return n&&n.GPU_DISJOINT_EXT?t(n.GPU_DISJOINT_EXT):0})),u()(W,37445,(function(e,t){var n=e.getExtension("WEBGL_debug_renderer_info");return t(n&&n.UNMASKED_VENDOR_WEBGL||7936)})),u()(W,37446,(function(e,t){var n=e.getExtension("WEBGL_debug_renderer_info");return t(n&&n.UNMASKED_RENDERER_WEBGL||7937)})),u()(W,34047,(function(e,t){var n=e.luma.extensions.EXT_texture_filter_anisotropic;return n?t(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1})),u()(W,32883,K),u()(W,35071,K),u()(W,37447,K),u()(W,36063,(function(e,t){if(!j(e)){var n=e.getExtension("WEBGL_draw_buffers");return n?t(n.MAX_COLOR_ATTACHMENTS_WEBGL):0}})),u()(W,35379,K),u()(W,35374,K),u()(W,35377,K),u()(W,34852,(function(e){if(!j(e)){var t=e.getExtension("WEBGL_draw_buffers");return t?t.MAX_DRAW_BUFFERS_WEBGL:0}})),u()(W,36203,(function(e){return e.getExtension("OES_element_index")?2147483647:65535})),u()(W,33001,(function(e){return e.getExtension("OES_element_index")?16777216:65535})),u()(W,33e3,(function(e){return 16777216})),u()(W,37157,K),u()(W,35373,K),u()(W,35657,K),u()(W,36183,K),u()(W,37137,K),u()(W,34045,K),u()(W,35978,K),u()(W,35979,K),u()(W,35968,K),u()(W,35376,K),u()(W,35375,K),u()(W,35659,K),u()(W,37154,K),u()(W,35371,K),u()(W,35658,K),u()(W,35076,K),u()(W,35077,K),u()(W,35380,K),W);var Q=(q={},u()(q,"OES_vertex_array_object",{meta:{suffix:"OES"},createVertexArray:function(){D(!1,"VertexArray requires WebGL2 or OES_vertex_array_object extension")},deleteVertexArray:function(){},bindVertexArray:function(){},isVertexArray:function(){return!1}}),u()(q,"ANGLE_instanced_arrays",{meta:{suffix:"ANGLE"},vertexAttribDivisor:function(e,t){D(0===t,"WebGL instanced rendering not supported")},drawElementsInstanced:function(){},drawArraysInstanced:function(){}}),u()(q,"WEBGL_draw_buffers",{meta:{suffix:"WEBGL"},drawBuffers:function(){D(!1)}}),u()(q,"EXT_disjoint_timer_query",{meta:{suffix:"EXT"},createQuery:function(){D(!1)},deleteQuery:function(){D(!1)},beginQuery:function(){D(!1)},endQuery:function(){},getQuery:function(e,t){return this.getQueryObject(e,t)},getQueryParameter:function(e,t){return this.getQueryObject(e,t)},getQueryObject:function(){}}),q),$={readBuffer:function(e,t,n){j(e)&&t(n)},getVertexAttrib:function(e,t,n,r){var i,a=function(e,t){return{webgl2:j(e),ext:e.getExtension(t)}}(e,"ANGLE_instanced_arrays"),o=a.webgl2,s=a.ext;switch(r){case 35069:i=!!o&&void 0;break;case 35070:i=o||s?void 0:0}return void 0!==i?i:t(n,r)},getProgramParameter:function(e,t,n,r){if(!j(e))switch(r){case 35967:return 35981;case 35971:case 35382:return 0}return t(n,r)},getInternalformatParameter:function(e,t,n,r,i){if(!j(e))switch(i){case 32937:return new Int32Array([0])}return e.getInternalformatParameter(n,r,i)},getTexParameter:function(e,t,n,r){switch(r){case 34046:var i=e.luma.extensions.EXT_texture_filter_anisotropic;r=i&&i.TEXTURE_MAX_ANISOTROPY_EXT||34046}return t(n,r)},getParameter:function(e,t,n){var r=Y[n],i="function"==typeof r?r(e,t,n):r;return void 0!==i?i:t(n)},hint:function(e,t,n,r){return t(n,r)}};function Z(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return J(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return J(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ee(e,t){var n=t.extension,r=t.target,i=t.target2,a=Q[n];D(a);for(var o=a.meta,s=(void 0===o?{}:o).suffix,u=void 0===s?"":s,c=e.getExtension(n),l=function(){var t=h[f],n="".concat(t).concat(u),o=null;"meta"===t||"function"==typeof e[t]||(c&&"function"==typeof c[n]?o=function(){return c[n].apply(c,arguments)}:"function"==typeof a[t]&&(o=a[t].bind(r))),o&&(r[t]=o,i[t]=o)},f=0,h=Object.keys(a);f<h.length;f++)l()}globalThis.polyfillContext=function(e){e.luma=e.luma||{};var t=e.luma;return t.polyfilled||(!function(e){if("function"!=typeof e.createVertexArray){var t=e.getSupportedExtensions;e.getSupportedExtensions=function(){var e=t.call(this)||[];return e.indexOf("OES_vertex_array_object")<0&&e.push("OES_vertex_array_object"),e};var n=e.getExtension;e.getExtension=function(t){var r=n.call(this,t);return r||("OES_vertex_array_object"!==t?null:(e.__OESVertexArrayObject||(this.__OESVertexArrayObject=new X(this)),this.__OESVertexArrayObject))}}}(e),function(e){e.luma.extensions={};var t,n=Z(e.getSupportedExtensions()||[]);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.luma[r]=e.getExtension(r)}}catch(e){n.e(e)}finally{n.f()}}(e),function(e,t){var n,r=Z(Object.getOwnPropertyNames(t));try{for(r.s();!(n=r.n()).done;){var i=n.value;"overrides"!==i&&ee(e,{extension:i,target:e.luma,target2:e})}}catch(e){r.e(e)}finally{r.f()}}(e,Q),function(e,t){var n=t.target,r=t.target2;Object.keys($).forEach((function(t){if("function"==typeof $[t]){var i=e[t]?e[t].bind(e):function(){},a=$[t].bind(null,e,i);n[t]=a,r[t]=a}}))}(e,{target:t,target2:e}),t.polyfilled=!0),e};var te,ne,re,ie=n(8),ae=n.n(ie),oe=(te={},u()(te,3042,!1),u()(te,32773,new Float32Array([0,0,0,0])),u()(te,32777,32774),u()(te,34877,32774),u()(te,32969,1),u()(te,32968,0),u()(te,32971,1),u()(te,32970,0),u()(te,3106,new Float32Array([0,0,0,0])),u()(te,3107,[!0,!0,!0,!0]),u()(te,2884,!1),u()(te,2885,1029),u()(te,2929,!1),u()(te,2931,1),u()(te,2932,513),u()(te,2928,new Float32Array([0,1])),u()(te,2930,!0),u()(te,3024,!0),u()(te,36006,null),u()(te,2886,2305),u()(te,33170,4352),u()(te,2849,1),u()(te,32823,!1),u()(te,32824,0),u()(te,10752,0),u()(te,32938,1),u()(te,32939,!1),u()(te,3089,!1),u()(te,3088,new Int32Array([0,0,1024,1024])),u()(te,2960,!1),u()(te,2961,0),u()(te,2968,4294967295),u()(te,36005,4294967295),u()(te,2962,519),u()(te,2967,0),u()(te,2963,4294967295),u()(te,34816,519),u()(te,36003,0),u()(te,36004,4294967295),u()(te,2964,7680),u()(te,2965,7680),u()(te,2966,7680),u()(te,34817,7680),u()(te,34818,7680),u()(te,34819,7680),u()(te,2978,[0,0,1024,1024]),u()(te,3333,4),u()(te,3317,4),u()(te,37440,!1),u()(te,37441,!1),u()(te,37443,37444),u()(te,35723,4352),u()(te,36010,null),u()(te,35977,!1),u()(te,3330,0),u()(te,3332,0),u()(te,3331,0),u()(te,3314,0),u()(te,32878,0),u()(te,3316,0),u()(te,3315,0),u()(te,32877,0),te),se=function(e,t,n){return t?e.enable(n):e.disable(n)},ue=function(e,t,n){return e.hint(n,t)},ce=function(e,t,n){return e.pixelStorei(n,t)};function le(e){return Array.isArray(e)||ArrayBuffer.isView(e)}var fe=(ne={},u()(ne,3042,se),u()(ne,32773,(function(e,t){return e.blendColor.apply(e,o()(t))})),u()(ne,32777,"blendEquation"),u()(ne,34877,"blendEquation"),u()(ne,32969,"blendFunc"),u()(ne,32968,"blendFunc"),u()(ne,32971,"blendFunc"),u()(ne,32970,"blendFunc"),u()(ne,3106,(function(e,t){return e.clearColor.apply(e,o()(t))})),u()(ne,3107,(function(e,t){return e.colorMask.apply(e,o()(t))})),u()(ne,2884,se),u()(ne,2885,(function(e,t){return e.cullFace(t)})),u()(ne,2929,se),u()(ne,2931,(function(e,t){return e.clearDepth(t)})),u()(ne,2932,(function(e,t){return e.depthFunc(t)})),u()(ne,2928,(function(e,t){return e.depthRange.apply(e,o()(t))})),u()(ne,2930,(function(e,t){return e.depthMask(t)})),u()(ne,3024,se),u()(ne,35723,ue),u()(ne,36006,(function(e,t){var n=j(e)?36009:36160;return e.bindFramebuffer(n,t)})),u()(ne,2886,(function(e,t){return e.frontFace(t)})),u()(ne,33170,ue),u()(ne,2849,(function(e,t){return e.lineWidth(t)})),u()(ne,32823,se),u()(ne,32824,"polygonOffset"),u()(ne,10752,"polygonOffset"),u()(ne,35977,se),u()(ne,32938,"sampleCoverage"),u()(ne,32939,"sampleCoverage"),u()(ne,3089,se),u()(ne,3088,(function(e,t){return e.scissor.apply(e,o()(t))})),u()(ne,2960,se),u()(ne,2961,(function(e,t){return e.clearStencil(t)})),u()(ne,2968,(function(e,t){return e.stencilMaskSeparate(1028,t)})),u()(ne,36005,(function(e,t){return e.stencilMaskSeparate(1029,t)})),u()(ne,2962,"stencilFuncFront"),u()(ne,2967,"stencilFuncFront"),u()(ne,2963,"stencilFuncFront"),u()(ne,34816,"stencilFuncBack"),u()(ne,36003,"stencilFuncBack"),u()(ne,36004,"stencilFuncBack"),u()(ne,2964,"stencilOpFront"),u()(ne,2965,"stencilOpFront"),u()(ne,2966,"stencilOpFront"),u()(ne,34817,"stencilOpBack"),u()(ne,34818,"stencilOpBack"),u()(ne,34819,"stencilOpBack"),u()(ne,2978,(function(e,t){return e.viewport.apply(e,o()(t))})),u()(ne,3333,ce),u()(ne,3317,ce),u()(ne,37440,ce),u()(ne,37441,ce),u()(ne,37443,ce),u()(ne,3330,ce),u()(ne,3332,ce),u()(ne,3331,ce),u()(ne,36010,(function(e,t){return e.bindFramebuffer(36008,t)})),u()(ne,3314,ce),u()(ne,32878,ce),u()(ne,3316,ce),u()(ne,3315,ce),u()(ne,32877,ce),u()(ne,"framebuffer",(function(e,t){var n=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,n)})),u()(ne,"blend",(function(e,t){return t?e.enable(3042):e.disable(3042)})),u()(ne,"blendColor",(function(e,t){return e.blendColor.apply(e,o()(t))})),u()(ne,"blendEquation",(function(e,t){t=le(t)?t:[t,t],e.blendEquationSeparate.apply(e,o()(t))})),u()(ne,"blendFunc",(function(e,t){t=le(t)&&2===t.length?[].concat(o()(t),o()(t)):t,e.blendFuncSeparate.apply(e,o()(t))})),u()(ne,"clearColor",(function(e,t){return e.clearColor.apply(e,o()(t))})),u()(ne,"clearDepth",(function(e,t){return e.clearDepth(t)})),u()(ne,"clearStencil",(function(e,t){return e.clearStencil(t)})),u()(ne,"colorMask",(function(e,t){return e.colorMask.apply(e,o()(t))})),u()(ne,"cull",(function(e,t){return t?e.enable(2884):e.disable(2884)})),u()(ne,"cullFace",(function(e,t){return e.cullFace(t)})),u()(ne,"depthTest",(function(e,t){return t?e.enable(2929):e.disable(2929)})),u()(ne,"depthFunc",(function(e,t){return e.depthFunc(t)})),u()(ne,"depthMask",(function(e,t){return e.depthMask(t)})),u()(ne,"depthRange",(function(e,t){return e.depthRange.apply(e,o()(t))})),u()(ne,"dither",(function(e,t){return t?e.enable(3024):e.disable(3024)})),u()(ne,"derivativeHint",(function(e,t){e.hint(35723,t)})),u()(ne,"frontFace",(function(e,t){return e.frontFace(t)})),u()(ne,"mipmapHint",(function(e,t){return e.hint(33170,t)})),u()(ne,"lineWidth",(function(e,t){return e.lineWidth(t)})),u()(ne,"polygonOffsetFill",(function(e,t){return t?e.enable(32823):e.disable(32823)})),u()(ne,"polygonOffset",(function(e,t){return e.polygonOffset.apply(e,o()(t))})),u()(ne,"sampleCoverage",(function(e,t){return e.sampleCoverage.apply(e,o()(t))})),u()(ne,"scissorTest",(function(e,t){return t?e.enable(3089):e.disable(3089)})),u()(ne,"scissor",(function(e,t){return e.scissor.apply(e,o()(t))})),u()(ne,"stencilTest",(function(e,t){return t?e.enable(2960):e.disable(2960)})),u()(ne,"stencilMask",(function(e,t){var n=t=le(t)?t:[t,t],r=ae()(n,2),i=r[0],a=r[1];e.stencilMaskSeparate(1028,i),e.stencilMaskSeparate(1029,a)})),u()(ne,"stencilFunc",(function(e,t){var n=t=le(t)&&3===t.length?[].concat(o()(t),o()(t)):t,r=ae()(n,6),i=r[0],a=r[1],s=r[2],u=r[3],c=r[4],l=r[5];e.stencilFuncSeparate(1028,i,a,s),e.stencilFuncSeparate(1029,u,c,l)})),u()(ne,"stencilOp",(function(e,t){var n=t=le(t)&&3===t.length?[].concat(o()(t),o()(t)):t,r=ae()(n,6),i=r[0],a=r[1],s=r[2],u=r[3],c=r[4],l=r[5];e.stencilOpSeparate(1028,i,a,s),e.stencilOpSeparate(1029,u,c,l)})),u()(ne,"viewport",(function(e,t){return e.viewport.apply(e,o()(t))})),ne);function he(e,t,n){return void 0!==t[e]?t[e]:n[e]}var de={blendEquation:function(e,t,n){return e.blendEquationSeparate(he(32777,t,n),he(34877,t,n))},blendFunc:function(e,t,n){return e.blendFuncSeparate(he(32969,t,n),he(32968,t,n),he(32971,t,n),he(32970,t,n))},polygonOffset:function(e,t,n){return e.polygonOffset(he(32824,t,n),he(10752,t,n))},sampleCoverage:function(e,t,n){return e.sampleCoverage(he(32938,t,n),he(32939,t,n))},stencilFuncFront:function(e,t,n){return e.stencilFuncSeparate(1028,he(2962,t,n),he(2967,t,n),he(2963,t,n))},stencilFuncBack:function(e,t,n){return e.stencilFuncSeparate(1029,he(34816,t,n),he(36003,t,n),he(36004,t,n))},stencilOpFront:function(e,t,n){return e.stencilOpSeparate(1028,he(2964,t,n),he(2965,t,n),he(2966,t,n))},stencilOpBack:function(e,t,n){return e.stencilOpSeparate(1029,he(34817,t,n),he(34818,t,n),he(34819,t,n))}},ve={enable:function(e,t){return e(u()({},t,!0))},disable:function(e,t){return e(u()({},t,!1))},pixelStorei:function(e,t,n){return e(u()({},t,n))},hint:function(e,t,n){return e(u()({},t,n))},bindFramebuffer:function(e,t,n){var r;switch(t){case 36160:return e((r={},u()(r,36006,n),u()(r,36010,n),r));case 36009:return e(u()({},36006,n));case 36008:return e(u()({},36010,n));default:return null}},blendColor:function(e,t,n,r,i){return e(u()({},32773,new Float32Array([t,n,r,i])))},blendEquation:function(e,t){var n;return e((n={},u()(n,32777,t),u()(n,34877,t),n))},blendEquationSeparate:function(e,t,n){var r;return e((r={},u()(r,32777,t),u()(r,34877,n),r))},blendFunc:function(e,t,n){var r;return e((r={},u()(r,32969,t),u()(r,32968,n),u()(r,32971,t),u()(r,32970,n),r))},blendFuncSeparate:function(e,t,n,r,i){var a;return e((a={},u()(a,32969,t),u()(a,32968,n),u()(a,32971,r),u()(a,32970,i),a))},clearColor:function(e,t,n,r,i){return e(u()({},3106,new Float32Array([t,n,r,i])))},clearDepth:function(e,t){return e(u()({},2931,t))},clearStencil:function(e,t){return e(u()({},2961,t))},colorMask:function(e,t,n,r,i){return e(u()({},3107,[t,n,r,i]))},cullFace:function(e,t){return e(u()({},2885,t))},depthFunc:function(e,t){return e(u()({},2932,t))},depthRange:function(e,t,n){return e(u()({},2928,new Float32Array([t,n])))},depthMask:function(e,t){return e(u()({},2930,t))},frontFace:function(e,t){return e(u()({},2886,t))},lineWidth:function(e,t){return e(u()({},2849,t))},polygonOffset:function(e,t,n){var r;return e((r={},u()(r,32824,t),u()(r,10752,n),r))},sampleCoverage:function(e,t,n){var r;return e((r={},u()(r,32938,t),u()(r,32939,n),r))},scissor:function(e,t,n,r,i){return e(u()({},3088,new Int32Array([t,n,r,i])))},stencilMask:function(e,t){var n;return e((n={},u()(n,2968,t),u()(n,36005,t),n))},stencilMaskSeparate:function(e,t,n){return e(u()({},1028===t?2968:36005,n))},stencilFunc:function(e,t,n,r){var i;return e((i={},u()(i,2962,t),u()(i,2967,n),u()(i,2963,r),u()(i,34816,t),u()(i,36003,n),u()(i,36004,r),i))},stencilFuncSeparate:function(e,t,n,r,i){var a;return e((a={},u()(a,1028===t?2962:34816,n),u()(a,1028===t?2967:36003,r),u()(a,1028===t?2963:36004,i),a))},stencilOp:function(e,t,n,r){var i;return e((i={},u()(i,2964,t),u()(i,2965,n),u()(i,2966,r),u()(i,34817,t),u()(i,34818,n),u()(i,34819,r),i))},stencilOpSeparate:function(e,t,n,r,i){var a;return e((a={},u()(a,1028===t?2964:34817,n),u()(a,1028===t?2965:34818,r),u()(a,1028===t?2966:34819,i),a))},viewport:function(e,t,n,r,i){return e(u()({},2978,[t,n,r,i]))}},ge=function(e,t){return e.isEnabled(t)},pe=(re={},u()(re,3042,ge),u()(re,2884,ge),u()(re,2929,ge),u()(re,3024,ge),u()(re,32823,ge),u()(re,32926,ge),u()(re,32928,ge),u()(re,3089,ge),u()(re,2960,ge),u()(re,35977,ge),re);function me(e){for(var t in e)return!1;return!0}function ye(e,t){if(e===t)return!0;var n=Array.isArray(e)||ArrayBuffer.isView(e),r=Array.isArray(t)||ArrayBuffer.isView(t);if(n&&r&&e.length===t.length){for(var i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}return!1}function _e(e,t){var n=e[t].bind(e);e[t]=function(){var t=arguments.length<=0?void 0:arguments[0];return t in e.state.cache&&e.state.enable?e.state.cache[t]:n.apply(void 0,arguments)},Object.defineProperty(e[t],"name",{value:"".concat(t,"-from-cache"),configurable:!1})}function be(e,t,n){var r=e[t].bind(e);e[t]=function(){for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];var o=n.apply(void 0,[e.state._updateCache].concat(i)),s=o.valueChanged,u=o.oldValue;return s&&r.apply(void 0,i),u},Object.defineProperty(e[t],"name",{value:"".concat(t,"-to-cache"),configurable:!1})}function Ae(e){var t=e.useProgram.bind(e);e.useProgram=function(n){e.state.program!==n&&(t(n),e.state.program=n)}}var xe=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.copyState,i=void 0!==r&&r,a=n.log,o=void 0===a?function(){}:a;l()(this,e),this.gl=t,this.program=null,this.stateStack=[],this.enable=!0,this.cache=i?Se(t):Object.assign({},oe),this.log=o,this._updateCache=this._updateCache.bind(this),Object.seal(this)}return h()(e,[{key:"push",value:function(){this.stateStack.push({})}},{key:"pop",value:function(){D(this.stateStack.length>0);var e=this.stateStack[this.stateStack.length-1];Oe(this.gl,e),this.stateStack.pop()}},{key:"_updateCache",value:function(e){var t,n=!1,r=this.stateStack.length>0&&this.stateStack[this.stateStack.length-1];for(var i in e){D(void 0!==i);var a=e[i],o=this.cache[i];ye(a,o)||(n=!0,t=o,r&&!(i in r)&&(r[i]=o),this.cache[i]=a)}return{valueChanged:n,oldValue:t}}}]),e}();function Ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.enable,r=void 0===n||n,i=t.copyState;if(D(void 0!==i),!e.state){var a=globalThis.polyfillContext;for(var o in a&&a(e),e.state=new xe(e,{copyState:i}),Ae(e),ve){var s=ve[o];be(e,o,s)}_e(e,"getParameter"),_e(e,"isEnabled")}return e.state.enable=r,e}function Te(e){D(e.state),e.state.pop()}function ke(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return we(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return we(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function we(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Oe(e,t){if(D(B(e),"setParameters requires a WebGL context"),!me(t)){var n={};for(var r in t){var i=Number(r),a=fe[r];a&&("string"==typeof a?n[a]=!0:a(e,t[r],i))}var o=e.state&&e.state.cache;if(o)for(var s in n){(0,de[s])(e,t,o)}}}function Se(e,t){if("number"==typeof(t=t||oe)){var n=t,r=pe[n];return r?r(e,n):e.getParameter(n)}var i,a={},o=ke(Array.isArray(t)?t:Object.keys(t));try{for(o.s();!(i=o.n()).done;){var s=i.value,u=pe[s];a[s]=u?u(e,Number(s)):e.getParameter(Number(s))}}catch(e){o.e(e)}finally{o.f()}return a}function Le(e){Oe(e,oe)}function Ie(e,t,n){if(me(t))return n(e);var r,i=t.nocatch,a=void 0===i||i;if(function(e){e.state||Ee(e,{copyState:!1}),e.state.push()}(e),Oe(e,t),a)r=n(e),Te(e);else try{r=n(e)}finally{Te(e)}return r}var Pe=n(45);function Re(e){var t=e.luma;if(e.canvas&&t){var n=t.canvasSizeInfo.clientWidth;return n?e.drawingBufferWidth/n:1}return 1}function Fe(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=Re(e),i=e.drawingBufferWidth,a=e.drawingBufferHeight;return Me(t,r,i,a,n)}function Ce(e){var t="undefined"==typeof window?1:window.devicePixelRatio||1;return Number.isFinite(e)?e<=0?1:e:e?t:1}function Me(e,t,n,r,i){var a,o=Ne(e[0],t,n),s=De(e[1],t,r,i),u=Ne(e[0]+1,t,n),c=u===n-1?u:u-1;return u=De(e[1]+1,t,r,i),i?(a=s,s=u=0===u?u:u+1):a=u===r-1?u:u-1,{x:o,y:s,width:Math.max(c-o+1,1),height:Math.max(a-s+1,1)}}function Ne(e,t,n){return Math.min(Math.round(e*t),n-1)}function De(e,t,n,r){return r?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}var Be=Object(Pe.a)(),je=Be&&"undefined"!=typeof document,Ue={webgl2:!0,webgl1:!0,throwOnError:!0,manageState:!0,canvas:null,debug:!1,width:800,height:600};function Ve(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};D(Be,"createGLContext only available in the browser.\nCreate your own headless context or use 'createHeadlessContext' from @luma.gl/test-utils");var t,n=e=Object.assign({},Ue,e),r=n.width,i=n.height;function a(t){if(e.throwOnError)throw new Error(t);return console.error(t),null}e.onError=a;var o=e,s=o.canvas,u=He({canvas:s,width:r,height:i,onError:a});return(t=ze(u,e))?(We(t=Ge(t,e)),t):null}function Ge(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e||e._instrumented)return e;e._version=e._version||Xe(e),e.luma=e.luma||{},e.luma.canvasSizeInfo=e.luma.canvasSizeInfo||{};var n=t=Object.assign({},Ue,t),r=n.manageState,i=n.debug;return r&&Ee(e,{copyState:!1,log:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return N.log.apply(N,[1].concat(t))()}}),Be&&i&&(globalThis.makeDebugContext?(e=globalThis.makeDebugContext(e,t),N.level=Math.max(N.level,1)):N.warn('WebGL debug mode not activated. import "@luma.gl/debug" to enable.')()),e._instrumented=!0,e}function ze(e,t){var n=t.onError,r=null,i=function(e){return r=e.statusMessage||r};e.addEventListener("webglcontextcreationerror",i,!1);var a=t.webgl1,o=void 0===a||a,s=t.webgl2,u=void 0===s||s,c=null;return u&&(c=(c=c||e.getContext("webgl2",t))||e.getContext("experimental-webgl2",t)),o&&(c=(c=c||e.getContext("webgl",t))||e.getContext("experimental-webgl",t)),e.removeEventListener("webglcontextcreationerror",i,!1),c?(t.onContextLost&&e.addEventListener("webglcontextlost",t.onContextLost,!1),t.onContextRestored&&e.addEventListener("webglcontextrestored",t.onContextRestored,!1),c):n("Failed to create ".concat(u&&!o?"WebGL2":"WebGL"," context: ").concat(r||"Unknown error"))}function He(e){var t,n=e.canvas,r=e.width,i=void 0===r?800:r,a=e.height,o=void 0===a?600:a,s=e.onError;"string"==typeof n?(je&&"complete"===document.readyState||s("createGLContext called on canvas '".concat(n,"' before page was loaded")),t=document.getElementById(n)):n?t=n:((t=document.createElement("canvas")).id="lumagl-canvas",t.style.width=Number.isFinite(i)?"".concat(i,"px"):"100%",t.style.height=Number.isFinite(o)?"".concat(o,"px"):"100%",document.body.insertBefore(t,document.body.firstChild));return t}function We(e){var t=j(e)?"WebGL2":"WebGL1",n=function(e){var t=e.getParameter(7936),n=e.getParameter(7937),r=e.getExtension("WEBGL_debug_renderer_info");return{vendor:r&&e.getParameter(r.UNMASKED_VENDOR_WEBGL||7936)||t,renderer:r&&e.getParameter(r.UNMASKED_RENDERER_WEBGL||7937)||n,vendorMasked:t,rendererMasked:n,version:e.getParameter(7938),shadingLanguageVersion:e.getParameter(35724)}}(e),r=n?"(".concat(n.vendor,",").concat(n.renderer,")"):"",i=e.debug?" debug":"";N.info(1,"".concat(t).concat(i," context ").concat(r))()}function Xe(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext?2:1}function qe(e,t,n){var r="width"in n?n.width:e.canvas.clientWidth,i="height"in n?n.height:e.canvas.clientHeight;r&&i||(N.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,r=e.canvas.width||1,i=e.canvas.height||1),e.luma=e.luma||{},e.luma.canvasSizeInfo=e.luma.canvasSizeInfo||{};var a=e.luma.canvasSizeInfo;if(a.clientWidth!==r||a.clientHeight!==i||a.devicePixelRatio!==t){var o=t,s=Math.floor(r*o),u=Math.floor(i*o);e.canvas.width=s,e.canvas.height=u,e.drawingBufferWidth===s&&e.drawingBufferHeight===u||(N.warn("Device pixel ratio clamped")(),o=Math.min(e.drawingBufferWidth/r,e.drawingBufferHeight/i),e.canvas.width=Math.floor(r*o),e.canvas.height=Math.floor(i*o)),Object.assign(e.luma.canvasSizeInfo,{clientWidth:r,clientHeight:i,devicePixelRatio:t})}}var Ke=n(15),Ye=function(){function e(t,n){l()(this,e),this.name=t,this.type=n,this.sampleSize=1,this.reset()}return h()(e,[{key:"setSampleSize",value:function(e){return this.sampleSize=e,this}},{key:"incrementCount",value:function(){return this.addCount(1),this}},{key:"decrementCount",value:function(){return this.subtractCount(1),this}},{key:"addCount",value:function(e){return this._count+=e,this._samples++,this._checkSampling(),this}},{key:"subtractCount",value:function(e){return this._count-=e,this._samples++,this._checkSampling(),this}},{key:"addTime",value:function(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}},{key:"timeStart",value:function(){return this._startTime=Object(Ke.a)(),this._timerPending=!0,this}},{key:"timeEnd",value:function(){return this._timerPending?(this.addTime(Object(Ke.a)()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}},{key:"getSampleAverageCount",value:function(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}},{key:"getSampleAverageTime",value:function(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}},{key:"getSampleHz",value:function(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}},{key:"getAverageCount",value:function(){return this.samples>0?this.count/this.samples:0}},{key:"getAverageTime",value:function(){return this.samples>0?this.time/this.samples:0}},{key:"getHz",value:function(){return this.time>0?this.samples/(this.time/1e3):0}},{key:"reset",value:function(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}},{key:"_checkSampling",value:function(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}]),e}(),Qe=function(){function e(t){var n=t.id,r=t.stats;l()(this,e),this.id=n,this.stats={},this._initializeStats(r),Object.seal(this)}return h()(e,[{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count";return this._getOrCreate({name:e,type:t})}},{key:"reset",value:function(){for(var e in this.stats)this.stats[e].reset();return this}},{key:"forEach",value:function(e){for(var t in this.stats)e(this.stats[t])}},{key:"getTable",value:function(){var e={};return this.forEach((function(t){e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}})),e}},{key:"_initializeStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t.forEach((function(t){return e._getOrCreate(t)}))}},{key:"_getOrCreate",value:function(e){if(!e||!e.name)return null;var t=e.name,n=e.type;return this.stats[t]||(this.stats[t]=e instanceof Ye?e:new Ye(t,n)),this.stats[t]}},{key:"size",get:function(){return Object.keys(this.stats).length}}]),e}(),$e=function(){function e(){l()(this,e),this.stats=new Map}return h()(e,[{key:"get",value:function(e){return this.stats.has(e)||this.stats.set(e,new Qe({id:e})),this.stats.get(e)}}]),e}(),Ze=new $e;if(globalThis.luma&&"8.5.14"!==globalThis.luma.VERSION)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat("8.5.14"));globalThis.luma||(Object(Pe.a)()&&N.log(1,"luma.gl ".concat("8.5.14"," - ").concat("set luma.log.level=1 (or higher) to trace rendering"))(),globalThis.luma=globalThis.luma||{VERSION:"8.5.14",version:"8.5.14",log:N,stats:Ze,globals:{modules:{},nodeIO:{}}});globalThis.luma;var Je=n(9),et=n.n(Je),tt=n(13),nt=n.n(tt),rt=n(4),it=n.n(rt),at=n(5),ot=n.n(at),st=n(3),ut=n.n(st);function ct(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function lt(e,t){if("string"!=typeof t)return t;var n=Number(t);if(!isNaN(n))return n;var r=e[t=t.replace(/^.*\./,"")];return ct(void 0!==r,"Accessing undefined constant GL.".concat(t)),r}function ft(e,t){for(var n in t=Number(t),e)if(e[n]===t)return"GL.".concat(n);return String(t)}var ht={};function dt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";ht[e]=ht[e]||1;var t=ht[e]++;return"".concat(e,"-").concat(t)}function vt(e){return ct("number"==typeof e,"Input must be a number"),e&&0==(e&e-1)}function gt(e){var t=!0;for(var n in e){t=!1;break}return t}function pt(e,t,n,r){var i="See luma.gl ".concat(n," Upgrade Guide at https://luma.gl/docs/upgrade-guide"),a=Object.getPrototypeOf(e);r.forEach((function(e){a.methodName||(a[e]=function(){throw N.removed("Calling removed method ".concat(t,".").concat(e,": "),i)(),new Error(e)})}))}function mt(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return yt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function yt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var _t="Resource subclass must define virtual methods",bt=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e),U(t);var r=n.id,i=n.userData,a=void 0===i?{}:i;this.gl=t,this.gl2=t,this.id=r||dt(this[Symbol.toStringTag]),this.userData=a,this._bound=!1,this._handle=n.handle,void 0===this._handle&&(this._handle=this._createHandle()),this.byteLength=0,this._initStats(),this._addStats()}return h()(e,[{key:Symbol.toStringTag,get:function(){return"Resource"}}]),h()(e,[{key:"toString",value:function(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.deleteChildren,n=void 0!==t&&t,r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this._removeStats(),this._handle=null,r&&n&&r.filter(Boolean).forEach((function(e){return e.delete()})),this}},{key:"bind",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.handle;return"function"!=typeof t?(this._bindHandle(t),this):(this._bound?e=t():(this._bindHandle(this.handle),this._bound=!0,e=t(),this._bound=!1,this._bindHandle(null)),e)}},{key:"unbind",value:function(){this.bind(null)}},{key:"getParameter",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ct(e=lt(this.gl,e));var n=this.constructor.PARAMETERS||{},r=n[e];if(r){var i=j(this.gl),a=(!("webgl2"in r)||i)&&(!("extension"in r)||this.gl.getExtension(r.extension));if(!a){var o=r.webgl1,s="webgl2"in r?r.webgl2:r.webgl1,u=i?s:o;return u}}return this._getParameter(e,t)}},{key:"getParameters",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.parameters,r=t.keys,i=this.constructor.PARAMETERS||{},a=j(this.gl),o={},s=n||Object.keys(i),u=mt(s);try{for(u.s();!(e=u.n()).done;){var c=e.value,l=i[c],f=l&&(!("webgl2"in l)||a)&&(!("extension"in l)||this.gl.getExtension(l.extension));if(f){var h=r?ft(this.gl,c):c;o[h]=this.getParameter(c,t),r&&"GLenum"===l.type&&(o[h]=ft(this.gl,o[h]))}}}catch(e){u.e(e)}finally{u.f()}return o}},{key:"setParameter",value:function(e,t){ct(e=lt(this.gl,e));var n=(this.constructor.PARAMETERS||{})[e];if(n){var r=j(this.gl);if(!((!("webgl2"in n)||r)&&(!("extension"in n)||this.gl.getExtension(n.extension))))throw new Error("Parameter not available on this platform");"GLenum"===n.type&&(t=lt(t))}return this._setParameter(e,t),this}},{key:"setParameters",value:function(e){for(var t in e)this.setParameter(t,e[t]);return this}},{key:"stubRemovedMethods",value:function(e,t,n){return pt(this,e,t,n)}},{key:"initialize",value:function(e){}},{key:"_createHandle",value:function(){throw new Error(_t)}},{key:"_deleteHandle",value:function(){throw new Error(_t)}},{key:"_bindHandle",value:function(e){throw new Error(_t)}},{key:"_getOptsFromHandle",value:function(){throw new Error(_t)}},{key:"_getParameter",value:function(e,t){throw new Error(_t)}},{key:"_setParameter",value:function(e,t){throw new Error(_t)}},{key:"_context",value:function(){return this.gl.luma=this.gl.luma||{},this.gl.luma}},{key:"_initStats",value:function(){this.gl.stats=this.gl.stats||new $e}},{key:"_addStats",value:function(){var e=this[Symbol.toStringTag],t=Ze.get("Resource Counts");t.get("Resources Created").incrementCount(),t.get("".concat(e,"s Created")).incrementCount(),t.get("".concat(e,"s Active")).incrementCount()}},{key:"_removeStats",value:function(){var e=this[Symbol.toStringTag];Ze.get("Resource Counts").get("".concat(e,"s Active")).decrementCount()}},{key:"_trackAllocatedMemory",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag];this._doTrackAllocatedMemory(e,t),this._doTrackAllocatedMemory(e,t,this.gl.stats.get("Memory Usage"))}},{key:"_doTrackAllocatedMemory",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ze.get("Memory Usage");n.get("GPU Memory").addCount(e),n.get("".concat(t," Memory")).addCount(e),this.byteLength=e}},{key:"_trackDeallocatedMemory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];this._doTrackDeallocatedMemory(e),this._doTrackDeallocatedMemory(e,this.gl.stats.get("Memory Usage"))}},{key:"_doTrackDeallocatedMemory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ze.get("Memory Usage");t.get("GPU Memory").subtractCount(this.byteLength),t.get("".concat(e," Memory")).subtractCount(this.byteLength),this.byteLength=0}},{key:"handle",get:function(){return this._handle}}]),e}(),At=n(20),xt=n.n(At);function Et(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}function Tt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.clamped,r=void 0===n||n;switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}function kt(e){var t=e.data,n=e.width,r=e.height,i=e.bytesPerPixel,a=void 0===i?4:i,o=e.temp,s=n*a;o=o||new Uint8Array(s);for(var u=0;u<r/2;++u){var c=u*s,l=(r-u-1)*s;o.set(t.subarray(c,c+s)),t.copyWithin(c,l,l+s),t.set(o,l)}}function wt(e){for(var t=e.data,n=e.width,r=e.height,i=Math.round(n/2),a=Math.round(r/2),o=new Uint8Array(i*a*4),s=0;s<a;s++)for(var u=0;u<i;u++)for(var c=0;c<4;c++)o[4*(s*i+u)+c]=t[4*(2*s*n+2*u)+c];return{data:o,width:i,height:a}}function Ot(e,t,n){var r=n.removedProps,i=void 0===r?{}:r,a=n.deprecatedProps,o=void 0===a?{}:a,s=n.replacedProps,u=void 0===s?{}:s;for(var c in i)if(c in t){var l=i[c]?"".concat(e,".").concat(i[c]):"N/A";N.removed("".concat(e,".").concat(c),l)()}for(var f in o)if(f in t){var h=o[f];N.deprecated("".concat(e,".").concat(f),"".concat(e,".").concat(h))()}var d=null;for(var v in u)if(v in t){var g=u[v];N.deprecated("".concat(e,".").concat(v),"".concat(e,".").concat(g))(),(d=d||Object.assign({},t))[g]=t[v],delete d[v]}return d||t}var St={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},Lt={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},It=function(){function e(){var t=this;l()(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];r.forEach((function(e){return t._assign(e)})),Object.freeze(this)}return h()(e,null,[{key:"getBytesPerElement",value:function(e){return Tt(e.type||5126).BYTES_PER_ELEMENT}},{key:"getBytesPerVertex",value:function(e){return ct(e.size),Tt(e.type||5126).BYTES_PER_ELEMENT*e.size}},{key:"resolve",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return xt()(e,[St].concat(n))}}]),h()(e,[{key:"toString",value:function(){return JSON.stringify(this)}},{key:"_assign",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return void 0!==(e=Ot("Accessor",e,Lt)).type&&(this.type=e.type,5124!==e.type&&5125!==e.type||(this.integer=!0)),void 0!==e.size&&(this.size=e.size),void 0!==e.offset&&(this.offset=e.offset),void 0!==e.stride&&(this.stride=e.stride),void 0!==e.normalized&&(this.normalized=e.normalized),void 0!==e.integer&&(this.integer=e.integer),void 0!==e.divisor&&(this.divisor=e.divisor),void 0!==e.buffer&&(this.buffer=e.buffer),void 0!==e.index&&("boolean"==typeof e.index?this.index=e.index?1:0:this.index=e.index),void 0!==e.instanced&&(this.divisor=e.instanced?1:0),void 0!==e.isInstanced&&(this.divisor=e.isInstanced?1:0),this}},{key:"BYTES_PER_ELEMENT",get:function(){return e.getBytesPerElement(this)}},{key:"BYTES_PER_VERTEX",get:function(){return e.getBytesPerVertex(this)}}]),e}();function Pt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Rt,Ft,Ct,Mt={offset:"accessor.offset",stride:"accessor.stride",type:"accessor.type",size:"accessor.size",divisor:"accessor.divisor",normalized:"accessor.normalized",integer:"accessor.integer",instanced:"accessor.divisor",isInstanced:"accessor.divisor"},Nt={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:Mt},Dt={removedProps:Mt},Bt=function(e){it()(n,e);var t=Pt(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),(r=t.call(this,e,i)).stubRemovedMethods("Buffer","v6.0",["layout","setLayout","getIndexedParameter"]),r.target=i.target||(r.gl.webgl2?36662:34962),r.initialize(i),Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Buffer"}}]),h()(n,[{key:"getElementCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/It.getBytesPerElement(e))}},{key:"getVertexCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/It.getBytesPerVertex(e))}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ArrayBuffer.isView(e)&&(e={data:e}),Number.isFinite(e)&&(e={byteLength:e}),e=Ot("Buffer",e,Nt),this.usage=e.usage||35044,this.debugData=null,this.setAccessor(Object.assign({},e,e.accessor)),e.data?this._setData(e.data,e.offset,e.byteLength):this._setByteLength(e.byteLength||0),this}},{key:"setProps",value:function(e){return"accessor"in(e=Ot("Buffer",e,Dt))&&this.setAccessor(e.accessor),this}},{key:"setAccessor",value:function(e){return delete(e=Object.assign({},e)).buffer,this.accessor=new It(e),this}},{key:"reallocate",value:function(e){return e>this.byteLength?(this._setByteLength(e),!0):(this.bytesUsed=e,!1)}},{key:"setData",value:function(e){return this.initialize(e)}},{key:"subData",value:function(e){ArrayBuffer.isView(e)&&(e={data:e});var t=e,n=t.data,r=t.offset,i=void 0===r?0:r,a=t.srcOffset,o=void 0===a?0:a,s=e.byteLength||e.length;ct(n);var u=this.gl.webgl2?36663:this.target;return this.gl.bindBuffer(u,this.handle),0!==o||void 0!==s?(V(this.gl),this.gl.bufferSubData(this.target,i,n,o,s)):this.gl.bufferSubData(u,i,n),this.gl.bindBuffer(u,null),this.debugData=null,this._inferType(n),this}},{key:"copyData",value:function(e){var t=e.sourceBuffer,n=e.readOffset,r=void 0===n?0:n,i=e.writeOffset,a=void 0===i?0:i,o=e.size,s=this.gl;return V(s),s.bindBuffer(36662,t.handle),s.bindBuffer(36663,this.handle),s.copyBufferSubData(36662,36663,r,a,o),s.bindBuffer(36662,null),s.bindBuffer(36663,null),this.debugData=null,this}},{key:"getData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.dstData,n=void 0===t?null:t,r=e.srcByteOffset,i=void 0===r?0:r,a=e.dstOffset,o=void 0===a?0:a,s=e.length,u=void 0===s?0:s;V(this.gl);var c,l,f=Tt(this.accessor.type||5126,{clamped:!1}),h=this._getAvailableElementCount(i),d=o;n?c=(l=n.length)-d:l=d+(c=Math.min(h,u||h));var v=Math.min(h,c);return ct((u=u||v)<=v),n=n||new f(l),this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,i,n,o,u),this.gl.bindBuffer(36662,null),n}},{key:"bind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?this.target:t,r=e.index,i=void 0===r?this.accessor&&this.accessor.index:r,a=e.offset,o=void 0===a?0:a,s=e.size;return 35345===n||35982===n?void 0!==s?this.gl.bindBufferRange(n,i,this.handle,o,s):(ct(0===o),this.gl.bindBufferBase(n,i,this.handle)):this.gl.bindBuffer(n,this.handle),this}},{key:"unbind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?this.target:t,r=e.index,i=void 0===r?this.accessor&&this.accessor.index:r,a=35345===n||35982===n;return a?this.gl.bindBufferBase(n,i,null):this.gl.bindBuffer(n,null),this}},{key:"getDebugData",value:function(){return this.debugData?{data:this.debugData,changed:!1}:(this.debugData=this.getData({length:Math.min(10,this.byteLength)}),{data:this.debugData,changed:!0})}},{key:"invalidateDebugData",value:function(){this.debugData=null}},{key:"_setData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.byteLength+t;ct(ArrayBuffer.isView(e)),this._trackDeallocatedMemory();var r=this._getTarget();this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,this.usage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.debugData=e.slice(0,10),this.bytesUsed=n,this._trackAllocatedMemory(n);var i=Et(e);return ct(i),this.setAccessor(new It(this.accessor,{type:i})),this}},{key:"_setByteLength",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.usage;ct(e>=0),this._trackDeallocatedMemory();var n=e;0===e&&(n=new Float32Array(0));var r=this._getTarget();return this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,t),this.gl.bindBuffer(r,null),this.usage=t,this.debugData=null,this.bytesUsed=e,this._trackAllocatedMemory(e),this}},{key:"_getTarget",value:function(){return this.gl.webgl2?36663:this.target}},{key:"_getAvailableElementCount",value:function(e){var t=e/Tt(this.accessor.type||5126,{clamped:!1}).BYTES_PER_ELEMENT;return this.getElementCount()-t}},{key:"_inferType",value:function(e){this.accessor.type||this.setAccessor(new It(this.accessor,{type:Et(e)}))}},{key:"_createHandle",value:function(){return this.gl.createBuffer()}},{key:"_deleteHandle",value:function(){this.gl.deleteBuffer(this.handle),this._trackDeallocatedMemory()}},{key:"_getParameter",value:function(e){this.gl.bindBuffer(this.target,this.handle);var t=this.gl.getBufferParameter(this.target,e);return this.gl.bindBuffer(this.target,null),t}},{key:"setByteLength",value:function(e){return N.deprecated("setByteLength","reallocate")(),this.reallocate(e)}},{key:"updateAccessor",value:function(e){return N.deprecated("updateAccessor(...)","setAccessor(new Accessor(buffer.accessor, ...)")(),this.accessor=new It(this.accessor,e),this}},{key:"type",get:function(){return N.deprecated("Buffer.type","Buffer.accessor.type")(),this.accessor.type}},{key:"bytes",get:function(){return N.deprecated("Buffer.bytes","Buffer.byteLength")(),this.byteLength}}]),n}(bt),jt=(Rt={},u()(Rt,6407,{dataFormat:6407,types:[5121,33635]}),u()(Rt,6408,{dataFormat:6408,types:[5121,32819,32820]}),u()(Rt,6406,{dataFormat:6406,types:[5121]}),u()(Rt,6409,{dataFormat:6409,types:[5121]}),u()(Rt,6410,{dataFormat:6410,types:[5121]}),u()(Rt,33326,{dataFormat:6403,types:[5126],gl2:!0}),u()(Rt,33328,{dataFormat:33319,types:[5126],gl2:!0}),u()(Rt,34837,{dataFormat:6407,types:[5126],gl2:!0}),u()(Rt,34836,{dataFormat:6408,types:[5126],gl2:!0}),Rt),Ut=(Ft={},u()(Ft,6403,1),u()(Ft,36244,1),u()(Ft,33319,2),u()(Ft,33320,2),u()(Ft,6407,3),u()(Ft,36248,3),u()(Ft,6408,4),u()(Ft,36249,4),u()(Ft,6402,1),u()(Ft,34041,1),u()(Ft,6406,1),u()(Ft,6409,1),u()(Ft,6410,2),Ft),Vt=(Ct={},u()(Ct,5126,4),u()(Ct,5125,4),u()(Ct,5124,4),u()(Ct,5123,2),u()(Ct,5122,2),u()(Ct,5131,2),u()(Ct,5120,1),u()(Ct,5121,1),Ct);function Gt(e,t){var n=jt[t];if(!n)return!1;if(void 0===n.gl1&&void 0===n.gl2)return!0;var r=j(e)&&n.gl2||n.gl1;return"string"==typeof r?e.getExtension(r):r}function zt(e,t){var n=jt[t];switch(n&&n.types[0]){case 5126:return e.getExtension("OES_texture_float_linear");case 5131:return e.getExtension("OES_texture_half_float_linear");default:return!0}}function Ht(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Wt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Wt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Wt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Xt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var qt=[9729,9728],Kt=globalThis.WebGLBuffer||function(){},Yt=function(e){it()(n,e);var t=Xt(n);function n(e,r){var i;l()(this,n);var a=r.id,o=void 0===a?dt("texture"):a,s=r.handle,u=r.target;return(i=t.call(this,e,{id:o,handle:s})).target=u,i.textureUnit=void 0,i.loaded=!1,i.width=void 0,i.height=void 0,i.depth=void 0,i.format=void 0,i.type=void 0,i.dataFormat=void 0,i.border=void 0,i.textureUnit=void 0,i.mipmaps=void 0,i}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Texture"}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.format,r=t.linearFiltering,i=!0;return n&&(i=(i=i&&Gt(e,n))&&(!r||zt(e,n))),i}}]),h()(n,[{key:"toString",value:function(){return"Texture(".concat(this.id,",").concat(this.width,"x").concat(this.height,")")}},{key:"initialize",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.data;if(n instanceof Promise)return n.then((function(n){return e.initialize(Object.assign({},t,{pixels:n,data:n}))})),this;var r="undefined"!=typeof HTMLVideoElement&&n instanceof HTMLVideoElement;if(r&&n.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,n.addEventListener("loadeddata",(function(){return e.initialize(t)})),this;var i=t.pixels,a=void 0===i?null:i,o=t.format,s=void 0===o?6408:o,u=t.border,c=void 0===u?0:u,l=t.recreate,f=void 0!==l&&l,h=t.parameters,d=void 0===h?{}:h,v=t.pixelStore,g=void 0===v?{}:v,p=t.textureUnit,m=void 0===p?void 0:p;n||(n=a);var y=t.width,_=t.height,b=t.dataFormat,A=t.type,x=t.compressed,E=void 0!==x&&x,T=t.mipmaps,k=void 0===T||T,w=t.depth,O=void 0===w?0:w,S=this._deduceParameters({format:s,type:A,dataFormat:b,compressed:E,data:n,width:y,height:_});return y=S.width,_=S.height,E=S.compressed,b=S.dataFormat,A=S.type,this.width=y,this.height=_,this.depth=O,this.format=s,this.type=A,this.dataFormat=b,this.border=c,this.textureUnit=m,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),k&&this._isNPOT()&&(N.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),k=!1,this._updateForNPOT(d)),this.mipmaps=k,this.setImageData({data:n,width:y,height:_,depth:O,format:s,type:A,dataFormat:b,border:c,mipmaps:k,parameters:g,compressed:E}),k&&this.generateMipmap(),this.setParameters(d),f&&(this.data=n),r&&(this._video={video:n,parameters:d,lastTime:n.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?n.currentTime:-1}),this}},{key:"update",value:function(){if(this._video){var e=this._video,t=e.video,n=e.parameters;if(e.lastTime===t.currentTime||t.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:t,parameters:n}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=t.currentTime}}},{key:"resize",value:function(e){var t=e.height,n=e.width,r=e.mipmaps,i=void 0!==r&&r;return n!==this.width||t!==this.height?this.initialize({width:n,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,border:this.border,mipmaps:i}):this}},{key:"generateMipmap",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isNPOT()?(N.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Ie(this.gl,t,(function(){e.gl.generateMipmap(e.target)})),this.gl.bindTexture(this.target,null),this)}},{key:"setImageData",value:function(e){this._trackDeallocatedMemory("Texture");var t=e.target,n=void 0===t?this.target:t,r=e.pixels,i=void 0===r?null:r,a=e.level,o=void 0===a?0:a,s=e.format,u=void 0===s?this.format:s,c=e.border,l=void 0===c?this.border:c,f=e.offset,h=void 0===f?0:f,d=e.parameters,v=void 0===d?{}:d,g=e.data,p=void 0===g?null:g,m=e.type,y=void 0===m?this.type:m,_=e.width,b=void 0===_?this.width:_,A=e.height,x=void 0===A?this.height:A,E=e.dataFormat,T=void 0===E?this.dataFormat:E,k=e.compressed,w=void 0!==k&&k;p||(p=i);var O=this._deduceParameters({format:u,type:y,dataFormat:T,compressed:w,data:p,width:b,height:x});y=O.type,T=O.dataFormat,w=O.compressed,b=O.width,x=O.height;var S=this.gl;S.bindTexture(this.target,this.handle);var L,I,P=this._getDataType({data:p,compressed:w});p=P.data,L=P.dataType;var R=0;if(Ie(this.gl,v,(function(){switch(L){case"null":S.texImage2D(n,o,u,b,x,l,T,y,p);break;case"typed-array":S.texImage2D(n,o,u,b,x,l,T,y,p,h);break;case"buffer":(I=V(S)).bindBuffer(35052,p.handle||p),I.texImage2D(n,o,u,b,x,l,T,y,h),I.bindBuffer(35052,null);break;case"browser-object":j(S)?S.texImage2D(n,o,u,b,x,l,T,y,p):S.texImage2D(n,o,u,T,y,p);break;case"compressed":var e,t=Ht(p.entries());try{for(t.s();!(e=t.n()).done;){var r=ae()(e.value,2),i=r[0],a=r[1];S.compressedTexImage2D(n,i,a.format,a.width,a.height,l,a.data),R+=a.levelSize}}catch(e){t.e(e)}finally{t.f()}break;default:ct(!1,"Unknown image data type")}})),"compressed"===L)this._trackAllocatedMemory(R,"Texture");else if(p&&p.byteLength)this._trackAllocatedMemory(p.byteLength,"Texture");else{var F=Ut[this.dataFormat]||4,C=Vt[this.type]||1;this._trackAllocatedMemory(this.width*this.height*F*C,"Texture")}return this.loaded=!0,this}},{key:"setSubImageData",value:function(e){var t=this,n=e.target,r=void 0===n?this.target:n,i=e.pixels,a=void 0===i?null:i,o=e.data,s=void 0===o?null:o,u=e.x,c=void 0===u?0:u,l=e.y,f=void 0===l?0:l,h=e.width,d=void 0===h?this.width:h,v=e.height,g=void 0===v?this.height:v,p=e.level,m=void 0===p?0:p,y=e.format,_=void 0===y?this.format:y,b=e.type,A=void 0===b?this.type:b,x=e.dataFormat,E=void 0===x?this.dataFormat:x,T=e.compressed,k=void 0!==T&&T,w=e.offset,O=void 0===w?0:w,S=e.border,L=(void 0===S&&this.border,e.parameters),I=void 0===L?{}:L,P=this._deduceParameters({format:_,type:A,dataFormat:E,compressed:k,data:s,width:d,height:g});if(A=P.type,E=P.dataFormat,k=P.compressed,d=P.width,g=P.height,ct(0===this.depth,"texSubImage not supported for 3D textures"),s||(s=a),s&&s.data){var R=s;s=R.data,d=R.shape[0],g=R.shape[1]}s instanceof Bt&&(s=s.handle),this.gl.bindTexture(this.target,this.handle),Ie(this.gl,I,(function(){if(k)t.gl.compressedTexSubImage2D(r,m,c,f,d,g,_,s);else if(null===s)t.gl.texSubImage2D(r,m,c,f,d,g,E,A,null);else if(ArrayBuffer.isView(s))t.gl.texSubImage2D(r,m,c,f,d,g,E,A,s,O);else if(s instanceof Kt){var e=V(t.gl);e.bindBuffer(35052,s),e.texSubImage2D(r,m,c,f,d,g,E,A,O),e.bindBuffer(35052,null)}else if(j(t.gl)){V(t.gl).texSubImage2D(r,m,c,f,d,g,E,A,s)}else t.gl.texSubImage2D(r,m,c,f,E,A,s)})),this.gl.bindTexture(this.target,null)}},{key:"copyFramebuffer",value:function(){return N.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}},{key:"getActiveUnit",value:function(){return this.gl.getParameter(34016)-33984}},{key:"bind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit,t=this.gl;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,this.handle),e}},{key:"unbind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit,t=this.gl;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,null),e}},{key:"_getDataType",value:function(e){var t=e.data,n=e.compressed;return void 0!==n&&n?{data:t,dataType:"compressed"}:null===t?{data:t,dataType:"null"}:ArrayBuffer.isView(t)?{data:t,dataType:"typed-array"}:t instanceof Bt?{data:t.handle,dataType:"buffer"}:t instanceof Kt?{data:t,dataType:"buffer"}:{data:t,dataType:"browser-object"}}},{key:"_deduceParameters",value:function(e){var t=e.format,n=e.data,r=e.width,i=e.height,a=e.dataFormat,o=e.type,s=e.compressed,u=jt[t];a=a||u&&u.dataFormat,o=o||u&&u.types[0],s=s||u&&u.compressed;var c=this._deduceImageSize(n,r,i);return{dataFormat:a,type:o,compressed:s,width:r=c.width,height:i=c.height,format:t,data:n}}},{key:"_deduceImageSize",value:function(e,t,n){var r;return ct(r="undefined"!=typeof ImageData&&e instanceof ImageData?{width:e.width,height:e.height}:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?{width:e.naturalWidth,height:e.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?{width:e.width,height:e.height}:"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e?{width:t,height:n}:{width:t>=0?t:1,height:n>=0?n:1},"Could not deduced texture size"),ct(void 0===t||r.width===t,"Deduced texture width does not match supplied width"),ct(void 0===n||r.height===n,"Deduced texture height does not match supplied height"),r}},{key:"_createHandle",value:function(){return this.gl.createTexture()}},{key:"_deleteHandle",value:function(){this.gl.deleteTexture(this.handle),this._trackDeallocatedMemory("Texture")}},{key:"_getParameter",value:function(e){switch(e){case 4096:return this.width;case 4097:return this.height;default:this.gl.bindTexture(this.target,this.handle);var t=this.gl.getTexParameter(this.target,e);return this.gl.bindTexture(this.target,null),t}}},{key:"_setParameter",value:function(e,t){switch(this.gl.bindTexture(this.target,this.handle),t=this._getNPOTParam(e,t),e){case 33082:case 33083:this.gl.texParameterf(this.handle,e,t);break;case 4096:case 4097:ct(!1);break;default:this.gl.texParameteri(this.target,e,t)}return this.gl.bindTexture(this.target,null),this}},{key:"_isNPOT",value:function(){return!j(this.gl)&&(!(!this.width||!this.height)&&(!vt(this.width)||!vt(this.height)))}},{key:"_updateForNPOT",value:function(e){void 0===e[this.gl.TEXTURE_MIN_FILTER]&&(e[this.gl.TEXTURE_MIN_FILTER]=this.gl.LINEAR),void 0===e[this.gl.TEXTURE_WRAP_S]&&(e[this.gl.TEXTURE_WRAP_S]=this.gl.CLAMP_TO_EDGE),void 0===e[this.gl.TEXTURE_WRAP_T]&&(e[this.gl.TEXTURE_WRAP_T]=this.gl.CLAMP_TO_EDGE)}},{key:"_getNPOTParam",value:function(e,t){if(this._isNPOT())switch(e){case 10241:-1===qt.indexOf(t)&&(t=9729);break;case 10242:case 10243:33071!==t&&(t=33071)}return t}}]),n}(bt),Qt="";function $t(e,t){return ct("string"==typeof e),e=Qt+e,new Promise((function(n,r){try{var i=new Image;i.onload=function(){return n(i)},i.onerror=function(){return r(new Error("Could not load image ".concat(e,".")))},i.crossOrigin=t&&t.crossOrigin||"anonymous",i.src=e}catch(e){r(e)}}))}function Zt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Jt,en=function(e){it()(n,e);var t=Zt(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),U(e),(i instanceof Promise||"string"==typeof i)&&(i={data:i}),"string"==typeof i.data&&(i=Object.assign({},i,{data:$t(i.data)})),(r=t.call(this,e,Object.assign({},i,{target:3553}))).initialize(i),Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Texture2D"}}],[{key:"isSupported",value:function(e,t){return Yt.isSupported(e,t)}}]),n}(Yt),tn="EXT_color_buffer_float",nn=(Jt={},u()(Jt,33189,{bpp:2}),u()(Jt,33190,{gl2:!0,bpp:3}),u()(Jt,36012,{gl2:!0,bpp:4}),u()(Jt,36168,{bpp:1}),u()(Jt,34041,{bpp:4}),u()(Jt,35056,{gl2:!0,bpp:4}),u()(Jt,36013,{gl2:!0,bpp:5}),u()(Jt,32854,{bpp:2}),u()(Jt,36194,{bpp:2}),u()(Jt,32855,{bpp:2}),u()(Jt,33321,{gl2:!0,bpp:1}),u()(Jt,33330,{gl2:!0,bpp:1}),u()(Jt,33329,{gl2:!0,bpp:1}),u()(Jt,33332,{gl2:!0,bpp:2}),u()(Jt,33331,{gl2:!0,bpp:2}),u()(Jt,33334,{gl2:!0,bpp:4}),u()(Jt,33333,{gl2:!0,bpp:4}),u()(Jt,33323,{gl2:!0,bpp:2}),u()(Jt,33336,{gl2:!0,bpp:2}),u()(Jt,33335,{gl2:!0,bpp:2}),u()(Jt,33338,{gl2:!0,bpp:4}),u()(Jt,33337,{gl2:!0,bpp:4}),u()(Jt,33340,{gl2:!0,bpp:8}),u()(Jt,33339,{gl2:!0,bpp:8}),u()(Jt,32849,{gl2:!0,bpp:3}),u()(Jt,32856,{gl2:!0,bpp:4}),u()(Jt,32857,{gl2:!0,bpp:4}),u()(Jt,36220,{gl2:!0,bpp:4}),u()(Jt,36238,{gl2:!0,bpp:4}),u()(Jt,36975,{gl2:!0,bpp:4}),u()(Jt,36214,{gl2:!0,bpp:8}),u()(Jt,36232,{gl2:!0,bpp:8}),u()(Jt,36226,{gl2:!0,bpp:16}),u()(Jt,36208,{gl2:!0,bpp:16}),u()(Jt,33325,{gl2:tn,bpp:2}),u()(Jt,33327,{gl2:tn,bpp:4}),u()(Jt,34842,{gl2:tn,bpp:8}),u()(Jt,33326,{gl2:tn,bpp:4}),u()(Jt,33328,{gl2:tn,bpp:8}),u()(Jt,34836,{gl2:tn,bpp:16}),u()(Jt,35898,{gl2:tn,bpp:4}),Jt);function rn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}function an(e,t,n){var r=n[t];if(!r)return!1;var i=j(e)&&r.gl2||r.gl1;return"string"==typeof i?e.getExtension(i):i}var on=function(e){it()(n,e);var t=rn(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),(r=t.call(this,e,i)).initialize(i),Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Renderbuffer"}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{format:null},n=t.format;return!n||an(e,n,nn)}},{key:"getSamplesForFormat",value:function(e,t){var n=t.format;return e.getInternalformatParameter(36161,n,32937)}}]),h()(n,[{key:"initialize",value:function(e){var t=e.format,n=e.width,r=void 0===n?1:n,i=e.height,a=void 0===i?1:i,o=e.samples,s=void 0===o?0:o;return ct(t,"Needs format"),this._trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),0!==s&&j(this.gl)?this.gl.renderbufferStorageMultisample(36161,s,t,r,a):this.gl.renderbufferStorage(36161,t,r,a),this.format=t,this.width=r,this.height=a,this.samples=s,this._trackAllocatedMemory(this.width*this.height*(this.samples||1)*nn[this.format].bpp),this}},{key:"resize",value:function(e){var t=e.width,n=e.height;return t!==this.width||n!==this.height?this.initialize({width:t,height:n,format:this.format,samples:this.samples}):this}},{key:"_createHandle",value:function(){return this.gl.createRenderbuffer()}},{key:"_deleteHandle",value:function(){this.gl.deleteRenderbuffer(this.handle),this._trackDeallocatedMemory()}},{key:"_bindHandle",value:function(e){this.gl.bindRenderbuffer(36161,e)}},{key:"_syncHandle",value:function(e){this.format=this.getParameter(36164),this.width=this.getParameter(36162),this.height=this.getParameter(36163),this.samples=this.getParameter(36011)}},{key:"_getParameter",value:function(e){return this.gl.bindRenderbuffer(36161,this.handle),this.gl.getRenderbufferParameter(36161,e)}}]),n}(bt);function sn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.framebuffer,r=void 0===n?null:n,i=t.color,a=void 0===i?null:i,o=t.depth,s=void 0===o?null:o,u=t.stencil,c=void 0===u?null:u,l={};r&&(l.framebuffer=r);var f=0;a&&(f|=16384,!0!==a&&(l.clearColor=a)),s&&(f|=256,!0!==s&&(l.clearDepth=s)),c&&(f|=1024,!0!==s&&(l.clearStencil=s)),ct(0!==f,"clear: bad arguments"),Ie(e,l,(function(){e.clear(f)}))}function un(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.framebuffer,r=void 0===n?null:n,i=t.buffer,a=void 0===i?6144:i,o=t.drawBuffer,s=void 0===o?0:o,u=t.value,c=void 0===u?[0,0,0,0]:u;V(e),Ie(e,{framebuffer:r},(function(){switch(a){case 6144:switch(c.constructor){case Int32Array:e.clearBufferiv(a,s,c);break;case Uint32Array:e.clearBufferuiv(a,s,c);break;case Float32Array:default:e.clearBufferfv(a,s,c)}break;case 6145:e.clearBufferfv(6145,0,[c]);break;case 6146:e.clearBufferiv(6146,0,[c]);break;case 34041:var t=ae()(c,2),n=t[0],r=t[1];e.clearBufferfi(34041,0,n,r);break;default:ct(!1,"clear: bad arguments")}}))}function cn(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return ct(!1),0}}var ln=n(14),fn=n.n(ln),hn=n(21),dn=n.n(hn);function vn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var gn=[34069,34070,34071,34072,34073,34074],pn=function(e){it()(r,e);var t,n=vn(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),U(e),(t=n.call(this,e,Object.assign({},i,{target:34067}))).initialize(i),Object.seal(et()(t)),t}return h()(r,[{key:Symbol.toStringTag,get:function(){return"TextureCube"}}]),h()(r,[{key:"initialize",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.mipmaps,r=void 0===n||n,i=t.parameters,a=void 0===i?{}:i;return this.opts=t,this.setCubeMapImageData(t).then((function(){e.loaded=!0,r&&e.generateMipmap(t),e.setParameters(a)})),this}},{key:"subImage",value:function(e){var t=e.face,n=e.data,r=e.x,i=void 0===r?0:r,a=e.y,o=void 0===a?0:a,s=e.mipmapLevel,u=void 0===s?0:s;return this._subImage({target:t,data:n,x:i,y:o,mipmapLevel:u})}},{key:"setCubeMapImageData",value:(t=dn()(fn.a.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,h,d,v,g=this;return fn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.width,r=t.height,i=t.pixels,a=t.data,o=t.border,s=void 0===o?0:o,u=t.format,c=void 0===u?6408:u,l=t.type,f=void 0===l?5121:l,h=this.gl,d=i||a,e.next=5,Promise.all(gn.map((function(e){var t=d[e];return Promise.all(Array.isArray(t)?t:[t])})));case 5:v=e.sent,this.bind(),gn.forEach((function(e,t){v[t].length>1&&!1!==g.opts.mipmaps&&N.warn("".concat(g.id," has mipmap and multiple LODs."))(),v[t].forEach((function(t,i){n&&r?h.texImage2D(e,i,c,n,r,s,c,f,t):h.texImage2D(e,i,c,c,f,t)}))})),this.unbind();case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setImageDataForFace",value:function(e){var t=this,n=e.face,r=e.width,i=e.height,a=e.pixels,o=e.data,s=e.border,u=void 0===s?0:s,c=e.format,l=void 0===c?6408:c,f=e.type,h=void 0===f?5121:f,d=this.gl,v=a||o;return this.bind(),v instanceof Promise?v.then((function(r){return t.setImageDataForFace(Object.assign({},e,{face:n,data:r,pixels:r}))})):this.width||this.height?d.texImage2D(n,0,l,r,i,u,l,h,v):d.texImage2D(n,0,l,l,h,v),this}}]),r}(Yt);function mn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}pn.FACES=gn;var yn=function(e){it()(n,e);var t=mn(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),V(e),i=Object.assign({depth:1},i,{target:32879,unpackFlipY:!1}),(r=t.call(this,e,i)).initialize(i),Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Texture3D"}}],[{key:"isSupported",value:function(e){return j(e)}}]),h()(n,[{key:"setImageData",value:function(e){var t=this,n=e.level,r=void 0===n?0:n,i=e.dataFormat,a=void 0===i?6408:i,o=e.width,s=e.height,u=e.depth,c=void 0===u?1:u,l=e.border,f=void 0===l?0:l,h=e.format,d=e.type,v=void 0===d?5121:d,g=e.offset,p=void 0===g?0:g,m=e.data,y=e.parameters,_=void 0===y?{}:y;if(this._trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle),Ie(this.gl,_,(function(){ArrayBuffer.isView(m)&&t.gl.texImage3D(t.target,r,a,o,s,c,f,h,v,m),m instanceof Bt&&(t.gl.bindBuffer(35052,m.handle),t.gl.texImage3D(t.target,r,a,o,s,c,f,h,v,p))})),m&&m.byteLength)this._trackAllocatedMemory(m.byteLength,"Texture");else{var b=Ut[this.dataFormat]||4,A=Vt[this.type]||1;this._trackAllocatedMemory(this.width*this.height*this.depth*b*A,"Texture")}return this.loaded=!0,this}}]),n}(Yt);function _n(e,t){ct(e instanceof en||e instanceof pn||e instanceof yn);var n=e.constructor,r=e.gl,i=e.width,a=e.height,o=e.format,s=e.type,u=e.dataFormat,c=e.border,l=e.mipmaps;return new n(r,Object.assign({width:i,height:a,format:o,type:s,dataFormat:u,border:c,mipmaps:l},t))}function bn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.sourceX,r=void 0===n?0:n,i=t.sourceY,a=void 0===i?0:i,o=t.sourceFormat,s=void 0===o?6408:o,u=t.sourceAttachment,c=void 0===u?36064:u,l=t.target,f=void 0===l?null:l,h=t.sourceWidth,d=t.sourceHeight,v=t.sourceType,g=Tn(e),p=g.framebuffer,m=g.deleteFramebuffer;ct(p);var y=p.gl,_=p.handle,b=p.attachments;h=h||p.width,d=d||p.height,36064===c&&null===_&&(c=1028),ct(b[c]),f=kn(f,v=v||b[c].type,s,h,d),v=v||Et(f);var A=y.bindFramebuffer(36160,_);return y.readPixels(r,a,h,d,s,v,f),y.bindFramebuffer(36160,A||null),m&&p.delete(),f}function An(e,t){var n=t.sourceX,r=void 0===n?0:n,i=t.sourceY,a=void 0===i?0:i,o=t.sourceFormat,s=void 0===o?6408:o,u=t.target,c=void 0===u?null:u,l=t.targetByteOffset,f=void 0===l?0:l,h=t.sourceWidth,d=t.sourceHeight,v=t.sourceType,g=Tn(e),p=g.framebuffer,m=g.deleteFramebuffer;ct(p),h=h||p.width,d=d||p.height;var y=V(p.gl);if(v=v||(c?c.type:5121),!c){var _=cn(s),b=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return ct(!1),0}}(v);c=new Bt(y,{byteLength:f+h*d*_*b,accessor:{type:v,size:_}})}return c.bind({target:35051}),Ie(y,{framebuffer:p},(function(){y.readPixels(r,a,h,d,s,v,f)})),c.unbind({target:35051}),m&&p.delete(),c}function xn(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.sourceAttachment,r=void 0===n?36064:n,i=t.targetMaxHeight,a=void 0===i?Number.MAX_SAFE_INTEGER:i,o=bn(e,{sourceAttachment:r}),s=e.width,u=e.height;u>a;){var c=wt({data:o,width:s,height:u});o=c.data,s=c.width,u=c.height}kt({data:o,width:s,height:u});var l=document.createElement("canvas");l.width=s,l.height=u;var f=l.getContext("2d"),h=f.createImageData(s,u);return h.data.set(o),f.putImageData(h,0,0),l.toDataURL()}function En(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.sourceX,i=void 0===r?0:r,a=n.sourceY,o=void 0===a?0:a,s=n.targetMipmaplevel,u=void 0===s?0:s,c=n.targetInternalFormat,l=void 0===c?6408:c,f=n.targetX,h=n.targetY,d=n.targetZ,v=n.width,g=n.height,p=Tn(e),m=p.framebuffer,y=p.deleteFramebuffer;ct(m);var _=m.gl,b=m.handle,A=void 0!==f||void 0!==h||void 0!==d;f=f||0,h=h||0,d=d||0;var x=_.bindFramebuffer(36160,b);ct(t);var E=null;if(t instanceof Yt&&(E=t,v=Number.isFinite(v)?v:E.width,g=Number.isFinite(g)?g:E.height,E.bind(0),t=E.target),A)switch(t){case 3553:case 34067:_.copyTexSubImage2D(t,u,f,h,i,o,v,g);break;case 35866:case 32879:var T=V(_);T.copyTexSubImage3D(t,u,f,h,d,i,o,v,g)}else _.copyTexImage2D(t,u,l,i,o,v,g,0);return E&&E.unbind(),_.bindFramebuffer(36160,x||null),y&&m.delete(),E}function Tn(e){return e instanceof Cn?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:(t=e,r=t.gl,i=t.width,a=t.height,o=t.id,new Cn(r,Object.assign({},n,{id:"framebuffer-for-".concat(o),width:i,height:a,attachments:u()({},36064,t)}))),deleteFramebuffer:!0};var t,n,r,i,a,o}function kn(e,t,n,r,i){return e||new(Tt(t=t||5121,{clamped:!1}))(r*i*cn(n))}function wn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return On(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return On(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function On(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Sn(e,t){return Ln(e,t)}function Ln(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return In(e,t)}))}function In(e,t){return e.luma=e.luma||{},e.luma.caps=e.luma.caps||{},void 0===e.luma.caps[t]&&(e.luma.caps[t]=function(e,t){var n,r=Bn[t];ct(r,t);var i=j(e)&&r[1]||r[0];if("function"==typeof i)n=i(e);else if(Array.isArray(i)){n=!0;var a,o=wn(i);try{for(o.s();!(a=o.n()).done;){var s=a.value;n=n&&Boolean(e.getExtension(s))}}catch(e){o.e(e)}finally{o.f()}}else"string"==typeof i?n=Boolean(e.getExtension(i)):"boolean"==typeof i?n=i:ct(!1);return n}(e,t)),e.luma.caps[t]||N.log(2,"Feature: ".concat(t," not supported"))(),e.luma.caps[t]}function Pn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Rn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Rn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Rn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Fn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Cn=function(e){it()(n,e);var t=Fn(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),(r=t.call(this,e,i)).width=null,r.height=null,r.attachments={},r.readBuffer=36064,r.drawBuffers=[36064],r.ownResources=[],r.initialize(i),Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Framebuffer"}},{key:"MAX_COLOR_ATTACHMENTS",get:function(){var e=V(this.gl);return e.getParameter(e.MAX_COLOR_ATTACHMENTS)}},{key:"MAX_DRAW_BUFFERS",get:function(){var e=V(this.gl);return e.getParameter(e.MAX_DRAW_BUFFERS)}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.colorBufferFloat,r=t.colorBufferHalfFloat,i=!0;return n&&(i=Boolean(e.getExtension("EXT_color_buffer_float")||e.getExtension("WEBGL_color_buffer_float")||e.getExtension("OES_texture_float"))),r&&(i=i&&Boolean(e.getExtension("EXT_color_buffer_float")||e.getExtension("EXT_color_buffer_half_float"))),i}},{key:"getDefaultFramebuffer",value:function(e){return e.luma=e.luma||{},e.luma.defaultFramebuffer=e.luma.defaultFramebuffer||new n(e,{id:"default-framebuffer",handle:null,attachments:{}}),e.luma.defaultFramebuffer}}]),h()(n,[{key:"initialize",value:function(e){var t=e.width,n=void 0===t?1:t,r=e.height,i=void 0===r?1:r,a=e.attachments,o=void 0===a?null:a,s=e.color,u=void 0===s||s,c=e.depth,l=void 0===c||c,f=e.stencil,h=void 0!==f&&f,d=e.check,v=void 0===d||d,g=e.readBuffer,p=void 0===g?void 0:g,m=e.drawBuffers,y=void 0===m?void 0:m;if(ct(n>=0&&i>=0,"Width and height need to be integers"),this.width=n,this.height=i,o)for(var _ in o){var b=o[_];(Array.isArray(b)?b[0]:b).resize({width:n,height:i})}else o=this._createDefaultAttachments(u,l,h,n,i);this.update({clearAttachments:!0,attachments:o,readBuffer:p,drawBuffers:y}),o&&v&&this.checkStatus()}},{key:"delete",value:function(){var e,t=Pn(this.ownResources);try{for(t.s();!(e=t.n()).done;){e.value.delete()}}catch(e){t.e(e)}finally{t.f()}return nt()(ut()(n.prototype),"delete",this).call(this),this}},{key:"update",value:function(e){var t=e.attachments,n=void 0===t?{}:t,r=e.readBuffer,i=e.drawBuffers,a=e.clearAttachments,o=void 0!==a&&a,s=e.resizeAttachments,u=void 0===s||s;this.attach(n,{clearAttachments:o,resizeAttachments:u});var c=this.gl,l=c.bindFramebuffer(36160,this.handle);return r&&this._setReadBuffer(r),i&&this._setDrawBuffers(i),c.bindFramebuffer(36160,l||null),this}},{key:"resize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.width,n=e.height;if(null===this.handle)return ct(void 0===t&&void 0===n),this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;for(var r in void 0===t&&(t=this.gl.drawingBufferWidth),void 0===n&&(n=this.gl.drawingBufferHeight),t!==this.width&&n!==this.height&&N.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(t,"x").concat(n))(),this.attachments)this.attachments[r].resize({width:t,height:n});return this.width=t,this.height=n,this}},{key:"attach",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.clearAttachments,i=void 0!==r&&r,a=n.resizeAttachments,o=void 0===a||a,s={};i&&Object.keys(this.attachments).forEach((function(e){s[e]=null})),Object.assign(s,e);var u=this.gl.bindFramebuffer(36160,this.handle);for(var c in s){ct(void 0!==c,"Misspelled framebuffer binding point?");var l=Number(c),f=s[l],h=f;if(h)if(h instanceof on)this._attachRenderbuffer({attachment:l,renderbuffer:h});else if(Array.isArray(f)){var d=ae()(f,3),v=d[0],g=d[1],p=void 0===g?0:g,m=d[2],y=void 0===m?0:m;h=v,this._attachTexture({attachment:l,texture:v,layer:p,level:y})}else this._attachTexture({attachment:l,texture:h,layer:0,level:0});else this._unattach(l);o&&h&&h.resize({width:this.width,height:this.height})}this.gl.bindFramebuffer(36160,u||null),Object.assign(this.attachments,e),Object.keys(this.attachments).filter((function(e){return!t.attachments[e]})).forEach((function(e){delete t.attachments[e]}))}},{key:"checkStatus",value:function(){this.gl;var e=this.getStatus();if(36053!==e)throw new Error(function(e){return(Cn.STATUS||{})[e]||"Framebuffer error ".concat(e)}(e));return this}},{key:"getStatus",value:function(){var e=this.gl,t=e.bindFramebuffer(36160,this.handle),n=e.checkFramebufferStatus(36160);return e.bindFramebuffer(36160,t||null),n}},{key:"clear",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.color,r=t.depth,i=t.stencil,a=t.drawBuffers,o=void 0===a?[]:a,s=this.gl.bindFramebuffer(36160,this.handle);return(n||r||i)&&sn(this.gl,{color:n,depth:r,stencil:i}),o.forEach((function(t,n){un(e.gl,{drawBuffer:n,value:t})})),this.gl.bindFramebuffer(36160,s||null),this}},{key:"readPixels",value:function(){return N.error("Framebuffer.readPixels() is no logner supported, use readPixelsToArray(framebuffer)")(),null}},{key:"readPixelsToBuffer",value:function(){return N.error("Framebuffer.readPixelsToBuffer()is no logner supported, use readPixelsToBuffer(framebuffer)")(),null}},{key:"copyToDataUrl",value:function(){return N.error("Framebuffer.copyToDataUrl() is no logner supported, use copyToDataUrl(framebuffer)")(),null}},{key:"copyToImage",value:function(){return N.error("Framebuffer.copyToImage() is no logner supported, use copyToImage(framebuffer)")(),null}},{key:"copyToTexture",value:function(){return N.error("Framebuffer.copyToTexture({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}},{key:"blit",value:function(){return N.error("Framebuffer.blit({...}) is no logner supported, use blit(source, target, opts)")(),null}},{key:"invalidate",value:function(e){var t=e.attachments,n=void 0===t?[]:t,r=e.x,i=void 0===r?0:r,a=e.y,o=void 0===a?0:a,s=e.width,u=e.height,c=V(this.gl),l=c.bindFramebuffer(36008,this.handle);return 0===i&&0===o&&void 0===s&&void 0===u?c.invalidateFramebuffer(36008,n):c.invalidateFramebuffer(36008,n,i,o,s,u),c.bindFramebuffer(36008,l),this}},{key:"getAttachmentParameter",value:function(e,t,n){var r=this._getAttachmentParameterFallback(t);return null===r&&(this.gl.bindFramebuffer(36160,this.handle),r=this.gl.getFramebufferAttachmentParameter(36160,e,t),this.gl.bindFramebuffer(36160,null)),n&&r>1e3&&(r=ft(this.gl,r)),r}},{key:"getAttachmentParameters",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36064,n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.constructor.ATTACHMENT_PARAMETERS||[],i={},a=Pn(r);try{for(a.s();!(e=a.n()).done;){var o=e.value,s=n?ft(this.gl,o):o;i[s]=this.getAttachmentParameter(t,o,n)}}catch(e){a.e(e)}finally{a.f()}return i}},{key:"getParameters",value:function(){for(var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=Object.keys(this.attachments),n={},r=0,i=t;r<i.length;r++){var a=i[r],o=Number(a),s=e?ft(this.gl,o):o;n[s]=this.getAttachmentParameters(o,e)}return n}},{key:"show",value:function(){return"undefined"!=typeof window&&window.open(xn(this),"luma-debug-texture"),this}},{key:"log",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e>N.level||"undefined"==typeof window)return this;t=t||"Framebuffer ".concat(this.id);var n=xn(this,{targetMaxHeight:100});return N.image({logLevel:e,message:t,image:n},t)(),this}},{key:"bind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?36160:t;return this.gl.bindFramebuffer(n,this.handle),this}},{key:"unbind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?36160:t;return this.gl.bindFramebuffer(n,null),this}},{key:"_createDefaultAttachments",value:function(e,t,n,r,i){var a,o=null;e&&((o=o||{})[36064]=new en(this.gl,{id:"".concat(this.id,"-color0"),pixels:null,format:6408,type:5121,width:r,height:i,mipmaps:!1,parameters:(a={},u()(a,10241,9729),u()(a,10240,9729),u()(a,10242,33071),u()(a,10243,33071),a)}),this.ownResources.push(o[36064]));return t&&n?((o=o||{})[33306]=new on(this.gl,{id:"".concat(this.id,"-depth-stencil"),format:35056,width:r,height:111}),this.ownResources.push(o[33306])):t?((o=o||{})[36096]=new on(this.gl,{id:"".concat(this.id,"-depth"),format:33189,width:r,height:i}),this.ownResources.push(o[36096])):n&&ct(!1),o}},{key:"_unattach",value:function(e){var t=this.attachments[e];t&&(t instanceof on?this.gl.framebufferRenderbuffer(36160,e,36161,null):this.gl.framebufferTexture2D(36160,e,3553,null,0),delete this.attachments[e])}},{key:"_attachRenderbuffer",value:function(e){var t=e.attachment,n=void 0===t?36064:t,r=e.renderbuffer;this.gl.framebufferRenderbuffer(36160,n,36161,r.handle),this.attachments[n]=r}},{key:"_attachTexture",value:function(e){var t=e.attachment,n=void 0===t?36064:t,r=e.texture,i=e.layer,a=e.level,o=this.gl;switch(o.bindTexture(r.target,r.handle),r.target){case 35866:case 32879:V(o).framebufferTextureLayer(36160,n,r.target,a,i);break;case 34067:var s=function(e){return e<34069?e+34069:e}(i);o.framebufferTexture2D(36160,n,s,r.handle,a);break;case 3553:o.framebufferTexture2D(36160,n,3553,r.handle,a);break;default:ct(!1,"Illegal texture type")}o.bindTexture(r.target,null),this.attachments[n]=r}},{key:"_setReadBuffer",value:function(e){var t,n=j(t=this.gl)?t:null;n?n.readBuffer(e):ct(36064===e||1029===e,"Multiple render targets not supported"),this.readBuffer=e}},{key:"_setDrawBuffers",value:function(e){var t=this.gl,n=V(t);if(n)n.drawBuffers(e);else{var r=t.getExtension("WEBGL_draw_buffers");r?r.drawBuffersWEBGL(e):ct(1===e.length&&(36064===e[0]||1029===e[0]),"Multiple render targets not supported")}this.drawBuffers=e}},{key:"_getAttachmentParameterFallback",value:function(e){var t=function(e){for(var t in e.luma=e.luma||{},e.luma.caps=e.luma.caps||{},Bn)void 0===e.luma.caps[t]&&(e.luma.caps[t]=In(e,t));return e.luma.caps}(this.gl);switch(e){case 36052:return t.WEBGL2?null:0;case 33298:case 33299:case 33300:case 33301:case 33302:case 33303:return t.WEBGL2?null:8;case 33297:return t.WEBGL2?null:5125;case 33296:return t.WEBGL2||t.EXT_sRGB?null:9729;default:return null}}},{key:"_createHandle",value:function(){return this.gl.createFramebuffer()}},{key:"_deleteHandle",value:function(){this.gl.deleteFramebuffer(this.handle)}},{key:"_bindHandle",value:function(e){return this.gl.bindFramebuffer(36160,e)}},{key:"color",get:function(){return this.attachments[36064]||null}},{key:"texture",get:function(){return this.attachments[36064]||null}},{key:"depth",get:function(){return this.attachments[36096]||this.attachments[33306]||null}},{key:"stencil",get:function(){return this.attachments[36128]||this.attachments[33306]||null}}]),n}(bt);var Mn;Cn.ATTACHMENT_PARAMETERS=[36049,36048,33296,33298,33299,33300,33301,33302,33303];var Nn={WEBGL2:"WEBGL2",VERTEX_ARRAY_OBJECT:"VERTEX_ARRAY_OBJECT",TIMER_QUERY:"TIMER_QUERY",INSTANCED_RENDERING:"INSTANCED_RENDERING",MULTIPLE_RENDER_TARGETS:"MULTIPLE_RENDER_TARGETS",ELEMENT_INDEX_UINT32:"ELEMENT_INDEX_UINT32",BLEND_EQUATION_MINMAX:"BLEND_EQUATION_MINMAX",FLOAT_BLEND:"FLOAT_BLEND",COLOR_ENCODING_SRGB:"COLOR_ENCODING_SRGB",TEXTURE_DEPTH:"TEXTURE_DEPTH",TEXTURE_FLOAT:"TEXTURE_FLOAT",TEXTURE_HALF_FLOAT:"TEXTURE_HALF_FLOAT",TEXTURE_FILTER_LINEAR_FLOAT:"TEXTURE_FILTER_LINEAR_FLOAT",TEXTURE_FILTER_LINEAR_HALF_FLOAT:"TEXTURE_FILTER_LINEAR_HALF_FLOAT",TEXTURE_FILTER_ANISOTROPIC:"TEXTURE_FILTER_ANISOTROPIC",COLOR_ATTACHMENT_RGBA32F:"COLOR_ATTACHMENT_RGBA32F",COLOR_ATTACHMENT_FLOAT:"COLOR_ATTACHMENT_FLOAT",COLOR_ATTACHMENT_HALF_FLOAT:"COLOR_ATTACHMENT_HALF_FLOAT",GLSL_FRAG_DATA:"GLSL_FRAG_DATA",GLSL_FRAG_DEPTH:"GLSL_FRAG_DEPTH",GLSL_DERIVATIVES:"GLSL_DERIVATIVES",GLSL_TEXTURE_LOD:"GLSL_TEXTURE_LOD"};var Dn,Bn=(Mn={},u()(Mn,Nn.WEBGL2,[!1,!0]),u()(Mn,Nn.VERTEX_ARRAY_OBJECT,["OES_vertex_array_object",!0]),u()(Mn,Nn.TIMER_QUERY,["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"]),u()(Mn,Nn.INSTANCED_RENDERING,["ANGLE_instanced_arrays",!0]),u()(Mn,Nn.MULTIPLE_RENDER_TARGETS,["WEBGL_draw_buffers",!0]),u()(Mn,Nn.ELEMENT_INDEX_UINT32,["OES_element_index_uint",!0]),u()(Mn,Nn.BLEND_EQUATION_MINMAX,["EXT_blend_minmax",!0]),u()(Mn,Nn.FLOAT_BLEND,["EXT_float_blend"]),u()(Mn,Nn.COLOR_ENCODING_SRGB,["EXT_sRGB",!0]),u()(Mn,Nn.TEXTURE_DEPTH,["WEBGL_depth_texture",!0]),u()(Mn,Nn.TEXTURE_FLOAT,["OES_texture_float",!0]),u()(Mn,Nn.TEXTURE_HALF_FLOAT,["OES_texture_half_float",!0]),u()(Mn,Nn.TEXTURE_FILTER_LINEAR_FLOAT,["OES_texture_float_linear"]),u()(Mn,Nn.TEXTURE_FILTER_LINEAR_HALF_FLOAT,["OES_texture_half_float_linear"]),u()(Mn,Nn.TEXTURE_FILTER_ANISOTROPIC,["EXT_texture_filter_anisotropic"]),u()(Mn,Nn.COLOR_ATTACHMENT_RGBA32F,[function(e){var t=new en(e,{format:6408,type:5126,dataFormat:6408}),n=new Cn(e,{id:"test-framebuffer",check:!1,attachments:u()({},36064,t)}),r=n.getStatus();return t.delete(),n.delete(),36053===r},"EXT_color_buffer_float"]),u()(Mn,Nn.COLOR_ATTACHMENT_FLOAT,[!1,"EXT_color_buffer_float"]),u()(Mn,Nn.COLOR_ATTACHMENT_HALF_FLOAT,["EXT_color_buffer_half_float"]),u()(Mn,Nn.GLSL_FRAG_DATA,["WEBGL_draw_buffers",!0]),u()(Mn,Nn.GLSL_FRAG_DEPTH,["EXT_frag_depth",!0]),u()(Mn,Nn.GLSL_DERIVATIVES,["OES_standard_derivatives",!0]),u()(Mn,Nn.GLSL_TEXTURE_LOD,["EXT_shader_texture_lod",!0]),Mn),jn=(Dn={},u()(Dn,5126,er.bind(null,"uniform1fv",Wn,1,tr)),u()(Dn,35664,er.bind(null,"uniform2fv",Wn,2,tr)),u()(Dn,35665,er.bind(null,"uniform3fv",Wn,3,tr)),u()(Dn,35666,er.bind(null,"uniform4fv",Wn,4,tr)),u()(Dn,5124,er.bind(null,"uniform1iv",Xn,1,tr)),u()(Dn,35667,er.bind(null,"uniform2iv",Xn,2,tr)),u()(Dn,35668,er.bind(null,"uniform3iv",Xn,3,tr)),u()(Dn,35669,er.bind(null,"uniform4iv",Xn,4,tr)),u()(Dn,35670,er.bind(null,"uniform1iv",Xn,1,tr)),u()(Dn,35671,er.bind(null,"uniform2iv",Xn,2,tr)),u()(Dn,35672,er.bind(null,"uniform3iv",Xn,3,tr)),u()(Dn,35673,er.bind(null,"uniform4iv",Xn,4,tr)),u()(Dn,35674,er.bind(null,"uniformMatrix2fv",Wn,4,nr)),u()(Dn,35675,er.bind(null,"uniformMatrix3fv",Wn,9,nr)),u()(Dn,35676,er.bind(null,"uniformMatrix4fv",Wn,16,nr)),u()(Dn,35678,Jn),u()(Dn,35680,Jn),u()(Dn,5125,er.bind(null,"uniform1uiv",qn,1,tr)),u()(Dn,36294,er.bind(null,"uniform2uiv",qn,2,tr)),u()(Dn,36295,er.bind(null,"uniform3uiv",qn,3,tr)),u()(Dn,36296,er.bind(null,"uniform4uiv",qn,4,tr)),u()(Dn,35685,er.bind(null,"uniformMatrix2x3fv",Wn,6,nr)),u()(Dn,35686,er.bind(null,"uniformMatrix2x4fv",Wn,8,nr)),u()(Dn,35687,er.bind(null,"uniformMatrix3x2fv",Wn,6,nr)),u()(Dn,35688,er.bind(null,"uniformMatrix3x4fv",Wn,12,nr)),u()(Dn,35689,er.bind(null,"uniformMatrix4x2fv",Wn,8,nr)),u()(Dn,35690,er.bind(null,"uniformMatrix4x3fv",Wn,12,nr)),u()(Dn,35678,Jn),u()(Dn,35680,Jn),u()(Dn,35679,Jn),u()(Dn,35682,Jn),u()(Dn,36289,Jn),u()(Dn,36292,Jn),u()(Dn,36293,Jn),u()(Dn,36298,Jn),u()(Dn,36299,Jn),u()(Dn,36300,Jn),u()(Dn,36303,Jn),u()(Dn,36306,Jn),u()(Dn,36307,Jn),u()(Dn,36308,Jn),u()(Dn,36311,Jn),Dn),Un={},Vn={},Gn={},zn=[0];function Hn(e,t,n,r){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(zn[0]=e,e=zn);var i=e.length;if(i%t&&N.warn("Uniform size should be multiples of ".concat(t),e)(),e instanceof n)return e;var a=r[i];a||(a=new n(i),r[i]=a);for(var o=0;o<i;o++)a[o]=e[o];return a}function Wn(e,t){return Hn(e,t,Float32Array,Un)}function Xn(e,t){return Hn(e,t,Int32Array,Vn)}function qn(e,t){return Hn(e,t,Uint32Array,Gn)}function Kn(e,t,n){var r=jn[n.type];if(!r)throw new Error("Unknown GLSL uniform type ".concat(n.type));return r().bind(null,e,t)}function Yn(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(/([^[]*)(\[[0-9]+\])?/);if(!t||t.length<2)throw new Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:t[2]||1,isArray:Boolean(t[2])}}function Qn(e,t,n){for(var r in e){var i=e[r];if((!n||Boolean(n[r]))&&!$n(i))throw t=t?"".concat(t," "):"",console.error("".concat(t," Bad uniform ").concat(r),i),new Error("".concat(t," Bad uniform ").concat(r))}return!0}function $n(e){return Array.isArray(e)||ArrayBuffer.isView(e)?function(e){if(0===e.length)return!1;for(var t=Math.min(e.length,16),n=0;n<t;++n)if(!Number.isFinite(e[n]))return!1;return!0}(e):!!isFinite(e)||(!0===e||!1===e||(e instanceof Yt||(e instanceof on||e instanceof Cn&&Boolean(e.texture))))}function Zn(e,t,n){if(Array.isArray(n)||ArrayBuffer.isView(n))if(e[t])for(var r=e[t],i=0,a=n.length;i<a;++i)r[i]=n[i];else e[t]=n.slice();else e[t]=n}function Jn(){var e=null;return function(t,n,r){var i=e!==r;return i&&(t.uniform1i(n,r),e=r),i}}function er(e,t,n,r){var i=null,a=null;return function(o,s,u){var c=t(u,n),l=c.length,f=!1;if(null===i)i=new Float32Array(l),a=l,f=!0;else{ct(a===l,"Uniform length cannot change.");for(var h=0;h<l;++h)if(c[h]!==i[h]){f=!0;break}}return f&&(r(o,e,s,c),i.set(c)),f}}function tr(e,t,n,r){e[t](n,r)}function nr(e,t,n,r){e[t](n,!1,r)}function rr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unnamed",n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/,r=e.match(n);return r?r[1]:t}function ir(e,t,n,r){for(var i=e.split(/\r?\n/),a={},o={},s=r||rr(t)||"(unnamed)",u="".concat(function(e){switch(e){case 35632:return"fragment";case 35633:return"vertex";default:return"unknown type"}}(n)," shader ").concat(s),c=0;c<i.length;c++){var l=i[c];if(!(l.length<=1)){var f=l.split(":"),h=f[0],d=parseInt(f[2],10);if(isNaN(d))throw new Error("GLSL compilation error in ".concat(u,": ").concat(e));"WARNING"!==h?a[d]=l:o[d]=l}}var v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:": ",r=e.split(/\r?\n/),i=String(r.length+t-1).length;return r.map((function(e,r){var a=String(r+t),o=a.length;return or(a,i-o)+n+e}))}(t);return{shaderName:u,errors:ar(a,v),warnings:ar(o,v)}}function ar(e,t){for(var n="",r=0;r<t.length;r++){var i=t[r];if((e[r+3]||e[r+2]||e[r+1])&&(n+="".concat(i,"\n"),e[r+1])){var a=e[r+1],o=a.split(":",3),s=o[0],u=parseInt(o[1],10)||0,c=a.substring(o.join(":").length+1).trim();n+=or("^^^ ".concat(s,": ").concat(c,"\n\n"),u)}}return n}function or(e,t){for(var n="",r=0;r<t;++r)n+=" ";return"".concat(n).concat(e)}function sr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var ur,cr=function(e){it()(n,e);var t=sr(n);function n(e,r){var i;l()(this,n),U(e),ct("string"==typeof r.source,"Shader: GLSL source code must be a JavaScript string");var a=rr(r.source,null)||r.id||dt("unnamed ".concat(n.getTypeName(r.shaderType)));return(i=t.call(this,e,{id:a})).shaderType=r.shaderType,i.source=r.source,i.initialize(r),i}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Shader"}}],[{key:"getTypeName",value:function(e){switch(e){case 35633:return"vertex-shader";case 35632:return"fragment-shader";default:return ct(!1),"unknown"}}}]),h()(n,[{key:"initialize",value:function(e){var t=e.source,n=rr(t,null);n&&(this.id=dt(n)),this._compile(t)}},{key:"getParameter",value:function(e){return this.gl.getShaderParameter(this.handle,e)}},{key:"toString",value:function(){return"".concat(n.getTypeName(this.shaderType),":").concat(this.id)}},{key:"getName",value:function(){return rr(this.source)||"unnamed-shader"}},{key:"getSource",value:function(){return this.gl.getShaderSource(this.handle)}},{key:"getTranslatedSource",value:function(){var e=this.gl.getExtension("WEBGL_debug_shaders");return e?e.getTranslatedShaderSource(this.handle):"No translated source available. WEBGL_debug_shaders not implemented"}},{key:"_compile",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.source;e.startsWith("#version ")||(e="#version 100\n".concat(e)),this.source=e,this.gl.shaderSource(this.handle,this.source),this.gl.compileShader(this.handle);var t=this.getParameter(35713);if(!t){var n=this.gl.getShaderInfoLog(this.handle),r=ir(n,this.source,this.shaderType,this.id),i=r.shaderName,a=r.errors,o=r.warnings;throw N.error("GLSL compilation errors in ".concat(i,"\n").concat(a))(),N.warn("GLSL compilation warnings in ".concat(i,"\n").concat(o))(),new Error("GLSL compilation errors in ".concat(i))}}},{key:"_deleteHandle",value:function(){this.gl.deleteShader(this.handle)}},{key:"_getOptsFromHandle",value:function(){return{type:this.getParameter(35663),source:this.getSource()}}}]),n}(bt),lr=function(e){it()(n,e);var t=sr(n);function n(e,r){return l()(this,n),"string"==typeof r&&(r={source:r}),t.call(this,e,Object.assign({},r,{shaderType:35633}))}return h()(n,[{key:Symbol.toStringTag,get:function(){return"VertexShader"}}]),h()(n,[{key:"_createHandle",value:function(){return this.gl.createShader(35633)}}]),n}(cr),fr=function(e){it()(n,e);var t=sr(n);function n(e,r){return l()(this,n),"string"==typeof r&&(r={source:r}),t.call(this,e,Object.assign({},r,{shaderType:35632}))}return h()(n,[{key:Symbol.toStringTag,get:function(){return"FragmentShader"}}]),h()(n,[{key:"_createHandle",value:function(){return this.gl.createShader(35632)}}]),n}(cr),hr=(ur={},u()(ur,5126,[5126,1,"float"]),u()(ur,35664,[5126,2,"vec2"]),u()(ur,35665,[5126,3,"vec3"]),u()(ur,35666,[5126,4,"vec4"]),u()(ur,5124,[5124,1,"int"]),u()(ur,35667,[5124,2,"ivec2"]),u()(ur,35668,[5124,3,"ivec3"]),u()(ur,35669,[5124,4,"ivec4"]),u()(ur,5125,[5125,1,"uint"]),u()(ur,36294,[5125,2,"uvec2"]),u()(ur,36295,[5125,3,"uvec3"]),u()(ur,36296,[5125,4,"uvec4"]),u()(ur,35670,[5126,1,"bool"]),u()(ur,35671,[5126,2,"bvec2"]),u()(ur,35672,[5126,3,"bvec3"]),u()(ur,35673,[5126,4,"bvec4"]),u()(ur,35674,[5126,8,"mat2"]),u()(ur,35685,[5126,8,"mat2x3"]),u()(ur,35686,[5126,8,"mat2x4"]),u()(ur,35675,[5126,12,"mat3"]),u()(ur,35687,[5126,12,"mat3x2"]),u()(ur,35688,[5126,12,"mat3x4"]),u()(ur,35676,[5126,16,"mat4"]),u()(ur,35689,[5126,16,"mat4x2"]),u()(ur,35690,[5126,16,"mat4x3"]),ur);function dr(e){switch(e){case 0:return 0;case 1:case 3:case 2:return 1;case 4:case 5:case 6:return 4;default:return ct(!1),0}}function vr(e){var t=hr[e];if(!t)return null;var n=ae()(t,2);return{type:n[0],components:n[1]}}function gr(e,t){switch(e){case 5120:case 5121:case 5122:case 5123:e=5126}for(var n in hr){var r=ae()(hr[n],3),i=r[0],a=r[1],o=r[2];if(i===e&&a===t)return{glType:n,name:o}}return null}var pr=function(){function e(t){l()(this,e),this.id=t.id,this.attributeInfos=[],this.attributeInfosByName={},this.attributeInfosByLocation=[],this.varyingInfos=[],this.varyingInfosByName={},Object.seal(this),this._readAttributesFromProgram(t),this._readVaryingsFromProgram(t)}return h()(e,[{key:"getAttributeInfo",value:function(e){var t=Number(e);return Number.isFinite(t)?this.attributeInfosByLocation[t]:this.attributeInfosByName[e]||null}},{key:"getAttributeLocation",value:function(e){var t=this.getAttributeInfo(e);return t?t.location:-1}},{key:"getAttributeAccessor",value:function(e){var t=this.getAttributeInfo(e);return t?t.accessor:null}},{key:"getVaryingInfo",value:function(e){var t=Number(e);return Number.isFinite(t)?this.varyingInfos[t]:this.varyingInfosByName[e]||null}},{key:"getVaryingIndex",value:function(e){var t=this.getVaryingInfo();return t?t.location:-1}},{key:"getVaryingAccessor",value:function(e){var t=this.getVaryingInfo();return t?t.accessor:null}},{key:"_readAttributesFromProgram",value:function(e){for(var t=e.gl,n=t.getProgramParameter(e.handle,35721),r=0;r<n;r++){var i=t.getActiveAttrib(e.handle,r),a=i.name,o=i.type,s=i.size,u=t.getAttribLocation(e.handle,a);u>=0&&this._addAttribute(u,a,o,s)}this.attributeInfos.sort((function(e,t){return e.location-t.location}))}},{key:"_readVaryingsFromProgram",value:function(e){var t=e.gl;if(j(t)){for(var n=t.getProgramParameter(e.handle,35971),r=0;r<n;r++){var i=t.getTransformFeedbackVarying(e.handle,r),a=i.name,o=i.type,s=i.size;this._addVarying(r,a,o,s)}this.varyingInfos.sort((function(e,t){return e.location-t.location}))}}},{key:"_addAttribute",value:function(e,t,n,r){var i=vr(n),a={type:i.type,size:r*i.components};this._inferProperties(e,t,a);var o={location:e,name:t,accessor:new It(a)};this.attributeInfos.push(o),this.attributeInfosByLocation[e]=o,this.attributeInfosByName[o.name]=o}},{key:"_inferProperties",value:function(e,t,n){/instance/i.test(t)&&(n.divisor=1)}},{key:"_addVarying",value:function(e,t,n,r){var i=vr(n),a=i.type,o=i.components,s={location:e,name:t,accessor:new It({type:a,size:r*o})};this.varyingInfos.push(s),this.varyingInfosByName[s.name]=s}}]),e}();function mr(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return yr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function yr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _r(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var br=["setVertexArray","setAttributes","setBuffers","unsetBuffers","use","getUniformCount","getUniformInfo","getUniformLocation","getUniformValue","getVarying","getFragDataLocation","getAttachedShaders","getAttributeCount","getAttributeLocation","getAttributeInfo"],Ar=function(e){it()(n,e);var t=_r(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),(r=t.call(this,e,i)).stubRemovedMethods("Program","v6.0",br),r._isCached=!1,r.initialize(i),Object.seal(et()(r)),r._setId(i.id),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Program"}}]),h()(n,[{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.hash,n=e.vs,r=e.fs,i=e.varyings,a=e.bufferMode,o=void 0===a?35981:a;return this.hash=t||"",this.vs="string"==typeof n?new lr(this.gl,{id:"".concat(e.id,"-vs"),source:n}):n,this.fs="string"==typeof r?new fr(this.gl,{id:"".concat(e.id,"-fs"),source:r}):r,ct(this.vs instanceof lr),ct(this.fs instanceof fr),this.uniforms={},this._textureUniforms={},i&&i.length>0&&(V(this.gl),this.varyings=i,this.gl2.transformFeedbackVaryings(this.handle,i,o)),this._compileAndLink(),this._readUniformLocationsFromLinkedProgram(),this.configuration=new pr(this),this.setProps(e)}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isCached?this:nt()(ut()(n.prototype),"delete",this).call(this,e)}},{key:"setProps",value:function(e){return"uniforms"in e&&this.setUniforms(e.uniforms),this}},{key:"draw",value:function(e){var t=this,n=e.logPriority,r=e.drawMode,i=void 0===r?4:r,a=e.vertexCount,o=e.offset,s=void 0===o?0:o,u=e.start,c=e.end,l=e.isIndexed,f=void 0!==l&&l,h=e.indexType,d=void 0===h?5123:h,v=e.instanceCount,g=void 0===v?0:v,p=e.isInstanced,m=void 0===p?g>0:p,y=e.vertexArray,_=void 0===y?null:y,b=e.transformFeedback,A=e.framebuffer,x=e.parameters,E=void 0===x?{}:x,T=e.uniforms,k=e.samplers;if((T||k)&&(N.deprecated("Program.draw({uniforms})","Program.setUniforms(uniforms)")(),this.setUniforms(T||{})),N.priority>=n){var w=A?A.id:"default",O="mode=".concat(ft(this.gl,i)," verts=").concat(a," ")+"instances=".concat(g," indexType=").concat(ft(this.gl,d)," ")+"isInstanced=".concat(m," isIndexed=").concat(f," ")+"Framebuffer=".concat(w);N.log(n,O)()}return ct(_),this.gl.useProgram(this.handle),!(!this._areTexturesRenderable()||0===a||m&&0===g)&&(_.bindForDraw(a,g,(function(){if(void 0!==A&&(E=Object.assign({},E,{framebuffer:A})),b){var e=dr(i);b.begin(e)}t._bindTextures(),Ie(t.gl,E,(function(){f&&m?t.gl2.drawElementsInstanced(i,a,d,s,g):f&&j(t.gl)&&!isNaN(u)&&!isNaN(c)?t.gl2.drawRangeElements(i,u,c,a,d,s):f?t.gl.drawElements(i,a,d,s):m?t.gl2.drawArraysInstanced(i,s,a,g):t.gl.drawArrays(i,s,a)})),b&&b.end()})),!0)}},{key:"setUniforms",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in N.priority>=2&&Qn(e,this.id,this._uniformSetters),this.gl.useProgram(this.handle),e){var n=e[t],r=this._uniformSetters[t];if(r){var i=n,a=!1;if(i instanceof Cn&&(i=i.texture),i instanceof Yt)if(a=this.uniforms[t]!==n){void 0===r.textureIndex&&(r.textureIndex=this._textureIndexCounter++);var o=i,s=r.textureIndex;o.bind(s),i=s,this._textureUniforms[t]=o}else i=r.textureIndex;else this._textureUniforms[t]&&delete this._textureUniforms[t];(r(i)||a)&&Zn(this.uniforms,t,n)}}return this}},{key:"_areTexturesRenderable",value:function(){var e=!0;for(var t in this._textureUniforms){var n=this._textureUniforms[t];n.update(),e=e&&n.loaded}return e}},{key:"_bindTextures",value:function(){for(var e in this._textureUniforms){var t=this._uniformSetters[e].textureIndex;this._textureUniforms[e].bind(t)}}},{key:"_createHandle",value:function(){return this.gl.createProgram()}},{key:"_deleteHandle",value:function(){this.gl.deleteProgram(this.handle)}},{key:"_getOptionsFromHandle",value:function(e){var t,n={},r=mr(this.gl.getAttachedShaders(e));try{for(r.s();!(t=r.n()).done;){var i=t.value;switch(this.gl.getShaderParameter(this.handle,35663)){case 35633:n.vs=new lr({handle:i});break;case 35632:n.fs=new fr({handle:i})}}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"_getParameter",value:function(e){return this.gl.getProgramParameter(this.handle,e)}},{key:"_setId",value:function(e){if(!e){var t=this._getName();this.id=dt(t)}}},{key:"_getName",value:function(){var e=this.vs.getName()||this.fs.getName();return e=(e=e.replace(/shader/i,""))?"".concat(e,"-program"):"program"}},{key:"_compileAndLink",value:function(){var e=this.gl;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),N.time(4,"linkProgram for ".concat(this._getName()))(),e.linkProgram(this.handle),N.timeEnd(4,"linkProgram for ".concat(this._getName()))(),e.debug||N.level>0){if(!e.getProgramParameter(this.handle,35714))throw new Error("Error linking: ".concat(e.getProgramInfoLog(this.handle)));if(e.validateProgram(this.handle),!e.getProgramParameter(this.handle,35715))throw new Error("Error validating: ".concat(e.getProgramInfoLog(this.handle)))}}},{key:"_readUniformLocationsFromLinkedProgram",value:function(){var e=this.gl;this._uniformSetters={},this._uniformCount=this._getParameter(35718);for(var t=0;t<this._uniformCount;t++){var n=this.gl.getActiveUniform(this.handle,t),r=Yn(n.name).name,i=e.getUniformLocation(this.handle,r);if(this._uniformSetters[r]=Kn(e,i,n),n.size>1)for(var a=0;a<n.size;a++)i=e.getUniformLocation(this.handle,"".concat(r,"[").concat(a,"]")),this._uniformSetters["".concat(r,"[").concat(a,"]")]=Kn(e,i,n)}this._textureIndexCounter=0}},{key:"getActiveUniforms",value:function(e,t){return this.gl2.getActiveUniforms(this.handle,e,t)}},{key:"getUniformBlockIndex",value:function(e){return this.gl2.getUniformBlockIndex(this.handle,e)}},{key:"getActiveUniformBlockParameter",value:function(e,t){return this.gl2.getActiveUniformBlockParameter(this.handle,e,t)}},{key:"uniformBlockBinding",value:function(e,t){this.gl2.uniformBlockBinding(this.handle,e,t)}}]),n}(bt);function xr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Er=function(e){it()(n,e);var t=xr(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),V(e),(r=t.call(this,e,i)).initialize(i),r.stubRemovedMethods("TransformFeedback","v6.0",["pause","resume"]),Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"TransformFeedback"}}],[{key:"isSupported",value:function(e){return j(e)}}]),h()(n,[{key:"initialize",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.buffers={},this.unused={},this.configuration=null,this.bindOnUse=!0,gt(this.buffers)||this.bind((function(){return e._unbindBuffers()})),this.setProps(t),this}},{key:"setProps",value:function(e){"program"in e&&(this.configuration=e.program&&e.program.configuration),"configuration"in e&&(this.configuration=e.configuration),"bindOnUse"in e&&(e=e.bindOnUse),"buffers"in e&&this.setBuffers(e.buffers)}},{key:"setBuffers",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.bind((function(){for(var n in t)e.setBuffer(n,t[n])})),this}},{key:"setBuffer",value:function(e,t){var n=this,r=this._getVaryingIndex(e),i=this._getBufferParams(t),a=i.buffer,o=i.byteSize,s=i.byteOffset;return r<0?(this.unused[e]=a,N.warn((function(){return"".concat(n.id," unused varying buffer ").concat(e)}))(),this):(this.buffers[r]=t,this.bindOnUse||this._bindBuffer(r,a,s,o),this)}},{key:"begin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.gl.bindTransformFeedback(36386,this.handle),this._bindBuffers(),this.gl.beginTransformFeedback(e),this}},{key:"end",value:function(){return this.gl.endTransformFeedback(),this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null),this}},{key:"_getBufferParams",value:function(e){var t,n,r;return e instanceof Bt==!1?(r=e.buffer,n=e.byteSize,t=e.byteOffset):r=e,void 0===t&&void 0===n||(t=t||0,n=n||r.byteLength-t),{buffer:r,byteOffset:t,byteSize:n}}},{key:"_getVaryingInfo",value:function(e){return this.configuration&&this.configuration.getVaryingInfo(e)}},{key:"_getVaryingIndex",value:function(e){if(this.configuration)return this.configuration.getVaryingInfo(e).location;var t=Number(e);return Number.isFinite(t)?t:-1}},{key:"_bindBuffers",value:function(){if(this.bindOnUse)for(var e in this.buffers){var t=this._getBufferParams(this.buffers[e]),n=t.buffer,r=t.byteSize,i=t.byteOffset;this._bindBuffer(e,n,i,r)}}},{key:"_unbindBuffers",value:function(){if(this.bindOnUse)for(var e in this.buffers)this._bindBuffer(e,null)}},{key:"_bindBuffer",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t&&t.handle;return i&&void 0!==r?this.gl.bindBufferRange(35982,e,i,n,r):this.gl.bindBufferBase(35982,e,i),this}},{key:"_createHandle",value:function(){return this.gl.createTransformFeedback()}},{key:"_deleteHandle",value:function(){this.gl.deleteTransformFeedback(this.handle)}},{key:"_bindHandle",value:function(e){this.gl.bindTransformFeedback(36386,this.handle)}}]),n}(bt);function Tr(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function kr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function wr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Or=function(e){it()(n,e);var t=wr(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,n),(r=t.call(this,e,i)).target=null,r._queryPending=!1,r._pollingPromise=null,Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"Query"}}],[{key:"isSupported",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=j(e),i=Ln(e,Nn.TIMER_QUERY),a=r||i,o=Tr(n);try{for(o.s();!(t=o.n()).done;){var s=t.value;switch(s){case"queries":a=a&&r;break;case"timers":a=a&&i;break;default:ct(!1)}}}catch(e){o.e(e)}finally{o.f()}return a}}]),h()(n,[{key:"beginTimeElapsedQuery",value:function(){return this.begin(35007)}},{key:"beginOcclusionQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.conservative,n=void 0!==t&&t;return this.begin(n?36202:35887)}},{key:"beginTransformFeedbackQuery",value:function(){return this.begin(35976)}},{key:"begin",value:function(e){return this._queryPending||(this.target=e,this.gl2.beginQuery(this.target,this.handle)),this}},{key:"end",value:function(){return this._queryPending||this.target&&(this.gl2.endQuery(this.target),this.target=null,this._queryPending=!0),this}},{key:"isResultAvailable",value:function(){if(!this._queryPending)return!1;var e=this.gl2.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}},{key:"isTimerDisjoint",value:function(){return this.gl2.getParameter(36795)}},{key:"getResult",value:function(){return this.gl2.getQueryParameter(this.handle,34918)}},{key:"getTimerMilliseconds",value:function(){return this.getResult()/1e6}},{key:"createPoll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.POSITIVE_INFINITY;if(this._pollingPromise)return this._pollingPromise;var n=0;return this._pollingPromise=new Promise((function(r,i){requestAnimationFrame((function a(){e.isResultAvailable()?(r(e.getResult()),e._pollingPromise=null):n++>t?(i("Timed out"),e._pollingPromise=null):requestAnimationFrame(a)}))})),this._pollingPromise}},{key:"_createHandle",value:function(){return n.isSupported(this.gl)?this.gl2.createQuery():null}},{key:"_deleteHandle",value:function(){this.gl2.deleteQuery(this.handle)}}]),n}(bt);var Sr=Object(Pe.a)()&&"undefined"!=typeof document,Lr=0,Ir=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,e);var n=t.onCreateContext,r=void 0===n?function(e){return Ve(e)}:n,i=t.onAddHTML,a=void 0===i?null:i,o=t.onInitialize,s=void 0===o?function(){}:o,u=t.onRender,c=void 0===u?function(){}:u,f=t.onFinalize,h=void 0===f?function(){}:f,d=t.onError,v=t.gl,g=void 0===v?null:v,p=t.glOptions,m=void 0===p?{}:p,y=t.debug,_=void 0!==y&&y,b=t.createFramebuffer,A=void 0!==b&&b,x=t.autoResizeViewport,E=void 0===x||x,T=t.autoResizeDrawingBuffer,k=void 0===T||T,w=t.stats,O=void 0===w?Ze.get("animation-loop-".concat(Lr++)):w,S=t.useDevicePixels,L=void 0===S||S;"useDevicePixelRatio"in t&&(N.deprecated("useDevicePixelRatio","useDevicePixels")(),L=t.useDevicePixelRatio),this.props={onCreateContext:r,onAddHTML:a,onInitialize:s,onRender:c,onFinalize:h,onError:d,gl:g,glOptions:m,debug:_,createFramebuffer:A},this.gl=g,this.needsRedraw=null,this.timeline=null,this.stats=O,this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this._initialized=!1,this._running=!1,this._animationFrameId=null,this._nextFramePromise=null,this._resolveNextFrame=null,this._cpuStartTime=0,this.setProps({autoResizeViewport:E,autoResizeDrawingBuffer:k,useDevicePixels:L}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._pageLoadPromise=null,this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}var t;return h()(e,[{key:"delete",value:function(){this.stop(),this._setDisplay(null)}},{key:"setNeedsRedraw",value:function(e){return ct("string"==typeof e),this.needsRedraw=this.needsRedraw||e,this}},{key:"setProps",value:function(e){return"autoResizeViewport"in e&&(this.autoResizeViewport=e.autoResizeViewport),"autoResizeDrawingBuffer"in e&&(this.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer),"useDevicePixels"in e&&(this.useDevicePixels=e.useDevicePixels),this}},{key:"start",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._running)return this;this._running=!0;var n=this._getPageLoadPromise().then((function(){return!e._running||e._initialized?null:(e._createWebGLContext(t),e._createFramebuffer(),e._startEventHandling(),e._initializeCallbackData(),e._updateCallbackData(),e._resizeCanvasDrawingBuffer(),e._resizeViewport(),e._gpuTimeQuery=Or.isSupported(e.gl,["timers"])?new Or(e.gl):null,e._initialized=!0,e.onInitialize(e.animationProps))})).then((function(t){e._running&&(e._addCallbackData(t||{}),!1!==t&&e._startLoop())}));return this.props.onError&&n.catch(this.props.onError),this}},{key:"redraw",value:function(){return this.isContextLost()||(this._beginTimers(),this._setupFrame(),this._updateCallbackData(),this._renderFrame(this.animationProps),this._clearNeedsRedraw(),this.offScreen&&this.gl.commit&&this.gl.commit(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endTimers()),this}},{key:"stop",value:function(){return this._running&&(this._finalizeCallbackData(),this._cancelAnimationFrame(this._animationFrameId),this._nextFramePromise=null,this._resolveNextFrame=null,this._animationFrameId=null,this._running=!1),this}},{key:"attachTimeline",value:function(e){return this.timeline=e,this.timeline}},{key:"detachTimeline",value:function(){this.timeline=null}},{key:"waitForRender",value:function(){var e=this;return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise((function(t){e._resolveNextFrame=t}))),this._nextFramePromise}},{key:"toDataURL",value:(t=dn()(fn.a.mark((function e(){return fn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setNeedsRedraw("toDataURL"),e.next=3,this.waitForRender();case 3:return e.abrupt("return",this.gl.canvas.toDataURL());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"isContextLost",value:function(){return this.gl.isContextLost()}},{key:"onCreateContext",value:function(){var e;return(e=this.props).onCreateContext.apply(e,arguments)}},{key:"onInitialize",value:function(){var e;return(e=this.props).onInitialize.apply(e,arguments)}},{key:"onRender",value:function(){var e;return(e=this.props).onRender.apply(e,arguments)}},{key:"onFinalize",value:function(){var e;return(e=this.props).onFinalize.apply(e,arguments)}},{key:"getHTMLControlValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=document.getElementById(e);return n?Number(n.value):t}},{key:"setViewParameters",value:function(){return N.removed("AnimationLoop.setViewParameters","AnimationLoop.setProps")(),this}},{key:"_startLoop",value:function(){var e=this;this._cancelAnimationFrame(this._animationFrameId),this._animationFrameId=this._requestAnimationFrame((function t(){e._running&&(e.redraw(),e._animationFrameId=e._requestAnimationFrame(t))}))}},{key:"_getPageLoadPromise",value:function(){return this._pageLoadPromise||(this._pageLoadPromise=Sr?new Promise((function(e,t){Sr&&"complete"===document.readyState?e(document):window.addEventListener("load",(function(){e(document)}))})):Promise.resolve({})),this._pageLoadPromise}},{key:"_setDisplay",value:function(e){this.display&&(this.display.delete(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}},{key:"_cancelAnimationFrame",value:function(e){return this.display&&this.display.cancelAnimationFrame?this.display.cancelAnimationFrame(e):(t=e,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(t):clearTimeout(t));var t}},{key:"_requestAnimationFrame",value:function(e){if(this._running)return this.display&&this.display.requestAnimationFrame?this.display.requestAnimationFrame(e):(t=e,"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,1e3/60));var t}},{key:"_renderFrame",value:function(){var e;this.display?(e=this.display)._renderFrame.apply(e,arguments):this.onRender.apply(this,arguments)}},{key:"_clearNeedsRedraw",value:function(){this.needsRedraw=null}},{key:"_setupFrame",value:function(){this._resizeCanvasDrawingBuffer(),this._resizeViewport(),this._resizeFramebuffer()}},{key:"_initializeCallbackData",value:function(){this.animationProps={gl:this.gl,stop:this.stop,canvas:this.gl.canvas,framebuffer:this.framebuffer,useDevicePixels:this.useDevicePixels,needsRedraw:null,startTime:Date.now(),engineTime:0,tick:0,tock:0,time:0,_timeline:this.timeline,_loop:this,_animationLoop:this,_mousePosition:null}}},{key:"_updateCallbackData",value:function(){var e=this._getSizeAndAspect(),t=e.width,n=e.height,r=e.aspect;t===this.animationProps.width&&n===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),r!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=n,this.animationProps.aspect=r,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime,this.animationProps._offScreen=this.offScreen}},{key:"_finalizeCallbackData",value:function(){this.onFinalize(this.animationProps)}},{key:"_addCallbackData",value:function(e){"object"===i()(e)&&null!==e&&(this.animationProps=Object.assign({},this.animationProps,e))}},{key:"_createWebGLContext",value:function(e){if(this.offScreen=e.canvas&&"undefined"!=typeof OffscreenCanvas&&e.canvas instanceof OffscreenCanvas,e=Object.assign({},e,this.props.glOptions),this.gl=this.props.gl?Ge(this.props.gl,e):this.onCreateContext(e),!B(this.gl))throw new Error("AnimationLoop.onCreateContext - illegal context returned");Le(this.gl),this._createInfoDiv()}},{key:"_createInfoDiv",value:function(){if(this.gl.canvas&&this.props.onAddHTML){var e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";var t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",e.appendChild(this.gl.canvas),e.appendChild(t);var n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}},{key:"_getSizeAndAspect",value:function(){var e=this.gl.drawingBufferWidth,t=this.gl.drawingBufferHeight,n=1,r=this.gl.canvas;return r&&r.clientHeight?n=r.clientWidth/r.clientHeight:e>0&&t>0&&(n=e/t),{width:e,height:t,aspect:n}}},{key:"_resizeViewport",value:function(){this.autoResizeViewport&&this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}},{key:"_resizeCanvasDrawingBuffer",value:function(){this.autoResizeDrawingBuffer&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.canvas){var n=Ce(t.useDevicePixels);qe(e,n,t)}else{var r=e.getExtension("STACKGL_resize_drawingbuffer");r&&"width"in t&&"height"in t&&r.resize(t.width,t.height)}}(this.gl,{useDevicePixels:this.useDevicePixels})}},{key:"_createFramebuffer",value:function(){this.props.createFramebuffer&&(this.framebuffer=new Cn(this.gl))}},{key:"_resizeFramebuffer",value:function(){this.framebuffer&&this.framebuffer.resize({width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight})}},{key:"_beginTimers",value:function(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this._gpuTimeQuery&&this._gpuTimeQuery.isResultAvailable()&&!this._gpuTimeQuery.isTimerDisjoint()&&this.stats.get("GPU Time").addTime(this._gpuTimeQuery.getTimerMilliseconds()),this._gpuTimeQuery&&this._gpuTimeQuery.beginTimeElapsedQuery(),this.cpuTime.timeStart()}},{key:"_endTimers",value:function(){this.cpuTime.timeEnd(),this._gpuTimeQuery&&this._gpuTimeQuery.end()}},{key:"_startEventHandling",value:function(){var e=this.gl.canvas;e&&(e.addEventListener("mousemove",this._onMousemove),e.addEventListener("mouseleave",this._onMouseleave))}},{key:"_onMousemove",value:function(e){this.animationProps._mousePosition=[e.offsetX,e.offsetY]}},{key:"_onMouseleave",value:function(e){this.animationProps._mousePosition=null}}]),e}();function Pr(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var Rr={number:{validate:function(e,t){return Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)}},array:{validate:function(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function Fr(e){var t=Cr(e);return"object"===t?e?"type"in e?Object.assign({},e,Rr[e.type]):"value"in e?(t=Cr(e.value),Object.assign({type:t},e,Rr[t])):{type:"object",value:e}:{type:"object",value:null}:Object.assign({type:t,value:e},Rr[t])}function Cr(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":i()(e)}var Mr=function(){function e(t){var n=t.name,r=t.vs,i=t.fs,a=t.dependencies,o=void 0===a?[]:a,s=t.uniforms,u=t.getUniforms,c=t.deprecations,f=void 0===c?[]:c,h=t.defines,d=void 0===h?{}:h,v=t.inject,g=void 0===v?{}:v,p=t.vertexShader,m=t.fragmentShader;l()(this,e),Pr("string"==typeof n),this.name=n,this.vs=r||p,this.fs=i||m,this.getModuleUniforms=u,this.dependencies=o,this.deprecations=this._parseDeprecationDefinitions(f),this.defines=d,this.injections=function(e){var t={vs:{},fs:{}};for(var n in e){var r=e[n],i=n.slice(0,2);"string"==typeof r&&(r={order:0,injection:r}),t[i][n]=r}return t}(g),s&&(this.uniforms=function(e){var t={};for(var n in e){var r=Fr(e[n]);t[n]=r}return t}(s))}return h()(e,[{key:"getModuleSource",value:function(e){var t;switch(e){case"vs":t=this.vs||"";break;case"fs":t=this.fs||"";break;default:Pr(!1)}return"#define MODULE_".concat(this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),"\n").concat(t,"// END MODULE_").concat(this.name,"\n\n")}},{key:"getUniforms",value:function(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):this.uniforms?this._defaultGetUniforms(e):{}}},{key:"getDefines",value:function(){return this.defines}},{key:"checkDeprecations",value:function(e,t){this.deprecations.forEach((function(n){n.regex.test(e)&&(n.deprecated?t.deprecated(n.old,n.new)():t.removed(n.old,n.new)())}))}},{key:"_parseDeprecationDefinitions",value:function(e){return e.forEach((function(e){switch(e.type){case"function":e.regex=new RegExp("\\b".concat(e.old,"\\("));break;default:e.regex=new RegExp("".concat(e.type," ").concat(e.old,";"))}})),e}},{key:"_defaultGetUniforms",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={},n=this.uniforms;for(var r in n){var i=n[r];r in e&&!i.private?(i.validate&&Pr(i.validate(e[r],i),"".concat(this.name,": invalid ").concat(r)),t[r]=e[r]):t[r]=i.value}return t}}]),e}();function Nr(e){if(!e.normalized&&(e.normalized=!0,e.uniforms&&!e.getUniforms)){var t=new Mr(e);e.getUniforms=t.getUniforms.bind(t)}return e}function Dr(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Br(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Br(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Br(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function jr(e){return Ur(function e(t,n){return t.map((function(t){return t instanceof Mr||(Pr("string"!=typeof t,"Shader module use by name is deprecated. Import shader module '".concat(t,"' and use it directly.")),Pr(t.name,"shader module has no name"),(t=new Mr(t)).dependencies=e(t.dependencies)),t}))}(e))}function Ur(e){var t={},n={};return Vr({modules:e,level:0,moduleMap:t,moduleDepth:n}),Object.keys(n).sort((function(e,t){return n[t]-n[e]})).map((function(e){return t[e]}))}function Vr(e){var t=e.modules,n=e.level,r=e.moduleMap,i=e.moduleDepth;if(n>=5)throw new Error("Possible loop in shader dependency graph");var a,o=Dr(t);try{for(o.s();!(a=o.n()).done;){var s=a.value;r[s.name]=s,(void 0===i[s.name]||i[s.name]<n)&&(i[s.name]=n)}}catch(e){o.e(e)}finally{o.f()}var u,c=Dr(t);try{for(c.s();!(u=c.n()).done;){var l=u.value;l.dependencies&&Vr({modules:l.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}}catch(e){c.e(e)}finally{c.f()}}function Gr(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="undefined"!=typeof window&&window.navigator||{},n=e.userAgent||t.userAgent||"",r=-1!==n.indexOf("MSIE "),i=-1!==n.indexOf("Trident/");return r||i}var zr={GLSL_FRAG_DATA:["WEBGL_draw_buffers",!0],GLSL_FRAG_DEPTH:["EXT_frag_depth",!0],GLSL_DERIVATIVES:["OES_standard_derivatives",!0],GLSL_TEXTURE_LOD:["EXT_shader_texture_lod",!0]},Hr={};Object.keys(zr).forEach((function(e){Hr[e]=e}));var Wr={};function Xr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=zr[t];if(Pr(r,t),!Gr(n))return!0;if(t in Wr)return Wr[t];var i=r[0],a=n.behavior||"enable",o="#extension GL_".concat(i," : ").concat(a,"\nvoid main(void) {}"),s=e.createShader(35633);e.shaderSource(s,o),e.compileShader(s);var u=e.getShaderParameter(s,35713);return e.deleteShader(s),Wr[t]=u,u}function qr(e,t){var n=zr[t];Pr(n,t);var r=function(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&2===e._version)}(e)&&n[1]||n[0],i="string"==typeof r?Boolean(e.getExtension(r)):r;return Pr(!1===i||!0===i),i}function Kr(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return qr(e,t)}))}var Yr,Qr=(Yr={},u()(Yr,"vs","#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n"),u()(Yr,"fs","#ifdef MODULE_MATERIAL\n gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n"),Yr),$r=/void\s+main\s*\([^)]*\)\s*\{\n?/,Zr=/}\n?[^{}]*$/,Jr=[];function ei(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i="vs"===t,a=function(t){var r=n[t];r.sort((function(e,t){return e.order-t.order})),Jr.length=r.length;for(var a=0,o=r.length;a<o;++a)Jr[a]=r[a].injection;var s="".concat(Jr.join("\n"),"\n");switch(t){case"vs:#decl":i&&(e=e.replace("__LUMA_INJECT_DECLARATIONS__",s));break;case"vs:#main-start":i&&(e=e.replace($r,(function(e){return e+s})));break;case"vs:#main-end":i&&(e=e.replace(Zr,(function(e){return s+e})));break;case"fs:#decl":i||(e=e.replace("__LUMA_INJECT_DECLARATIONS__",s));break;case"fs:#main-start":i||(e=e.replace($r,(function(e){return e+s})));break;case"fs:#main-end":i||(e=e.replace(Zr,(function(e){return s+e})));break;default:e=e.replace(t,(function(e){return e+s}))}};for(var o in n)a(o);return e=e.replace("__LUMA_INJECT_DECLARATIONS__",""),r&&(e=e.replace(/\}\s*$/,(function(e){return e+Qr[t]}))),e}function ti(e){var t={};return Pr(Array.isArray(e)&&e.length>1),e.forEach((function(e){for(var n in e)t[n]=t[n]?"".concat(t[n],"\n").concat(e[n]):e[n]})),t}function ni(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ri(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ri(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ri(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ii(e){return new RegExp("\\b".concat(e,"[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)"),"g")}var ai,oi=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],si=[].concat(oi,[[ii("attribute"),"in $1"],[ii("varying"),"out $1"]]),ui=[].concat(oi,[[ii("varying"),"in $1"]]),ci=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],li=[].concat(ci,[[ii("in"),"attribute $1"],[ii("out"),"varying $1"]]),fi=[].concat(ci,[[ii("in"),"varying $1"]]),hi=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,di=/void\s+main\s*\([^)]*\)\s*\{\n?/;function vi(e,t,n){switch(t){case 300:return n?gi(e,si):function(e){var t=(e=gi(e,ui)).match(hi);if(t){var n=t[1];e=e.replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),n)}else{e=e.replace(di,(function(e){return"out vec4 ".concat("fragmentColor",";\n").concat(e)})).replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),"fragmentColor")}return e}(e);case 100:return n?gi(e,li):function(e){var t=(e=gi(e,fi)).match(hi);if(t){var n=t[1];e=e.replace(hi,"").replace(new RegExp("\\b".concat(n,"\\b"),"g"),"gl_FragColor")}return e}(e);default:throw new Error("unknown GLSL version ".concat(t))}}function gi(e,t){var n,r=ni(t);try{for(r.s();!(n=r.n()).done;){var i=ae()(n.value,2),a=i[0],o=i[1];e=e.replace(a,o)}}catch(e){r.e(e)}finally{r.f()}return e}function pi(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function mi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var yi="\n\n".concat("__LUMA_INJECT_DECLARATIONS__","\n\n"),_i=(ai={},u()(ai,"vs","vertex"),u()(ai,"fs","fragment"),ai);function bi(e,t){var n=t.vs,r=t.fs,i=jr(t.modules||[]);return{gl:e,vs:Ai(e,Object.assign({},t,{source:n,type:"vs",modules:i})),fs:Ai(e,Object.assign({},t,{source:r,type:"fs",modules:i})),getUniforms:xi(i)}}function Ai(e,t){var n=t.id,r=t.source,i=t.type,a=t.modules,o=t.defines,s=void 0===o?{}:o,u=t.hookFunctions,c=void 0===u?[]:u,l=t.inject,f=void 0===l?{}:l,h=t.transpileToGLSL100,d=void 0!==h&&h,v=t.prologue,g=void 0===v||v,p=t.log;Pr("string"==typeof r,"shader source must be a string");var m="vs"===i,y=r.split("\n"),_=100,b="",A=r;0===y[0].indexOf("#version ")?(_=300,b=y[0],A=y.slice(1).join("\n")):b="#version ".concat(_);var x={};a.forEach((function(e){Object.assign(x,e.getDefines())})),Object.assign(x,s);var E=g?"".concat(b,"\n").concat(function(e){var t=e.id,n=e.source,r=e.type;return t&&"string"==typeof t&&-1===n.indexOf("SHADER_NAME")?"\n#define SHADER_NAME ".concat(t,"_").concat(_i[r],"\n\n"):""}({id:n,source:r,type:i}),"\n").concat(function(e){var t=e.type;return"\n#define SHADER_TYPE_".concat(_i[t].toUpperCase(),"\n")}({type:i}),"\n").concat(function(e){switch(function(e){var t=e.getExtension("WEBGL_debug_renderer_info"),n=e.getParameter(t&&t.UNMASKED_VENDOR_WEBGL||7936),r=e.getParameter(t&&t.UNMASKED_RENDERER_WEBGL||7937);return{gpuVendor:function(e,t){if(e.match(/NVIDIA/i)||t.match(/NVIDIA/i))return"NVIDIA";if(e.match(/INTEL/i)||t.match(/INTEL/i))return"INTEL";if(e.match(/AMD/i)||t.match(/AMD/i)||e.match(/ATI/i)||t.match(/ATI/i))return"AMD";return"UNKNOWN GPU"}(n,r),vendor:n,renderer:r,version:e.getParameter(7938),shadingLanguageVersion:e.getParameter(35724)}}(e).gpuVendor.toLowerCase()){case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e),"\n").concat(function(e,t,n){var r="#if (__VERSION__ > 120)\n\n# define FEATURE_GLSL_DERIVATIVES\n# define FEATURE_GLSL_DRAW_BUFFERS\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FEATURE_GLSL_TEXTURE_LOD\n\n// DEPRECATED FLAGS, remove in v9\n# define FRAG_DEPTH\n# define DERIVATIVES\n# define DRAW_BUFFERS\n# define TEXTURE_LOD\n\n#endif // __VERSION\n";return Kr(e,Hr.GLSL_FRAG_DEPTH)&&(r+="\n// FRAG_DEPTH => gl_FragDepth is available\n#ifdef GL_EXT_frag_depth\n#extension GL_EXT_frag_depth : enable\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FRAG_DEPTH\n# define gl_FragDepth gl_FragDepthEXT\n#endif\n"),Kr(e,Hr.GLSL_DERIVATIVES)&&Xr(e,Hr.GLSL_DERIVATIVES)&&(r+="\n// DERIVATIVES => dxdF, dxdY and fwidth are available\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n# define FEATURE_GLSL_DERIVATIVES\n# define DERIVATIVES\n#endif\n"),Kr(e,Hr.GLSL_FRAG_DATA)&&Xr(e,Hr.GLSL_FRAG_DATA,{behavior:"require"})&&(r+="\n// DRAW_BUFFERS => gl_FragData[] is available\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers : require\n#define FEATURE_GLSL_DRAW_BUFFERS\n#define DRAW_BUFFERS\n#endif\n"),Kr(e,Hr.GLSL_TEXTURE_LOD)&&(r+="// TEXTURE_LOD => texture2DLod etc are available\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod : enable\n\n# define FEATURE_GLSL_TEXTURE_LOD\n# define TEXTURE_LOD\n\n#endif\n"),r}(e),"\n").concat(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=0,n="";for(var r in e){0===t&&(n+="\n// APPLICATION DEFINES\n"),t++;var i=e[r];(i||Number.isFinite(i))&&(n+="#define ".concat(r.toUpperCase()," ").concat(e[r],"\n"))}0===t&&(n+="\n");return n}(x),"\n").concat(m?"":"precision highp float;\n\n","\n"):"".concat(b,"\n"),T=function(e){var t={vs:{},fs:{}};return e.forEach((function(e){var n;"string"!=typeof e?e=(n=e).hook:n={};var r=(e=e.trim()).split(":"),i=ae()(r,2),a=i[0],o=i[1],s=e.replace(/\(.+/,"");t[a][s]=Object.assign(n,{signature:o})})),t}(c),k={},w={},O={};for(var S in f){var L="string"==typeof f[S]?{injection:f[S],order:0}:f[S],I=S.match(/^(v|f)s:(#)?([\w-]+)$/);if(I){var P=I[2],R=I[3];P?"decl"===R?w[S]=[L]:O[S]=[L]:k[S]=[L]}else O[S]=[L]}var F,C=pi(a);try{for(C.s();!(F=C.n()).done;){var M=F.value;p&&M.checkDeprecations(A,p),E+=M.getModuleSource(i,_);var N=M.injections[i];for(var D in N){var B=D.match(/^(v|f)s:#([\w-]+)$/);if(B){var j="decl"===B[2]?w:O;j[D]=j[D]||[],j[D].push(N[D])}else k[D]=k[D]||[],k[D].push(N[D])}}}catch(e){C.e(e)}finally{C.f()}return E=ei(E+=yi,i,w),E+=function(e,t){var n="";for(var r in e){var i=e[r];if(n+="void ".concat(i.signature," {\n"),i.header&&(n+=" ".concat(i.header)),t[r]){var a=t[r];a.sort((function(e,t){return e.order-t.order}));var o,s=pi(a);try{for(s.s();!(o=s.n()).done;){var u=o.value;n+=" ".concat(u.injection,"\n")}}catch(e){s.e(e)}finally{s.f()}}i.footer&&(n+=" ".concat(i.footer)),n+="}\n"}return n}(T[i],k),E=vi(E=ei(E+=A,i,O),d?100:_,m)}function xi(e){return function(t){var n,r={},i=pi(e);try{for(i.s();!(n=i.n()).done;){var a=n.value.getUniforms(t,r);Object.assign(r,a)}}catch(e){i.e(e)}finally{i.f()}return r}}function Ei(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ti(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ti(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Ti(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ki=function(){function e(t){l()(this,e),this.gl=t,this._programCache={},this._getUniforms={},this._registeredModules={},this._hookFunctions=[],this._defaultModules=[],this._hashes={},this._hashCounter=0,this.stateHash=0,this._useCounts={}}return h()(e,null,[{key:"getDefaultProgramManager",value:function(t){return t.luma=t.luma||{},t.luma.defaultProgramManager=t.luma.defaultProgramManager||new e(t),t.luma.defaultProgramManager}}]),h()(e,[{key:"addDefaultModule",value:function(e){this._defaultModules.find((function(t){return t.name===e.name}))||this._defaultModules.push(e),this.stateHash++}},{key:"removeDefaultModule",value:function(e){var t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter((function(e){return e.name!==t})),this.stateHash++}},{key:"addShaderHook",value:function(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e),this.stateHash++}},{key:"get",value:function(){var e,t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.vs,i=void 0===r?"":r,a=n.fs,o=void 0===a?"":a,s=n.defines,u=void 0===s?{}:s,c=n.inject,l=void 0===c?{}:c,f=n.varyings,h=void 0===f?[]:f,d=n.bufferMode,v=void 0===d?35981:d,g=n.transpileToGLSL100,p=void 0!==g&&g,m=this._getModuleList(n.modules),y=this._getHash(i),_=this._getHash(o),b=m.map((function(e){return t._getHash(e.name)})).sort(),A=h.map((function(e){return t._getHash(e)})),x=Object.keys(u).sort(),E=Object.keys(l).sort(),T=[],k=[],w=Ei(x);try{for(w.s();!(e=w.n()).done;){var O=e.value;T.push(this._getHash(O)),T.push(this._getHash(u[O]))}}catch(e){w.e(e)}finally{w.f()}var S,L=Ei(E);try{for(L.s();!(S=L.n()).done;){var I=S.value;k.push(this._getHash(I)),k.push(this._getHash(l[I]))}}catch(e){L.e(e)}finally{L.f()}var P="".concat(y,"/").concat(_,"D").concat(T.join("/"),"M").concat(b.join("/"),"I").concat(k.join("/"),"V").concat(A.join("/"),"H").concat(this.stateHash,"B").concat(v).concat(p?"T":"");if(!this._programCache[P]){var R=bi(this.gl,{vs:i,fs:o,modules:m,inject:l,defines:u,hookFunctions:this._hookFunctions,transpileToGLSL100:p});this._programCache[P]=new Ar(this.gl,{hash:P,vs:R.vs,fs:R.fs,varyings:h,bufferMode:v}),this._getUniforms[P]=R.getUniforms||function(e){},this._useCounts[P]=0}return this._useCounts[P]++,this._programCache[P]}},{key:"getUniforms",value:function(e){return this._getUniforms[e.hash]||null}},{key:"release",value:function(e){var t=e.hash;this._useCounts[t]--,0===this._useCounts[t]&&(this._programCache[t].delete(),delete this._programCache[t],delete this._getUniforms[t],delete this._useCounts[t])}},{key:"_getHash",value:function(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},{key:"_getModuleList",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=new Array(this._defaultModules.length+e.length),n={},r=0,i=0,a=this._defaultModules.length;i<a;++i){var o=this._defaultModules[i],s=o.name;t[r++]=o,n[s]=!0}for(var u=0,c=e.length;u<c;++u){var l=e[u],f=l.name;n[f]||(t[r++]=l,n[f]=!0)}return t.length=r,t}}]),e}(),wi=null;function Oi(e,t){var n;return new e((n=e.BYTES_PER_ELEMENT*t,(!wi||wi.byteLength<n)&&(wi=new ArrayBuffer(n)),wi),0,t)}var Si=n(19);function Li(e){if(!e&&!Object(d.a)())return"Node";if(Object(Si.a)(e))return"Electron";var t="undefined"!=typeof navigator?navigator:{},n=e||t.userAgent||"";if(n.indexOf("Edge")>-1)return"Edge";var r=-1!==n.indexOf("MSIE "),i=-1!==n.indexOf("Trident/");return r||i?"IE":T.b.chrome?"Chrome":T.b.safari?"Safari":T.b.mozInnerScreenX?"Firefox":"Unknown"}function Ii(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Pi="elements must be GL.ELEMENT_ARRAY_BUFFER",Ri=function(e){it()(n,e);var t=Ii(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,n);var a=i.id||i.program&&i.program.id;return(r=t.call(this,e,Object.assign({},i,{id:a}))).buffer=null,r.bufferValue=null,r.isDefaultArray=i.isDefaultArray||!1,r.gl2=e,r.initialize(i),Object.seal(et()(r)),r}return h()(n,[{key:Symbol.toStringTag,get:function(){return"VertexArrayObject"}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!t.constantAttributeZero||(j(e)||"Chrome"===Li())}},{key:"getDefaultArray",value:function(e){return e.luma=e.luma||{},e.luma.defaultVertexArray||(e.luma.defaultVertexArray=new n(e,{handle:null,isDefaultArray:!0})),e.luma.defaultVertexArray}},{key:"getMaxAttributes",value:function(e){return n.MAX_ATTRIBUTES=n.MAX_ATTRIBUTES||e.getParameter(34921),n.MAX_ATTRIBUTES}},{key:"setConstant",value:function(e,t,r){switch(r.constructor){case Float32Array:n._setConstantFloatArray(e,t,r);break;case Int32Array:n._setConstantIntArray(e,t,r);break;case Uint32Array:n._setConstantUintArray(e,t,r);break;default:ct(!1)}}}]),h()(n,[{key:"delete",value:function(){return nt()(ut()(n.prototype),"delete",this).call(this),this.buffer&&this.buffer.delete(),this}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setProps(e)}},{key:"setProps",value:function(e){return this}},{key:"setElementBuffer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return ct(!t||34963===t.target,Pi),this.bind((function(){e.gl.bindBuffer(34963,t?t.handle:null)})),this}},{key:"setBuffer",value:function(e,t,n){if(34963===t.target)return this.setElementBuffer(t,n);var r=n.size,i=n.type,a=n.stride,o=n.offset,s=n.normalized,u=n.integer,c=n.divisor,l=this.gl,f=this.gl2;return e=Number(e),this.bind((function(){l.bindBuffer(34962,t.handle),u?(ct(j(l)),f.vertexAttribIPointer(e,r,i,a,o)):l.vertexAttribPointer(e,r,i,s,a,o),l.enableVertexAttribArray(e),f.vertexAttribDivisor(e,c||0)})),this}},{key:"enable",value:function(e){var t=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!r&&0===e&&!n.isSupported(this.gl,{constantAttributeZero:!0});return i||(e=Number(e),this.bind((function(){return r?t.gl.enableVertexAttribArray(e):t.gl.disableVertexAttribArray(e)}))),this}},{key:"getConstantBuffer",value:function(e,t){var n=this._normalizeConstantArrayValue(t),r=n.byteLength*e,i=n.length*e,a=!this.buffer;if(this.buffer=this.buffer||new Bt(this.gl,r),a=(a=a||this.buffer.reallocate(r))||!this._compareConstantArrayValues(n,this.bufferValue)){var o=Oi(t.constructor,i);!function(e){for(var t=e.target,n=e.source,r=e.start,i=void 0===r?0:r,a=e.count,o=void 0===a?1:a,s=n.length,u=o*s,c=0,l=i;c<s;c++)t[l++]=n[c];for(;c<u;)c<u-c?(t.copyWithin(i+c,i,i+c),c*=2):(t.copyWithin(i+c,i,i+u-c),c=u)}({target:o,source:n,start:0,count:i}),this.buffer.subData(o),this.bufferValue=t}return this.buffer}},{key:"_normalizeConstantArrayValue",value:function(e){return Array.isArray(e)?new Float32Array(e):e}},{key:"_compareConstantArrayValues",value:function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}},{key:"_createHandle",value:function(){return this.gl.createVertexArray()}},{key:"_deleteHandle",value:function(e){return this.gl2.deleteVertexArray(e),[this.elements]}},{key:"_bindHandle",value:function(e){this.gl2.bindVertexArray(e)}},{key:"_getParameter",value:function(e,t){var n=this,r=t.location;return ct(Number.isFinite(r)),this.bind((function(){switch(e){case 34373:return n.gl.getVertexAttribOffset(r,e);default:return n.gl.getVertexAttrib(r,e)}}))}},{key:"MAX_ATTRIBUTES",get:function(){return n.getMaxAttributes(this.gl)}}],[{key:"_setConstantFloatArray",value:function(e,t,n){switch(n.length){case 1:e.vertexAttrib1fv(t,n);break;case 2:e.vertexAttrib2fv(t,n);break;case 3:e.vertexAttrib3fv(t,n);break;case 4:e.vertexAttrib4fv(t,n);break;default:ct(!1)}}},{key:"_setConstantIntArray",value:function(e,t,n){switch(ct(j(e)),n.length){case 1:e.vertexAttribI1iv(t,n);break;case 2:e.vertexAttribI2iv(t,n);break;case 3:e.vertexAttribI3iv(t,n);break;case 4:e.vertexAttribI4iv(t,n);break;default:ct(!1)}}},{key:"_setConstantUintArray",value:function(e,t,n){switch(ct(j(e)),n.length){case 1:e.vertexAttribI1uiv(t,n);break;case 2:e.vertexAttribI2uiv(t,n);break;case 3:e.vertexAttribI3uiv(t,n);break;case 4:e.vertexAttribI4uiv(t,n);break;default:ct(!1)}}}]),n}(bt),Fi=/^(.+)__LOCATION_([0-9]+)$/,Ci=["setBuffers","setGeneric","clearBindings","setLocations","setGenericValues","setDivisor","enable","disable"],Mi=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e);var r=n.id||n.program&&n.program.id;this.id=r,this.gl=t,this.configuration=null,this.elements=null,this.elementsAccessor=null,this.values=null,this.accessors=null,this.unused=null,this.drawParams=null,this.buffer=null,this.attributes={},this.vertexArrayObject=new Ri(t),pt(this,"VertexArray","v6.0",Ci),this.initialize(n),Object.seal(this)}return h()(e,[{key:"delete",value:function(){this.buffer&&this.buffer.delete(),this.vertexArrayObject.delete()}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.reset(),this.configuration=null,this.bindOnUse=!1,this.setProps(e)}},{key:"reset",value:function(){this.elements=null,this.elementsAccessor=null;var e=this.vertexArrayObject.MAX_ATTRIBUTES;return this.values=new Array(e).fill(null),this.accessors=new Array(e).fill(null),this.unused={},this.drawParams=null,this}},{key:"setProps",value:function(e){return"program"in e&&(this.configuration=e.program&&e.program.configuration),"configuration"in e&&(this.configuration=e.configuration),"attributes"in e&&this.setAttributes(e.attributes),"elements"in e&&this.setElementBuffer(e.elements),"bindOnUse"in e&&(e=e.bindOnUse),this}},{key:"clearDrawParams",value:function(){this.drawParams=null}},{key:"getDrawParams",value:function(){return this.drawParams=this.drawParams||this._updateDrawParams(),this.drawParams}},{key:"setAttributes",value:function(e){var t=this;return Object.assign(this.attributes,e),this.vertexArrayObject.bind((function(){for(var n in e){var r=e[n];t._setAttribute(n,r)}t.gl.bindBuffer(34962,null)})),this}},{key:"setElementBuffer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.elements=e,this.elementsAccessor=t,this.clearDrawParams(),this.vertexArrayObject.setElementBuffer(e,t),this}},{key:"setBuffer",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(34963===t.target)return this.setElementBuffer(t,n);var r=this._resolveLocationAndAccessor(e,t,t.accessor,n),i=r.location,a=r.accessor;return i>=0&&(this.values[i]=t,this.accessors[i]=a,this.clearDrawParams(),this.vertexArrayObject.setBuffer(i,t,a)),this}},{key:"setConstant",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this._resolveLocationAndAccessor(e,t,Object.assign({size:t.length},n)),i=r.location,a=r.accessor;return i>=0&&(t=this.vertexArrayObject._normalizeConstantArrayValue(t),this.values[i]=t,this.accessors[i]=a,this.clearDrawParams(),this.vertexArrayObject.enable(i,!1)),this}},{key:"unbindBuffers",value:function(){var e=this;return this.vertexArrayObject.bind((function(){e.elements&&e.vertexArrayObject.setElementBuffer(null),e.buffer=e.buffer||new Bt(e.gl,{accessor:{size:4}});for(var t=0;t<e.vertexArrayObject.MAX_ATTRIBUTES;t++)e.values[t]instanceof Bt&&(e.gl.disableVertexAttribArray(t),e.gl.bindBuffer(34962,e.buffer.handle),e.gl.vertexAttribPointer(t,1,5126,!1,0,0))})),this}},{key:"bindBuffers",value:function(){var e=this;return this.vertexArrayObject.bind((function(){e.elements&&e.setElementBuffer(e.elements);for(var t=0;t<e.vertexArrayObject.MAX_ATTRIBUTES;t++){var n=e.values[t];n instanceof Bt&&e.setBuffer(t,n)}})),this}},{key:"bindForDraw",value:function(e,t,n){var r,i=this;return this.vertexArrayObject.bind((function(){i._setConstantAttributes(e,t),r=n()})),r}},{key:"_resolveLocationAndAccessor",value:function(e,t,n,r){var i=this,a={location:-1,accessor:null},o=this._getAttributeIndex(e),s=o.location,u=o.name;if(!Number.isFinite(s)||s<0)return this.unused[e]=t,N.once(3,(function(){return"unused value ".concat(e," in ").concat(i.id)}))(),a;var c=this._getAttributeInfo(u||s);if(!c)return a;var l=this.accessors[s]||{},f=It.resolve(c.accessor,l,n,r),h=f.size,d=f.type;return ct(Number.isFinite(h)&&Number.isFinite(d)),{location:s,accessor:f}}},{key:"_getAttributeInfo",value:function(e){return this.configuration&&this.configuration.getAttributeInfo(e)}},{key:"_getAttributeIndex",value:function(e){var t=Number(e);if(Number.isFinite(t))return{location:t};var n=Fi.exec(e),r=n?n[1]:e,i=n?Number(n[2]):0;return this.configuration?{location:this.configuration.getAttributeLocation(r)+i,name:r}:{location:-1}}},{key:"_setAttribute",value:function(e,t){if(t instanceof Bt)this.setBuffer(e,t);else if(Array.isArray(t)&&t.length&&t[0]instanceof Bt){var n=t[0],r=t[1];this.setBuffer(e,n,r)}else if(ArrayBuffer.isView(t)||Array.isArray(t)){var i=t;this.setConstant(e,i)}else{if(!(t.buffer instanceof Bt))throw new Error("VertexArray: attributes must be Buffers or constants (i.e. typed array)");var a=t;this.setBuffer(e,a.buffer,a)}}},{key:"_setConstantAttributes",value:function(e,t){var n=Math.max(0|e,0|t),r=this.values[0];ArrayBuffer.isView(r)&&this._setConstantAttributeZero(r,n);for(var i=1;i<this.vertexArrayObject.MAX_ATTRIBUTES;i++)r=this.values[i],ArrayBuffer.isView(r)&&this._setConstantAttribute(i,r)}},{key:"_setConstantAttributeZero",value:function(e,t){if(Ri.isSupported(this.gl,{constantAttributeZero:!0}))this._setConstantAttribute(0,e);else{var n=this.vertexArrayObject.getConstantBuffer(t,e);this.vertexArrayObject.setBuffer(0,n,this.accessors[0])}}},{key:"_setConstantAttribute",value:function(e,t){Ri.setConstant(this.gl,e,t)}},{key:"_updateDrawParams",value:function(){for(var e={isIndexed:!1,isInstanced:!1,indexCount:1/0,vertexCount:1/0,instanceCount:1/0},t=0;t<this.vertexArrayObject.MAX_ATTRIBUTES;t++)this._updateDrawParamsForLocation(e,t);return this.elements&&(e.elementCount=this.elements.getElementCount(this.elements.accessor),e.isIndexed=!0,e.indexType=this.elementsAccessor.type||this.elements.accessor.type,e.indexOffset=this.elementsAccessor.offset||0),e.indexCount===1/0&&(e.indexCount=0),e.vertexCount===1/0&&(e.vertexCount=0),e.instanceCount===1/0&&(e.instanceCount=0),e}},{key:"_updateDrawParamsForLocation",value:function(e,t){var n=this.values[t],r=this.accessors[t];if(n){var i=r.divisor>0;if(e.isInstanced=e.isInstanced||i,n instanceof Bt){var a=n;if(i){var o=a.getVertexCount(r);e.instanceCount=Math.min(e.instanceCount,o)}else{var s=a.getVertexCount(r);e.vertexCount=Math.min(e.vertexCount,s)}}}}},{key:"setElements",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return N.deprecated("setElements","setElementBuffer")(),this.setElementBuffer(e,t)}}]),e}();function Ni(e,t){for(var n=t.maxElts,r=void 0===n?16:n,i=t.size,a=void 0===i?1:i,o="[",s=0;s<e.length&&s<r;++s)s>0&&(o+=",".concat(s%a==0?" ":"")),o+=Di(e[s],t);var u=e.length>r?"...":"]";return"".concat(o).concat(u)}function Di(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=1e-16,r=t.isInteger,i=void 0!==r&&r;if(Array.isArray(e)||ArrayBuffer.isView(e))return Ni(e,t);if(!Number.isFinite(e))return String(e);if(Math.abs(e)<n)return i?"0":"0.";if(i)return e.toFixed(0);if(Math.abs(e)>100&&Math.abs(e)<1e4)return e.toFixed(0);var a=e.toPrecision(2),o=a.indexOf(".0");return o===a.length-2?a.slice(0,-1):a}function Bi(e,t,n,r){var i,a,o=e.gl;if(!t)return a={},u()(a,r,"null"),u()(a,"Format ","N/A"),a;var s,c,l,f="NOT PROVIDED",h=1,d=0,v=0;if(n&&(f=n.type,h=n.size,s=-1!==(f=String(f).replace("Array","")).indexOf("nt")),t instanceof Bt){var g,p,m=t,y=m.getDebugData(),_=y.data;if(c=y.changed?"*":"",l=_,d=(v=m.byteLength)/_.BYTES_PER_ELEMENT/h,n){var b=n.divisor>0;p="".concat(b?"I ":"P "," ").concat(d," (x").concat(h,"=").concat(v," bytes ").concat(ft(o,f),")")}else s=!0,p="".concat(v," bytes");return g={},u()(g,r,"".concat(c).concat(Di(l,{size:h,isInteger:s}))),u()(g,"Format ",p),g}return l=t,h=t.length,s=-1!==(f=String(t.constructor.name).replace("Array","")).indexOf("nt"),i={},u()(i,r,"".concat(Di(l,{size:h,isInteger:s})," (constant)")),u()(i,"Format ","".concat(h,"x").concat(f," (constant)")),i}function ji(e,t){var n=gr(t.type,t.size);return n?"".concat(e," (").concat(n.name,")"):e}function Ui(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Gi(e){var t=e.header,n=void 0===t?"Uniforms":t,r=e.program,i=e.uniforms,a=e.undefinedOnly,o=void 0!==a&&a;ct(r);var s,c=r._uniformSetters,l={},f=Object.keys(c).sort(),h=0,d=Ui(f);try{for(d.s();!(s=d.n()).done;){var v=s.value;v.match(".*_.*")||v.match(".*Matrix")||zi({table:l,header:n,uniforms:i,uniformName:v,undefinedOnly:o})&&h++}}catch(e){d.e(e)}finally{d.f()}var g,p=Ui(f);try{for(p.s();!(g=p.n()).done;){var m=g.value;m.match(".*Matrix")&&zi({table:l,header:n,uniforms:i,uniformName:m,undefinedOnly:o})&&h++}}catch(e){p.e(e)}finally{p.f()}var y,_=Ui(f);try{for(_.s();!(y=_.n()).done;){var b=y.value;l[b]||zi({table:l,header:n,uniforms:i,uniformName:b,undefinedOnly:o})&&h++}}catch(e){_.e(e)}finally{_.f()}var A=0,x={};if(!o)for(var E in i){var T=i[E];l[E]||(A++,x[E]=u()({Type:"NOT USED: ".concat(T)},n,Di(T)))}return{table:l,count:h,unusedTable:x,unusedCount:A}}function zi(e){var t,n=e.table,r=e.header,i=e.uniforms,a=e.uniformName,o=e.undefinedOnly,s=i[a],c=function(e){return null!=e}(s);return(!o||!c)&&(n[a]=(t={},u()(t,r,c?Di(s):"N/A"),u()(t,"Uniform Type",c?s:"NOT PROVIDED"),t),!0)}function Hi(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Wi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Wi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Wi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Xi(e){var t=e.accessor,n=gr(t.type,t.size);return n?"".concat(n.name," ").concat(e.name):e.name}function qi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ki(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qi(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Yi={POSITION:"positions",NORMAL:"normals",COLOR_0:"colors",TEXCOORD_0:"texCoords",TEXCOORD_1:"texCoords1",TEXCOORD_2:"texCoords2"};function Qi(e,t){var n=(t||{}).attributeMap,r=void 0===n?Yi:n;return r&&r[e]||e}function $i(e,t){var n;switch(e){case"texCoords":case"texCoord1":case"texCoord2":case"texCoord3":n="uvs";break;case"vertices":case"positions":case"normals":case"pickingColors":n="vectors"}switch(n){case"vectors":t.size=t.size||3;break;case"uvs":t.size=t.size||2}ct(Number.isFinite(t.size),"attribute ".concat(e," needs size"))}var Zi=function(){},Ji={},ea=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e);var r=n.id,i=void 0===r?dt("model"):r;ct(B(t)),this.id=i,this.gl=t,this.id=n.id||dt("Model"),this.lastLogTime=0,this.animated=!1,this.initialize(n)}return h()(e,[{key:"initialize",value:function(e){this.props={},this.programManager=e.programManager||ki.getDefaultProgramManager(this.gl),this._programManagerState=-1,this._managedProgram=!1;var t=e.program,n=void 0===t?null:t,r=e.vs,i=e.fs,a=e.modules,o=e.defines,s=e.inject,u=e.varyings,c=e.bufferMode,l=e.transpileToGLSL100;this.programProps={program:n,vs:r,fs:i,modules:a,defines:o,inject:s,varyings:u,bufferMode:c,transpileToGLSL100:l},this.program=null,this.vertexArray=null,this._programDirty=!0,this.userData={},this.needsRedraw=!0,this._attributes={},this.attributes={},this.uniforms={},this.pickable=!0,this._checkProgram(),this.setUniforms(Object.assign({},this.getModuleUniforms(e.moduleSettings))),this.drawMode=void 0!==e.drawMode?e.drawMode:4,this.vertexCount=e.vertexCount||0,this.geometryBuffers={},this.isInstanced=e.isInstanced||e.instanced||e.instanceCount>0,this._setModelProps(e),this.geometry={},ct(void 0!==this.drawMode&&Number.isFinite(this.vertexCount),"Model needs drawMode and vertexCount")}},{key:"setProps",value:function(e){this._setModelProps(e)}},{key:"delete",value:function(){for(var e in this._attributes)this._attributes[e]!==this.attributes[e]&&this._attributes[e].delete();this._managedProgram&&(this.programManager.release(this.program),this._managedProgram=!1),this.vertexArray.delete(),this._deleteGeometryBuffers()}},{key:"getDrawMode",value:function(){return this.drawMode}},{key:"getVertexCount",value:function(){return this.vertexCount}},{key:"getInstanceCount",value:function(){return this.instanceCount}},{key:"getAttributes",value:function(){return this.attributes}},{key:"getProgram",value:function(){return this.program}},{key:"setProgram",value:function(e){var t=e.program,n=e.vs,r=e.fs,i=e.modules,a=e.defines,o=e.inject,s=e.varyings,u=e.bufferMode,c=e.transpileToGLSL100;this.programProps={program:t,vs:n,fs:r,modules:i,defines:a,inject:o,varyings:s,bufferMode:u,transpileToGLSL100:c},this._programDirty=!0}},{key:"getUniforms",value:function(){return this.uniforms}},{key:"setDrawMode",value:function(e){return this.drawMode=e,this}},{key:"setVertexCount",value:function(e){return ct(Number.isFinite(e)),this.vertexCount=e,this}},{key:"setInstanceCount",value:function(e){return ct(Number.isFinite(e)),this.instanceCount=e,this}},{key:"setGeometry",value:function(e){return this.drawMode=e.drawMode,this.vertexCount=e.getVertexCount(),this._deleteGeometryBuffers(),this.geometryBuffers=function(e,t,n){var r={},i=t.indices;for(var a in t.attributes){var o=t.attributes[a],s=Qi(a,n);if("indices"===a)i=o;else if(o.constant)r[s]=o.value;else{var u=o.value,c=Ki({},o);delete c.value,r[s]=[new Bt(e,u),c],$i(a,c)}}if(i){var l=i.value||i;ct(l instanceof Uint16Array||l instanceof Uint32Array,'attribute array for "indices" must be of integer type');var f={size:1,isIndexed:void 0===i.isIndexed||i.isIndexed};r.indices=[new Bt(e,{data:l,target:34963}),f]}return r}(this.gl,e),this.vertexArray.setAttributes(this.geometryBuffers),this}},{key:"setAttributes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(gt(e))return this;var t={};for(var n in e){var r=e[n];t[n]=r.getValue?r.getValue():r}return this.vertexArray.setAttributes(t),this}},{key:"setUniforms",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(this.uniforms,e),this}},{key:"getModuleUniforms",value:function(e){this._checkProgram();var t=this.programManager.getUniforms(this.program);return t?t(e):{}}},{key:"updateModuleSettings",value:function(e){var t=this.getModuleUniforms(e||{});return this.setUniforms(t)}},{key:"clear",value:function(e){return sn(this.program.gl,e),this}},{key:"draw",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._checkProgram();var t,n=e.moduleSettings,r=void 0===n?null:n,i=e.framebuffer,a=e.uniforms,o=void 0===a?{}:a,s=e.attributes,u=void 0===s?{}:s,c=e.transformFeedback,l=void 0===c?this.transformFeedback:c,f=e.parameters,h=void 0===f?{}:f,d=e.vertexArray,v=void 0===d?this.vertexArray:d;this.setAttributes(u),this.updateModuleSettings(r),this.setUniforms(o),N.priority>=2&&(t=this._logDrawCallStart(2));var g=this.vertexArray.getDrawParams(),p=this.props,m=p.isIndexed,y=void 0===m?g.isIndexed:m,_=p.indexType,b=void 0===_?g.indexType:_,A=p.indexOffset,x=void 0===A?g.indexOffset:A,E=p.vertexArrayInstanced,T=void 0===E?g.isInstanced:E;T&&!this.isInstanced&&N.warn("Found instanced attributes on non-instanced model",this.id)();var k=this.isInstanced,w=this.instanceCount,O=this.props,S=O.onBeforeRender,L=void 0===S?Zi:S,I=O.onAfterRender,P=void 0===I?Zi:I;L(),this.program.setUniforms(this.uniforms);var R=this.program.draw(Object.assign(Ji,e,{logPriority:t,uniforms:null,framebuffer:i,parameters:h,drawMode:this.getDrawMode(),vertexCount:this.getVertexCount(),vertexArray:v,transformFeedback:l,isIndexed:y,indexType:b,isInstanced:k,instanceCount:w,offset:y?x:0}));return P(),N.priority>=2&&this._logDrawCallEnd(t,v,i),R}},{key:"transform",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.discard,n=void 0===t||t,r=e.feedbackBuffers,i=e.unbindModels,a=void 0===i?[]:i,o=e.parameters;r&&this._setFeedbackBuffers(r),n&&(o=Object.assign({},o,u()({},35977,n))),a.forEach((function(e){return e.vertexArray.unbindBuffers()}));try{this.draw(Object.assign({},e,{parameters:o}))}finally{a.forEach((function(e){return e.vertexArray.bindBuffers()}))}return this}},{key:"render",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return N.warn("Model.render() is deprecated. Use Model.setUniforms() and Model.draw()")(),this.setUniforms(e).draw()}},{key:"_setModelProps",value:function(e){Object.assign(this.props,e),"uniforms"in e&&this.setUniforms(e.uniforms),"pickable"in e&&(this.pickable=e.pickable),"instanceCount"in e&&(this.instanceCount=e.instanceCount),"geometry"in e&&this.setGeometry(e.geometry),"attributes"in e&&this.setAttributes(e.attributes),"_feedbackBuffers"in e&&this._setFeedbackBuffers(e._feedbackBuffers)}},{key:"_checkProgram",value:function(){if(this._programDirty||this.programManager.stateHash!==this._programManagerState){var e=this.programProps.program;if(e)this._managedProgram=!1;else{var t=this.programProps,n=t.vs,r=t.fs,i=t.modules,a=t.inject,o=t.defines,s=t.varyings,u=t.bufferMode,c=t.transpileToGLSL100;e=this.programManager.get({vs:n,fs:r,modules:i,inject:a,defines:o,varyings:s,bufferMode:u,transpileToGLSL100:c}),this.program&&this._managedProgram&&this.programManager.release(this.program),this._programManagerState=this.programManager.stateHash,this._managedProgram=!0}ct(e instanceof Ar,"Model needs a program"),this._programDirty=!1,e!==this.program&&(this.program=e,this.vertexArray?this.vertexArray.setProps({program:this.program,attributes:this.vertexArray.attributes}):this.vertexArray=new Mi(this.gl,{program:this.program}),this.setUniforms(Object.assign({},this.getModuleUniforms())))}}},{key:"_deleteGeometryBuffers",value:function(){for(var e in this.geometryBuffers){var t=this.geometryBuffers[e][0]||this.geometryBuffers[e];t instanceof Bt&&t.delete()}}},{key:"_setAnimationProps",value:function(e){this.animated&&ct(e,"Model.draw(): animated uniforms but no animationProps")}},{key:"_setFeedbackBuffers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(gt(e))return this;var t=this.program.gl;return this.transformFeedback=this.transformFeedback||new Er(t,{program:this.program}),this.transformFeedback.setBuffers(e),this}},{key:"_logDrawCallStart",value:function(e){var t=e>3?0:1e4;if(!(Date.now()-this.lastLogTime<t))return this.lastLogTime=Date.now(),N.group(2,">>> DRAWING MODEL ".concat(this.id),{collapsed:N.level<=2})(),e}},{key:"_logDrawCallEnd",value:function(e,t,n,r){if(void 0!==e){var i=function(e){var t=e.vertexArray,n=e.header,r=void 0===n?"Attributes":n;if(!t.configuration)return{};var i={};t.elements&&(i.ELEMENT_ARRAY_BUFFER=Bi(t,t.elements,null,r));var a=t.values;for(var o in a){var s=t._getAttributeInfo(o);if(s){var u="".concat(o,": ").concat(s.name),c=t.accessors[s.location];c&&(u="".concat(o,": ").concat(ji(s.name,c))),i[u]=Bi(t,a[o],c,r)}}return i}({vertexArray:t,header:"".concat(this.id," attributes"),attributes:this._attributes}),a=Gi({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,n)}),o=a.table,s=a.unusedTable,c=a.unusedCount,l=Gi({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,n),undefinedOnly:!0}),f=l.table;l.count>0&&N.log("MISSING UNIFORMS",Object.keys(f))(),c>0&&N.log("UNUSED UNIFORMS",Object.keys(s))();var h=function(e){var t,n={},r="Accessors for ".concat(e.id),i=Hi(e.attributeInfos);try{for(i.s();!(t=i.n()).done;){var a=t.value;if(a){var o=Xi(a);n["in ".concat(o)]=u()({},r,JSON.stringify(a.accessor))}}}catch(e){i.e(e)}finally{i.f()}var s,c=Hi(e.varyingInfos);try{for(c.s();!(s=c.n()).done;){var l=s.value;if(l){var f=Xi(l);n["out ".concat(f)]=u()({},r,JSON.stringify(l.accessor))}}}catch(e){c.e(e)}finally{c.f()}return n}(this.vertexArray.configuration);N.table(e,i)(),N.table(e,o)(),N.table(e+1,h)(),r&&r.log({logLevel:2,message:"Rendered to ".concat(r.id)}),N.groupEnd(2,">>> DRAWING MODEL ".concat(this.id))()}}}]),e}(),ta="void main() {gl_FragColor = vec4(0);}",na="out vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}",ra="#version 300 es\n".concat(na);function ia(e,t){t=Array.isArray(t)?t:[t];var n=e.replace(/^\s+/,"").split(/\s+/),r=ae()(n,3),i=r[0],a=r[1],o=r[2];return t.includes(i)&&a&&o?{qualifier:i,type:a,name:o.split(";")[0]}:null}function aa(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.version,n=void 0===t?100:t,r=e.input,i=e.inputType,a=e.output;if(!r)return 300===n?ra:n>300?"#version ".concat(n,"\n").concat(na):ta;var o=sa(r,i);return n>=300?"#version ".concat(n," ").concat(300===n?"es":"","\nin ").concat(i," ").concat(r,";\nout vec4 ").concat(a,";\nvoid main() {\n ").concat(a," = ").concat(o,";\n}"):"varying ".concat(i," ").concat(r,";\nvoid main() {\n gl_FragColor = ").concat(o,";\n}")}function oa(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:return Pr(!1),null}}function sa(e,t){switch(t){case"float":return"vec4(".concat(e,", 0.0, 0.0, 1.0)");case"vec2":return"vec4(".concat(e,", 0.0, 1.0)");case"vec3":return"vec4(".concat(e,", 1.0)");case"vec4":return e;default:return Pr(!1),null}}function ua(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ca(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ca(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ca(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var la=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e),this.gl=t,this.currentIndex=0,this.feedbackMap={},this.varyings=null,this.bindings=[],this.resources={},this._initialize(n),Object.seal(this)}return h()(e,[{key:"setupResources",value:function(e){var t,n=ua(this.bindings);try{for(n.s();!(t=n.n()).done;){var r=t.value;this._setupTransformFeedback(r,e)}}catch(e){n.e(e)}finally{n.f()}}},{key:"updateModelProps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.varyings;return t.length>0&&(e=Object.assign({},e,{varyings:t})),e}},{key:"getDrawOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.bindings[this.currentIndex],n=t.sourceBuffers,r=t.transformFeedback,i=Object.assign({},n,e.attributes);return{attributes:i,transformFeedback:r}}},{key:"swap",value:function(){return!!this.feedbackMap&&(this.currentIndex=this._getNextIndex(),!0)}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(e)}},{key:"getBuffer",value:function(e){var t=this.bindings[this.currentIndex].feedbackBuffers,n=e?t[e]:null;return n?n instanceof Bt?n:n.buffer:null}},{key:"getData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.varyingName,n=this.getBuffer(t);return n?n.getData():null}},{key:"delete",value:function(){for(var e in this.resources)this.resources[e].delete()}},{key:"_initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(e),this.varyings=e.varyings||Object.keys(this.bindings[this.currentIndex].feedbackBuffers),this.varyings.length>0&&ct(j(this.gl))}},{key:"_getFeedbackBuffers",value:function(e){var t=e.sourceBuffers,n=void 0===t?{}:t,r={};if(this.bindings[this.currentIndex]&&Object.assign(r,this.bindings[this.currentIndex].feedbackBuffers),this.feedbackMap)for(var i in this.feedbackMap){var a=this.feedbackMap[i];i in n&&(r[a]=i)}for(var o in Object.assign(r,e.feedbackBuffers),r){var s=r[o];if("string"==typeof s){var u=n[s],c=u.byteLength,l=u.usage,f=u.accessor;r[o]=this._createNewBuffer(o,{byteLength:c,usage:l,accessor:f})}}return r}},{key:"_setupBuffers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.sourceBuffers,n=void 0===t?null:t;Object.assign(this.feedbackMap,e.feedbackMap);var r=this._getFeedbackBuffers(e);this._updateBindings({sourceBuffers:n,feedbackBuffers:r})}},{key:"_setupTransformFeedback",value:function(e,t){var n=t.model.program;e.transformFeedback=new Er(this.gl,{program:n,buffers:e.feedbackBuffers})}},{key:"_updateBindings",value:function(e){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e),this.feedbackMap){var t=this._swapBuffers(this.bindings[this.currentIndex]),n=t.sourceBuffers,r=t.feedbackBuffers,i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceBuffers:n,feedbackBuffers:r})}}},{key:"_updateBinding",value:function(e,t){return e?(Object.assign(e.sourceBuffers,t.sourceBuffers),Object.assign(e.feedbackBuffers,t.feedbackBuffers),e.transformFeedback&&e.transformFeedback.setBuffers(e.feedbackBuffers),e):{sourceBuffers:Object.assign({},t.sourceBuffers),feedbackBuffers:Object.assign({},t.feedbackBuffers)}}},{key:"_swapBuffers",value:function(e){if(!this.feedbackMap)return null;var t=Object.assign({},e.sourceBuffers),n=Object.assign({},e.feedbackBuffers);for(var r in this.feedbackMap){var i=this.feedbackMap[r];t[r]=e.feedbackBuffers[i],n[i]=e.sourceBuffers[r],ct(n[i]instanceof Bt)}return{sourceBuffers:t,feedbackBuffers:n}}},{key:"_createNewBuffer",value:function(e,t){var n=new Bt(this.gl,t);return this.resources[e]&&this.resources[e].delete(),this.resources[e]=n,n}},{key:"_getNextIndex",value:function(){return(this.currentIndex+1)%2}}]),e}();function fa(e){var t=100,n=e.match(/[^\s]+/g);if(n.length>=2&&"#version"===n[0]){var r=parseInt(n[1],10);Number.isFinite(r)&&(t=r)}return t}var ha,da={name:"transform",vs:"attribute float transform_elementID;\n\n// returns half of pixel size, used to move the pixel position to center of the pixel.\nvec2 transform_getPixelSizeHalf(vec2 size) {\n return vec2(1.) / (2. * size);\n}\n\n// returns current elements pixel indeces [x, y],\n// where x ranges in [0 to texSize-1] and y ranges in [0 to texSize-1]\nvec2 transform_getPixelIndices(vec2 texSize, vec2 pixelSizeHalf) {\n // Add safe offset (half of pixel height) before doing floor\n float yIndex = floor((transform_elementID / texSize[0]) + pixelSizeHalf[1]);\n float xIndex = transform_elementID - (yIndex * texSize[0]);\n return vec2(xIndex, yIndex);\n}\n\n// returns current elementID's texture co-ordianate\nvec2 transform_getTexCoord(vec2 size) {\n vec2 pixelSizeHalf = transform_getPixelSizeHalf(size);\n vec2 indices = transform_getPixelIndices(size, pixelSizeHalf);\n vec2 coord = indices / size + pixelSizeHalf;\n return coord;\n}\n\n// returns current elementID's position\nvec2 transform_getPos(vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n // Change from [0 1] range to [-1 1]\n vec2 pos = (texCoord * (2.0, 2.0)) - (1., 1.);\n return pos;\n}\n\n// returns current elementID's pixel value\nvec4 transform_getInput(sampler2D texSampler, vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n vec4 textureColor = texture2D(texSampler, texCoord);\n return textureColor;\n}\n",fs:null};function va(e){var t=e.vs,n=e.sourceTextureMap,r=e.targetTextureVarying,i=e.targetTexture,a=Object.keys(n).length,o=null,s={},u=t,c={};if(a>0||r){var l=u.split("\n"),f=l.slice();if(l.forEach((function(e,t,i){if(a>0){var u=function(e,t){var n={},r=function(e){return ia(e,["attribute","in"])}(e);if(!r)return null;var i=r.type,a=r.name;if(a&&t[a]){var o="// ".concat(e," => Replaced by Transform with a sampler"),s=function(e){var t="".concat("transform_uSampler_").concat(e),n="".concat("transform_uSize_").concat(e),r=" uniform sampler2D ".concat(t,";\n uniform vec2 ").concat(n,";");return{samplerName:t,sizeName:n,uniformDeclerations:r}}(a),u=s.samplerName,c=s.sizeName,l=s.uniformDeclerations,f=function(e){switch(e){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:return Pr(!1),null}}(i),h=" ".concat(i," ").concat(a," = transform_getInput(").concat(u,", ").concat(c,").").concat(f,";\n");return n[u]=a,{updatedLine:o,inject:{"vs:#decl":l,"vs:#main-start":h},samplerTextureMap:n}}return null}(e,n);if(u){var l=u.updatedLine,h=u.inject;f[t]=l,c=ti([c,h]),Object.assign(s,u.samplerTextureMap),a--}}r&&!o&&(o=function(e,t){var n=ia(e,["varying","out"]);if(!n)return null;return n.name===t?n.type:null}(e,r))})),r){ct(i);var h="".concat("transform_uSize_").concat(r),d="uniform vec2 ".concat(h,";\n"),v=" vec2 ".concat("transform_position"," = transform_getPos(").concat(h,");\n gl_Position = vec4(").concat("transform_position",", 0, 1.);\n");c=ti([c,{"vs:#decl":d,"vs:#main-start":v}])}u=f.join("\n")}return{vs:u,targetTextureType:o,inject:c,samplerTextureMap:s}}function ga(e){var t,n,r=e.sourceTextureMap,i=e.targetTextureVarying,a=e.targetTexture,o={};for(var s in i&&(t=a.width,n=a.height,o["".concat("transform_uSize_").concat(i)]=[t,n]),r){var u=r[s];t=u.width,n=u.height,o["".concat("transform_uSize_").concat(s)]=[t,n]}return o}var pa=(ha={},u()(ha,10241,9728),u()(ha,10240,9728),u()(ha,10242,33071),u()(ha,10243,33071),ha),ma=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e),this.gl=t,this.id=this.currentIndex=0,this._swapTexture=null,this.targetTextureVarying=null,this.targetTextureType=null,this.samplerTextureMap=null,this.bindings=[],this.resources={},this._initialize(n),Object.seal(this)}return h()(e,[{key:"updateModelProps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this._processVertexShader(e);return Object.assign({},e,t)}},{key:"getDrawOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.bindings[this.currentIndex],n=t.sourceBuffers,r=t.sourceTextures,i=t.framebuffer,a=t.targetTexture,o=Object.assign({},n,e.attributes),s=Object.assign({},e.uniforms),u=Object.assign({},e.parameters),c=e.discard;if(this.hasSourceTextures||this.hasTargetTexture){for(var l in o.transform_elementID=this.elementIDBuffer,this.samplerTextureMap){var f=this.samplerTextureMap[l];s[l]=r[f]}this._setSourceTextureParameters();var h=ga({sourceTextureMap:r,targetTextureVarying:this.targetTextureVarying,targetTexture:a});Object.assign(s,h)}return this.hasTargetTexture&&(c=!1,u.viewport=[0,0,i.width,i.height]),{attributes:o,framebuffer:i,uniforms:s,discard:c,parameters:u}}},{key:"swap",value:function(){return!!this._swapTexture&&(this.currentIndex=this._getNextIndex(),!0)}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupTextures(e)}},{key:"getTargetTexture",value:function(){return this.bindings[this.currentIndex].targetTexture}},{key:"getData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.packed,n=void 0!==t&&t,r=this.bindings[this.currentIndex].framebuffer,i=bn(r);if(!n)return i;for(var a=i.constructor,o=oa(this.targetTextureType),s=new a(i.length*o/4),u=0,c=0;c<i.length;c+=4)for(var l=0;l<o;l++)s[u++]=i[c+l];return s}},{key:"getFramebuffer",value:function(){return this.bindings[this.currentIndex].framebuffer}},{key:"delete",value:function(){this.ownTexture&&this.ownTexture.delete(),this.elementIDBuffer&&this.elementIDBuffer.delete()}},{key:"_initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e._targetTextureVarying,n=e._swapTexture;this._swapTexture=n,this.targetTextureVarying=t,this.hasTargetTexture=t,this._setupTextures(e)}},{key:"_createTargetTexture",value:function(e){var t=e.sourceTextures,n=e.textureOrReference;if(n instanceof en)return n;var r=t[n];return r?(this._targetRefTexName=n,this._createNewTexture(r)):null}},{key:"_setupTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.sourceBuffers,n=e._sourceTextures,r=void 0===n?{}:n,i=e._targetTexture,a=this._createTargetTexture({sourceTextures:r,textureOrReference:i});this.hasSourceTextures=this.hasSourceTextures||r&&Object.keys(r).length>0,this._updateBindings({sourceBuffers:t,sourceTextures:r,targetTexture:a}),"elementCount"in e&&this._updateElementIDBuffer(e.elementCount)}},{key:"_updateElementIDBuffer",value:function(e){if(!("number"!=typeof e||this.elementCount>=e)){var t=new Float32Array(e);t.forEach((function(e,t,n){n[t]=t})),this.elementIDBuffer?this.elementIDBuffer.setData({data:t}):this.elementIDBuffer=new Bt(this.gl,{data:t,accessor:{size:1}}),this.elementCount=e}}},{key:"_updateBindings",value:function(e){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e),this._swapTexture){var t=this._swapTextures(this.bindings[this.currentIndex]),n=t.sourceTextures,r=t.targetTexture,i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceTextures:n,targetTexture:r})}}},{key:"_updateBinding",value:function(e,t){var n=t.sourceBuffers,r=t.sourceTextures,i=t.targetTexture;if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,r),Object.assign(e.sourceBuffers,n),i){e.targetTexture=i;var a=i.width,o=i.height,s=e.framebuffer;s?(s.update({attachments:u()({},36064,i),resizeAttachments:!1}),s.resize({width:a,height:o})):e.framebuffer=new Cn(this.gl,{id:"transform-framebuffer",width:a,height:o,attachments:u()({},36064,i)})}return e}},{key:"_setSourceTextureParameters",value:function(){var e=this.currentIndex,t=this.bindings[e].sourceTextures;for(var n in t)t[n].setParameters(pa)}},{key:"_swapTextures",value:function(e){if(!this._swapTexture)return null;var t=Object.assign({},e.sourceTextures);return t[this._swapTexture]=e.targetTexture,{sourceTextures:t,targetTexture:e.sourceTextures[this._swapTexture]}}},{key:"_createNewTexture",value:function(e){var t,n=_n(e,{parameters:(t={},u()(t,10241,9728),u()(t,10240,9728),u()(t,10242,33071),u()(t,10243,33071),t),pixelStore:u()({},37440,!1)});return this.ownTexture&&this.ownTexture.delete(),this.ownTexture=n,n}},{key:"_getNextIndex",value:function(){return(this.currentIndex+1)%2}},{key:"_processVertexShader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.bindings[this.currentIndex],n=t.sourceTextures,r=t.targetTexture,i=va({vs:e.vs,sourceTextureMap:n,targetTextureVarying:this.targetTextureVarying,targetTexture:r}),a=i.vs,o=i.uniforms,s=i.targetTextureType,u=i.inject,c=i.samplerTextureMap,l=ti([e.inject||{},u]);this.targetTextureType=s,this.samplerTextureMap=c;var f=e._fs||aa({version:fa(a),input:this.targetTextureVarying,inputType:s,output:"transform_output"}),h=this.hasSourceTextures||this.targetTextureVarying?[da].concat(e.modules||[]):e.modules;return{vs:a,fs:f,modules:h,uniforms:o,inject:l}}}]),e}();function ya(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _a(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function _a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ba=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e),this.gl=t,this.model=null,this.elementCount=0,this.bufferTransform=null,this.textureTransform=null,this.elementIDBuffer=null,this._initialize(n),Object.seal(this)}return h()(e,null,[{key:"isSupported",value:function(e){return j(e)}}]),h()(e,[{key:"delete",value:function(){var e=this.model,t=this.bufferTransform,n=this.textureTransform;e&&e.delete(),t&&t.delete(),n&&n.delete()}},{key:"run",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.clearRenderTarget,n=void 0===t||t,r=this._updateDrawOptions(e);n&&r.framebuffer&&r.framebuffer.clear({color:!0}),this.model.transform(r)}},{key:"swap",value:function(){var e,t=!1,n=ya([this.bufferTransform,this.textureTransform].filter(Boolean));try{for(n.s();!(e=n.n()).done;){var r=e.value;t=t||r.swap()}}catch(e){n.e(e)}finally{n.f()}ct(t,"Nothing to swap")}},{key:"getBuffer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.bufferTransform&&this.bufferTransform.getBuffer(e)}},{key:"getData",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=[this.bufferTransform,this.textureTransform].filter(Boolean),r=ya(n);try{for(r.s();!(e=r.n()).done;){var i=e.value,a=i.getData(t);if(a)return a}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"getFramebuffer",value:function(){return this.textureTransform&&this.textureTransform.getFramebuffer()}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"elementCount"in e&&this.model.setVertexCount(e.elementCount);var t,n=[this.bufferTransform,this.textureTransform].filter(Boolean),r=ya(n);try{for(r.s();!(t=r.n()).done;){var i=t.value;i.update(e)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.gl;this._buildResourceTransforms(t,e),e=this._updateModelProps(e),this.model=new ea(t,Object.assign({},e,{fs:e.fs||aa({version:fa(e.vs)}),id:e.id||"transform-model",drawMode:e.drawMode||0,vertexCount:e.elementCount})),this.bufferTransform&&this.bufferTransform.setupResources({model:this.model})}},{key:"_updateModelProps",value:function(e){var t,n=Object.assign({},e),r=ya([this.bufferTransform,this.textureTransform].filter(Boolean));try{for(r.s();!(t=r.n()).done;){n=t.value.updateModelProps(n)}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"_buildResourceTransforms",value:function(e,t){(function(e){if(!gt(e.feedbackBuffers)||!gt(e.feedbackMap)||e.varyings&&e.varyings.length>0)return!0;return!1})(t)&&(this.bufferTransform=new la(e,t)),function(e){if(!gt(e._sourceTextures)||e._targetTexture||e._targetTextureVarying)return!0;return!1}(t)&&(this.textureTransform=new ma(e,t)),ct(this.bufferTransform||this.textureTransform,"must provide source/feedback buffers or source/target textures")}},{key:"_updateDrawOptions",value:function(e){var t,n=Object.assign({},e),r=ya([this.bufferTransform,this.textureTransform].filter(Boolean));try{for(r.s();!(t=r.n()).done;){var i=t.value;n=Object.assign(n,i.getDrawOptions(n))}}catch(e){r.e(e)}finally{r.f()}return n}}]),e}();function Aa(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return xa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xa(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function xa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ea=1,Ta=1,ka=function(){function e(){l()(this,e),this.time=0,this.channels=new Map,this.animations=new Map,this.playing=!1,this.lastEngineTime=-1}return h()(e,[{key:"addChannel",value:function(e){var t=e.delay,n=void 0===t?0:t,r=e.duration,i=void 0===r?Number.POSITIVE_INFINITY:r,a=e.rate,o=void 0===a?1:a,s=e.repeat,u=Ea++,c={time:0,delay:n,duration:i,rate:o,repeat:void 0===s?1:s};return this._setChannelTime(c,this.time),this.channels.set(u,c),u}},{key:"removeChannel",value:function(e){this.channels.delete(e);var t,n=Aa(this.animations);try{for(n.s();!(t=n.n()).done;){var r=ae()(t.value,2),i=r[0];r[1].channel===e&&this.detachAnimation(i)}}catch(e){n.e(e)}finally{n.f()}}},{key:"isFinished",value:function(e){var t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}},{key:"getTime",value:function(e){if(void 0===e)return this.time;var t=this.channels.get(e);return void 0===t?-1:t.time}},{key:"setTime",value:function(e){this.time=Math.max(0,e);var t,n=Aa(this.channels.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;this._setChannelTime(r,this.time)}}catch(e){n.e(e)}finally{n.f()}var i,a=Aa(this.animations.values());try{for(a.s();!(i=a.n()).done;){var o=i.value,s=o.animation,u=o.channel;s.setTime(this.getTime(u))}}catch(e){a.e(e)}finally{a.f()}}},{key:"play",value:function(){this.playing=!0}},{key:"pause",value:function(){this.playing=!1,this.lastEngineTime=-1}},{key:"reset",value:function(){this.setTime(0)}},{key:"attachAnimation",value:function(e,t){var n=Ta++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}},{key:"detachAnimation",value:function(e){this.animations.delete(e)}},{key:"update",value:function(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}},{key:"_setChannelTime",value:function(e,t){var n=t-e.delay;n>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}}]),e}();function wa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Oa={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Sa=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,e);var n=t.id,r=void 0===n?dt("geometry"):n,i=t.drawMode,a=void 0===i?Oa.TRIANGLES:i,o=t.attributes,s=void 0===o?{}:o,u=t.indices,c=void 0===u?null:u,f=t.vertexCount,h=void 0===f?null:f;this.id=r,this.drawMode=0|a,this.attributes={},this.userData={},this._setAttributes(s,c),this.vertexCount=h||this._calculateVertexCount(this.attributes,this.indices)}return h()(e,null,[{key:"DRAW_MODE",get:function(){return Oa}}]),h()(e,[{key:"getVertexCount",value:function(){return this.vertexCount}},{key:"getAttributes",value:function(){return this.indices?function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wa(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({indices:this.indices},this.attributes):this.attributes}},{key:"_print",value:function(e){return"Geometry ".concat(this.id," attribute ").concat(e)}},{key:"_setAttributes",value:function(e,t){for(var n in t&&(this.indices=ArrayBuffer.isView(t)?{value:t,size:1}:t),e){var r=e[n];r=ArrayBuffer.isView(r)?{value:r}:r,ct(ArrayBuffer.isView(r.value),"".concat(this._print(n),": must be typed array or object with value as typed array")),"POSITION"!==n&&"positions"!==n||r.size||(r.size=3),"indices"===n?(ct(!this.indices),this.indices=r):this.attributes[n]=r}return this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this}},{key:"_calculateVertexCount",value:function(e,t){if(t)return t.value.length;var n=1/0;for(var r in e){var i=e[r],a=i.value,o=i.size;!i.constant&&a&&o>=1&&(n=Math.min(n,a.length/o))}return ct(Number.isFinite(n)),n}},{key:"mode",get:function(){return this.drawMode}}]),e}();function La(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Ia=[-1,-1,1,-1,-1,1,1,1],Pa=function(e){it()(n,e);var t=La(n);function n(e,r){var i;l()(this,n);var a=Ia.map((function(e){return-1===e?0:e}));return(i=t.call(this,e,Object.assign({},r,{vs:"attribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n",geometry:new Sa({drawMode:5,vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(Ia)},aTexCoord:{size:2,value:new Float32Array(a)},aCoordinate:{size:2,value:new Float32Array(a)}}})}))).setVertexCount(4),i}return n}(ea);function Ra(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Fa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ra(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ra(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ca(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Ma={x:[2,0,1],y:[0,1,2],z:[1,2,0]},Na=function(e){it()(n,e);var t=Ca(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?dt("truncated-code-geometry"):r,a=Da(e),o=a.indices,s=a.attributes;return t.call(this,Fa(Fa({},e),{},{id:i,indices:o,attributes:Fa(Fa({},s),e.attributes)}))}return n}(Sa);function Da(e){for(var t=e.bottomRadius,n=void 0===t?0:t,r=e.topRadius,i=void 0===r?0:r,a=e.height,o=void 0===a?1:a,s=e.nradial,u=void 0===s?10:s,c=e.nvertical,l=void 0===c?10:c,f=e.verticalAxis,h=void 0===f?"y":f,d=e.topCap,v=void 0!==d&&d,g=e.bottomCap,p=void 0!==g&&g,m=(v?2:0)+(p?2:0),y=(u+1)*(l+1+m),_=Math.atan2(n-i,o),b=Math.sin,A=Math.cos,x=Math.PI,E=A(_),T=b(_),k=v?-2:0,w=l+(p?2:0),O=u+1,S=new Uint16Array(u*(l+m)*6),L=Ma[h],I=new Float32Array(3*y),P=new Float32Array(3*y),R=new Float32Array(2*y),F=0,C=0,M=k;M<=w;M++){var N=M/l,D=o*N,B=void 0;M<0?(D=0,N=1,B=n):M>l?(D=o,N=1,B=i):B=n+M/l*(i-n),-2!==M&&M!==l+2||(B=0,N=0),D-=o/2;for(var j=0;j<O;j++){var U=b(j*x*2/u),V=A(j*x*2/u);I[F+L[0]]=U*B,I[F+L[1]]=D,I[F+L[2]]=V*B,P[F+L[0]]=M<0||M>l?0:U*E,P[F+L[1]]=M<0?-1:M>l?1:T,P[F+L[2]]=M<0||M>l?0:V*E,R[C+0]=j/u,R[C+1]=N,C+=2,F+=3}}for(var G=0;G<l+m;G++)for(var z=0;z<u;z++){var H=6*(G*u+z);S[H+0]=O*(G+0)+0+z,S[H+1]=O*(G+0)+1+z,S[H+2]=O*(G+1)+1+z,S[H+3]=O*(G+0)+0+z,S[H+4]=O*(G+1)+1+z,S[H+5]=O*(G+1)+0+z}return{indices:S,attributes:{POSITION:{size:3,value:I},NORMAL:{size:3,value:P},TEXCOORD_0:{size:2,value:R}}}}function Ba(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ja(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ba(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ba(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ua(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Va=function(e){it()(n,e);var t=Ua(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?dt("cone-geometry"):r,a=e.radius,o=void 0===a?1:a,s=e.cap,u=void 0===s||s;return t.call(this,ja(ja({},e),{},{id:i,topRadius:0,topCap:Boolean(u),bottomCap:Boolean(u),bottomRadius:o}))}return n}(Na);function Ga(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function za(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ga(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ga(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ha(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Wa=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),Xa=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),qa=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),Ka=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),Ya={POSITION:{size:3,value:new Float32Array(Xa)},NORMAL:{size:3,value:new Float32Array(qa)},TEXCOORD_0:{size:2,value:new Float32Array(Ka)}},Qa=function(e){it()(n,e);var t=Ha(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?dt("cube-geometry"):r;return t.call(this,za(za({},e),{},{id:i,indices:{size:1,value:new Uint16Array(Wa)},attributes:za(za({},Ya),e.attributes)}))}return n}(Sa);function $a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Za(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$a(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ja(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var eo=function(e){it()(n,e);var t=Ja(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?dt("cylinder-geometry"):r,a=e.radius,o=void 0===a?1:a;return t.call(this,Za(Za({},e),{},{id:i,bottomRadius:o,topRadius:o}))}return n}(Na);function to(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}Math.PI,Math.PI;var no={};function ro(e){return Math.round(e/no.EPSILON)*no.EPSILON}function io(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.precision,r=void 0===n?no.precision||4:n;return e=ro(e),"".concat(parseFloat(e.toPrecision(r)))}function ao(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function oo(e,t,n){var r=no.EPSILON;n&&(no.EPSILON=n);try{if(e===t)return!0;if(ao(e)&&ao(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!oo(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):!(!Number.isFinite(e)||!Number.isFinite(t))&&Math.abs(e-t)<=no.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{no.EPSILON=r}}function so(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}no.EPSILON=1e-12,no.debug=!1,no.precision=4,no.printTypes=!1,no.printDegrees=!1,no.printRowMajor=!0;var uo=function(e){it()(n,e);var t=so(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"from",value:function(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}},{key:"fromArray",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}},{key:"to",value:function(e){return e===this?this:ao(e)?this.toArray(e):this.toObject(e)}},{key:"toTarget",value:function(e){return e?this.to(e):this}},{key:"toArray",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}},{key:"toFloat32Array",value:function(){return new Float32Array(this)}},{key:"toString",value:function(){return this.formatString(no)}},{key:"formatString",value:function(e){for(var t="",n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+io(this[n],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}},{key:"equals",value:function(e){if(!e||this.length!==e.length)return!1;for(var t=0;t<this.ELEMENTS;++t)if(!oo(this[t],e[t]))return!1;return!0}},{key:"exactEquals",value:function(e){if(!e||this.length!==e.length)return!1;for(var t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}},{key:"negate",value:function(){for(var e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}},{key:"lerp",value:function(e,t,n){void 0===n&&(n=t,t=e,e=this);for(var r=0;r<this.ELEMENTS;++r){var i=e[r];this[r]=i+n*(t[r]-i)}return this.check()}},{key:"min",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}},{key:"max",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}},{key:"clamp",value:function(e,t){for(var n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}},{key:"add",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]+=a[o];return this.check()}},{key:"subtract",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]-=a[o];return this.check()}},{key:"scale",value:function(e){if(Array.isArray(e))return this.multiply(e);for(var t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}},{key:"sub",value:function(e){return this.subtract(e)}},{key:"setScalar",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}},{key:"addScalar",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}},{key:"subScalar",value:function(e){return this.addScalar(-e)}},{key:"multiplyScalar",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}},{key:"divideScalar",value:function(e){return this.scale(1/e)}},{key:"clampScalar",value:function(e,t){for(var n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}},{key:"multiplyByScalar",value:function(e){return this.scale(e)}},{key:"check",value:function(){if(no.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}},{key:"validate",value:function(){for(var e=this.length===this.ELEMENTS,t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}},{key:"ELEMENTS",get:function(){return to(!1),0}},{key:"elements",get:function(){return this}}]),n}(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array));function co(e,t){if(e.length!==t)return!1;for(var n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function lo(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function fo(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(no.debug&&!co(e,t))throw new Error("math.gl: ".concat(n," some fields set to invalid numbers'"));return e}var ho={};function vo(e,t){ho[e]||(ho[e]=!0,console.warn("".concat(e," has been removed in version ").concat(t,", see upgrade guide for more information")))}function go(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var po=function(e){it()(n,e);var t=go(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"copy",value:function(e){return to(!1),this}},{key:"len",value:function(){return Math.sqrt(this.lengthSquared())}},{key:"magnitude",value:function(){return this.len()}},{key:"lengthSquared",value:function(){for(var e=0,t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}},{key:"magnitudeSquared",value:function(){return this.lengthSquared()}},{key:"distance",value:function(e){return Math.sqrt(this.distanceSquared(e))}},{key:"distanceSquared",value:function(e){for(var t=0,n=0;n<this.ELEMENTS;++n){var r=this[n]-e[n];t+=r*r}return lo(t)}},{key:"dot",value:function(e){for(var t=0,n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return lo(t)}},{key:"normalize",value:function(){var e=this.magnitude();if(0!==e)for(var t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}},{key:"multiply",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]*=a[o];return this.check()}},{key:"divide",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]/=a[o];return this.check()}},{key:"lengthSq",value:function(){return this.lengthSquared()}},{key:"distanceTo",value:function(e){return this.distance(e)}},{key:"distanceToSquared",value:function(e){return this.distanceSquared(e)}},{key:"getComponent",value:function(e){return to(e>=0&&e<this.ELEMENTS,"index is out of range"),lo(this[e])}},{key:"setComponent",value:function(e,t){return to(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}},{key:"addVectors",value:function(e,t){return this.copy(e).add(t)}},{key:"subVectors",value:function(e,t){return this.copy(e).subtract(t)}},{key:"multiplyVectors",value:function(e,t){return this.copy(e).multiply(t)}},{key:"addScaledVector",value:function(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}},{key:"ELEMENTS",get:function(){return to(!1),0}},{key:"x",get:function(){return this[0]},set:function(e){this[0]=lo(e)}},{key:"y",get:function(){return this[1]},set:function(e){this[1]=lo(e)}}]),n}(uo),mo=1e-6,yo="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function _o(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var bo,Ao;bo=new yo(3),yo!=Float32Array&&(bo[0]=0,bo[1]=0,bo[2]=0),Ao=bo;function xo(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a||1;return e[0]=(n[0]*r+n[4]*i+n[8]*a)/o,e[1]=(n[1]*r+n[5]*i+n[9]*a)/o,e[2]=(n[2]*r+n[6]*i+n[10]*a)/o,e}function Eo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var To=[0,0,0],ko={},wo=function(e){it()(n,e);var t=Eo(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return l()(this,n),e=t.call(this,-0,-0,-0),1===arguments.length&&ao(r)?e.copy(r):(no.debug&&(lo(r),lo(i),lo(a)),e[0]=r,e[1]=i,e[2]=a),e}return h()(n,null,[{key:"ZERO",get:function(){return ko.ZERO=ko.ZERO||Object.freeze(new n(0,0,0,0))}}]),h()(n,[{key:"set",value:function(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}},{key:"copy",value:function(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}},{key:"fromObject",value:function(e){return no.debug&&(lo(e.x),lo(e.y),lo(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}},{key:"toObject",value:function(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}},{key:"angle",value:function(e){return n=e,r=(t=this)[0],i=t[1],a=t[2],o=n[0],s=n[1],u=n[2],c=Math.sqrt(r*r+i*i+a*a)*Math.sqrt(o*o+s*s+u*u),l=c&&function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}(t,n)/c,Math.acos(Math.min(Math.max(l,-1),1));var t,n,r,i,a,o,s,u,c,l}},{key:"cross",value:function(e){return function(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],u=n[2];e[0]=i*u-a*s,e[1]=a*o-r*u,e[2]=r*s-i*o}(this,this,e),this.check()}},{key:"rotateX",value:function(e){var t=e.radians,n=e.origin;return function(e,t,n,r){var i=[],a=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2]}(this,this,void 0===n?To:n,t),this.check()}},{key:"rotateY",value:function(e){var t=e.radians,n=e.origin;return function(e,t,n,r){var i=[],a=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2]}(this,this,void 0===n?To:n,t),this.check()}},{key:"rotateZ",value:function(e){var t=e.radians,n=e.origin;return function(e,t,n,r){var i=[],a=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2]}(this,this,void 0===n?To:n,t),this.check()}},{key:"transform",value:function(e){return this.transformAsPoint(e)}},{key:"transformAsPoint",value:function(e){return _o(this,this,e),this.check()}},{key:"transformAsVector",value:function(e){return xo(this,this,e),this.check()}},{key:"transformByMatrix3",value:function(e){return function(e,t,n){var r=t[0],i=t[1],a=t[2];e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8]}(this,this,e),this.check()}},{key:"transformByMatrix2",value:function(e){return function(e,t,n){var r=t[0],i=t[1];e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2]}(this,this,e),this.check()}},{key:"transformByQuaternion",value:function(e){return function(e,t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],u=t[1],c=t[2],l=i*c-a*u,f=a*s-r*c,h=r*u-i*s,d=i*h-a*f,v=a*l-r*h,g=r*f-i*l,p=2*o;l*=p,f*=p,h*=p,d*=2,v*=2,g*=2,e[0]=s+l+d,e[1]=u+f+v,e[2]=c+h+g}(this,this,e),this.check()}},{key:"ELEMENTS",get:function(){return 3}},{key:"z",get:function(){return this[2]},set:function(e){this[2]=lo(e)}}]),n}(po);function Oo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function So(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oo(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Lo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Io=[-1,0,0,0,1,0,0,0,-1,0,0,1,0,-1,0,1,0,0],Po=[3,4,5,3,5,1,3,1,0,3,0,4,4,0,2,4,2,5,2,0,1,5,2,1],Ro=function(e){it()(n,e);var t=Lo(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?dt("ico-sphere-geometry"):r,a=Fo(e),o=a.indices,s=a.attributes;return t.call(this,So(So({},e),{},{id:i,indices:o,attributes:So(So({},s),e.attributes)}))}return n}(Sa);function Fo(e){var t=e.iterations,n=void 0===t?0:t,r=Math.PI,i=2*r,a=[].concat(Io),o=[].concat(Po);a.push(),o.push();for(var s,u=(s={},function(e,t){var n=(e*=3)>(t*=3)?e:t,r="".concat(e<t?e:t,"|").concat(n);if(r in s)return s[r];var i=a[e],o=a[e+1],u=a[e+2],c=(i+a[t])/2,l=(o+a[t+1])/2,f=(u+a[t+2])/2,h=Math.sqrt(c*c+l*l+f*f);return c/=h,l/=h,f/=h,a.push(c,l,f),s[r]=a.length/3-1}),c=0;c<n;c++){for(var l=[],f=0;f<o.length;f+=3){var h=u(o[f+0],o[f+1]),d=u(o[f+1],o[f+2]),v=u(o[f+2],o[f+0]);l.push(v,o[f+0],h,h,o[f+1],d,d,o[f+2],v,h,d,v)}o=l}for(var g=new Array(a.length),p=new Array(a.length/3*2),m=o.length-3;m>=0;m-=3){var y=o[m+0],_=o[m+1],b=o[m+2],A=3*y,x=3*_,E=3*b,T=2*y,k=2*_,w=2*b,O=a[A+0],S=a[A+1],L=a[A+2],I=Math.acos(L/Math.sqrt(O*O+S*S+L*L))/r,P=1-(Math.atan2(S,O)+r)/i,R=a[x+0],F=a[x+1],C=a[x+2],M=Math.acos(C/Math.sqrt(R*R+F*F+C*C))/r,N=1-(Math.atan2(F,R)+r)/i,D=a[E+0],B=a[E+1],j=a[E+2],U=Math.acos(j/Math.sqrt(D*D+B*B+j*j))/r,V=1-(Math.atan2(B,D)+r)/i,G=[O-R,S-F,L-C],z=new wo([D-R,B-F,j-C]).cross(G).normalize(),H=void 0;(0===P||0===N||0===V)&&(0===P||P>.5)&&(0===N||N>.5)&&(0===V||V>.5)&&(a.push(a[A+0],a[A+1],a[A+2]),H=a.length/3-1,o.push(H),p[2*H+0]=1,p[2*H+1]=I,g[3*H+0]=z.x,g[3*H+1]=z.y,g[3*H+2]=z.z,a.push(a[x+0],a[x+1],a[x+2]),H=a.length/3-1,o.push(H),p[2*H+0]=1,p[2*H+1]=M,g[3*H+0]=z.x,g[3*H+1]=z.y,g[3*H+2]=z.z,a.push(a[E+0],a[E+1],a[E+2]),H=a.length/3-1,o.push(H),p[2*H+0]=1,p[2*H+1]=U,g[3*H+0]=z.x,g[3*H+1]=z.y,g[3*H+2]=z.z),g[A+0]=g[x+0]=g[E+0]=z.x,g[A+1]=g[x+1]=g[E+1]=z.y,g[A+2]=g[x+2]=g[E+2]=z.z,p[T+0]=P,p[T+1]=I,p[k+0]=N,p[k+1]=M,p[w+0]=V,p[w+1]=U}return{indices:{size:1,value:new Uint16Array(o)},attributes:{POSITION:{size:3,value:new Float32Array(a)},NORMAL:{size:3,value:new Float32Array(g)},TEXCOORD_0:{size:2,value:new Float32Array(p)}}}}function Co(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Mo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Co(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Co(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function No(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Do=function(e){it()(n,e);var t=No(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?dt("plane-geometry"):r,a=Bo(e),o=a.indices,s=a.attributes;return t.call(this,Mo(Mo({},e),{},{id:i,indices:o,attributes:Mo(Mo({},s),e.attributes)}))}return n}(Sa);function Bo(e){var t=e.type,n=void 0===t?"x,y":t,r=e.offset,i=void 0===r?0:r,a=e.flipCull,o=void 0!==a&&a,s=e.unpack,u=void 0!==s&&s,c=n.split(","),l=e["".concat(c[0],"len")]||1,f=e["".concat(c[1],"len")]||1,h=e["n".concat(c[0])]||1,d=e["n".concat(c[1])]||1,v=(h+1)*(d+1),g=new Float32Array(3*v),p=new Float32Array(3*v),m=new Float32Array(2*v);o&&(l=-l);for(var y=0,_=0,b=0;b<=d;b++)for(var A=0;A<=h;A++){var x=A/h,E=b/d;switch(m[y+0]=o?1-x:x,m[y+1]=E,n){case"x,y":g[_+0]=l*x-.5*l,g[_+1]=f*E-.5*f,g[_+2]=i,p[_+0]=0,p[_+1]=0,p[_+2]=o?1:-1;break;case"x,z":g[_+0]=l*x-.5*l,g[_+1]=i,g[_+2]=f*E-.5*f,p[_+0]=0,p[_+1]=o?1:-1,p[_+2]=0;break;case"y,z":g[_+0]=i,g[_+1]=l*x-.5*l,g[_+2]=f*E-.5*f,p[_+0]=o?1:-1,p[_+1]=0,p[_+2]=0;break;default:throw new Error("PlaneGeometry: unknown type")}y+=2,_+=3}for(var T=h+1,k=new Uint16Array(h*d*6),w=0;w<d;w++)for(var O=0;O<h;O++){var S=6*(w*h+O);k[S+0]=(w+0)*T+O,k[S+1]=(w+1)*T+O,k[S+2]=(w+0)*T+O+1,k[S+3]=(w+1)*T+O,k[S+4]=(w+1)*T+O+1,k[S+5]=(w+0)*T+O+1}var L={indices:{size:1,value:k},attributes:{POSITION:{size:3,value:g},NORMAL:{size:3,value:p},TEXCOORD_0:{size:2,value:m}}};return u?function(e){var t=e.indices,n=e.attributes;if(!t)return e;var r=t.value.length,i={};for(var a in n){var o=n[a],s=o.constant,u=o.value,c=o.size;if(!s&&c){for(var l=new u.constructor(r*c),f=0;f<r;++f)for(var h=t.value[f],d=0;d<c;d++)l[f*c+d]=u[h*c+d];i[a]={size:c,value:l}}}return{attributes:Object.assign({},n,i)}}(L):L}function jo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Uo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jo(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Vo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var Go=function(e){it()(n,e);var t=Vo(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?dt("sphere-geometry"):r,a=zo(e),o=a.indices,s=a.attributes;return t.call(this,Uo(Uo({},e),{},{id:i,indices:o,attributes:Uo(Uo({},s),e.attributes)}))}return n}(Sa);function zo(e){var t=e.nlat,n=void 0===t?10:t,r=e.nlong,i=void 0===r?10:r,a=e.radius,o=void 0===a?1:a,s=Math.PI-0,u=2*Math.PI-0,c=(n+1)*(i+1);if("number"==typeof o){var l=o;o=function(e,t,n,r,i){return l}}for(var f=new Float32Array(3*c),h=new Float32Array(3*c),d=new Float32Array(2*c),v=new(c>65535?Uint32Array:Uint16Array)(n*i*6),g=0;g<=n;g++)for(var p=0;p<=i;p++){var m=p/i,y=g/n,_=p+g*(i+1),b=2*_,A=3*_,x=u*m,E=s*y,T=Math.sin(x),k=Math.cos(x),w=Math.sin(E),O=k*w,S=Math.cos(E),L=T*w,I=o(O,S,L,m,y);f[A+0]=I*O,f[A+1]=I*S,f[A+2]=I*L,h[A+0]=O,h[A+1]=S,h[A+2]=L,d[b+0]=m,d[b+1]=1-y}for(var P=i+1,R=0;R<i;R++)for(var F=0;F<n;F++){var C=6*(R*n+F);v[C+0]=F*P+R,v[C+1]=F*P+R+1,v[C+2]=(F+1)*P+R,v[C+3]=(F+1)*P+R,v[C+4]=F*P+R+1,v[C+5]=(F+1)*P+R+1}return{indices:{size:1,value:v},attributes:{POSITION:{size:3,value:f},NORMAL:{size:3,value:h},TEXCOORD_0:{size:2,value:d}}}}var Ho={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n\n// All these functions are for substituting tan() function from Intel GPU only\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\n\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\n\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\n\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!\n\nfloat sin_taylor_fp32(float a) {\n float r, s, t, x;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n x = -a * a;\n s = a;\n r = a;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_3;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_5;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_7;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_9;\n s = s + t;\n\n return s;\n}\n\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\n if (a == 0.0) {\n sin_t = 0.0;\n cos_t = 1.0;\n }\n sin_t = sin_taylor_fp32(a);\n cos_t = sqrt(1.0 - sin_t * sin_t);\n}\n\nfloat tan_taylor_fp32(float a) {\n float sin_a;\n float cos_a;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n // 2pi range reduction\n float z = floor(a / TWO_PI);\n float r = a - TWO_PI * z;\n\n float t;\n float q = floor(r / PI_2 + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return 1.0 / 0.0;\n }\n\n t = r - PI_2 * q;\n\n q = floor(t / PI_16 + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return 1.0 / 0.0;\n } else {\n t = t - PI_16 * q;\n }\n\n float u = 0.0;\n float v = 0.0;\n\n float sin_t, cos_t;\n float s, c;\n sincos_taylor_fp32(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0;\n v = SIN_TABLE_0;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1;\n v = SIN_TABLE_1;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2;\n v = SIN_TABLE_2;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3;\n v = SIN_TABLE_3;\n }\n if (k > 0) {\n s = u * sin_t + v * cos_t;\n c = u * cos_t - v * sin_t;\n } else {\n s = u * sin_t - v * cos_t;\n c = u * cos_t + v * sin_t;\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return sin_a / cos_a;\n}\n#endif\n\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n return tan_taylor_fp32(a);\n#else\n return tan(a);\n#endif\n}\n",fs:null};function Wo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=Math.fround(e),i=e-r;return t[n]=r,t[n+1]=i,t}function Xo(e){return e-Math.fround(e)}function qo(e){for(var t=new Float32Array(32),n=0;n<4;++n)for(var r=0;r<4;++r){var i=4*n+r;Wo(e[4*r+n],t,2*i)}return t}var Ko={ONE:1};var Yo={name:"fp64",vs:"const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);\nconst vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);\nconst vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);\nconst vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);\nconst vec2 PI_2_FP64 = vec2(1.5707963705062866, -4.371139006309477e-8);\nconst vec2 PI_4_FP64 = vec2(0.7853981852531433, -2.1855695031547384e-8);\nconst vec2 PI_16_FP64 = vec2(0.19634954631328583, -5.463923757886846e-9);\nconst vec2 PI_16_2_FP64 = vec2(0.39269909262657166, -1.0927847515773692e-8);\nconst vec2 PI_16_3_FP64 = vec2(0.5890486240386963, -1.4906100798128818e-9);\nconst vec2 PI_180_FP64 = vec2(0.01745329238474369, 1.3519960498364902e-10);\n\nconst vec2 SIN_TABLE_0_FP64 = vec2(0.19509032368659973, -1.6704714833615242e-9);\nconst vec2 SIN_TABLE_1_FP64 = vec2(0.3826834261417389, 6.22335089017767e-9);\nconst vec2 SIN_TABLE_2_FP64 = vec2(0.5555702447891235, -1.1769521357507529e-8);\nconst vec2 SIN_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617041793133e-8);\n\nconst vec2 COS_TABLE_0_FP64 = vec2(0.9807852506637573, 2.9739473106360492e-8);\nconst vec2 COS_TABLE_1_FP64 = vec2(0.9238795042037964, 2.8307490351764386e-8);\nconst vec2 COS_TABLE_2_FP64 = vec2(0.8314695954322815, 1.6870263741530778e-8);\nconst vec2 COS_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617152815436e-8);\n\nconst vec2 INVERSE_FACTORIAL_3_FP64 = vec2(1.666666716337204e-01, -4.967053879312289e-09);\nconst vec2 INVERSE_FACTORIAL_4_FP64 = vec2(4.16666679084301e-02, -1.2417634698280722e-09);\nconst vec2 INVERSE_FACTORIAL_5_FP64 = vec2(8.333333767950535e-03, -4.34617203337595e-10);\nconst vec2 INVERSE_FACTORIAL_6_FP64 = vec2(1.3888889225199819e-03, -3.3631094437103215e-11);\nconst vec2 INVERSE_FACTORIAL_7_FP64 = vec2(1.9841270113829523e-04, -2.725596874933456e-12);\nconst vec2 INVERSE_FACTORIAL_8_FP64 = vec2(2.4801587642286904e-05, -3.406996025904184e-13);\nconst vec2 INVERSE_FACTORIAL_9_FP64 = vec2(2.75573188446287533e-06, 3.7935713937038186e-14);\nconst vec2 INVERSE_FACTORIAL_10_FP64 = vec2(2.755731998149713e-07, -7.575112367869873e-15);\n\nfloat nint(float d) {\n if (d == floor(d)) return d;\n return floor(d + 0.5);\n}\n\nvec2 nint_fp64(vec2 a) {\n float hi = nint(a.x);\n float lo;\n vec2 tmp;\n if (hi == a.x) {\n lo = nint(a.y);\n tmp = quickTwoSum(hi, lo);\n } else {\n lo = 0.0;\n if (abs(hi - a.x) == 0.5 && a.y < 0.0) {\n hi -= 1.0;\n }\n tmp = vec2(hi, lo);\n }\n return tmp;\n}\n\nvec2 exp_fp64(vec2 a) {\n\n const int k_power = 4;\n const float k = 16.0;\n\n const float inv_k = 1.0 / k;\n\n if (a.x <= -88.0) return vec2(0.0, 0.0);\n if (a.x >= 88.0) return vec2(1.0 / 0.0, 1.0 / 0.0);\n if (a.x == 0.0 && a.y == 0.0) return vec2(1.0, 0.0);\n if (a.x == 1.0 && a.y == 0.0) return E_FP64;\n\n float m = floor(a.x / LOG2_FP64.x + 0.5);\n vec2 r = sub_fp64(a, mul_fp64(LOG2_FP64, vec2(m, 0.0))) * inv_k;\n vec2 s, t, p;\n\n p = mul_fp64(r, r);\n s = sum_fp64(r, p * 0.5);\n p = mul_fp64(p, r);\n t = mul_fp64(p, INVERSE_FACTORIAL_3_FP64);\n\n s = sum_fp64(s, t);\n p = mul_fp64(p, r);\n t = mul_fp64(p, INVERSE_FACTORIAL_4_FP64);\n\n s = sum_fp64(s, t);\n p = mul_fp64(p, r);\n t = mul_fp64(p, INVERSE_FACTORIAL_5_FP64);\n\n\n\n\n\n\n s = sum_fp64(s, t);\n for (int i = 0; i < k_power; i++) {\n s = sum_fp64(s * 2.0, mul_fp64(s, s));\n }\n\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n s = sum_fp64(s, vec2(ONE, 0.0));\n#else\n s = sum_fp64(s, vec2(1.0, 0.0));\n#endif\n\n return s * pow(2.0, m);\n}\n\nvec2 log_fp64(vec2 a)\n{\n if (a.x == 1.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x <= 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n vec2 x = vec2(log(a.x), 0.0);\n vec2 s;\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n s = vec2(ONE, 0.0);\n#else\n s = vec2(1.0, 0.0);\n#endif\n\n x = sub_fp64(sum_fp64(x, mul_fp64(a, exp_fp64(-x))), s);\n return x;\n}\n\nvec2 sin_taylor_fp64(vec2 a) {\n vec2 r, s, t, x;\n\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(0.0, 0.0);\n }\n\n x = -mul_fp64(a, a);\n s = a;\n r = a;\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_3_FP64);\n s = sum_fp64(s, t);\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_5_FP64);\n s = sum_fp64(s, t);\n\n\n\n\n\n\n return s;\n}\n\nvec2 cos_taylor_fp64(vec2 a) {\n vec2 r, s, t, x;\n\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(1.0, 0.0);\n }\n\n x = -mul_fp64(a, a);\n r = x;\n s = sum_fp64(vec2(1.0, 0.0), r * 0.5);\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_4_FP64);\n s = sum_fp64(s, t);\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_6_FP64);\n s = sum_fp64(s, t);\n\n\n\n\n\n\n return s;\n}\n\nvoid sincos_taylor_fp64(vec2 a, out vec2 sin_t, out vec2 cos_t) {\n if (a.x == 0.0 && a.y == 0.0) {\n sin_t = vec2(0.0, 0.0);\n cos_t = vec2(1.0, 0.0);\n }\n\n sin_t = sin_taylor_fp64(a);\n cos_t = sqrt_fp64(sub_fp64(vec2(1.0, 0.0), mul_fp64(sin_t, sin_t)));\n}\n\nvec2 sin_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(0.0, 0.0);\n }\n vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));\n vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));\n\n vec2 t;\n float q = floor(r.x / PI_2_FP64.x + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n }\n\n t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));\n\n q = floor(t.x / PI_16_FP64.x + 0.5);\n int k = int(q);\n\n if (k == 0) {\n if (j == 0) {\n return sin_taylor_fp64(t);\n } else if (j == 1) {\n return cos_taylor_fp64(t);\n } else if (j == -1) {\n return -cos_taylor_fp64(t);\n } else {\n return -sin_taylor_fp64(t);\n }\n }\n\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n } else {\n t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));\n }\n\n vec2 u = vec2(0.0, 0.0);\n vec2 v = vec2(0.0, 0.0);\n\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#else\n if (abs_k == 1) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs_k == 2) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs_k == 3) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs_k == 4) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#endif\n\n vec2 sin_t, cos_t;\n sincos_taylor_fp64(t, sin_t, cos_t);\n\n\n\n vec2 result = vec2(0.0, 0.0);\n if (j == 0) {\n if (k > 0) {\n result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n }\n } else if (j == 1) {\n if (k > 0) {\n result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n } else {\n result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n } else if (j == -1) {\n if (k > 0) {\n result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));\n } else {\n result = -sum_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));\n }\n } else {\n if (k > 0) {\n result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));\n }\n }\n\n return result;\n}\n\nvec2 cos_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(1.0, 0.0);\n }\n vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));\n vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));\n\n vec2 t;\n float q = floor(r.x / PI_2_FP64.x + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n }\n\n t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));\n\n q = floor(t.x / PI_16_FP64.x + 0.5);\n int k = int(q);\n\n if (k == 0) {\n if (j == 0) {\n return cos_taylor_fp64(t);\n } else if (j == 1) {\n return -sin_taylor_fp64(t);\n } else if (j == -1) {\n return sin_taylor_fp64(t);\n } else {\n return -cos_taylor_fp64(t);\n }\n }\n\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n } else {\n t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));\n }\n\n vec2 u = vec2(0.0, 0.0);\n vec2 v = vec2(0.0, 0.0);\n\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#else\n if (abs_k == 1) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs_k == 2) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs_k == 3) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs_k == 4) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#endif\n\n vec2 sin_t, cos_t;\n sincos_taylor_fp64(t, sin_t, cos_t);\n\n vec2 result = vec2(0.0, 0.0);\n if (j == 0) {\n if (k > 0) {\n result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n } else {\n result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n } else if (j == 1) {\n if (k > 0) {\n result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));\n }\n } else if (j == -1) {\n if (k > 0) {\n result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n }\n } else {\n if (k > 0) {\n result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));\n } else {\n result = -sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n }\n\n return result;\n}\n\nvec2 tan_fp64(vec2 a) {\n vec2 sin_a;\n vec2 cos_a;\n\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(0.0, 0.0);\n }\n vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));\n vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));\n\n vec2 t;\n float q = floor(r.x / PI_2_FP64.x + 0.5);\n int j = int(q);\n\n\n if (j < -2 || j > 2) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n }\n\n t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));\n\n q = floor(t.x / PI_16_FP64.x + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n } else {\n t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));\n }\n\n\n vec2 u = vec2(0.0, 0.0);\n vec2 v = vec2(0.0, 0.0);\n\n vec2 sin_t, cos_t;\n vec2 s, c;\n sincos_taylor_fp64(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#else\n if (abs_k == 1) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs_k == 2) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs_k == 3) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs_k == 4) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#endif\n if (k > 0) {\n s = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n c = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n } else {\n s = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n c = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return div_fp64(sin_a, cos_a);\n}\n\nvec2 radians_fp64(vec2 degree) {\n return mul_fp64(degree, PI_180_FP64);\n}\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid vec2_sum_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = sum_fp64(a[0], b[0]);\n out_val[1] = sum_fp64(a[1], b[1]);\n}\n\nvoid vec2_sub_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = sub_fp64(a[0], b[0]);\n out_val[1] = sub_fp64(a[1], b[1]);\n}\n\nvoid vec2_mul_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = mul_fp64(a[0], b[0]);\n out_val[1] = mul_fp64(a[1], b[1]);\n}\n\nvoid vec2_div_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = div_fp64(a[0], b[0]);\n out_val[1] = div_fp64(a[1], b[1]);\n}\n\nvoid vec2_mix_fp64(vec2 x[2], vec2 y[2], float a, out vec2 out_val[2]) {\n vec2 range[2];\n vec2_sub_fp64(y, x, range);\n vec2 portion[2];\n portion[0] = range[0] * a;\n portion[1] = range[1] * a;\n vec2_sum_fp64(x, portion, out_val);\n}\n\nvec2 vec2_length_fp64(vec2 x[2]) {\n return sqrt_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])));\n}\n\nvoid vec2_normalize_fp64(vec2 x[2], out vec2 out_val[2]) {\n vec2 length = vec2_length_fp64(x);\n vec2 length_vec2[2];\n length_vec2[0] = length;\n length_vec2[1] = length;\n\n vec2_div_fp64(x, length_vec2, out_val);\n}\n\nvec2 vec2_distance_fp64(vec2 x[2], vec2 y[2]) {\n vec2 diff[2];\n vec2_sub_fp64(x, y, diff);\n return vec2_length_fp64(diff);\n}\n\nvec2 vec2_dot_fp64(vec2 a[2], vec2 b[2]) {\n vec2 v[2];\n\n v[0] = mul_fp64(a[0], b[0]);\n v[1] = mul_fp64(a[1], b[1]);\n\n return sum_fp64(v[0], v[1]);\n}\nvoid vec3_sub_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {\n for (int i = 0; i < 3; i++) {\n out_val[i] = sum_fp64(a[i], b[i]);\n }\n}\n\nvoid vec3_sum_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {\n for (int i = 0; i < 3; i++) {\n out_val[i] = sum_fp64(a[i], b[i]);\n }\n}\n\nvec2 vec3_length_fp64(vec2 x[3]) {\n return sqrt_fp64(sum_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])),\n mul_fp64(x[2], x[2])));\n}\n\nvec2 vec3_distance_fp64(vec2 x[3], vec2 y[3]) {\n vec2 diff[3];\n vec3_sub_fp64(x, y, diff);\n return vec3_length_fp64(diff);\n}\nvoid vec4_fp64(vec4 a, out vec2 out_val[4]) {\n out_val[0].x = a[0];\n out_val[0].y = 0.0;\n\n out_val[1].x = a[1];\n out_val[1].y = 0.0;\n\n out_val[2].x = a[2];\n out_val[2].y = 0.0;\n\n out_val[3].x = a[3];\n out_val[3].y = 0.0;\n}\n\nvoid vec4_scalar_mul_fp64(vec2 a[4], vec2 b, out vec2 out_val[4]) {\n out_val[0] = mul_fp64(a[0], b);\n out_val[1] = mul_fp64(a[1], b);\n out_val[2] = mul_fp64(a[2], b);\n out_val[3] = mul_fp64(a[3], b);\n}\n\nvoid vec4_sum_fp64(vec2 a[4], vec2 b[4], out vec2 out_val[4]) {\n for (int i = 0; i < 4; i++) {\n out_val[i] = sum_fp64(a[i], b[i]);\n }\n}\n\nvoid vec4_dot_fp64(vec2 a[4], vec2 b[4], out vec2 out_val) {\n vec2 v[4];\n\n v[0] = mul_fp64(a[0], b[0]);\n v[1] = mul_fp64(a[1], b[1]);\n v[2] = mul_fp64(a[2], b[2]);\n v[3] = mul_fp64(a[3], b[3]);\n\n out_val = sum_fp64(sum_fp64(v[0], v[1]), sum_fp64(v[2], v[3]));\n}\n\nvoid mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {\n vec2 tmp[4];\n\n for (int i = 0; i < 4; i++)\n {\n for (int j = 0; j < 4; j++)\n {\n tmp[j] = b[j + i * 4];\n }\n vec4_dot_fp64(a, tmp, out_val[i]);\n }\n}\n",fs:null,dependencies:[{name:"fp64-arithmetic",vs:"uniform float ONE;\nvec2 split(float a) {\n const float SPLIT = 4097.0;\n float t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float a_hi = t * ONE - (t - a);\n float a_lo = a * ONE - a_hi;\n#else\n float a_hi = t - (t - a);\n float a_lo = a - a_hi;\n#endif\n return vec2(a_hi, a_lo);\n}\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * ONE;\n float err = b - (sum - a) * ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * ONE - a) * ONE;\n float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * ONE - a) * ONE;\n float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *\n a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\n a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",fs:null,getUniforms:function(){return Ko},fp64ify:Wo,fp64LowPart:Xo,fp64ifyMatrix4:qo}],fp64ify:Wo,fp64LowPart:Xo,fp64ifyMatrix4:qo};function Qo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var $o=function(e){it()(n,e);var t=Qo(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"toString",value:function(){var e="[";if(no.printRowMajor){e+="row-major:";for(var t=0;t<this.RANK;++t)for(var n=0;n<this.RANK;++n)e+=" ".concat(this[n*this.RANK+t])}else{e+="column-major:";for(var r=0;r<this.ELEMENTS;++r)e+=" ".concat(this[r])}return e+="]"}},{key:"getElementIndex",value:function(e,t){return t*this.RANK+e}},{key:"getElement",value:function(e,t){return this[t*this.RANK+e]}},{key:"setElement",value:function(e,t,n){return this[t*this.RANK+e]=lo(n),this}},{key:"getColumn",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Array(this.RANK).fill(-0),n=e*this.RANK,r=0;r<this.RANK;++r)t[r]=this[n+r];return t}},{key:"setColumn",value:function(e,t){for(var n=e*this.RANK,r=0;r<this.RANK;++r)this[n+r]=t[r];return this}},{key:"ELEMENTS",get:function(){return to(!1),0}},{key:"RANK",get:function(){return to(!1),0}}]),n}(uo);function Zo(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],f=t[8],h=t[9],d=t[10],v=t[11],g=t[12],p=t[13],m=t[14],y=t[15],_=n[0],b=n[1],A=n[2],x=n[3];return e[0]=_*r+b*s+A*f+x*g,e[1]=_*i+b*u+A*h+x*p,e[2]=_*a+b*c+A*d+x*m,e[3]=_*o+b*l+A*v+x*y,_=n[4],b=n[5],A=n[6],x=n[7],e[4]=_*r+b*s+A*f+x*g,e[5]=_*i+b*u+A*h+x*p,e[6]=_*a+b*c+A*d+x*m,e[7]=_*o+b*l+A*v+x*y,_=n[8],b=n[9],A=n[10],x=n[11],e[8]=_*r+b*s+A*f+x*g,e[9]=_*i+b*u+A*h+x*p,e[10]=_*a+b*c+A*d+x*m,e[11]=_*o+b*l+A*v+x*y,_=n[12],b=n[13],A=n[14],x=n[15],e[12]=_*r+b*s+A*f+x*g,e[13]=_*i+b*u+A*h+x*p,e[14]=_*a+b*c+A*d+x*m,e[15]=_*o+b*l+A*v+x*y,e}function Jo(e,t,n){var r=n[0],i=n[1],a=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function es(e,t,n,r,i){var a,o=1/Math.tan(t/2);return e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(a=1/(r-i),e[10]=(i+r)*a,e[14]=2*i*r*a):(e[10]=-1,e[14]=-2*r),e}function ts(e,t,n,r){var i,a,o,s,u,c,l,f,h,d,v=t[0],g=t[1],p=t[2],m=r[0],y=r[1],_=r[2],b=n[0],A=n[1],x=n[2];return Math.abs(v-b)<mo&&Math.abs(g-A)<mo&&Math.abs(p-x)<mo?function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(e):(l=v-b,f=g-A,h=p-x,i=y*(h*=d=1/Math.hypot(l,f,h))-_*(f*=d),a=_*(l*=d)-m*h,o=m*f-y*l,(d=Math.hypot(i,a,o))?(i*=d=1/d,a*=d,o*=d):(i=0,a=0,o=0),s=f*o-h*a,u=h*i-l*o,c=l*a-f*i,(d=Math.hypot(s,u,c))?(s*=d=1/d,u*=d,c*=d):(s=0,u=0,c=0),e[0]=i,e[1]=s,e[2]=l,e[3]=0,e[4]=a,e[5]=u,e[6]=f,e[7]=0,e[8]=o,e[9]=c,e[10]=h,e[11]=0,e[12]=-(i*v+a*g+o*p),e[13]=-(s*v+u*g+c*p),e[14]=-(l*v+f*g+h*p),e[15]=1,e)}!function(){var e=function(){var e=new yo(2);return yo!=Float32Array&&(e[0]=0,e[1]=0),e}()}();!function(){var e=function(){var e=new yo(4);return yo!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();function ns(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut()(e);if(t){var i=ut()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ot()(this,n)}}var rs=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),is=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),as=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL0ROW3:3,COL1ROW0:4,COL1ROW1:5,COL1ROW2:6,COL1ROW3:7,COL2ROW0:8,COL2ROW1:9,COL2ROW2:10,COL2ROW3:11,COL3ROW0:12,COL3ROW1:13,COL3ROW2:14,COL3ROW3:15}),os={},ss=function(e){it()(n,e);var t=ns(n);function n(e){var r;return l()(this,n),r=t.call(this,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?r.copy(e):r.identity(),r}return h()(n,[{key:"INDICES",get:function(){return as}},{key:"ELEMENTS",get:function(){return 16}},{key:"RANK",get:function(){return 4}}],[{key:"IDENTITY",get:function(){return os.IDENTITY=os.IDENTITY||Object.freeze(new n(rs)),os.IDENTITY}},{key:"ZERO",get:function(){return os.ZERO=os.ZERO||Object.freeze(new n(is)),os.ZERO}}]),h()(n,[{key:"copy",value:function(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}},{key:"set",value:function(e,t,n,r,i,a,o,s,u,c,l,f,h,d,v,g){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=u,this[9]=c,this[10]=l,this[11]=f,this[12]=h,this[13]=d,this[14]=v,this[15]=g,this.check()}},{key:"setRowMajor",value:function(e,t,n,r,i,a,o,s,u,c,l,f,h,d,v,g){return this[0]=e,this[1]=i,this[2]=u,this[3]=h,this[4]=t,this[5]=a,this[6]=c,this[7]=d,this[8]=n,this[9]=o,this[10]=l,this[11]=v,this[12]=r,this[13]=s,this[14]=f,this[15]=g,this.check()}},{key:"toRowMajor",value:function(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}},{key:"identity",value:function(){return this.copy(rs)}},{key:"fromQuaternion",value:function(e){return function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,u=i+i,c=n*o,l=r*o,f=r*s,h=i*o,d=i*s,v=i*u,g=a*o,p=a*s,m=a*u;e[0]=1-f-v,e[1]=l+m,e[2]=h-p,e[3]=0,e[4]=l-m,e[5]=1-c-v,e[6]=d+g,e[7]=0,e[8]=h+p,e[9]=d-g,e[10]=1-c-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}},{key:"frustum",value:function(e){var t=e.left,r=e.right,i=e.bottom,a=e.top,o=e.near,s=e.far;return s===1/0?n._computeInfinitePerspectiveOffCenter(this,t,r,i,a,o):function(e,t,n,r,i,a,o){var s=1/(n-t),u=1/(i-r),c=1/(a-o);e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*u,e[10]=(o+a)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*c,e[15]=0}(this,t,r,i,a,o,s),this.check()}},{key:"lookAt",value:function(e,t,n){if(1===arguments.length){var r=e;e=r.eye,t=r.center,n=r.up}return ts(this,e,t=t||[0,0,0],n=n||[0,1,0]),this.check()}},{key:"ortho",value:function(e){var t=e.left,n=e.right,r=e.bottom,i=e.top,a=e.near,o=void 0===a?.1:a,s=e.far;return function(e,t,n,r,i,a,o){var s=1/(t-n),u=1/(r-i),c=1/(a-o);e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*u,e[14]=(o+a)*c,e[15]=1}(this,t,n,r,i,o,void 0===s?500:s),this.check()}},{key:"orthographic",value:function(e){var t=e.fovy,r=void 0===t?45*Math.PI/180:t,i=e.aspect,a=void 0===i?1:i,o=e.focalDistance,s=void 0===o?1:o,u=e.near,c=void 0===u?.1:u,l=e.far,f=void 0===l?500:l;if(r>2*Math.PI)throw Error("radians");var h=r/2,d=s*Math.tan(h),v=d*a;return(new n).ortho({left:-v,right:v,bottom:-d,top:d,near:c,far:f})}},{key:"perspective",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.fovy,n=void 0===t?void 0:t,r=e.fov,i=void 0===r?45*Math.PI/180:r,a=e.aspect,o=void 0===a?1:a,s=e.near,u=void 0===s?.1:s,c=e.far,l=void 0===c?500:c;if((n=n||i)>2*Math.PI)throw Error("radians");return es(this,n,o,u,l),this.check()}},{key:"determinant",value:function(){return t=(e=this)[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],c=e[8],l=e[9],f=e[10],h=e[11],d=e[12],v=e[13],g=e[14],p=e[15],(t*o-n*a)*(f*p-h*g)-(t*s-r*a)*(l*p-h*v)+(t*u-i*a)*(l*g-f*v)+(n*s-r*o)*(c*p-h*d)-(n*u-i*o)*(c*g-f*d)+(r*u-i*s)*(c*v-l*d);var e,t,n,r,i,a,o,s,u,c,l,f,h,d,v,g,p}},{key:"getScale",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0];return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}},{key:"getTranslation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0];return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}},{key:"getRotation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getScale(t||[-0,-0,-0]),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}},{key:"getRotationMatrix3",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getScale(t||[-0,-0,-0]),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*a,e}},{key:"transpose",value:function(){return function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15]}(this,this),this.check()}},{key:"invert",value:function(){return function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],c=t[7],l=t[8],f=t[9],h=t[10],d=t[11],v=t[12],g=t[13],p=t[14],m=t[15],y=n*s-r*o,_=n*u-i*o,b=n*c-a*o,A=r*u-i*s,x=r*c-a*s,E=i*c-a*u,T=l*g-f*v,k=l*p-h*v,w=l*m-d*v,O=f*p-h*g,S=f*m-d*g,L=h*m-d*p,I=y*L-_*S+b*O+A*w-x*k+E*T;I&&(I=1/I,e[0]=(s*L-u*S+c*O)*I,e[1]=(i*S-r*L-a*O)*I,e[2]=(g*E-p*x+m*A)*I,e[3]=(h*x-f*E-d*A)*I,e[4]=(u*w-o*L-c*k)*I,e[5]=(n*L-i*w+a*k)*I,e[6]=(p*b-v*E-m*_)*I,e[7]=(l*E-h*b+d*_)*I,e[8]=(o*S-s*w+c*T)*I,e[9]=(r*w-n*S-a*T)*I,e[10]=(v*x-g*b+m*y)*I,e[11]=(f*b-l*x-d*y)*I,e[12]=(s*k-o*O-u*T)*I,e[13]=(n*O-r*k+i*T)*I,e[14]=(g*_-v*A-p*y)*I,e[15]=(l*A-f*_+h*y)*I)}(this,this),this.check()}},{key:"multiplyLeft",value:function(e){return Zo(this,e,this),this.check()}},{key:"multiplyRight",value:function(e){return Zo(this,this,e),this.check()}},{key:"rotateX",value:function(e){return function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],u=t[7],c=t[8],l=t[9],f=t[10],h=t[11];t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*i+c*r,e[5]=o*i+l*r,e[6]=s*i+f*r,e[7]=u*i+h*r,e[8]=c*i-a*r,e[9]=l*i-o*r,e[10]=f*i-s*r,e[11]=h*i-u*r}(this,this,e),this.check()}},{key:"rotateY",value:function(e){return function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],u=t[3],c=t[8],l=t[9],f=t[10],h=t[11];t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i-c*r,e[1]=o*i-l*r,e[2]=s*i-f*r,e[3]=u*i-h*r,e[8]=a*r+c*i,e[9]=o*r+l*i,e[10]=s*r+f*i,e[11]=u*r+h*i}(this,this,e),this.check()}},{key:"rotateZ",value:function(e){return function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],u=t[3],c=t[4],l=t[5],f=t[6],h=t[7];t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i+c*r,e[1]=o*i+l*r,e[2]=s*i+f*r,e[3]=u*i+h*r,e[4]=c*i-a*r,e[5]=l*i-o*r,e[6]=f*i-s*r,e[7]=h*i-u*r}(this,this,e),this.check()}},{key:"rotateXYZ",value:function(e){var t=ae()(e,3),n=t[0],r=t[1],i=t[2];return this.rotateX(n).rotateY(r).rotateZ(i)}},{key:"rotateAxis",value:function(e,t){return function(e,t,n,r){var i,a,o,s,u,c,l,f,h,d,v,g,p,m,y,_,b,A,x,E,T,k,w,O,S=r[0],L=r[1],I=r[2],P=Math.hypot(S,L,I);P<mo||(S*=P=1/P,L*=P,I*=P,i=Math.sin(n),o=1-(a=Math.cos(n)),s=t[0],u=t[1],c=t[2],l=t[3],f=t[4],h=t[5],d=t[6],v=t[7],g=t[8],p=t[9],m=t[10],y=t[11],_=S*S*o+a,b=L*S*o+I*i,A=I*S*o-L*i,x=S*L*o-I*i,E=L*L*o+a,T=I*L*o+S*i,k=S*I*o+L*i,w=L*I*o-S*i,O=I*I*o+a,e[0]=s*_+f*b+g*A,e[1]=u*_+h*b+p*A,e[2]=c*_+d*b+m*A,e[3]=l*_+v*b+y*A,e[4]=s*x+f*E+g*T,e[5]=u*x+h*E+p*T,e[6]=c*x+d*E+m*T,e[7]=l*x+v*E+y*T,e[8]=s*k+f*w+g*O,e[9]=u*k+h*w+p*O,e[10]=c*k+d*w+m*O,e[11]=l*k+v*w+y*O,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}},{key:"scale",value:function(e){return Array.isArray(e)?Jo(this,this,e):Jo(this,this,[e,e,e]),this.check()}},{key:"translate",value:function(e){return function(e,t,n){var r,i,a,o,s,u,c,l,f,h,d,v,g=n[0],p=n[1],m=n[2];t===e?(e[12]=t[0]*g+t[4]*p+t[8]*m+t[12],e[13]=t[1]*g+t[5]*p+t[9]*m+t[13],e[14]=t[2]*g+t[6]*p+t[10]*m+t[14],e[15]=t[3]*g+t[7]*p+t[11]*m+t[15]):(r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],f=t[8],h=t[9],d=t[10],v=t[11],e[0]=r,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=u,e[6]=c,e[7]=l,e[8]=f,e[9]=h,e[10]=d,e[11]=v,e[12]=r*g+s*p+f*m+t[12],e[13]=i*g+u*p+h*m+t[13],e[14]=a*g+c*p+d*m+t[14],e[15]=o*g+l*p+v*m+t[15])}(this,this,e),this.check()}},{key:"transform",value:function(e,t){return 4===e.length?(fo(t=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}},{key:"transformAsPoint",value:function(e,t){switch(e.length){case 2:t=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e}(t||[-0,-0],e,this);break;case 3:t=_o(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return fo(t,e.length),t}},{key:"transformAsVector",value:function(e,t){switch(e.length){case 2:t=function(e,t,n){var r=t[0],i=t[1],a=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/a,e[1]=(n[1]*r+n[5]*i)/a,e}(t||[-0,-0],e,this);break;case 3:t=xo(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return fo(t,e.length),t}},{key:"makeRotationX",value:function(e){return this.identity().rotateX(e)}},{key:"makeTranslation",value:function(e,t,n){return this.identity().translate([e,t,n])}},{key:"transformPoint",value:function(e,t){return vo("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}},{key:"transformVector",value:function(e,t){return vo("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}},{key:"transformDirection",value:function(e,t){return vo("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}],[{key:"_computeInfinitePerspectiveOffCenter",value:function(e,t,n,r,i,a){var o=2*a/(n-t),s=2*a/(i-r),u=(n+t)/(n-t),c=(i+r)/(i-r),l=-2*a;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=u,e[9]=c,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=l,e[15]=0,e}}]),n}($o),us=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],cs={modelMatrix:us,viewMatrix:us,projectionMatrix:us,cameraPositionWorld:[0,0,0]};var ls="varying vec4 project_vPositionWorld;\nvarying vec3 project_vNormalWorld;\n\nvec4 project_getPosition_World() {\n return project_vPositionWorld;\n}\n\nvec3 project_getNormal_World() {\n return project_vNormalWorld;\n}\n",fs={name:"project",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:cs,t={};return void 0!==e.modelMatrix&&(t.modelMatrix=e.modelMatrix),void 0!==e.viewMatrix&&(t.viewMatrix=e.viewMatrix),void 0!==e.projectionMatrix&&(t.projectionMatrix=e.projectionMatrix),void 0!==e.cameraPositionWorld&&(t.cameraPositionWorld=e.cameraPositionWorld),void 0===e.projectionMatrix&&void 0===e.viewMatrix||(t.viewProjectionMatrix=new ss(e.projectionMatrix).multiplyRight(e.viewMatrix)),t},vs:"".concat(ls,"\n\n// Unprefixed uniforms\nuniform mat4 modelMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewProjectionMatrix;\nuniform vec3 cameraPositionWorld;\n\nstruct World {\n vec3 position;\n vec3 normal;\n};\n\nWorld world;\n\nvoid project_setPosition(vec4 position) {\n project_vPositionWorld = position;\n}\n\nvoid project_setNormal(vec3 normal) {\n project_vNormalWorld = normal;\n}\n\nvoid project_setPositionAndNormal_World(vec3 position, vec3 normal) {\n world.position = position;\n world.normal = normal;\n}\n\nvoid project_setPositionAndNormal_Model(vec3 position, vec3 normal) {\n world.position = (modelMatrix * vec4(position, 1.)).xyz;\n world.normal = mat3(modelMatrix) * normal;\n}\n\nvec4 project_model_to_clipspace(vec4 position) {\n return viewProjectionMatrix * modelMatrix * position;\n}\n\nvec4 project_model_to_clipspace(vec3 position) {\n return viewProjectionMatrix * modelMatrix * vec4(position, 1.);\n}\n\nvec4 project_world_to_clipspace(vec3 position) {\n return viewProjectionMatrix * vec4(position, 1.);\n}\n\nvec4 project_view_to_clipspace(vec3 position) {\n return projectionMatrix * vec4(position, 1.);\n}\n\nvec4 project_to_clipspace(vec3 position) {\n return viewProjectionMatrix * vec4(position, 1.);\n}\n"),fs:"\n".concat(ls)},hs={lightDirection:new Float32Array([1,1,2])};var ds={name:"dirlight",vs:null,fs:"uniform vec3 dirlight_uLightDirection;\n\n/*\n * Returns color attenuated by angle from light source\n */\nvec4 dirlight_filterColor(vec4 color) {\n vec3 normal = project_getNormal_World();\n float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));\n return vec4(color.rgb * d, color.a);\n}\n",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:hs,t={};return e.lightDirection&&(t.dirlight_uLightDirection=e.lightDirection),t},dependencies:[fs]},vs={pickingSelectedColor:null,pickingHighlightColor:new Uint8Array([0,255,255,255]),pickingActive:!1,pickingAttribute:!1};var gs={name:"picking",vs:"uniform bool picking_uActive;\nuniform bool picking_uAttribute;\nuniform vec3 picking_uSelectedColor;\nuniform bool picking_uSelectedColorValid;\n\nout vec4 picking_vRGBcolor_Avalid;\n\nconst float COLOR_SCALE = 1. / 255.;\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.001;\n}\n\nbool isVertexPicked(vec3 vertexColor) {\n return\n picking_uSelectedColorValid &&\n !picking_isColorValid(abs(vertexColor - picking_uSelectedColor));\n}\n\nvoid picking_setPickingColor(vec3 pickingColor) {\n if (picking_uActive) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!picking_uAttribute) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor * COLOR_SCALE;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexPicked(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\nvoid picking_setPickingAttribute(vec2 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\nvoid picking_setPickingAttribute(vec3 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"uniform bool picking_uActive;\nuniform vec3 picking_uSelectedColor;\nuniform vec4 picking_uHighlightColor;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n if (picking_uActive) {\n return color;\n }\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n float highLightAlpha = picking_uHighlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking_uHighlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (picking_uActive) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highightColor);\n}\n\n",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:vs,t={};if(void 0!==e.pickingSelectedColor)if(e.pickingSelectedColor){var n=e.pickingSelectedColor.slice(0,3);t.picking_uSelectedColorValid=1,t.picking_uSelectedColor=n}else t.picking_uSelectedColorValid=0;if(e.pickingHighlightColor){var r=Array.from(e.pickingHighlightColor,(function(e){return e/255}));Number.isFinite(r[3])||(r[3]=1),t.picking_uHighlightColor=r}return void 0!==e.pickingActive&&(t.picking_uActive=Boolean(e.pickingActive),t.picking_uAttribute=Boolean(e.pickingAttribute)),t}},ps="#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n";function ms(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ys(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ys(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ys(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var _s={lightSources:{}};function bs(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.color,n=void 0===t?[0,0,0]:t,r=e.intensity,i=void 0===r?1:r;return n.map((function(e){return e*i/255}))}function As(e){var t=e.ambientLight,n=e.pointLights,r=void 0===n?[]:n,i=e.directionalLights,a=void 0===i?[]:i,o={};return o["lighting_uAmbientLight.color"]=t?bs(t):[0,0,0],r.forEach((function(e,t){o["lighting_uPointLight[".concat(t,"].color")]=bs(e),o["lighting_uPointLight[".concat(t,"].position")]=e.position,o["lighting_uPointLight[".concat(t,"].attenuation")]=e.attenuation||[1,0,0]})),o.lighting_uPointLightCount=r.length,a.forEach((function(e,t){o["lighting_uDirectionalLight[".concat(t,"].color")]=bs(e),o["lighting_uDirectionalLight[".concat(t,"].direction")]=e.direction})),o.lighting_uDirectionalLightCount=a.length,o}var xs={name:"lights",vs:ps,fs:ps,getUniforms:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_s;if("lightSources"in t){var n=t.lightSources||{},r=n.ambientLight,i=n.pointLights,a=n.directionalLights,o=r||i&&i.length>0||a&&a.length>0;return o?Object.assign({},As({ambientLight:r,pointLights:i,directionalLights:a}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){var s,u={pointLights:[],directionalLights:[]},c=ms(t.lights||[]);try{for(c.s();!(s=c.n()).done;){var l=s.value;switch(l.type){case"ambient":u.ambientLight=l;break;case"directional":u.directionalLights.push(l);break;case"point":u.pointLights.push(l)}}}catch(e){c.e(e)}finally{c.f()}return e({lightSources:u})}return{}},defines:{MAX_LIGHTS:3}},Es="\nuniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, lighting_uShininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n",Ts={};function ks(e){var t=e.ambient,n=void 0===t?.35:t,r=e.diffuse,i=void 0===r?.6:r,a=e.shininess,o=void 0===a?32:a,s=e.specularColor;return{lighting_uAmbient:n,lighting_uDiffuse:i,lighting_uShininess:o,lighting_uSpecularColor:(void 0===s?[30,30,30]:s).map((function(e){return e/255}))}}function ws(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ts;if(!("material"in e))return{};var t=e.material;return t?ks(t):{lighting_uEnabled:!1}}var Os={name:"gouraud-lighting",dependencies:[xs],vs:Es,defines:{LIGHTING_VERTEX:1},getUniforms:ws},Ss={name:"phong-lighting",dependencies:[xs],fs:Es,defines:{LIGHTING_FRAGMENT:1},getUniforms:ws},Ls={name:"pbr",vs:"uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n",fs:"#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)\n# error PBR fragment shader: Texture LOD is not available\n#endif\n\n#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)\n# error PBR fragment shader: Derivatives are not available\n#endif\n\n\n#if (__VERSION__ < 300)\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)\n#else\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)\n#endif\n\nprecision highp float;\n\nuniform bool pbr_uUnlit;\n\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\n\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\n\nuniform vec3 u_Camera;\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\n\nvarying vec3 pbr_vPosition;\n\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n#else\nvarying vec3 pbr_vNormal;\n#endif\n#endif\n\n\nstruct PBRInfo\n{\n float NdotL;\n float NdotV;\n float NdotH;\n float LdotH;\n float VdotH;\n float perceptualRoughness;\n float metalness;\n vec3 reflectance0;\n vec3 reflectance90;\n float alphaRoughness;\n vec3 diffuseColor;\n vec3 specularColor;\n vec3 n;\n vec3 v;\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif\n return vec4(linOut,srgbIn.w);;\n#else\n return srgbIn;\n#endif\n}\n\nvec3 getNormal()\n{\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\n vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else\n mat3 tbn = pbr_vTBN;\n#endif\n\n#ifdef HAS_NORMALMAP\n vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;\n n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n return n;\n}\n\n\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0;\n float lod = (pbrInputs.perceptualRoughness * mipCount);\n vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,\n vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\n vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\n diffuse *= u_ScaleIBLAmbient.x;\n specular *= u_ScaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n\nvec3 diffuse(PBRInfo pbrInputs)\n{\n return pbrInputs.diffuseColor / M_PI;\n}\n\nvec3 specularReflection(PBRInfo pbrInputs)\n{\n return pbrInputs.reflectance0 +\n (pbrInputs.reflectance90 - pbrInputs.reflectance0) *\n pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\n\n\n\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\n float NdotL = pbrInputs.NdotL;\n float NdotV = pbrInputs.NdotV;\n float r = pbrInputs.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n\n\n\n\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\n float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\n pbrInputs.NdotL = 1.0;\n pbrInputs.NdotH = 0.0;\n pbrInputs.LdotH = 0.0;\n pbrInputs.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\n vec3 n = pbrInputs.n;\n vec3 v = pbrInputs.v;\n vec3 l = normalize(lightDirection);\n vec3 h = normalize(l+v);\n\n pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\n vec3 F = specularReflection(pbrInputs);\n float G = geometricOcclusion(pbrInputs);\n float D = microfacetDistribution(pbrInputs);\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\n vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\n return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\n vec4 baseColor = u_BaseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < u_AlphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n if(pbr_uUnlit){\n color.rgb = baseColor.rgb;\n }\n else{\n\n\n float perceptualRoughness = u_MetallicRoughnessValues.y;\n float metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n\n vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n\n\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n\n vec3 n = getNormal();\n vec3 v = normalize(u_Camera - pbr_vPosition);\n\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInputs = PBRInfo(\n 0.0,\n NdotV,\n 0.0,\n 0.0,\n 0.0,\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n#ifdef USE_LIGHTS\n PBRInfo_setAmbientLight(pbrInputs);\n color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {\n if (i < lighting_uDirectionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\n color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n }\n }\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {\n if (i < lighting_uPointLightCount) {\n PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\n float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\n color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n }\n }\n#endif\n#ifdef USE_IBL\n color += getIBLContribution(pbrInputs, n, reflection);\n#endif\n#ifdef HAS_OCCLUSIONMAP\n float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;\n color = mix(color, color * ao, u_OcclusionStrength);\n#endif\n\n#ifdef HAS_EMISSIVEMAP\n vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\n color += emissive;\n#endif\n\n#ifdef PBR_DEBUG\n\n\n\n\n\n color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n\n }\n\n return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n",defines:{LIGHTING_FRAGMENT:1},dependencies:[xs]}},,,function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return o}));var r=n(7),i=n.n(r),a=n(28);function o(){return!("object"===(void 0===e?"undefined":i()(e))&&"[object process]"===String(e)&&!e.browser)||Object(a.a)()}}).call(this,n(12))}])}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=27)}([function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){var r=n(26);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},function(e,t,n){var r=n(9),i=n(8);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},function(e,t,n){var r=n(30),i=n(31),a=n(25),o=n(32);e.exports=function(e){return r(e)||i(e)||a(e)||o()}},function(e,t,n){var r=n(34),i=n(35),a=n(25),o=n(36);e.exports=function(e,t){return r(e)||i(e,t)||a(e,t)||o()}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},,function(e,t,n){"use strict";(function(e,r){n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return s}));var i=n(9),a={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document,process:"object"===(void 0===r?"undefined":n.n(i)()(r))&&r},o=(globalThis,a.window||a.self||a.global),s=a.process||{};console}).call(this,n(23),n(18))},,function(e,t,n){var r=n(38);function i(t,n,a){return"undefined"!=typeof Reflect&&Reflect.get?e.exports=i=Reflect.get:e.exports=i=function(e,t,n){var i=r(e,t);if(i){var a=Object.getOwnPropertyDescriptor(i,t);return a.get?a.get.call(n):a.value}},i(t,n,a||t)}e.exports=i},function(e,t,n){e.exports=n(39)},function(e,t,n){"use strict";(function(e){function r(){var t;if("undefined"!=typeof window&&window.performance)t=window.performance.now();else if(void 0!==e&&e.hrtime){var n=e.hrtime();t=1e3*n[0]+n[1]/1e6}else t=Date.now();return t}n.d(t,"a",(function(){return r}))}).call(this,n(18))},,,function(e,t){var n,r,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&d())}function d(){if(!l){var e=s(h);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new v(e,t)),1!==c.length||l||s(d)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return o}));var r=n(9),i=n.n(r),a=n(20);function o(){return!("object"===(void 0===e?"undefined":i()(e))&&"[object process]"===String(e)&&!e.browser)||Object(a.a)()}}).call(this,n(18))},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return a}));var r=n(9),i=n.n(r);function a(t){if("undefined"!=typeof window&&"object"===i()(window.process)&&"renderer"===window.process.type)return!0;if(void 0!==e&&"object"===i()(e.versions)&&Boolean(e.versions.electron))return!0;var n="object"===("undefined"==typeof navigator?"undefined":i()(navigator))&&"string"==typeof navigator.userAgent&&navigator.userAgent,r=t||n;return!!(r&&r.indexOf("Electron")>=0)}}).call(this,n(18))},function(e,t,n){var r=n(26),i=n(37);function a(t,n,o){return i()?e.exports=a=Reflect.construct:e.exports=a=function(e,t,n){var i=[null];i.push.apply(i,t);var a=new(Function.bind.apply(e,i));return n&&r(a,n.prototype),a},a.apply(null,arguments)}e.exports=a},function(e,t){function n(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,u,"next",e)}function u(e){n(o,i,a,s,u,"throw",e)}s(void 0)}))}}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}},function(e,t,n){var r=n(24);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},function(e,t,n){(function(t){var r=n(40),i="undefined"==typeof window?t:window;i.luma=i.luma||{},e.exports=Object.assign(i.luma,r)}).call(this,n(23))},,,function(e,t,n){var r=n(24);e.exports=function(e){if(Array.isArray(e))return r(e)}},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t){},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}},function(e,t,n){var r=n(3);e.exports=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=r(e)););return e}},function(e,t,n){var r=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,a=Object.create(i.prototype),o=new E(r||[]);return a._invoke=function(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return k()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=b(o,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=c(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,o),a}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function h(){}function d(){}var v={};v[i]=function(){return this};var g=Object.getPrototypeOf,p=g&&g(g(T([])));p&&p!==t&&n.call(p,i)&&(v=p);var m=d.prototype=f.prototype=Object.create(v);function y(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){var r;this._invoke=function(i,a){function o(){return new t((function(r,o){!function r(i,a,o,s){var u=c(e[i],e,a);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){l.value=e,o(l)}),(function(e){return r("throw",e,o,s)}))}s(u.arg)}(i,a,r,o)}))}return r=r?r.then(o,o):o()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:k}}function k(){return{value:void 0,done:!0}}return h.prototype=m.constructor=d,d.constructor=h,h.displayName=s(d,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,o,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},y(_.prototype),_.prototype[a]=function(){return this},e.AsyncIterator=_,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new _(u(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},y(m),s(m,o,"Generator"),m[i]=function(){return this},m.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}},function(e,t,n){"use strict";n.r(t),n.d(t,"createGLContext",(function(){return je})),n.d(t,"instrumentGLContext",(function(){return Ue})),n.d(t,"isWebGL",(function(){return N})),n.d(t,"isWebGL2",(function(){return D})),n.d(t,"getParameters",(function(){return Oe})),n.d(t,"setParameters",(function(){return we})),n.d(t,"withParameters",(function(){return Le})),n.d(t,"resetParameters",(function(){return Se})),n.d(t,"cssToDeviceRatio",(function(){return Ie})),n.d(t,"cssToDevicePixels",(function(){return Pe})),n.d(t,"lumaStats",(function(){return Qe})),n.d(t,"FEATURES",(function(){return Cn})),n.d(t,"hasFeature",(function(){return wn})),n.d(t,"hasFeatures",(function(){return On})),n.d(t,"Buffer",(function(){return Mt})),n.d(t,"Program",(function(){return _r})),n.d(t,"Framebuffer",(function(){return Rn})),n.d(t,"Renderbuffer",(function(){return rn})),n.d(t,"Texture2D",(function(){return Zt})),n.d(t,"TextureCube",(function(){return vn})),n.d(t,"VertexShader",(function(){return ur})),n.d(t,"FragmentShader",(function(){return cr})),n.d(t,"clear",(function(){return an})),n.d(t,"readPixelsToArray",(function(){return yn})),n.d(t,"readPixelsToBuffer",(function(){return _n})),n.d(t,"cloneTextureFrom",(function(){return mn})),n.d(t,"copyToTexture",(function(){return An})),n.d(t,"Texture3D",(function(){return pn})),n.d(t,"TransformFeedback",(function(){return Ar})),n.d(t,"AnimationLoop",(function(){return Sr})),n.d(t,"Model",(function(){return Ji})),n.d(t,"Transform",(function(){return _a})),n.d(t,"ProgramManager",(function(){return Ei})),n.d(t,"Timeline",(function(){return Ta})),n.d(t,"Geometry",(function(){return Oa})),n.d(t,"ClipSpace",(function(){return Ia})),n.d(t,"ConeGeometry",(function(){return Ua})),n.d(t,"CubeGeometry",(function(){return Ya})),n.d(t,"CylinderGeometry",(function(){return Ja})),n.d(t,"IcoSphereGeometry",(function(){return Po})),n.d(t,"PlaneGeometry",(function(){return Mo})),n.d(t,"SphereGeometry",(function(){return Go})),n.d(t,"TruncatedConeGeometry",(function(){return Ba})),n.d(t,"normalizeShaderModule",(function(){return Cr})),n.d(t,"fp32",(function(){return zo})),n.d(t,"fp64",(function(){return Ko})),n.d(t,"project",(function(){return ls})),n.d(t,"dirlight",(function(){return hs})),n.d(t,"picking",(function(){return vs})),n.d(t,"gouraudLighting",(function(){return ws})),n.d(t,"phongLighting",(function(){return Os})),n.d(t,"pbr",(function(){return Ss})),n.d(t,"log",(function(){return B})),n.d(t,"assert",(function(){return st})),n.d(t,"uid",(function(){return ft}));var r=n(9),i=n.n(r),a=n(6),o=n.n(a),s=n(0),u=n.n(s),c=n(1),l=n.n(c),f=n(2),h=n.n(f);function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=n(19);Object(v.a)();function g(e){try{var t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch(e){return null}}var p,m=function(){function e(t){l()(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";d(this,"storage",void 0),d(this,"id",void 0),d(this,"config",{}),this.storage=g(r),this.id=t,this.config={},Object.assign(this.config,n),this._loadConfiguration()}return h()(e,[{key:"getConfiguration",value:function(){return this.config}},{key:"setConfiguration",value:function(e){return this.config={},this.updateConfiguration(e)}},{key:"updateConfiguration",value:function(e){if(Object.assign(this.config,e),this.storage){var t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}},{key:"_loadConfiguration",value:function(){var e={};if(this.storage){var t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}]),e}();function y(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600,i=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>r&&(n=Math.min(n,r/e.width));var a=e.width*n,o=e.height*n,s=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(a/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(i,");"),"background-size:".concat(a,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),s]}function _(e){return"string"==typeof e?p[e.toUpperCase()]||p.WHITE:e}function b(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function x(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"],r=Object.getPrototypeOf(e),i=Object.getOwnPropertyNames(r),a=b(i);try{var o=function(){var r=t.value;"function"==typeof e[r]&&(n.find((function(e){return r===e}))||(e[r]=e[r].bind(e)))};for(a.s();!(t=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}}function E(e,t){if(!e)throw new Error(t||"Assertion failed")}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(p||(p={}));var T=n(11);function k(){var e,t,n;if(v.a&&"performance"in T.b)e=null===T.b||void 0===T.b||null===(t=T.b.performance)||void 0===t||null===(n=t.now)||void 0===n?void 0:n.call(t);else if("hrtime"in T.a){var r,i=null===T.a||void 0===T.a||null===(r=T.a.hrtime)||void 0===r?void 0:r.call(T.a);e=1e3*i[0]+i[1]/1e6}else e=Date.now();return e}var w={debug:v.a&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},O={enabled:!0,level:0};function S(){}var L={},I={once:!0},P=function(){function e(){l()(this,e);var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""},n=t.id;d(this,"id",void 0),d(this,"VERSION","8.5.15"),d(this,"_startTs",k()),d(this,"_deltaTs",k()),d(this,"_storage",void 0),d(this,"userData",{}),d(this,"LOG_THROTTLE_TIMEOUT",0),this.id=n,this._storage=new m("__probe-".concat(this.id,"__"),O),this.userData={},this.timeStamp("".concat(this.id," started")),x(this),Object.seal(this)}return h()(e,[{key:"level",get:function(){return this.getLevel()},set:function(e){this.setLevel(e)}},{key:"isEnabled",value:function(){return this._storage.config.enabled}},{key:"getLevel",value:function(){return this._storage.config.level}},{key:"getTotal",value:function(){return Number((k()-this._startTs).toPrecision(10))}},{key:"getDelta",value:function(){return Number((k()-this._deltaTs).toPrecision(10))}},{key:"priority",get:function(){return this.level},set:function(e){this.level=e}},{key:"getPriority",value:function(){return this.level}},{key:"enable",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}},{key:"setLevel",value:function(e){return this._storage.updateConfiguration({level:e}),this}},{key:"get",value:function(e){return this._storage.config[e]}},{key:"set",value:function(e,t){this._storage.updateConfiguration(u()({},e,t))}},{key:"settings",value:function(){console.table?console.table(this._storage.config):console.log(this._storage.config)}},{key:"assert",value:function(e,t){E(e,t)}},{key:"warn",value:function(e){return this._getLogFunction(0,e,w.warn,arguments,I)}},{key:"error",value:function(e){return this._getLogFunction(0,e,w.error,arguments)}},{key:"deprecated",value:function(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}},{key:"removed",value:function(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}},{key:"probe",value:function(e,t){return this._getLogFunction(e,t,w.log,arguments,{time:!0,once:!0})}},{key:"log",value:function(e,t){return this._getLogFunction(e,t,w.debug,arguments)}},{key:"info",value:function(e,t){return this._getLogFunction(e,t,console.info,arguments)}},{key:"once",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return this._getLogFunction(e,t,w.debug||w.info,arguments,I)}},{key:"table",value:function(e,t,n){return t?this._getLogFunction(e,t,console.table||S,n&&[n],{tag:C(t)}):S}},{key:"image",value:function(e){var t=e.logLevel,r=e.priority,i=e.image,a=e.message,s=void 0===a?"":a,u=e.scale,c=void 0===u?1:u;return this._shouldLog(t||r)?v.a?function(e){var t=e.image,n=e.message,r=void 0===n?"":n,i=e.scale,a=void 0===i?1:i;if("string"==typeof t){var s=new Image;return s.onload=function(){var e,t=y(s,r,a);(e=console).log.apply(e,o()(t))},s.src=t,S}var u=t.nodeName||"";if("img"===u.toLowerCase()){var c;return(c=console).log.apply(c,o()(y(t,r,a))),S}if("canvas"===u.toLowerCase()){var l=new Image;return l.onload=function(){var e;return(e=console).log.apply(e,o()(y(l,r,a)))},l.src=t.toDataURL(),S}return S}({image:i,message:s,scale:c}):function(e){var t=e.image,r=(e.message,e.scale),i=void 0===r?1:r,a=null;try{a=n(33)}catch(e){}if(a)return function(){return a(t,{fit:"box",width:"".concat(Math.round(80*i),"%")}).then((function(e){return console.log(e)}))};return S}({image:i,message:s,scale:c}):S}},{key:"time",value:function(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}},{key:"timeEnd",value:function(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}},{key:"timeStamp",value:function(e,t){return this._getLogFunction(e,t,console.timeStamp||S)}},{key:"group",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1},r=F({logLevel:e,message:t,opts:n}),i=n.collapsed;return r.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}},{key:"groupCollapsed",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},n,{collapsed:!0}))}},{key:"groupEnd",value:function(e){return this._getLogFunction(e,"",console.groupEnd||S)}},{key:"withGroup",value:function(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}},{key:"trace",value:function(){console.trace&&console.trace()}},{key:"_shouldLog",value:function(e){return this.isEnabled()&&this.getLevel()>=R(e)}},{key:"_getLogFunction",value:function(e,t,n,r,i){if(this._shouldLog(e)){var a;i=F({logLevel:e,message:t,args:r,opts:i}),E(n=n||i.method),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=k();var s=i.tag||i.message;if(i.once){if(L[s])return S;L[s]=k()}return t=function(e,t,n){if("string"==typeof t){var r=n.time?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,n=Math.max(t-e.length,0);return"".concat(" ".repeat(n)).concat(e)}((s=n.total)<10?"".concat(s.toFixed(2),"ms"):s<100?"".concat(s.toFixed(1),"ms"):s<1e3?"".concat(s.toFixed(0),"ms"):"".concat((s/1e3).toFixed(2),"s")):"";t=n.time?"".concat(e,": ").concat(r," ").concat(t):"".concat(e,": ").concat(t),i=t,a=n.color,o=n.background,v.a||"string"!=typeof i||(a&&(a=_(a),i="[".concat(a,"m").concat(i,"")),o&&(a=_(o),i="[".concat(o+10,"m").concat(i,""))),t=i}var i,a,o;var s;return t}(this.id,i.message,i),(a=n).bind.apply(a,[console,t].concat(o()(i.args)))}return S}}]),e}();function R(e){if(!e)return 0;var t;switch(i()(e)){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return E(Number.isFinite(t)&&t>=0),t}function F(e){var t=e.logLevel,n=e.message;e.logLevel=R(t);for(var r=e.args?Array.from(e.args):[];r.length&&r.shift()!==n;);switch(i()(t)){case"string":case"function":void 0!==n&&r.unshift(n),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());var a=i()(e.message);return E("string"===a||"object"===a),Object.assign(e,{args:r},e.opts)}function C(e){for(var t in e)for(var n in e[t])return n||"untitled";return"empty"}d(P,"VERSION","8.5.15");var B=new P({id:"luma.gl"});function M(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function N(e){return"undefined"!=typeof WebGLRenderingContext&&e instanceof WebGLRenderingContext||("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&Number.isFinite(e._version)))}function D(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&2===e._version)}function j(e){return M(N(e),"Invalid WebGLRenderingContext"),e}function U(e){return M(D(e),"Requires WebGL2"),e}var G={};function V(e,t){var n;G[e]=!0,void 0!==t&&(n=t,globalThis.console&&globalThis.console.error&&globalThis.console.error(n))}var z=function e(t){var n=t.gl;this.ext=t,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(t.maxVertexAttribs);for(var r=0;r<this.attribs.length;r++){var i=new e.VertexAttrib(n);this.attribs[r]=i}this.maxAttrib=0};(z.VertexAttrib=function(e){this.enabled=!1,this.buffer=null,this.size=4,this.type=5126,this.normalized=!1,this.stride=16,this.offset=0,this.cached="",this.recache()}).prototype.recache=function(){this.cached=[this.size,this.type,this.normalized,this.stride,this.offset].join(":")};var H,W=function(e){var t=this;this.gl=e,function(e){var t=e.getError;e.getError=function(){var n;do{0!==(n=t.apply(e))&&(G[n]=!0)}while(0!==n);for(n in G)if(G[n])return delete G[n],parseInt(n,10);return 0}}(e);var n=this.original={getParameter:e.getParameter,enableVertexAttribArray:e.enableVertexAttribArray,disableVertexAttribArray:e.disableVertexAttribArray,bindBuffer:e.bindBuffer,getVertexAttrib:e.getVertexAttrib,vertexAttribPointer:e.vertexAttribPointer};e.getParameter=function(e){return e===t.VERTEX_ARRAY_BINDING_OES?t.currentVertexArrayObject===t.defaultVertexArrayObject?null:t.currentVertexArrayObject:n.getParameter.apply(this,arguments)},e.enableVertexAttribArray=function(e){var r=t.currentVertexArrayObject;r.maxAttrib=Math.max(r.maxAttrib,e);var i=r.attribs[e];return i.enabled=!0,n.enableVertexAttribArray.apply(this,arguments)},e.disableVertexAttribArray=function(e){var r=t.currentVertexArrayObject;r.maxAttrib=Math.max(r.maxAttrib,e);var i=r.attribs[e];return i.enabled=!1,n.disableVertexAttribArray.apply(this,arguments)},e.bindBuffer=function(e,r){switch(e){case 34962:t.currentArrayBuffer=r;break;case 34963:t.currentVertexArrayObject.elementArrayBuffer=r}return n.bindBuffer.apply(this,arguments)},e.getVertexAttrib=function(e,r){var i=t.currentVertexArrayObject,a=i.attribs[e];switch(r){case 34975:return a.buffer;case 34338:return a.enabled;case 34339:return a.size;case 34340:return a.stride;case 34341:return a.type;case 34922:return a.normalized;default:return n.getVertexAttrib.apply(this,arguments)}},e.vertexAttribPointer=function(e,r,i,a,o,s){var u=t.currentVertexArrayObject;u.maxAttrib=Math.max(u.maxAttrib,e);var c=u.attribs[e];return c.buffer=t.currentArrayBuffer,c.size=r,c.type=i,c.normalized=a,c.stride=o,c.offset=s,c.recache(),n.vertexAttribPointer.apply(this,arguments)},e.instrumentExtension&&e.instrumentExtension(this,"OES_vertex_array_object"),e.canvas&&e.canvas.addEventListener("webglcontextrestored",(function(){var e;e="OESVertexArrayObject emulation library context restored",globalThis.console&&globalThis.console.log&&globalThis.console.log(e),t.reset_()}),!0),this.reset_()};W.prototype.VERTEX_ARRAY_BINDING_OES=34229,W.prototype.reset_=function(){if(void 0!==this.vertexArrayObjects)for(var e=0;e<this.vertexArrayObjects.length;++e)this.vertexArrayObjects.isAlive=!1;var t=this.gl;this.maxVertexAttribs=t.getParameter(34921),this.defaultVertexArrayObject=new z(this),this.currentVertexArrayObject=null,this.currentArrayBuffer=null,this.vertexArrayObjects=[this.defaultVertexArrayObject],this.bindVertexArrayOES(null)},W.prototype.createVertexArrayOES=function(){var e=new z(this);return this.vertexArrayObjects.push(e),e},W.prototype.deleteVertexArrayOES=function(e){e.isAlive=!1,this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(e),1),this.currentVertexArrayObject===e&&this.bindVertexArrayOES(null)},W.prototype.isVertexArrayOES=function(e){return!!(e&&e instanceof z&&e.hasBeenBound&&e.ext===this)},W.prototype.bindVertexArrayOES=function(e){var t=this.gl;if(!e||e.isAlive){var n=this.original,r=this.currentVertexArrayObject;this.currentVertexArrayObject=e||this.defaultVertexArrayObject,this.currentVertexArrayObject.hasBeenBound=!0;var i=this.currentVertexArrayObject;if(r!==i){r&&i.elementArrayBuffer===r.elementArrayBuffer||n.bindBuffer.call(t,34963,i.elementArrayBuffer);for(var a=this.currentArrayBuffer,o=Math.max(r?r.maxAttrib:0,i.maxAttrib),s=0;s<=o;s++){var u=i.attribs[s],c=r?r.attribs[s]:null;if(r&&u.enabled===c.enabled||(u.enabled?n.enableVertexAttribArray.call(t,s):n.disableVertexAttribArray.call(t,s)),u.enabled){var l=!1;r&&u.buffer===c.buffer||(a!==u.buffer&&(n.bindBuffer.call(t,34962,u.buffer),a=u.buffer),l=!0),(l||u.cached!==c.cached)&&n.vertexAttribPointer.call(t,s,u.size,u.type,u.normalized,u.stride,u.offset)}}this.currentArrayBuffer!==a&&n.bindBuffer.call(t,34962,this.currentArrayBuffer)}}else V(1282,"bindVertexArrayOES: attempt to bind deleted arrayObject")};var X,q=function(e){return D(e)?void 0:0},K=(H={},u()(H,3074,(function(e){return D(e)?void 0:36064})),u()(H,35723,(function(e){return D(e)?void 0:4352})),u()(H,35977,q),u()(H,32937,q),u()(H,36795,(function(e,t){var n=D(e)?e.getExtension("EXT_disjoint_timer_query_webgl2"):e.getExtension("EXT_disjoint_timer_query");return n&&n.GPU_DISJOINT_EXT?t(n.GPU_DISJOINT_EXT):0})),u()(H,37445,(function(e,t){var n=e.getExtension("WEBGL_debug_renderer_info");return t(n&&n.UNMASKED_VENDOR_WEBGL||7936)})),u()(H,37446,(function(e,t){var n=e.getExtension("WEBGL_debug_renderer_info");return t(n&&n.UNMASKED_RENDERER_WEBGL||7937)})),u()(H,34047,(function(e,t){var n=e.luma.extensions.EXT_texture_filter_anisotropic;return n?t(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1})),u()(H,32883,q),u()(H,35071,q),u()(H,37447,q),u()(H,36063,(function(e,t){if(!D(e)){var n=e.getExtension("WEBGL_draw_buffers");return n?t(n.MAX_COLOR_ATTACHMENTS_WEBGL):0}})),u()(H,35379,q),u()(H,35374,q),u()(H,35377,q),u()(H,34852,(function(e){if(!D(e)){var t=e.getExtension("WEBGL_draw_buffers");return t?t.MAX_DRAW_BUFFERS_WEBGL:0}})),u()(H,36203,(function(e){return e.getExtension("OES_element_index")?2147483647:65535})),u()(H,33001,(function(e){return e.getExtension("OES_element_index")?16777216:65535})),u()(H,33e3,(function(e){return 16777216})),u()(H,37157,q),u()(H,35373,q),u()(H,35657,q),u()(H,36183,q),u()(H,37137,q),u()(H,34045,q),u()(H,35978,q),u()(H,35979,q),u()(H,35968,q),u()(H,35376,q),u()(H,35375,q),u()(H,35659,q),u()(H,37154,q),u()(H,35371,q),u()(H,35658,q),u()(H,35076,q),u()(H,35077,q),u()(H,35380,q),H);var Y=(X={},u()(X,"OES_vertex_array_object",{meta:{suffix:"OES"},createVertexArray:function(){M(!1,"VertexArray requires WebGL2 or OES_vertex_array_object extension")},deleteVertexArray:function(){},bindVertexArray:function(){},isVertexArray:function(){return!1}}),u()(X,"ANGLE_instanced_arrays",{meta:{suffix:"ANGLE"},vertexAttribDivisor:function(e,t){M(0===t,"WebGL instanced rendering not supported")},drawElementsInstanced:function(){},drawArraysInstanced:function(){}}),u()(X,"WEBGL_draw_buffers",{meta:{suffix:"WEBGL"},drawBuffers:function(){M(!1)}}),u()(X,"EXT_disjoint_timer_query",{meta:{suffix:"EXT"},createQuery:function(){M(!1)},deleteQuery:function(){M(!1)},beginQuery:function(){M(!1)},endQuery:function(){},getQuery:function(e,t){return this.getQueryObject(e,t)},getQueryParameter:function(e,t){return this.getQueryObject(e,t)},getQueryObject:function(){}}),X),Q={readBuffer:function(e,t,n){D(e)&&t(n)},getVertexAttrib:function(e,t,n,r){var i,a=function(e,t){return{webgl2:D(e),ext:e.getExtension(t)}}(e,"ANGLE_instanced_arrays"),o=a.webgl2,s=a.ext;switch(r){case 35069:i=!!o&&void 0;break;case 35070:i=o||s?void 0:0}return void 0!==i?i:t(n,r)},getProgramParameter:function(e,t,n,r){if(!D(e))switch(r){case 35967:return 35981;case 35971:case 35382:return 0}return t(n,r)},getInternalformatParameter:function(e,t,n,r,i){if(!D(e))switch(i){case 32937:return new Int32Array([0])}return e.getInternalformatParameter(n,r,i)},getTexParameter:function(e,t,n,r){switch(r){case 34046:var i=e.luma.extensions.EXT_texture_filter_anisotropic;r=i&&i.TEXTURE_MAX_ANISOTROPY_EXT||34046}return t(n,r)},getParameter:function(e,t,n){var r=K[n],i="function"==typeof r?r(e,t,n):r;return void 0!==i?i:t(n)},hint:function(e,t,n,r){return t(n,r)}};function $(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function J(e,t){var n=t.extension,r=t.target,i=t.target2,a=Y[n];M(a);for(var o=a.meta,s=(void 0===o?{}:o).suffix,u=void 0===s?"":s,c=e.getExtension(n),l=function(){var t=h[f],n="".concat(t).concat(u),o=null;"meta"===t||"function"==typeof e[t]||(c&&"function"==typeof c[n]?o=function(){return c[n].apply(c,arguments)}:"function"==typeof a[t]&&(o=a[t].bind(r))),o&&(r[t]=o,i[t]=o)},f=0,h=Object.keys(a);f<h.length;f++)l()}globalThis.polyfillContext=function(e){e.luma=e.luma||{};var t=e.luma;return t.polyfilled||(!function(e){if("function"!=typeof e.createVertexArray){var t=e.getSupportedExtensions;e.getSupportedExtensions=function(){var e=t.call(this)||[];return e.indexOf("OES_vertex_array_object")<0&&e.push("OES_vertex_array_object"),e};var n=e.getExtension;e.getExtension=function(t){var r=n.call(this,t);return r||("OES_vertex_array_object"!==t?null:(e.__OESVertexArrayObject||(this.__OESVertexArrayObject=new W(this)),this.__OESVertexArrayObject))}}}(e),function(e){e.luma.extensions={};var t,n=$(e.getSupportedExtensions()||[]);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.luma[r]=e.getExtension(r)}}catch(e){n.e(e)}finally{n.f()}}(e),function(e,t){var n,r=$(Object.getOwnPropertyNames(t));try{for(r.s();!(n=r.n()).done;){var i=n.value;"overrides"!==i&&J(e,{extension:i,target:e.luma,target2:e})}}catch(e){r.e(e)}finally{r.f()}}(e,Y),function(e,t){var n=t.target,r=t.target2;Object.keys(Q).forEach((function(t){if("function"==typeof Q[t]){var i=e[t]?e[t].bind(e):function(){},a=Q[t].bind(null,e,i);n[t]=a,r[t]=a}}))}(e,{target:t,target2:e}),t.polyfilled=!0),e};var ee,te,ne,re=n(7),ie=n.n(re),ae=(ee={},u()(ee,3042,!1),u()(ee,32773,new Float32Array([0,0,0,0])),u()(ee,32777,32774),u()(ee,34877,32774),u()(ee,32969,1),u()(ee,32968,0),u()(ee,32971,1),u()(ee,32970,0),u()(ee,3106,new Float32Array([0,0,0,0])),u()(ee,3107,[!0,!0,!0,!0]),u()(ee,2884,!1),u()(ee,2885,1029),u()(ee,2929,!1),u()(ee,2931,1),u()(ee,2932,513),u()(ee,2928,new Float32Array([0,1])),u()(ee,2930,!0),u()(ee,3024,!0),u()(ee,36006,null),u()(ee,2886,2305),u()(ee,33170,4352),u()(ee,2849,1),u()(ee,32823,!1),u()(ee,32824,0),u()(ee,10752,0),u()(ee,32938,1),u()(ee,32939,!1),u()(ee,3089,!1),u()(ee,3088,new Int32Array([0,0,1024,1024])),u()(ee,2960,!1),u()(ee,2961,0),u()(ee,2968,4294967295),u()(ee,36005,4294967295),u()(ee,2962,519),u()(ee,2967,0),u()(ee,2963,4294967295),u()(ee,34816,519),u()(ee,36003,0),u()(ee,36004,4294967295),u()(ee,2964,7680),u()(ee,2965,7680),u()(ee,2966,7680),u()(ee,34817,7680),u()(ee,34818,7680),u()(ee,34819,7680),u()(ee,2978,[0,0,1024,1024]),u()(ee,3333,4),u()(ee,3317,4),u()(ee,37440,!1),u()(ee,37441,!1),u()(ee,37443,37444),u()(ee,35723,4352),u()(ee,36010,null),u()(ee,35977,!1),u()(ee,3330,0),u()(ee,3332,0),u()(ee,3331,0),u()(ee,3314,0),u()(ee,32878,0),u()(ee,3316,0),u()(ee,3315,0),u()(ee,32877,0),ee),oe=function(e,t,n){return t?e.enable(n):e.disable(n)},se=function(e,t,n){return e.hint(n,t)},ue=function(e,t,n){return e.pixelStorei(n,t)};function ce(e){return Array.isArray(e)||ArrayBuffer.isView(e)}var le=(te={},u()(te,3042,oe),u()(te,32773,(function(e,t){return e.blendColor.apply(e,o()(t))})),u()(te,32777,"blendEquation"),u()(te,34877,"blendEquation"),u()(te,32969,"blendFunc"),u()(te,32968,"blendFunc"),u()(te,32971,"blendFunc"),u()(te,32970,"blendFunc"),u()(te,3106,(function(e,t){return e.clearColor.apply(e,o()(t))})),u()(te,3107,(function(e,t){return e.colorMask.apply(e,o()(t))})),u()(te,2884,oe),u()(te,2885,(function(e,t){return e.cullFace(t)})),u()(te,2929,oe),u()(te,2931,(function(e,t){return e.clearDepth(t)})),u()(te,2932,(function(e,t){return e.depthFunc(t)})),u()(te,2928,(function(e,t){return e.depthRange.apply(e,o()(t))})),u()(te,2930,(function(e,t){return e.depthMask(t)})),u()(te,3024,oe),u()(te,35723,se),u()(te,36006,(function(e,t){var n=D(e)?36009:36160;return e.bindFramebuffer(n,t)})),u()(te,2886,(function(e,t){return e.frontFace(t)})),u()(te,33170,se),u()(te,2849,(function(e,t){return e.lineWidth(t)})),u()(te,32823,oe),u()(te,32824,"polygonOffset"),u()(te,10752,"polygonOffset"),u()(te,35977,oe),u()(te,32938,"sampleCoverage"),u()(te,32939,"sampleCoverage"),u()(te,3089,oe),u()(te,3088,(function(e,t){return e.scissor.apply(e,o()(t))})),u()(te,2960,oe),u()(te,2961,(function(e,t){return e.clearStencil(t)})),u()(te,2968,(function(e,t){return e.stencilMaskSeparate(1028,t)})),u()(te,36005,(function(e,t){return e.stencilMaskSeparate(1029,t)})),u()(te,2962,"stencilFuncFront"),u()(te,2967,"stencilFuncFront"),u()(te,2963,"stencilFuncFront"),u()(te,34816,"stencilFuncBack"),u()(te,36003,"stencilFuncBack"),u()(te,36004,"stencilFuncBack"),u()(te,2964,"stencilOpFront"),u()(te,2965,"stencilOpFront"),u()(te,2966,"stencilOpFront"),u()(te,34817,"stencilOpBack"),u()(te,34818,"stencilOpBack"),u()(te,34819,"stencilOpBack"),u()(te,2978,(function(e,t){return e.viewport.apply(e,o()(t))})),u()(te,3333,ue),u()(te,3317,ue),u()(te,37440,ue),u()(te,37441,ue),u()(te,37443,ue),u()(te,3330,ue),u()(te,3332,ue),u()(te,3331,ue),u()(te,36010,(function(e,t){return e.bindFramebuffer(36008,t)})),u()(te,3314,ue),u()(te,32878,ue),u()(te,3316,ue),u()(te,3315,ue),u()(te,32877,ue),u()(te,"framebuffer",(function(e,t){var n=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,n)})),u()(te,"blend",(function(e,t){return t?e.enable(3042):e.disable(3042)})),u()(te,"blendColor",(function(e,t){return e.blendColor.apply(e,o()(t))})),u()(te,"blendEquation",(function(e,t){t=ce(t)?t:[t,t],e.blendEquationSeparate.apply(e,o()(t))})),u()(te,"blendFunc",(function(e,t){t=ce(t)&&2===t.length?[].concat(o()(t),o()(t)):t,e.blendFuncSeparate.apply(e,o()(t))})),u()(te,"clearColor",(function(e,t){return e.clearColor.apply(e,o()(t))})),u()(te,"clearDepth",(function(e,t){return e.clearDepth(t)})),u()(te,"clearStencil",(function(e,t){return e.clearStencil(t)})),u()(te,"colorMask",(function(e,t){return e.colorMask.apply(e,o()(t))})),u()(te,"cull",(function(e,t){return t?e.enable(2884):e.disable(2884)})),u()(te,"cullFace",(function(e,t){return e.cullFace(t)})),u()(te,"depthTest",(function(e,t){return t?e.enable(2929):e.disable(2929)})),u()(te,"depthFunc",(function(e,t){return e.depthFunc(t)})),u()(te,"depthMask",(function(e,t){return e.depthMask(t)})),u()(te,"depthRange",(function(e,t){return e.depthRange.apply(e,o()(t))})),u()(te,"dither",(function(e,t){return t?e.enable(3024):e.disable(3024)})),u()(te,"derivativeHint",(function(e,t){e.hint(35723,t)})),u()(te,"frontFace",(function(e,t){return e.frontFace(t)})),u()(te,"mipmapHint",(function(e,t){return e.hint(33170,t)})),u()(te,"lineWidth",(function(e,t){return e.lineWidth(t)})),u()(te,"polygonOffsetFill",(function(e,t){return t?e.enable(32823):e.disable(32823)})),u()(te,"polygonOffset",(function(e,t){return e.polygonOffset.apply(e,o()(t))})),u()(te,"sampleCoverage",(function(e,t){return e.sampleCoverage.apply(e,o()(t))})),u()(te,"scissorTest",(function(e,t){return t?e.enable(3089):e.disable(3089)})),u()(te,"scissor",(function(e,t){return e.scissor.apply(e,o()(t))})),u()(te,"stencilTest",(function(e,t){return t?e.enable(2960):e.disable(2960)})),u()(te,"stencilMask",(function(e,t){var n=t=ce(t)?t:[t,t],r=ie()(n,2),i=r[0],a=r[1];e.stencilMaskSeparate(1028,i),e.stencilMaskSeparate(1029,a)})),u()(te,"stencilFunc",(function(e,t){var n=t=ce(t)&&3===t.length?[].concat(o()(t),o()(t)):t,r=ie()(n,6),i=r[0],a=r[1],s=r[2],u=r[3],c=r[4],l=r[5];e.stencilFuncSeparate(1028,i,a,s),e.stencilFuncSeparate(1029,u,c,l)})),u()(te,"stencilOp",(function(e,t){var n=t=ce(t)&&3===t.length?[].concat(o()(t),o()(t)):t,r=ie()(n,6),i=r[0],a=r[1],s=r[2],u=r[3],c=r[4],l=r[5];e.stencilOpSeparate(1028,i,a,s),e.stencilOpSeparate(1029,u,c,l)})),u()(te,"viewport",(function(e,t){return e.viewport.apply(e,o()(t))})),te);function fe(e,t,n){return void 0!==t[e]?t[e]:n[e]}var he={blendEquation:function(e,t,n){return e.blendEquationSeparate(fe(32777,t,n),fe(34877,t,n))},blendFunc:function(e,t,n){return e.blendFuncSeparate(fe(32969,t,n),fe(32968,t,n),fe(32971,t,n),fe(32970,t,n))},polygonOffset:function(e,t,n){return e.polygonOffset(fe(32824,t,n),fe(10752,t,n))},sampleCoverage:function(e,t,n){return e.sampleCoverage(fe(32938,t,n),fe(32939,t,n))},stencilFuncFront:function(e,t,n){return e.stencilFuncSeparate(1028,fe(2962,t,n),fe(2967,t,n),fe(2963,t,n))},stencilFuncBack:function(e,t,n){return e.stencilFuncSeparate(1029,fe(34816,t,n),fe(36003,t,n),fe(36004,t,n))},stencilOpFront:function(e,t,n){return e.stencilOpSeparate(1028,fe(2964,t,n),fe(2965,t,n),fe(2966,t,n))},stencilOpBack:function(e,t,n){return e.stencilOpSeparate(1029,fe(34817,t,n),fe(34818,t,n),fe(34819,t,n))}},de={enable:function(e,t){return e(u()({},t,!0))},disable:function(e,t){return e(u()({},t,!1))},pixelStorei:function(e,t,n){return e(u()({},t,n))},hint:function(e,t,n){return e(u()({},t,n))},bindFramebuffer:function(e,t,n){var r;switch(t){case 36160:return e((r={},u()(r,36006,n),u()(r,36010,n),r));case 36009:return e(u()({},36006,n));case 36008:return e(u()({},36010,n));default:return null}},blendColor:function(e,t,n,r,i){return e(u()({},32773,new Float32Array([t,n,r,i])))},blendEquation:function(e,t){var n;return e((n={},u()(n,32777,t),u()(n,34877,t),n))},blendEquationSeparate:function(e,t,n){var r;return e((r={},u()(r,32777,t),u()(r,34877,n),r))},blendFunc:function(e,t,n){var r;return e((r={},u()(r,32969,t),u()(r,32968,n),u()(r,32971,t),u()(r,32970,n),r))},blendFuncSeparate:function(e,t,n,r,i){var a;return e((a={},u()(a,32969,t),u()(a,32968,n),u()(a,32971,r),u()(a,32970,i),a))},clearColor:function(e,t,n,r,i){return e(u()({},3106,new Float32Array([t,n,r,i])))},clearDepth:function(e,t){return e(u()({},2931,t))},clearStencil:function(e,t){return e(u()({},2961,t))},colorMask:function(e,t,n,r,i){return e(u()({},3107,[t,n,r,i]))},cullFace:function(e,t){return e(u()({},2885,t))},depthFunc:function(e,t){return e(u()({},2932,t))},depthRange:function(e,t,n){return e(u()({},2928,new Float32Array([t,n])))},depthMask:function(e,t){return e(u()({},2930,t))},frontFace:function(e,t){return e(u()({},2886,t))},lineWidth:function(e,t){return e(u()({},2849,t))},polygonOffset:function(e,t,n){var r;return e((r={},u()(r,32824,t),u()(r,10752,n),r))},sampleCoverage:function(e,t,n){var r;return e((r={},u()(r,32938,t),u()(r,32939,n),r))},scissor:function(e,t,n,r,i){return e(u()({},3088,new Int32Array([t,n,r,i])))},stencilMask:function(e,t){var n;return e((n={},u()(n,2968,t),u()(n,36005,t),n))},stencilMaskSeparate:function(e,t,n){return e(u()({},1028===t?2968:36005,n))},stencilFunc:function(e,t,n,r){var i;return e((i={},u()(i,2962,t),u()(i,2967,n),u()(i,2963,r),u()(i,34816,t),u()(i,36003,n),u()(i,36004,r),i))},stencilFuncSeparate:function(e,t,n,r,i){var a;return e((a={},u()(a,1028===t?2962:34816,n),u()(a,1028===t?2967:36003,r),u()(a,1028===t?2963:36004,i),a))},stencilOp:function(e,t,n,r){var i;return e((i={},u()(i,2964,t),u()(i,2965,n),u()(i,2966,r),u()(i,34817,t),u()(i,34818,n),u()(i,34819,r),i))},stencilOpSeparate:function(e,t,n,r,i){var a;return e((a={},u()(a,1028===t?2964:34817,n),u()(a,1028===t?2965:34818,r),u()(a,1028===t?2966:34819,i),a))},viewport:function(e,t,n,r,i){return e(u()({},2978,[t,n,r,i]))}},ve=function(e,t){return e.isEnabled(t)},ge=(ne={},u()(ne,3042,ve),u()(ne,2884,ve),u()(ne,2929,ve),u()(ne,3024,ve),u()(ne,32823,ve),u()(ne,32926,ve),u()(ne,32928,ve),u()(ne,3089,ve),u()(ne,2960,ve),u()(ne,35977,ve),ne);function pe(e){for(var t in e)return!1;return!0}function me(e,t){if(e===t)return!0;var n=Array.isArray(e)||ArrayBuffer.isView(e),r=Array.isArray(t)||ArrayBuffer.isView(t);if(n&&r&&e.length===t.length){for(var i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}return!1}function ye(e,t){var n=e[t].bind(e);e[t]=function(){var t=arguments.length<=0?void 0:arguments[0];return t in e.state.cache&&e.state.enable?e.state.cache[t]:n.apply(void 0,arguments)},Object.defineProperty(e[t],"name",{value:"".concat(t,"-from-cache"),configurable:!1})}function _e(e,t,n){var r=e[t].bind(e);e[t]=function(){for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];var o=n.apply(void 0,[e.state._updateCache].concat(i)),s=o.valueChanged,u=o.oldValue;return s&&r.apply(void 0,i),u},Object.defineProperty(e[t],"name",{value:"".concat(t,"-to-cache"),configurable:!1})}function be(e){var t=e.useProgram.bind(e);e.useProgram=function(n){e.state.program!==n&&(t(n),e.state.program=n)}}var Ae=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.copyState,i=void 0!==r&&r,a=n.log,o=void 0===a?function(){}:a;l()(this,e),this.gl=t,this.program=null,this.stateStack=[],this.enable=!0,this.cache=i?Oe(t):Object.assign({},ae),this.log=o,this._updateCache=this._updateCache.bind(this),Object.seal(this)}return h()(e,[{key:"push",value:function(){this.stateStack.push({})}},{key:"pop",value:function(){M(this.stateStack.length>0);var e=this.stateStack[this.stateStack.length-1];we(this.gl,e),this.stateStack.pop()}},{key:"_updateCache",value:function(e){var t,n=!1,r=this.stateStack.length>0&&this.stateStack[this.stateStack.length-1];for(var i in e){M(void 0!==i);var a=e[i],o=this.cache[i];me(a,o)||(n=!0,t=o,r&&!(i in r)&&(r[i]=o),this.cache[i]=a)}return{valueChanged:n,oldValue:t}}}]),e}();function xe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.enable,r=void 0===n||n,i=t.copyState;if(M(void 0!==i),!e.state){var a=globalThis.polyfillContext;for(var o in a&&a(e),e.state=new Ae(e,{copyState:i}),be(e),de){var s=de[o];_e(e,o,s)}ye(e,"getParameter"),ye(e,"isEnabled")}return e.state.enable=r,e}function Ee(e){M(e.state),e.state.pop()}function Te(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ke(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ke(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ke(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function we(e,t){if(M(N(e),"setParameters requires a WebGL context"),!pe(t)){var n={};for(var r in t){var i=Number(r),a=le[r];a&&("string"==typeof a?n[a]=!0:a(e,t[r],i))}var o=e.state&&e.state.cache;if(o)for(var s in n){(0,he[s])(e,t,o)}}}function Oe(e,t){if("number"==typeof(t=t||ae)){var n=t,r=ge[n];return r?r(e,n):e.getParameter(n)}var i,a={},o=Te(Array.isArray(t)?t:Object.keys(t));try{for(o.s();!(i=o.n()).done;){var s=i.value,u=ge[s];a[s]=u?u(e,Number(s)):e.getParameter(Number(s))}}catch(e){o.e(e)}finally{o.f()}return a}function Se(e){we(e,ae)}function Le(e,t,n){if(pe(t))return n(e);var r,i=t.nocatch,a=void 0===i||i;if(function(e){e.state||xe(e,{copyState:!1}),e.state.push()}(e),we(e,t),a)r=n(e),Ee(e);else try{r=n(e)}finally{Ee(e)}return r}function Ie(e){var t=e.luma;if(e.canvas&&t){var n=t.canvasSizeInfo.clientWidth;return n?e.drawingBufferWidth/n:1}return 1}function Pe(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=Ie(e),i=e.drawingBufferWidth,a=e.drawingBufferHeight;return Fe(t,r,i,a,n)}function Re(e){var t="undefined"==typeof window?1:window.devicePixelRatio||1;return Number.isFinite(e)?e<=0?1:e:e?t:1}function Fe(e,t,n,r,i){var a,o=Ce(e[0],t,n),s=Be(e[1],t,r,i),u=Ce(e[0]+1,t,n),c=u===n-1?u:u-1;return u=Be(e[1]+1,t,r,i),i?(a=s,s=u=0===u?u:u+1):a=u===r-1?u:u-1,{x:o,y:s,width:Math.max(c-o+1,1),height:Math.max(a-s+1,1)}}function Ce(e,t,n){return Math.min(Math.round(e*t),n-1)}function Be(e,t,n,r){return r?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}var Me=Object(v.a)(),Ne=Me&&"undefined"!=typeof document,De={webgl2:!0,webgl1:!0,throwOnError:!0,manageState:!0,canvas:null,debug:!1,width:800,height:600};function je(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};M(Me,"createGLContext only available in the browser.\nCreate your own headless context or use 'createHeadlessContext' from @luma.gl/test-utils");var t,n=e=Object.assign({},De,e),r=n.width,i=n.height;function a(t){if(e.throwOnError)throw new Error(t);return console.error(t),null}e.onError=a;var o=e,s=o.canvas,u=Ve({canvas:s,width:r,height:i,onError:a});return(t=Ge(u,e))?(ze(t=Ue(t,e)),t):null}function Ue(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e||e._instrumented)return e;e._version=e._version||He(e),e.luma=e.luma||{},e.luma.canvasSizeInfo=e.luma.canvasSizeInfo||{};var n=t=Object.assign({},De,t),r=n.manageState,i=n.debug;return r&&xe(e,{copyState:!1,log:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return B.log.apply(B,[1].concat(t))()}}),Me&&i&&(globalThis.makeDebugContext?(e=globalThis.makeDebugContext(e,t),B.level=Math.max(B.level,1)):B.warn('WebGL debug mode not activated. import "@luma.gl/debug" to enable.')()),e._instrumented=!0,e}function Ge(e,t){var n=t.onError,r=null,i=function(e){return r=e.statusMessage||r};e.addEventListener("webglcontextcreationerror",i,!1);var a=t.webgl1,o=void 0===a||a,s=t.webgl2,u=void 0===s||s,c=null;return u&&(c=(c=c||e.getContext("webgl2",t))||e.getContext("experimental-webgl2",t)),o&&(c=(c=c||e.getContext("webgl",t))||e.getContext("experimental-webgl",t)),e.removeEventListener("webglcontextcreationerror",i,!1),c?(t.onContextLost&&e.addEventListener("webglcontextlost",t.onContextLost,!1),t.onContextRestored&&e.addEventListener("webglcontextrestored",t.onContextRestored,!1),c):n("Failed to create ".concat(u&&!o?"WebGL2":"WebGL"," context: ").concat(r||"Unknown error"))}function Ve(e){var t,n=e.canvas,r=e.width,i=void 0===r?800:r,a=e.height,o=void 0===a?600:a,s=e.onError;"string"==typeof n?(Ne&&"complete"===document.readyState||s("createGLContext called on canvas '".concat(n,"' before page was loaded")),t=document.getElementById(n)):n?t=n:((t=document.createElement("canvas")).id="lumagl-canvas",t.style.width=Number.isFinite(i)?"".concat(i,"px"):"100%",t.style.height=Number.isFinite(o)?"".concat(o,"px"):"100%",document.body.insertBefore(t,document.body.firstChild));return t}function ze(e){var t=D(e)?"WebGL2":"WebGL1",n=function(e){var t=e.getParameter(7936),n=e.getParameter(7937),r=e.getExtension("WEBGL_debug_renderer_info");return{vendor:r&&e.getParameter(r.UNMASKED_VENDOR_WEBGL||7936)||t,renderer:r&&e.getParameter(r.UNMASKED_RENDERER_WEBGL||7937)||n,vendorMasked:t,rendererMasked:n,version:e.getParameter(7938),shadingLanguageVersion:e.getParameter(35724)}}(e),r=n?"(".concat(n.vendor,",").concat(n.renderer,")"):"",i=e.debug?" debug":"";B.info(1,"".concat(t).concat(i," context ").concat(r))()}function He(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext?2:1}function We(e,t,n){var r="width"in n?n.width:e.canvas.clientWidth,i="height"in n?n.height:e.canvas.clientHeight;r&&i||(B.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,r=e.canvas.width||1,i=e.canvas.height||1),e.luma=e.luma||{},e.luma.canvasSizeInfo=e.luma.canvasSizeInfo||{};var a=e.luma.canvasSizeInfo;if(a.clientWidth!==r||a.clientHeight!==i||a.devicePixelRatio!==t){var o=t,s=Math.floor(r*o),u=Math.floor(i*o);e.canvas.width=s,e.canvas.height=u,e.drawingBufferWidth===s&&e.drawingBufferHeight===u||(B.warn("Device pixel ratio clamped")(),o=Math.min(e.drawingBufferWidth/r,e.drawingBufferHeight/i),e.canvas.width=Math.floor(r*o),e.canvas.height=Math.floor(i*o)),Object.assign(e.luma.canvasSizeInfo,{clientWidth:r,clientHeight:i,devicePixelRatio:t})}}var Xe=n(15),qe=function(){function e(t,n){l()(this,e),d(this,"name",void 0),d(this,"type",void 0),d(this,"sampleSize",1),d(this,"time",void 0),d(this,"count",void 0),d(this,"samples",void 0),d(this,"lastTiming",void 0),d(this,"lastSampleTime",void 0),d(this,"lastSampleCount",void 0),d(this,"_count",0),d(this,"_time",0),d(this,"_samples",0),d(this,"_startTime",0),d(this,"_timerPending",!1),this.name=t,this.type=n,this.reset()}return h()(e,[{key:"setSampleSize",value:function(e){return this.sampleSize=e,this}},{key:"incrementCount",value:function(){return this.addCount(1),this}},{key:"decrementCount",value:function(){return this.subtractCount(1),this}},{key:"addCount",value:function(e){return this._count+=e,this._samples++,this._checkSampling(),this}},{key:"subtractCount",value:function(e){return this._count-=e,this._samples++,this._checkSampling(),this}},{key:"addTime",value:function(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}},{key:"timeStart",value:function(){return this._startTime=Object(Xe.a)(),this._timerPending=!0,this}},{key:"timeEnd",value:function(){return this._timerPending?(this.addTime(Object(Xe.a)()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}},{key:"getSampleAverageCount",value:function(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}},{key:"getSampleAverageTime",value:function(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}},{key:"getSampleHz",value:function(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}},{key:"getAverageCount",value:function(){return this.samples>0?this.count/this.samples:0}},{key:"getAverageTime",value:function(){return this.samples>0?this.time/this.samples:0}},{key:"getHz",value:function(){return this.time>0?this.samples/(this.time/1e3):0}},{key:"reset",value:function(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}},{key:"_checkSampling",value:function(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}]),e}(),Ke=function(){function e(t){l()(this,e),d(this,"id",void 0),d(this,"stats",{}),this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}return h()(e,[{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count";return this._getOrCreate({name:e,type:t})}},{key:"size",get:function(){return Object.keys(this.stats).length}},{key:"reset",value:function(){for(var e in this.stats)this.stats[e].reset();return this}},{key:"forEach",value:function(e){for(var t in this.stats)e(this.stats[t])}},{key:"getTable",value:function(){var e={};return this.forEach((function(t){e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}})),e}},{key:"_initializeStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t.forEach((function(t){return e._getOrCreate(t)}))}},{key:"_getOrCreate",value:function(e){if(!e||!e.name)return null;var t=e.name,n=e.type;return this.stats[t]||(this.stats[t]=e instanceof qe?e:new qe(t,n)),this.stats[t]}}]),e}(),Ye=function(){function e(){l()(this,e),this.stats=new Map}return h()(e,[{key:"get",value:function(e){return this.stats.has(e)||this.stats.set(e,new Ke({id:e})),this.stats.get(e)}}]),e}(),Qe=new Ye;if(globalThis.luma&&"8.5.15"!==globalThis.luma.VERSION)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat("8.5.15"));globalThis.luma||(Object(v.a)()&&B.log(1,"luma.gl ".concat("8.5.15"," - ").concat("set luma.log.level=1 (or higher) to trace rendering"))(),globalThis.luma=globalThis.luma||{VERSION:"8.5.15",version:"8.5.15",log:B,stats:Qe,globals:{modules:{},nodeIO:{}}});globalThis.luma;var $e=n(8),Ze=n.n($e),Je=n(13),et=n.n(Je),tt=n(4),nt=n.n(tt),rt=n(5),it=n.n(rt),at=n(3),ot=n.n(at);function st(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function ut(e,t){if("string"!=typeof t)return t;var n=Number(t);if(!isNaN(n))return n;var r=e[t=t.replace(/^.*\./,"")];return st(void 0!==r,"Accessing undefined constant GL.".concat(t)),r}function ct(e,t){for(var n in t=Number(t),e)if(e[n]===t)return"GL.".concat(n);return String(t)}var lt={};function ft(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";lt[e]=lt[e]||1;var t=lt[e]++;return"".concat(e,"-").concat(t)}function ht(e){return st("number"==typeof e,"Input must be a number"),e&&0==(e&e-1)}function dt(e){var t=!0;for(var n in e){t=!1;break}return t}function vt(e,t,n,r){var i="See luma.gl ".concat(n," Upgrade Guide at https://luma.gl/docs/upgrade-guide"),a=Object.getPrototypeOf(e);r.forEach((function(e){a.methodName||(a[e]=function(){throw B.removed("Calling removed method ".concat(t,".").concat(e,": "),i)(),new Error(e)})}))}function gt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return pt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var mt="Resource subclass must define virtual methods",yt=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,t),j(e);var r=n.id,i=n.userData,a=void 0===i?{}:i;this.gl=e,this.gl2=e,this.id=r||ft(this[Symbol.toStringTag]),this.userData=a,this._bound=!1,this._handle=n.handle,void 0===this._handle&&(this._handle=this._createHandle()),this.byteLength=0,this._initStats(),this._addStats()}return h()(t,[{key:e,get:function(){return"Resource"}},{key:"toString",value:function(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")}},{key:"handle",get:function(){return this._handle}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.deleteChildren,n=void 0!==t&&t,r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this._removeStats(),this._handle=null,r&&n&&r.filter(Boolean).forEach((function(e){return e.delete()})),this}},{key:"bind",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.handle;return"function"!=typeof t?(this._bindHandle(t),this):(this._bound?e=t():(this._bindHandle(this.handle),this._bound=!0,e=t(),this._bound=!1,this._bindHandle(null)),e)}},{key:"unbind",value:function(){this.bind(null)}},{key:"getParameter",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};st(e=ut(this.gl,e));var n=this.constructor.PARAMETERS||{},r=n[e];if(r){var i=D(this.gl),a=(!("webgl2"in r)||i)&&(!("extension"in r)||this.gl.getExtension(r.extension));if(!a){var o=r.webgl1,s="webgl2"in r?r.webgl2:r.webgl1,u=i?s:o;return u}}return this._getParameter(e,t)}},{key:"getParameters",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.parameters,r=t.keys,i=this.constructor.PARAMETERS||{},a=D(this.gl),o={},s=n||Object.keys(i),u=gt(s);try{for(u.s();!(e=u.n()).done;){var c=e.value,l=i[c],f=l&&(!("webgl2"in l)||a)&&(!("extension"in l)||this.gl.getExtension(l.extension));if(f){var h=r?ct(this.gl,c):c;o[h]=this.getParameter(c,t),r&&"GLenum"===l.type&&(o[h]=ct(this.gl,o[h]))}}}catch(e){u.e(e)}finally{u.f()}return o}},{key:"setParameter",value:function(e,t){st(e=ut(this.gl,e));var n=(this.constructor.PARAMETERS||{})[e];if(n){var r=D(this.gl);if(!((!("webgl2"in n)||r)&&(!("extension"in n)||this.gl.getExtension(n.extension))))throw new Error("Parameter not available on this platform");"GLenum"===n.type&&(t=ut(t))}return this._setParameter(e,t),this}},{key:"setParameters",value:function(e){for(var t in e)this.setParameter(t,e[t]);return this}},{key:"stubRemovedMethods",value:function(e,t,n){return vt(this,e,t,n)}},{key:"initialize",value:function(e){}},{key:"_createHandle",value:function(){throw new Error(mt)}},{key:"_deleteHandle",value:function(){throw new Error(mt)}},{key:"_bindHandle",value:function(e){throw new Error(mt)}},{key:"_getOptsFromHandle",value:function(){throw new Error(mt)}},{key:"_getParameter",value:function(e,t){throw new Error(mt)}},{key:"_setParameter",value:function(e,t){throw new Error(mt)}},{key:"_context",value:function(){return this.gl.luma=this.gl.luma||{},this.gl.luma}},{key:"_initStats",value:function(){this.gl.stats=this.gl.stats||new Ye}},{key:"_addStats",value:function(){var e=this[Symbol.toStringTag],t=Qe.get("Resource Counts");t.get("Resources Created").incrementCount(),t.get("".concat(e,"s Created")).incrementCount(),t.get("".concat(e,"s Active")).incrementCount()}},{key:"_removeStats",value:function(){var e=this[Symbol.toStringTag];Qe.get("Resource Counts").get("".concat(e,"s Active")).decrementCount()}},{key:"_trackAllocatedMemory",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag];this._doTrackAllocatedMemory(e,t),this._doTrackAllocatedMemory(e,t,this.gl.stats.get("Memory Usage"))}},{key:"_doTrackAllocatedMemory",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qe.get("Memory Usage");n.get("GPU Memory").addCount(e),n.get("".concat(t," Memory")).addCount(e),this.byteLength=e}},{key:"_trackDeallocatedMemory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];this._doTrackDeallocatedMemory(e),this._doTrackDeallocatedMemory(e,this.gl.stats.get("Memory Usage"))}},{key:"_doTrackDeallocatedMemory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Qe.get("Memory Usage");t.get("GPU Memory").subtractCount(this.byteLength),t.get("".concat(e," Memory")).subtractCount(this.byteLength),this.byteLength=0}}]),t}(Symbol.toStringTag),_t=n(21),bt=n.n(_t);function At(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}function xt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.clamped,r=void 0===n||n;switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}function Et(e){var t=e.data,n=e.width,r=e.height,i=e.bytesPerPixel,a=void 0===i?4:i,o=e.temp,s=n*a;o=o||new Uint8Array(s);for(var u=0;u<r/2;++u){var c=u*s,l=(r-u-1)*s;o.set(t.subarray(c,c+s)),t.copyWithin(c,l,l+s),t.set(o,l)}}function Tt(e){for(var t=e.data,n=e.width,r=e.height,i=Math.round(n/2),a=Math.round(r/2),o=new Uint8Array(i*a*4),s=0;s<a;s++)for(var u=0;u<i;u++)for(var c=0;c<4;c++)o[4*(s*i+u)+c]=t[4*(2*s*n+2*u)+c];return{data:o,width:i,height:a}}function kt(e,t,n){var r=n.removedProps,i=void 0===r?{}:r,a=n.deprecatedProps,o=void 0===a?{}:a,s=n.replacedProps,u=void 0===s?{}:s;for(var c in i)if(c in t){var l=i[c]?"".concat(e,".").concat(i[c]):"N/A";B.removed("".concat(e,".").concat(c),l)()}for(var f in o)if(f in t){var h=o[f];B.deprecated("".concat(e,".").concat(f),"".concat(e,".").concat(h))()}var d=null;for(var v in u)if(v in t){var g=u[v];B.deprecated("".concat(e,".").concat(v),"".concat(e,".").concat(g))(),(d=d||Object.assign({},t))[g]=t[v],delete d[v]}return d||t}var wt={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},Ot={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},St=function(){function e(){var t=this;l()(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];r.forEach((function(e){return t._assign(e)})),Object.freeze(this)}return h()(e,[{key:"toString",value:function(){return JSON.stringify(this)}},{key:"BYTES_PER_ELEMENT",get:function(){return e.getBytesPerElement(this)}},{key:"BYTES_PER_VERTEX",get:function(){return e.getBytesPerVertex(this)}},{key:"_assign",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return void 0!==(e=kt("Accessor",e,Ot)).type&&(this.type=e.type,5124!==e.type&&5125!==e.type||(this.integer=!0)),void 0!==e.size&&(this.size=e.size),void 0!==e.offset&&(this.offset=e.offset),void 0!==e.stride&&(this.stride=e.stride),void 0!==e.normalized&&(this.normalized=e.normalized),void 0!==e.integer&&(this.integer=e.integer),void 0!==e.divisor&&(this.divisor=e.divisor),void 0!==e.buffer&&(this.buffer=e.buffer),void 0!==e.index&&("boolean"==typeof e.index?this.index=e.index?1:0:this.index=e.index),void 0!==e.instanced&&(this.divisor=e.instanced?1:0),void 0!==e.isInstanced&&(this.divisor=e.isInstanced?1:0),this}}],[{key:"getBytesPerElement",value:function(e){return xt(e.type||5126).BYTES_PER_ELEMENT}},{key:"getBytesPerVertex",value:function(e){return st(e.size),xt(e.type||5126).BYTES_PER_ELEMENT*e.size}},{key:"resolve",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return bt()(e,[wt].concat(n))}}]),e}();function Lt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var It,Pt,Rt,Ft={offset:"accessor.offset",stride:"accessor.stride",type:"accessor.type",size:"accessor.size",divisor:"accessor.divisor",normalized:"accessor.normalized",integer:"accessor.integer",instanced:"accessor.divisor",isInstanced:"accessor.divisor"},Ct={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:Ft},Bt={removedProps:Ft},Mt=function(e,t){nt()(r,e);var n=Lt(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),(t=n.call(this,e,i)).stubRemovedMethods("Buffer","v6.0",["layout","setLayout","getIndexedParameter"]),t.target=i.target||(t.gl.webgl2?36662:34962),t.initialize(i),Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"Buffer"}},{key:"getElementCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/St.getBytesPerElement(e))}},{key:"getVertexCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/St.getBytesPerVertex(e))}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ArrayBuffer.isView(e)&&(e={data:e}),Number.isFinite(e)&&(e={byteLength:e}),e=kt("Buffer",e,Ct),this.usage=e.usage||35044,this.debugData=null,this.setAccessor(Object.assign({},e,e.accessor)),e.data?this._setData(e.data,e.offset,e.byteLength):this._setByteLength(e.byteLength||0),this}},{key:"setProps",value:function(e){return"accessor"in(e=kt("Buffer",e,Bt))&&this.setAccessor(e.accessor),this}},{key:"setAccessor",value:function(e){return delete(e=Object.assign({},e)).buffer,this.accessor=new St(e),this}},{key:"reallocate",value:function(e){return e>this.byteLength?(this._setByteLength(e),!0):(this.bytesUsed=e,!1)}},{key:"setData",value:function(e){return this.initialize(e)}},{key:"subData",value:function(e){ArrayBuffer.isView(e)&&(e={data:e});var t=e,n=t.data,r=t.offset,i=void 0===r?0:r,a=t.srcOffset,o=void 0===a?0:a,s=e.byteLength||e.length;st(n);var u=this.gl.webgl2?36663:this.target;return this.gl.bindBuffer(u,this.handle),0!==o||void 0!==s?(U(this.gl),this.gl.bufferSubData(this.target,i,n,o,s)):this.gl.bufferSubData(u,i,n),this.gl.bindBuffer(u,null),this.debugData=null,this._inferType(n),this}},{key:"copyData",value:function(e){var t=e.sourceBuffer,n=e.readOffset,r=void 0===n?0:n,i=e.writeOffset,a=void 0===i?0:i,o=e.size,s=this.gl;return U(s),s.bindBuffer(36662,t.handle),s.bindBuffer(36663,this.handle),s.copyBufferSubData(36662,36663,r,a,o),s.bindBuffer(36662,null),s.bindBuffer(36663,null),this.debugData=null,this}},{key:"getData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.dstData,n=void 0===t?null:t,r=e.srcByteOffset,i=void 0===r?0:r,a=e.dstOffset,o=void 0===a?0:a,s=e.length,u=void 0===s?0:s;U(this.gl);var c,l,f=xt(this.accessor.type||5126,{clamped:!1}),h=this._getAvailableElementCount(i),d=o;n?c=(l=n.length)-d:l=d+(c=Math.min(h,u||h));var v=Math.min(h,c);return st((u=u||v)<=v),n=n||new f(l),this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,i,n,o,u),this.gl.bindBuffer(36662,null),n}},{key:"bind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?this.target:t,r=e.index,i=void 0===r?this.accessor&&this.accessor.index:r,a=e.offset,o=void 0===a?0:a,s=e.size;return 35345===n||35982===n?void 0!==s?this.gl.bindBufferRange(n,i,this.handle,o,s):(st(0===o),this.gl.bindBufferBase(n,i,this.handle)):this.gl.bindBuffer(n,this.handle),this}},{key:"unbind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?this.target:t,r=e.index,i=void 0===r?this.accessor&&this.accessor.index:r,a=35345===n||35982===n;return a?this.gl.bindBufferBase(n,i,null):this.gl.bindBuffer(n,null),this}},{key:"getDebugData",value:function(){return this.debugData?{data:this.debugData,changed:!1}:(this.debugData=this.getData({length:Math.min(10,this.byteLength)}),{data:this.debugData,changed:!0})}},{key:"invalidateDebugData",value:function(){this.debugData=null}},{key:"_setData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.byteLength+t;st(ArrayBuffer.isView(e)),this._trackDeallocatedMemory();var r=this._getTarget();this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,this.usage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.debugData=e.slice(0,10),this.bytesUsed=n,this._trackAllocatedMemory(n);var i=At(e);return st(i),this.setAccessor(new St(this.accessor,{type:i})),this}},{key:"_setByteLength",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.usage;st(e>=0),this._trackDeallocatedMemory();var n=e;0===e&&(n=new Float32Array(0));var r=this._getTarget();return this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,t),this.gl.bindBuffer(r,null),this.usage=t,this.debugData=null,this.bytesUsed=e,this._trackAllocatedMemory(e),this}},{key:"_getTarget",value:function(){return this.gl.webgl2?36663:this.target}},{key:"_getAvailableElementCount",value:function(e){var t=e/xt(this.accessor.type||5126,{clamped:!1}).BYTES_PER_ELEMENT;return this.getElementCount()-t}},{key:"_inferType",value:function(e){this.accessor.type||this.setAccessor(new St(this.accessor,{type:At(e)}))}},{key:"_createHandle",value:function(){return this.gl.createBuffer()}},{key:"_deleteHandle",value:function(){this.gl.deleteBuffer(this.handle),this._trackDeallocatedMemory()}},{key:"_getParameter",value:function(e){this.gl.bindBuffer(this.target,this.handle);var t=this.gl.getBufferParameter(this.target,e);return this.gl.bindBuffer(this.target,null),t}},{key:"type",get:function(){return B.deprecated("Buffer.type","Buffer.accessor.type")(),this.accessor.type}},{key:"bytes",get:function(){return B.deprecated("Buffer.bytes","Buffer.byteLength")(),this.byteLength}},{key:"setByteLength",value:function(e){return B.deprecated("setByteLength","reallocate")(),this.reallocate(e)}},{key:"updateAccessor",value:function(e){return B.deprecated("updateAccessor(...)","setAccessor(new Accessor(buffer.accessor, ...)")(),this.accessor=new St(this.accessor,e),this}}]),r}(yt,Symbol.toStringTag),Nt=(It={},u()(It,6407,{dataFormat:6407,types:[5121,33635]}),u()(It,6408,{dataFormat:6408,types:[5121,32819,32820]}),u()(It,6406,{dataFormat:6406,types:[5121]}),u()(It,6409,{dataFormat:6409,types:[5121]}),u()(It,6410,{dataFormat:6410,types:[5121]}),u()(It,33326,{dataFormat:6403,types:[5126],gl2:!0}),u()(It,33328,{dataFormat:33319,types:[5126],gl2:!0}),u()(It,34837,{dataFormat:6407,types:[5126],gl2:!0}),u()(It,34836,{dataFormat:6408,types:[5126],gl2:!0}),It),Dt=(Pt={},u()(Pt,6403,1),u()(Pt,36244,1),u()(Pt,33319,2),u()(Pt,33320,2),u()(Pt,6407,3),u()(Pt,36248,3),u()(Pt,6408,4),u()(Pt,36249,4),u()(Pt,6402,1),u()(Pt,34041,1),u()(Pt,6406,1),u()(Pt,6409,1),u()(Pt,6410,2),Pt),jt=(Rt={},u()(Rt,5126,4),u()(Rt,5125,4),u()(Rt,5124,4),u()(Rt,5123,2),u()(Rt,5122,2),u()(Rt,5131,2),u()(Rt,5120,1),u()(Rt,5121,1),Rt);function Ut(e,t){var n=Nt[t];if(!n)return!1;if(void 0===n.gl1&&void 0===n.gl2)return!0;var r=D(e)&&n.gl2||n.gl1;return"string"==typeof r?e.getExtension(r):r}function Gt(e,t){var n=Nt[t];switch(n&&n.types[0]){case 5126:return e.getExtension("OES_texture_float_linear");case 5131:return e.getExtension("OES_texture_half_float_linear");default:return!0}}function Vt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return zt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ht(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Wt=[9729,9728],Xt=globalThis.WebGLBuffer||function(){},qt=function(e,t){nt()(r,e);var n=Ht(r);function r(e,t){var i;l()(this,r);var a=t.id,o=void 0===a?ft("texture"):a,s=t.handle,u=t.target;return(i=n.call(this,e,{id:o,handle:s})).target=u,i.textureUnit=void 0,i.loaded=!1,i.width=void 0,i.height=void 0,i.depth=void 0,i.format=void 0,i.type=void 0,i.dataFormat=void 0,i.border=void 0,i.textureUnit=void 0,i.mipmaps=void 0,i}return h()(r,[{key:t,get:function(){return"Texture"}},{key:"toString",value:function(){return"Texture(".concat(this.id,",").concat(this.width,"x").concat(this.height,")")}},{key:"initialize",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.data;if(n instanceof Promise)return n.then((function(n){return e.initialize(Object.assign({},t,{pixels:n,data:n}))})),this;var r="undefined"!=typeof HTMLVideoElement&&n instanceof HTMLVideoElement;if(r&&n.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,n.addEventListener("loadeddata",(function(){return e.initialize(t)})),this;var i=t.pixels,a=void 0===i?null:i,o=t.format,s=void 0===o?6408:o,u=t.border,c=void 0===u?0:u,l=t.recreate,f=void 0!==l&&l,h=t.parameters,d=void 0===h?{}:h,v=t.pixelStore,g=void 0===v?{}:v,p=t.textureUnit,m=void 0===p?void 0:p;n||(n=a);var y=t.width,_=t.height,b=t.dataFormat,A=t.type,x=t.compressed,E=void 0!==x&&x,T=t.mipmaps,k=void 0===T||T,w=t.depth,O=void 0===w?0:w,S=this._deduceParameters({format:s,type:A,dataFormat:b,compressed:E,data:n,width:y,height:_});return y=S.width,_=S.height,E=S.compressed,b=S.dataFormat,A=S.type,this.width=y,this.height=_,this.depth=O,this.format=s,this.type=A,this.dataFormat=b,this.border=c,this.textureUnit=m,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),k&&this._isNPOT()&&(B.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),k=!1,this._updateForNPOT(d)),this.mipmaps=k,this.setImageData({data:n,width:y,height:_,depth:O,format:s,type:A,dataFormat:b,border:c,mipmaps:k,parameters:g,compressed:E}),k&&this.generateMipmap(),this.setParameters(d),f&&(this.data=n),r&&(this._video={video:n,parameters:d,lastTime:n.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?n.currentTime:-1}),this}},{key:"update",value:function(){if(this._video){var e=this._video,t=e.video,n=e.parameters;if(e.lastTime===t.currentTime||t.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:t,parameters:n}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=t.currentTime}}},{key:"resize",value:function(e){var t=e.height,n=e.width,r=e.mipmaps,i=void 0!==r&&r;return n!==this.width||t!==this.height?this.initialize({width:n,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,border:this.border,mipmaps:i}):this}},{key:"generateMipmap",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isNPOT()?(B.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Le(this.gl,t,(function(){e.gl.generateMipmap(e.target)})),this.gl.bindTexture(this.target,null),this)}},{key:"setImageData",value:function(e){this._trackDeallocatedMemory("Texture");var t=e.target,n=void 0===t?this.target:t,r=e.pixels,i=void 0===r?null:r,a=e.level,o=void 0===a?0:a,s=e.format,u=void 0===s?this.format:s,c=e.border,l=void 0===c?this.border:c,f=e.offset,h=void 0===f?0:f,d=e.parameters,v=void 0===d?{}:d,g=e.data,p=void 0===g?null:g,m=e.type,y=void 0===m?this.type:m,_=e.width,b=void 0===_?this.width:_,A=e.height,x=void 0===A?this.height:A,E=e.dataFormat,T=void 0===E?this.dataFormat:E,k=e.compressed,w=void 0!==k&&k;p||(p=i);var O=this._deduceParameters({format:u,type:y,dataFormat:T,compressed:w,data:p,width:b,height:x});y=O.type,T=O.dataFormat,w=O.compressed,b=O.width,x=O.height;var S=this.gl;S.bindTexture(this.target,this.handle);var L,I,P=this._getDataType({data:p,compressed:w});p=P.data,L=P.dataType;var R=0;if(Le(this.gl,v,(function(){switch(L){case"null":S.texImage2D(n,o,u,b,x,l,T,y,p);break;case"typed-array":S.texImage2D(n,o,u,b,x,l,T,y,p,h);break;case"buffer":(I=U(S)).bindBuffer(35052,p.handle||p),I.texImage2D(n,o,u,b,x,l,T,y,h),I.bindBuffer(35052,null);break;case"browser-object":D(S)?S.texImage2D(n,o,u,b,x,l,T,y,p):S.texImage2D(n,o,u,T,y,p);break;case"compressed":var e,t=Vt(p.entries());try{for(t.s();!(e=t.n()).done;){var r=ie()(e.value,2),i=r[0],a=r[1];S.compressedTexImage2D(n,i,a.format,a.width,a.height,l,a.data),R+=a.levelSize}}catch(e){t.e(e)}finally{t.f()}break;default:st(!1,"Unknown image data type")}})),"compressed"===L)this._trackAllocatedMemory(R,"Texture");else if(p&&p.byteLength)this._trackAllocatedMemory(p.byteLength,"Texture");else{var F=Dt[this.dataFormat]||4,C=jt[this.type]||1;this._trackAllocatedMemory(this.width*this.height*F*C,"Texture")}return this.loaded=!0,this}},{key:"setSubImageData",value:function(e){var t=this,n=e.target,r=void 0===n?this.target:n,i=e.pixels,a=void 0===i?null:i,o=e.data,s=void 0===o?null:o,u=e.x,c=void 0===u?0:u,l=e.y,f=void 0===l?0:l,h=e.width,d=void 0===h?this.width:h,v=e.height,g=void 0===v?this.height:v,p=e.level,m=void 0===p?0:p,y=e.format,_=void 0===y?this.format:y,b=e.type,A=void 0===b?this.type:b,x=e.dataFormat,E=void 0===x?this.dataFormat:x,T=e.compressed,k=void 0!==T&&T,w=e.offset,O=void 0===w?0:w,S=e.border,L=(void 0===S&&this.border,e.parameters),I=void 0===L?{}:L,P=this._deduceParameters({format:_,type:A,dataFormat:E,compressed:k,data:s,width:d,height:g});if(A=P.type,E=P.dataFormat,k=P.compressed,d=P.width,g=P.height,st(0===this.depth,"texSubImage not supported for 3D textures"),s||(s=a),s&&s.data){var R=s;s=R.data,d=R.shape[0],g=R.shape[1]}s instanceof Mt&&(s=s.handle),this.gl.bindTexture(this.target,this.handle),Le(this.gl,I,(function(){if(k)t.gl.compressedTexSubImage2D(r,m,c,f,d,g,_,s);else if(null===s)t.gl.texSubImage2D(r,m,c,f,d,g,E,A,null);else if(ArrayBuffer.isView(s))t.gl.texSubImage2D(r,m,c,f,d,g,E,A,s,O);else if(s instanceof Xt){var e=U(t.gl);e.bindBuffer(35052,s),e.texSubImage2D(r,m,c,f,d,g,E,A,O),e.bindBuffer(35052,null)}else if(D(t.gl)){U(t.gl).texSubImage2D(r,m,c,f,d,g,E,A,s)}else t.gl.texSubImage2D(r,m,c,f,E,A,s)})),this.gl.bindTexture(this.target,null)}},{key:"copyFramebuffer",value:function(){return B.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}},{key:"getActiveUnit",value:function(){return this.gl.getParameter(34016)-33984}},{key:"bind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit,t=this.gl;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,this.handle),e}},{key:"unbind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit,t=this.gl;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,null),e}},{key:"_getDataType",value:function(e){var t=e.data,n=e.compressed;return void 0!==n&&n?{data:t,dataType:"compressed"}:null===t?{data:t,dataType:"null"}:ArrayBuffer.isView(t)?{data:t,dataType:"typed-array"}:t instanceof Mt?{data:t.handle,dataType:"buffer"}:t instanceof Xt?{data:t,dataType:"buffer"}:{data:t,dataType:"browser-object"}}},{key:"_deduceParameters",value:function(e){var t=e.format,n=e.data,r=e.width,i=e.height,a=e.dataFormat,o=e.type,s=e.compressed,u=Nt[t];a=a||u&&u.dataFormat,o=o||u&&u.types[0],s=s||u&&u.compressed;var c=this._deduceImageSize(n,r,i);return{dataFormat:a,type:o,compressed:s,width:r=c.width,height:i=c.height,format:t,data:n}}},{key:"_deduceImageSize",value:function(e,t,n){var r;return st(r="undefined"!=typeof ImageData&&e instanceof ImageData?{width:e.width,height:e.height}:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?{width:e.naturalWidth,height:e.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?{width:e.width,height:e.height}:"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e?{width:t,height:n}:{width:t>=0?t:1,height:n>=0?n:1},"Could not deduced texture size"),st(void 0===t||r.width===t,"Deduced texture width does not match supplied width"),st(void 0===n||r.height===n,"Deduced texture height does not match supplied height"),r}},{key:"_createHandle",value:function(){return this.gl.createTexture()}},{key:"_deleteHandle",value:function(){this.gl.deleteTexture(this.handle),this._trackDeallocatedMemory("Texture")}},{key:"_getParameter",value:function(e){switch(e){case 4096:return this.width;case 4097:return this.height;default:this.gl.bindTexture(this.target,this.handle);var t=this.gl.getTexParameter(this.target,e);return this.gl.bindTexture(this.target,null),t}}},{key:"_setParameter",value:function(e,t){switch(this.gl.bindTexture(this.target,this.handle),t=this._getNPOTParam(e,t),e){case 33082:case 33083:this.gl.texParameterf(this.handle,e,t);break;case 4096:case 4097:st(!1);break;default:this.gl.texParameteri(this.target,e,t)}return this.gl.bindTexture(this.target,null),this}},{key:"_isNPOT",value:function(){return!D(this.gl)&&(!(!this.width||!this.height)&&(!ht(this.width)||!ht(this.height)))}},{key:"_updateForNPOT",value:function(e){void 0===e[this.gl.TEXTURE_MIN_FILTER]&&(e[this.gl.TEXTURE_MIN_FILTER]=this.gl.LINEAR),void 0===e[this.gl.TEXTURE_WRAP_S]&&(e[this.gl.TEXTURE_WRAP_S]=this.gl.CLAMP_TO_EDGE),void 0===e[this.gl.TEXTURE_WRAP_T]&&(e[this.gl.TEXTURE_WRAP_T]=this.gl.CLAMP_TO_EDGE)}},{key:"_getNPOTParam",value:function(e,t){if(this._isNPOT())switch(e){case 10241:-1===Wt.indexOf(t)&&(t=9729);break;case 10242:case 10243:33071!==t&&(t=33071)}return t}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.format,r=t.linearFiltering,i=!0;return n&&(i=(i=i&&Ut(e,n))&&(!r||Gt(e,n))),i}}]),r}(yt,Symbol.toStringTag),Kt="";function Yt(e,t){return st("string"==typeof e),e=Kt+e,new Promise((function(n,r){try{var i=new Image;i.onload=function(){return n(i)},i.onerror=function(){return r(new Error("Could not load image ".concat(e,".")))},i.crossOrigin=t&&t.crossOrigin||"anonymous",i.src=e}catch(e){r(e)}}))}function Qt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var $t,Zt=function(e,t){nt()(r,e);var n=Qt(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),j(e),(i instanceof Promise||"string"==typeof i)&&(i={data:i}),"string"==typeof i.data&&(i=Object.assign({},i,{data:Yt(i.data)})),(t=n.call(this,e,Object.assign({},i,{target:3553}))).initialize(i),Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"Texture2D"}}],[{key:"isSupported",value:function(e,t){return qt.isSupported(e,t)}}]),r}(qt,Symbol.toStringTag),Jt="EXT_color_buffer_float",en=($t={},u()($t,33189,{bpp:2}),u()($t,33190,{gl2:!0,bpp:3}),u()($t,36012,{gl2:!0,bpp:4}),u()($t,36168,{bpp:1}),u()($t,34041,{bpp:4}),u()($t,35056,{gl2:!0,bpp:4}),u()($t,36013,{gl2:!0,bpp:5}),u()($t,32854,{bpp:2}),u()($t,36194,{bpp:2}),u()($t,32855,{bpp:2}),u()($t,33321,{gl2:!0,bpp:1}),u()($t,33330,{gl2:!0,bpp:1}),u()($t,33329,{gl2:!0,bpp:1}),u()($t,33332,{gl2:!0,bpp:2}),u()($t,33331,{gl2:!0,bpp:2}),u()($t,33334,{gl2:!0,bpp:4}),u()($t,33333,{gl2:!0,bpp:4}),u()($t,33323,{gl2:!0,bpp:2}),u()($t,33336,{gl2:!0,bpp:2}),u()($t,33335,{gl2:!0,bpp:2}),u()($t,33338,{gl2:!0,bpp:4}),u()($t,33337,{gl2:!0,bpp:4}),u()($t,33340,{gl2:!0,bpp:8}),u()($t,33339,{gl2:!0,bpp:8}),u()($t,32849,{gl2:!0,bpp:3}),u()($t,32856,{gl2:!0,bpp:4}),u()($t,32857,{gl2:!0,bpp:4}),u()($t,36220,{gl2:!0,bpp:4}),u()($t,36238,{gl2:!0,bpp:4}),u()($t,36975,{gl2:!0,bpp:4}),u()($t,36214,{gl2:!0,bpp:8}),u()($t,36232,{gl2:!0,bpp:8}),u()($t,36226,{gl2:!0,bpp:16}),u()($t,36208,{gl2:!0,bpp:16}),u()($t,33325,{gl2:Jt,bpp:2}),u()($t,33327,{gl2:Jt,bpp:4}),u()($t,34842,{gl2:Jt,bpp:8}),u()($t,33326,{gl2:Jt,bpp:4}),u()($t,33328,{gl2:Jt,bpp:8}),u()($t,34836,{gl2:Jt,bpp:16}),u()($t,35898,{gl2:Jt,bpp:4}),$t);function tn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}function nn(e,t,n){var r=n[t];if(!r)return!1;var i=D(e)&&r.gl2||r.gl1;return"string"==typeof i?e.getExtension(i):i}var rn=function(e,t){nt()(r,e);var n=tn(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),(t=n.call(this,e,i)).initialize(i),Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"Renderbuffer"}},{key:"initialize",value:function(e){var t=e.format,n=e.width,r=void 0===n?1:n,i=e.height,a=void 0===i?1:i,o=e.samples,s=void 0===o?0:o;return st(t,"Needs format"),this._trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),0!==s&&D(this.gl)?this.gl.renderbufferStorageMultisample(36161,s,t,r,a):this.gl.renderbufferStorage(36161,t,r,a),this.format=t,this.width=r,this.height=a,this.samples=s,this._trackAllocatedMemory(this.width*this.height*(this.samples||1)*en[this.format].bpp),this}},{key:"resize",value:function(e){var t=e.width,n=e.height;return t!==this.width||n!==this.height?this.initialize({width:t,height:n,format:this.format,samples:this.samples}):this}},{key:"_createHandle",value:function(){return this.gl.createRenderbuffer()}},{key:"_deleteHandle",value:function(){this.gl.deleteRenderbuffer(this.handle),this._trackDeallocatedMemory()}},{key:"_bindHandle",value:function(e){this.gl.bindRenderbuffer(36161,e)}},{key:"_syncHandle",value:function(e){this.format=this.getParameter(36164),this.width=this.getParameter(36162),this.height=this.getParameter(36163),this.samples=this.getParameter(36011)}},{key:"_getParameter",value:function(e){return this.gl.bindRenderbuffer(36161,this.handle),this.gl.getRenderbufferParameter(36161,e)}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{format:null},n=t.format;return!n||nn(e,n,en)}},{key:"getSamplesForFormat",value:function(e,t){var n=t.format;return e.getInternalformatParameter(36161,n,32937)}}]),r}(yt,Symbol.toStringTag);function an(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.framebuffer,r=void 0===n?null:n,i=t.color,a=void 0===i?null:i,o=t.depth,s=void 0===o?null:o,u=t.stencil,c=void 0===u?null:u,l={};r&&(l.framebuffer=r);var f=0;a&&(f|=16384,!0!==a&&(l.clearColor=a)),s&&(f|=256,!0!==s&&(l.clearDepth=s)),c&&(f|=1024,!0!==s&&(l.clearStencil=s)),st(0!==f,"clear: bad arguments"),Le(e,l,(function(){e.clear(f)}))}function on(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.framebuffer,r=void 0===n?null:n,i=t.buffer,a=void 0===i?6144:i,o=t.drawBuffer,s=void 0===o?0:o,u=t.value,c=void 0===u?[0,0,0,0]:u;U(e),Le(e,{framebuffer:r},(function(){switch(a){case 6144:switch(c.constructor){case Int32Array:e.clearBufferiv(a,s,c);break;case Uint32Array:e.clearBufferuiv(a,s,c);break;case Float32Array:default:e.clearBufferfv(a,s,c)}break;case 6145:e.clearBufferfv(6145,0,[c]);break;case 6146:e.clearBufferiv(6146,0,[c]);break;case 34041:var t=ie()(c,2),n=t[0],r=t[1];e.clearBufferfi(34041,0,n,r);break;default:st(!1,"clear: bad arguments")}}))}function sn(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return st(!1),0}}var un=n(22),cn=n.n(un),ln=n(14),fn=n.n(ln);function hn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var dn=[34069,34070,34071,34072,34073,34074],vn=function(e,t){nt()(i,e);var n,r=hn(i);function i(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,i),j(e),(t=r.call(this,e,Object.assign({},n,{target:34067}))).initialize(n),Object.seal(Ze()(t)),t}return h()(i,[{key:t,get:function(){return"TextureCube"}},{key:"initialize",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.mipmaps,r=void 0===n||n,i=t.parameters,a=void 0===i?{}:i;return this.opts=t,this.setCubeMapImageData(t).then((function(){e.loaded=!0,r&&e.generateMipmap(t),e.setParameters(a)})),this}},{key:"subImage",value:function(e){var t=e.face,n=e.data,r=e.x,i=void 0===r?0:r,a=e.y,o=void 0===a?0:a,s=e.mipmapLevel,u=void 0===s?0:s;return this._subImage({target:t,data:n,x:i,y:o,mipmapLevel:u})}},{key:"setCubeMapImageData",value:(n=cn()(fn.a.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,h,d,v,g=this;return fn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.width,r=t.height,i=t.pixels,a=t.data,o=t.border,s=void 0===o?0:o,u=t.format,c=void 0===u?6408:u,l=t.type,f=void 0===l?5121:l,h=this.gl,d=i||a,e.next=5,Promise.all(dn.map((function(e){var t=d[e];return Promise.all(Array.isArray(t)?t:[t])})));case 5:v=e.sent,this.bind(),dn.forEach((function(e,t){v[t].length>1&&!1!==g.opts.mipmaps&&B.warn("".concat(g.id," has mipmap and multiple LODs."))(),v[t].forEach((function(t,i){n&&r?h.texImage2D(e,i,c,n,r,s,c,f,t):h.texImage2D(e,i,c,c,f,t)}))})),this.unbind();case 9:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setImageDataForFace",value:function(e){var t=this,n=e.face,r=e.width,i=e.height,a=e.pixels,o=e.data,s=e.border,u=void 0===s?0:s,c=e.format,l=void 0===c?6408:c,f=e.type,h=void 0===f?5121:f,d=this.gl,v=a||o;return this.bind(),v instanceof Promise?v.then((function(r){return t.setImageDataForFace(Object.assign({},e,{face:n,data:r,pixels:r}))})):this.width||this.height?d.texImage2D(n,0,l,r,i,u,l,h,v):d.texImage2D(n,0,l,l,h,v),this}}]),i}(qt,Symbol.toStringTag);function gn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}vn.FACES=dn;var pn=function(e,t){nt()(r,e);var n=gn(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),U(e),i=Object.assign({depth:1},i,{target:32879,unpackFlipY:!1}),(t=n.call(this,e,i)).initialize(i),Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"Texture3D"}},{key:"setImageData",value:function(e){var t=this,n=e.level,r=void 0===n?0:n,i=e.dataFormat,a=void 0===i?6408:i,o=e.width,s=e.height,u=e.depth,c=void 0===u?1:u,l=e.border,f=void 0===l?0:l,h=e.format,d=e.type,v=void 0===d?5121:d,g=e.offset,p=void 0===g?0:g,m=e.data,y=e.parameters,_=void 0===y?{}:y;if(this._trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle),Le(this.gl,_,(function(){ArrayBuffer.isView(m)&&t.gl.texImage3D(t.target,r,a,o,s,c,f,h,v,m),m instanceof Mt&&(t.gl.bindBuffer(35052,m.handle),t.gl.texImage3D(t.target,r,a,o,s,c,f,h,v,p))})),m&&m.byteLength)this._trackAllocatedMemory(m.byteLength,"Texture");else{var b=Dt[this.dataFormat]||4,A=jt[this.type]||1;this._trackAllocatedMemory(this.width*this.height*this.depth*b*A,"Texture")}return this.loaded=!0,this}}],[{key:"isSupported",value:function(e){return D(e)}}]),r}(qt,Symbol.toStringTag);function mn(e,t){st(e instanceof Zt||e instanceof vn||e instanceof pn);var n=e.constructor,r=e.gl,i=e.width,a=e.height,o=e.format,s=e.type,u=e.dataFormat,c=e.border,l=e.mipmaps;return new n(r,Object.assign({width:i,height:a,format:o,type:s,dataFormat:u,border:c,mipmaps:l},t))}function yn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.sourceX,r=void 0===n?0:n,i=t.sourceY,a=void 0===i?0:i,o=t.sourceFormat,s=void 0===o?6408:o,u=t.sourceAttachment,c=void 0===u?36064:u,l=t.target,f=void 0===l?null:l,h=t.sourceWidth,d=t.sourceHeight,v=t.sourceType,g=xn(e),p=g.framebuffer,m=g.deleteFramebuffer;st(p);var y=p.gl,_=p.handle,b=p.attachments;h=h||p.width,d=d||p.height,36064===c&&null===_&&(c=1028),st(b[c]),f=En(f,v=v||b[c].type,s,h,d),v=v||At(f);var A=y.bindFramebuffer(36160,_);return y.readPixels(r,a,h,d,s,v,f),y.bindFramebuffer(36160,A||null),m&&p.delete(),f}function _n(e,t){var n=t.sourceX,r=void 0===n?0:n,i=t.sourceY,a=void 0===i?0:i,o=t.sourceFormat,s=void 0===o?6408:o,u=t.target,c=void 0===u?null:u,l=t.targetByteOffset,f=void 0===l?0:l,h=t.sourceWidth,d=t.sourceHeight,v=t.sourceType,g=xn(e),p=g.framebuffer,m=g.deleteFramebuffer;st(p),h=h||p.width,d=d||p.height;var y=U(p.gl);if(v=v||(c?c.type:5121),!c){var _=sn(s),b=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return st(!1),0}}(v);c=new Mt(y,{byteLength:f+h*d*_*b,accessor:{type:v,size:_}})}return c.bind({target:35051}),Le(y,{framebuffer:p},(function(){y.readPixels(r,a,h,d,s,v,f)})),c.unbind({target:35051}),m&&p.delete(),c}function bn(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.sourceAttachment,r=void 0===n?36064:n,i=t.targetMaxHeight,a=void 0===i?Number.MAX_SAFE_INTEGER:i,o=yn(e,{sourceAttachment:r}),s=e.width,u=e.height;u>a;){var c=Tt({data:o,width:s,height:u});o=c.data,s=c.width,u=c.height}Et({data:o,width:s,height:u});var l=document.createElement("canvas");l.width=s,l.height=u;var f=l.getContext("2d"),h=f.createImageData(s,u);return h.data.set(o),f.putImageData(h,0,0),l.toDataURL()}function An(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.sourceX,i=void 0===r?0:r,a=n.sourceY,o=void 0===a?0:a,s=n.targetMipmaplevel,u=void 0===s?0:s,c=n.targetInternalFormat,l=void 0===c?6408:c,f=n.targetX,h=n.targetY,d=n.targetZ,v=n.width,g=n.height,p=xn(e),m=p.framebuffer,y=p.deleteFramebuffer;st(m);var _=m.gl,b=m.handle,A=void 0!==f||void 0!==h||void 0!==d;f=f||0,h=h||0,d=d||0;var x=_.bindFramebuffer(36160,b);st(t);var E=null;if(t instanceof qt&&(E=t,v=Number.isFinite(v)?v:E.width,g=Number.isFinite(g)?g:E.height,E.bind(0),t=E.target),A)switch(t){case 3553:case 34067:_.copyTexSubImage2D(t,u,f,h,i,o,v,g);break;case 35866:case 32879:var T=U(_);T.copyTexSubImage3D(t,u,f,h,d,i,o,v,g)}else _.copyTexImage2D(t,u,l,i,o,v,g,0);return E&&E.unbind(),_.bindFramebuffer(36160,x||null),y&&m.delete(),E}function xn(e){return e instanceof Rn?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:(t=e,r=t.gl,i=t.width,a=t.height,o=t.id,new Rn(r,Object.assign({},n,{id:"framebuffer-for-".concat(o),width:i,height:a,attachments:u()({},36064,t)}))),deleteFramebuffer:!0};var t,n,r,i,a,o}function En(e,t,n,r,i){return e||new(xt(t=t||5121,{clamped:!1}))(r*i*sn(n))}function Tn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function kn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function wn(e,t){return On(e,t)}function On(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return Sn(e,t)}))}function Sn(e,t){return e.luma=e.luma||{},e.luma.caps=e.luma.caps||{},void 0===e.luma.caps[t]&&(e.luma.caps[t]=function(e,t){var n,r=Mn[t];st(r,t);var i=D(e)&&r[1]||r[0];if("function"==typeof i)n=i(e);else if(Array.isArray(i)){n=!0;var a,o=Tn(i);try{for(o.s();!(a=o.n()).done;){var s=a.value;n=n&&Boolean(e.getExtension(s))}}catch(e){o.e(e)}finally{o.f()}}else"string"==typeof i?n=Boolean(e.getExtension(i)):"boolean"==typeof i?n=i:st(!1);return n}(e,t)),e.luma.caps[t]||B.log(2,"Feature: ".concat(t," not supported"))(),e.luma.caps[t]}function Ln(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return In(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return In(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function In(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Pn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Rn=function(e,t){nt()(r,e);var n=Pn(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),(t=n.call(this,e,i)).width=null,t.height=null,t.attachments={},t.readBuffer=36064,t.drawBuffers=[36064],t.ownResources=[],t.initialize(i),Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"Framebuffer"}},{key:"MAX_COLOR_ATTACHMENTS",get:function(){var e=U(this.gl);return e.getParameter(e.MAX_COLOR_ATTACHMENTS)}},{key:"MAX_DRAW_BUFFERS",get:function(){var e=U(this.gl);return e.getParameter(e.MAX_DRAW_BUFFERS)}},{key:"color",get:function(){return this.attachments[36064]||null}},{key:"texture",get:function(){return this.attachments[36064]||null}},{key:"depth",get:function(){return this.attachments[36096]||this.attachments[33306]||null}},{key:"stencil",get:function(){return this.attachments[36128]||this.attachments[33306]||null}},{key:"initialize",value:function(e){var t=e.width,n=void 0===t?1:t,r=e.height,i=void 0===r?1:r,a=e.attachments,o=void 0===a?null:a,s=e.color,u=void 0===s||s,c=e.depth,l=void 0===c||c,f=e.stencil,h=void 0!==f&&f,d=e.check,v=void 0===d||d,g=e.readBuffer,p=void 0===g?void 0:g,m=e.drawBuffers,y=void 0===m?void 0:m;if(st(n>=0&&i>=0,"Width and height need to be integers"),this.width=n,this.height=i,o)for(var _ in o){var b=o[_];(Array.isArray(b)?b[0]:b).resize({width:n,height:i})}else o=this._createDefaultAttachments(u,l,h,n,i);this.update({clearAttachments:!0,attachments:o,readBuffer:p,drawBuffers:y}),o&&v&&this.checkStatus()}},{key:"delete",value:function(){var e,t=Ln(this.ownResources);try{for(t.s();!(e=t.n()).done;){e.value.delete()}}catch(e){t.e(e)}finally{t.f()}return et()(ot()(r.prototype),"delete",this).call(this),this}},{key:"update",value:function(e){var t=e.attachments,n=void 0===t?{}:t,r=e.readBuffer,i=e.drawBuffers,a=e.clearAttachments,o=void 0!==a&&a,s=e.resizeAttachments,u=void 0===s||s;this.attach(n,{clearAttachments:o,resizeAttachments:u});var c=this.gl,l=c.bindFramebuffer(36160,this.handle);return r&&this._setReadBuffer(r),i&&this._setDrawBuffers(i),c.bindFramebuffer(36160,l||null),this}},{key:"resize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.width,n=e.height;if(null===this.handle)return st(void 0===t&&void 0===n),this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;for(var r in void 0===t&&(t=this.gl.drawingBufferWidth),void 0===n&&(n=this.gl.drawingBufferHeight),t!==this.width&&n!==this.height&&B.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(t,"x").concat(n))(),this.attachments)this.attachments[r].resize({width:t,height:n});return this.width=t,this.height=n,this}},{key:"attach",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.clearAttachments,i=void 0!==r&&r,a=n.resizeAttachments,o=void 0===a||a,s={};i&&Object.keys(this.attachments).forEach((function(e){s[e]=null})),Object.assign(s,e);var u=this.gl.bindFramebuffer(36160,this.handle);for(var c in s){st(void 0!==c,"Misspelled framebuffer binding point?");var l=Number(c),f=s[l],h=f;if(h)if(h instanceof rn)this._attachRenderbuffer({attachment:l,renderbuffer:h});else if(Array.isArray(f)){var d=ie()(f,3),v=d[0],g=d[1],p=void 0===g?0:g,m=d[2],y=void 0===m?0:m;h=v,this._attachTexture({attachment:l,texture:v,layer:p,level:y})}else this._attachTexture({attachment:l,texture:h,layer:0,level:0});else this._unattach(l);o&&h&&h.resize({width:this.width,height:this.height})}this.gl.bindFramebuffer(36160,u||null),Object.assign(this.attachments,e),Object.keys(this.attachments).filter((function(e){return!t.attachments[e]})).forEach((function(e){delete t.attachments[e]}))}},{key:"checkStatus",value:function(){this.gl;var e=this.getStatus();if(36053!==e)throw new Error(function(e){return(Rn.STATUS||{})[e]||"Framebuffer error ".concat(e)}(e));return this}},{key:"getStatus",value:function(){var e=this.gl,t=e.bindFramebuffer(36160,this.handle),n=e.checkFramebufferStatus(36160);return e.bindFramebuffer(36160,t||null),n}},{key:"clear",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.color,r=t.depth,i=t.stencil,a=t.drawBuffers,o=void 0===a?[]:a,s=this.gl.bindFramebuffer(36160,this.handle);return(n||r||i)&&an(this.gl,{color:n,depth:r,stencil:i}),o.forEach((function(t,n){on(e.gl,{drawBuffer:n,value:t})})),this.gl.bindFramebuffer(36160,s||null),this}},{key:"readPixels",value:function(){return B.error("Framebuffer.readPixels() is no logner supported, use readPixelsToArray(framebuffer)")(),null}},{key:"readPixelsToBuffer",value:function(){return B.error("Framebuffer.readPixelsToBuffer()is no logner supported, use readPixelsToBuffer(framebuffer)")(),null}},{key:"copyToDataUrl",value:function(){return B.error("Framebuffer.copyToDataUrl() is no logner supported, use copyToDataUrl(framebuffer)")(),null}},{key:"copyToImage",value:function(){return B.error("Framebuffer.copyToImage() is no logner supported, use copyToImage(framebuffer)")(),null}},{key:"copyToTexture",value:function(){return B.error("Framebuffer.copyToTexture({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}},{key:"blit",value:function(){return B.error("Framebuffer.blit({...}) is no logner supported, use blit(source, target, opts)")(),null}},{key:"invalidate",value:function(e){var t=e.attachments,n=void 0===t?[]:t,r=e.x,i=void 0===r?0:r,a=e.y,o=void 0===a?0:a,s=e.width,u=e.height,c=U(this.gl),l=c.bindFramebuffer(36008,this.handle);return 0===i&&0===o&&void 0===s&&void 0===u?c.invalidateFramebuffer(36008,n):c.invalidateFramebuffer(36008,n,i,o,s,u),c.bindFramebuffer(36008,l),this}},{key:"getAttachmentParameter",value:function(e,t,n){var r=this._getAttachmentParameterFallback(t);return null===r&&(this.gl.bindFramebuffer(36160,this.handle),r=this.gl.getFramebufferAttachmentParameter(36160,e,t),this.gl.bindFramebuffer(36160,null)),n&&r>1e3&&(r=ct(this.gl,r)),r}},{key:"getAttachmentParameters",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36064,n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.constructor.ATTACHMENT_PARAMETERS||[],i={},a=Ln(r);try{for(a.s();!(e=a.n()).done;){var o=e.value,s=n?ct(this.gl,o):o;i[s]=this.getAttachmentParameter(t,o,n)}}catch(e){a.e(e)}finally{a.f()}return i}},{key:"getParameters",value:function(){for(var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=Object.keys(this.attachments),n={},r=0,i=t;r<i.length;r++){var a=i[r],o=Number(a),s=e?ct(this.gl,o):o;n[s]=this.getAttachmentParameters(o,e)}return n}},{key:"show",value:function(){return"undefined"!=typeof window&&window.open(bn(this),"luma-debug-texture"),this}},{key:"log",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e>B.level||"undefined"==typeof window)return this;t=t||"Framebuffer ".concat(this.id);var n=bn(this,{targetMaxHeight:100});return B.image({logLevel:e,message:t,image:n},t)(),this}},{key:"bind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?36160:t;return this.gl.bindFramebuffer(n,this.handle),this}},{key:"unbind",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.target,n=void 0===t?36160:t;return this.gl.bindFramebuffer(n,null),this}},{key:"_createDefaultAttachments",value:function(e,t,n,r,i){var a,o=null;e&&((o=o||{})[36064]=new Zt(this.gl,{id:"".concat(this.id,"-color0"),pixels:null,format:6408,type:5121,width:r,height:i,mipmaps:!1,parameters:(a={},u()(a,10241,9729),u()(a,10240,9729),u()(a,10242,33071),u()(a,10243,33071),a)}),this.ownResources.push(o[36064]));return t&&n?((o=o||{})[33306]=new rn(this.gl,{id:"".concat(this.id,"-depth-stencil"),format:35056,width:r,height:111}),this.ownResources.push(o[33306])):t?((o=o||{})[36096]=new rn(this.gl,{id:"".concat(this.id,"-depth"),format:33189,width:r,height:i}),this.ownResources.push(o[36096])):n&&st(!1),o}},{key:"_unattach",value:function(e){var t=this.attachments[e];t&&(t instanceof rn?this.gl.framebufferRenderbuffer(36160,e,36161,null):this.gl.framebufferTexture2D(36160,e,3553,null,0),delete this.attachments[e])}},{key:"_attachRenderbuffer",value:function(e){var t=e.attachment,n=void 0===t?36064:t,r=e.renderbuffer;this.gl.framebufferRenderbuffer(36160,n,36161,r.handle),this.attachments[n]=r}},{key:"_attachTexture",value:function(e){var t=e.attachment,n=void 0===t?36064:t,r=e.texture,i=e.layer,a=e.level,o=this.gl;switch(o.bindTexture(r.target,r.handle),r.target){case 35866:case 32879:U(o).framebufferTextureLayer(36160,n,r.target,a,i);break;case 34067:var s=function(e){return e<34069?e+34069:e}(i);o.framebufferTexture2D(36160,n,s,r.handle,a);break;case 3553:o.framebufferTexture2D(36160,n,3553,r.handle,a);break;default:st(!1,"Illegal texture type")}o.bindTexture(r.target,null),this.attachments[n]=r}},{key:"_setReadBuffer",value:function(e){var t,n=D(t=this.gl)?t:null;n?n.readBuffer(e):st(36064===e||1029===e,"Multiple render targets not supported"),this.readBuffer=e}},{key:"_setDrawBuffers",value:function(e){var t=this.gl,n=U(t);if(n)n.drawBuffers(e);else{var r=t.getExtension("WEBGL_draw_buffers");r?r.drawBuffersWEBGL(e):st(1===e.length&&(36064===e[0]||1029===e[0]),"Multiple render targets not supported")}this.drawBuffers=e}},{key:"_getAttachmentParameterFallback",value:function(e){var t=function(e){for(var t in e.luma=e.luma||{},e.luma.caps=e.luma.caps||{},Mn)void 0===e.luma.caps[t]&&(e.luma.caps[t]=Sn(e,t));return e.luma.caps}(this.gl);switch(e){case 36052:return t.WEBGL2?null:0;case 33298:case 33299:case 33300:case 33301:case 33302:case 33303:return t.WEBGL2?null:8;case 33297:return t.WEBGL2?null:5125;case 33296:return t.WEBGL2||t.EXT_sRGB?null:9729;default:return null}}},{key:"_createHandle",value:function(){return this.gl.createFramebuffer()}},{key:"_deleteHandle",value:function(){this.gl.deleteFramebuffer(this.handle)}},{key:"_bindHandle",value:function(e){return this.gl.bindFramebuffer(36160,e)}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.colorBufferFloat,r=t.colorBufferHalfFloat,i=!0;return n&&(i=Boolean(e.getExtension("EXT_color_buffer_float")||e.getExtension("WEBGL_color_buffer_float")||e.getExtension("OES_texture_float"))),r&&(i=i&&Boolean(e.getExtension("EXT_color_buffer_float")||e.getExtension("EXT_color_buffer_half_float"))),i}},{key:"getDefaultFramebuffer",value:function(e){return e.luma=e.luma||{},e.luma.defaultFramebuffer=e.luma.defaultFramebuffer||new r(e,{id:"default-framebuffer",handle:null,attachments:{}}),e.luma.defaultFramebuffer}}]),r}(yt,Symbol.toStringTag);var Fn;Rn.ATTACHMENT_PARAMETERS=[36049,36048,33296,33298,33299,33300,33301,33302,33303];var Cn={WEBGL2:"WEBGL2",VERTEX_ARRAY_OBJECT:"VERTEX_ARRAY_OBJECT",TIMER_QUERY:"TIMER_QUERY",INSTANCED_RENDERING:"INSTANCED_RENDERING",MULTIPLE_RENDER_TARGETS:"MULTIPLE_RENDER_TARGETS",ELEMENT_INDEX_UINT32:"ELEMENT_INDEX_UINT32",BLEND_EQUATION_MINMAX:"BLEND_EQUATION_MINMAX",FLOAT_BLEND:"FLOAT_BLEND",COLOR_ENCODING_SRGB:"COLOR_ENCODING_SRGB",TEXTURE_DEPTH:"TEXTURE_DEPTH",TEXTURE_FLOAT:"TEXTURE_FLOAT",TEXTURE_HALF_FLOAT:"TEXTURE_HALF_FLOAT",TEXTURE_FILTER_LINEAR_FLOAT:"TEXTURE_FILTER_LINEAR_FLOAT",TEXTURE_FILTER_LINEAR_HALF_FLOAT:"TEXTURE_FILTER_LINEAR_HALF_FLOAT",TEXTURE_FILTER_ANISOTROPIC:"TEXTURE_FILTER_ANISOTROPIC",COLOR_ATTACHMENT_RGBA32F:"COLOR_ATTACHMENT_RGBA32F",COLOR_ATTACHMENT_FLOAT:"COLOR_ATTACHMENT_FLOAT",COLOR_ATTACHMENT_HALF_FLOAT:"COLOR_ATTACHMENT_HALF_FLOAT",GLSL_FRAG_DATA:"GLSL_FRAG_DATA",GLSL_FRAG_DEPTH:"GLSL_FRAG_DEPTH",GLSL_DERIVATIVES:"GLSL_DERIVATIVES",GLSL_TEXTURE_LOD:"GLSL_TEXTURE_LOD"};var Bn,Mn=(Fn={},u()(Fn,Cn.WEBGL2,[!1,!0]),u()(Fn,Cn.VERTEX_ARRAY_OBJECT,["OES_vertex_array_object",!0]),u()(Fn,Cn.TIMER_QUERY,["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"]),u()(Fn,Cn.INSTANCED_RENDERING,["ANGLE_instanced_arrays",!0]),u()(Fn,Cn.MULTIPLE_RENDER_TARGETS,["WEBGL_draw_buffers",!0]),u()(Fn,Cn.ELEMENT_INDEX_UINT32,["OES_element_index_uint",!0]),u()(Fn,Cn.BLEND_EQUATION_MINMAX,["EXT_blend_minmax",!0]),u()(Fn,Cn.FLOAT_BLEND,["EXT_float_blend"]),u()(Fn,Cn.COLOR_ENCODING_SRGB,["EXT_sRGB",!0]),u()(Fn,Cn.TEXTURE_DEPTH,["WEBGL_depth_texture",!0]),u()(Fn,Cn.TEXTURE_FLOAT,["OES_texture_float",!0]),u()(Fn,Cn.TEXTURE_HALF_FLOAT,["OES_texture_half_float",!0]),u()(Fn,Cn.TEXTURE_FILTER_LINEAR_FLOAT,["OES_texture_float_linear"]),u()(Fn,Cn.TEXTURE_FILTER_LINEAR_HALF_FLOAT,["OES_texture_half_float_linear"]),u()(Fn,Cn.TEXTURE_FILTER_ANISOTROPIC,["EXT_texture_filter_anisotropic"]),u()(Fn,Cn.COLOR_ATTACHMENT_RGBA32F,[function(e){var t=new Zt(e,{format:6408,type:5126,dataFormat:6408}),n=new Rn(e,{id:"test-framebuffer",check:!1,attachments:u()({},36064,t)}),r=n.getStatus();return t.delete(),n.delete(),36053===r},"EXT_color_buffer_float"]),u()(Fn,Cn.COLOR_ATTACHMENT_FLOAT,[!1,"EXT_color_buffer_float"]),u()(Fn,Cn.COLOR_ATTACHMENT_HALF_FLOAT,["EXT_color_buffer_half_float"]),u()(Fn,Cn.GLSL_FRAG_DATA,["WEBGL_draw_buffers",!0]),u()(Fn,Cn.GLSL_FRAG_DEPTH,["EXT_frag_depth",!0]),u()(Fn,Cn.GLSL_DERIVATIVES,["OES_standard_derivatives",!0]),u()(Fn,Cn.GLSL_TEXTURE_LOD,["EXT_shader_texture_lod",!0]),Fn),Nn=(Bn={},u()(Bn,5126,Zn.bind(null,"uniform1fv",zn,1,Jn)),u()(Bn,35664,Zn.bind(null,"uniform2fv",zn,2,Jn)),u()(Bn,35665,Zn.bind(null,"uniform3fv",zn,3,Jn)),u()(Bn,35666,Zn.bind(null,"uniform4fv",zn,4,Jn)),u()(Bn,5124,Zn.bind(null,"uniform1iv",Hn,1,Jn)),u()(Bn,35667,Zn.bind(null,"uniform2iv",Hn,2,Jn)),u()(Bn,35668,Zn.bind(null,"uniform3iv",Hn,3,Jn)),u()(Bn,35669,Zn.bind(null,"uniform4iv",Hn,4,Jn)),u()(Bn,35670,Zn.bind(null,"uniform1iv",Hn,1,Jn)),u()(Bn,35671,Zn.bind(null,"uniform2iv",Hn,2,Jn)),u()(Bn,35672,Zn.bind(null,"uniform3iv",Hn,3,Jn)),u()(Bn,35673,Zn.bind(null,"uniform4iv",Hn,4,Jn)),u()(Bn,35674,Zn.bind(null,"uniformMatrix2fv",zn,4,er)),u()(Bn,35675,Zn.bind(null,"uniformMatrix3fv",zn,9,er)),u()(Bn,35676,Zn.bind(null,"uniformMatrix4fv",zn,16,er)),u()(Bn,35678,$n),u()(Bn,35680,$n),u()(Bn,5125,Zn.bind(null,"uniform1uiv",Wn,1,Jn)),u()(Bn,36294,Zn.bind(null,"uniform2uiv",Wn,2,Jn)),u()(Bn,36295,Zn.bind(null,"uniform3uiv",Wn,3,Jn)),u()(Bn,36296,Zn.bind(null,"uniform4uiv",Wn,4,Jn)),u()(Bn,35685,Zn.bind(null,"uniformMatrix2x3fv",zn,6,er)),u()(Bn,35686,Zn.bind(null,"uniformMatrix2x4fv",zn,8,er)),u()(Bn,35687,Zn.bind(null,"uniformMatrix3x2fv",zn,6,er)),u()(Bn,35688,Zn.bind(null,"uniformMatrix3x4fv",zn,12,er)),u()(Bn,35689,Zn.bind(null,"uniformMatrix4x2fv",zn,8,er)),u()(Bn,35690,Zn.bind(null,"uniformMatrix4x3fv",zn,12,er)),u()(Bn,35678,$n),u()(Bn,35680,$n),u()(Bn,35679,$n),u()(Bn,35682,$n),u()(Bn,36289,$n),u()(Bn,36292,$n),u()(Bn,36293,$n),u()(Bn,36298,$n),u()(Bn,36299,$n),u()(Bn,36300,$n),u()(Bn,36303,$n),u()(Bn,36306,$n),u()(Bn,36307,$n),u()(Bn,36308,$n),u()(Bn,36311,$n),Bn),Dn={},jn={},Un={},Gn=[0];function Vn(e,t,n,r){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Gn[0]=e,e=Gn);var i=e.length;if(i%t&&B.warn("Uniform size should be multiples of ".concat(t),e)(),e instanceof n)return e;var a=r[i];a||(a=new n(i),r[i]=a);for(var o=0;o<i;o++)a[o]=e[o];return a}function zn(e,t){return Vn(e,t,Float32Array,Dn)}function Hn(e,t){return Vn(e,t,Int32Array,jn)}function Wn(e,t){return Vn(e,t,Uint32Array,Un)}function Xn(e,t,n){var r=Nn[n.type];if(!r)throw new Error("Unknown GLSL uniform type ".concat(n.type));return r().bind(null,e,t)}function qn(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(/([^[]*)(\[[0-9]+\])?/);if(!t||t.length<2)throw new Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:t[2]||1,isArray:Boolean(t[2])}}function Kn(e,t,n){for(var r in e){var i=e[r];if((!n||Boolean(n[r]))&&!Yn(i))throw t=t?"".concat(t," "):"",console.error("".concat(t," Bad uniform ").concat(r),i),new Error("".concat(t," Bad uniform ").concat(r))}return!0}function Yn(e){return Array.isArray(e)||ArrayBuffer.isView(e)?function(e){if(0===e.length)return!1;for(var t=Math.min(e.length,16),n=0;n<t;++n)if(!Number.isFinite(e[n]))return!1;return!0}(e):!!isFinite(e)||(!0===e||!1===e||(e instanceof qt||(e instanceof rn||e instanceof Rn&&Boolean(e.texture))))}function Qn(e,t,n){if(Array.isArray(n)||ArrayBuffer.isView(n))if(e[t])for(var r=e[t],i=0,a=n.length;i<a;++i)r[i]=n[i];else e[t]=n.slice();else e[t]=n}function $n(){var e=null;return function(t,n,r){var i=e!==r;return i&&(t.uniform1i(n,r),e=r),i}}function Zn(e,t,n,r){var i=null,a=null;return function(o,s,u){var c=t(u,n),l=c.length,f=!1;if(null===i)i=new Float32Array(l),a=l,f=!0;else{st(a===l,"Uniform length cannot change.");for(var h=0;h<l;++h)if(c[h]!==i[h]){f=!0;break}}return f&&(r(o,e,s,c),i.set(c)),f}}function Jn(e,t,n,r){e[t](n,r)}function er(e,t,n,r){e[t](n,!1,r)}function tr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unnamed",n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/,r=e.match(n);return r?r[1]:t}function nr(e,t,n,r){for(var i=e.split(/\r?\n/),a={},o={},s=r||tr(t)||"(unnamed)",u="".concat(function(e){switch(e){case 35632:return"fragment";case 35633:return"vertex";default:return"unknown type"}}(n)," shader ").concat(s),c=0;c<i.length;c++){var l=i[c];if(!(l.length<=1)){var f=l.split(":"),h=f[0],d=parseInt(f[2],10);if(isNaN(d))throw new Error("GLSL compilation error in ".concat(u,": ").concat(e));"WARNING"!==h?a[d]=l:o[d]=l}}var v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:": ",r=e.split(/\r?\n/),i=String(r.length+t-1).length;return r.map((function(e,r){var a=String(r+t),o=a.length;return ir(a,i-o)+n+e}))}(t);return{shaderName:u,errors:rr(a,v),warnings:rr(o,v)}}function rr(e,t){for(var n="",r=0;r<t.length;r++){var i=t[r];if((e[r+3]||e[r+2]||e[r+1])&&(n+="".concat(i,"\n"),e[r+1])){var a=e[r+1],o=a.split(":",3),s=o[0],u=parseInt(o[1],10)||0,c=a.substring(o.join(":").length+1).trim();n+=ir("^^^ ".concat(s,": ").concat(c,"\n\n"),u)}}return n}function ir(e,t){for(var n="",r=0;r<t;++r)n+=" ";return"".concat(n).concat(e)}function ar(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var or,sr=function(e,t){nt()(r,e);var n=ar(r);function r(e,t){var i;l()(this,r),j(e),st("string"==typeof t.source,"Shader: GLSL source code must be a JavaScript string");var a=tr(t.source,null)||t.id||ft("unnamed ".concat(r.getTypeName(t.shaderType)));return(i=n.call(this,e,{id:a})).shaderType=t.shaderType,i.source=t.source,i.initialize(t),i}return h()(r,[{key:t,get:function(){return"Shader"}},{key:"initialize",value:function(e){var t=e.source,n=tr(t,null);n&&(this.id=ft(n)),this._compile(t)}},{key:"getParameter",value:function(e){return this.gl.getShaderParameter(this.handle,e)}},{key:"toString",value:function(){return"".concat(r.getTypeName(this.shaderType),":").concat(this.id)}},{key:"getName",value:function(){return tr(this.source)||"unnamed-shader"}},{key:"getSource",value:function(){return this.gl.getShaderSource(this.handle)}},{key:"getTranslatedSource",value:function(){var e=this.gl.getExtension("WEBGL_debug_shaders");return e?e.getTranslatedShaderSource(this.handle):"No translated source available. WEBGL_debug_shaders not implemented"}},{key:"_compile",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.source;e.startsWith("#version ")||(e="#version 100\n".concat(e)),this.source=e,this.gl.shaderSource(this.handle,this.source),this.gl.compileShader(this.handle);var t=this.getParameter(35713);if(!t){var n=this.gl.getShaderInfoLog(this.handle),r=nr(n,this.source,this.shaderType,this.id),i=r.shaderName,a=r.errors,o=r.warnings;throw B.error("GLSL compilation errors in ".concat(i,"\n").concat(a))(),B.warn("GLSL compilation warnings in ".concat(i,"\n").concat(o))(),new Error("GLSL compilation errors in ".concat(i))}}},{key:"_deleteHandle",value:function(){this.gl.deleteShader(this.handle)}},{key:"_getOptsFromHandle",value:function(){return{type:this.getParameter(35663),source:this.getSource()}}}],[{key:"getTypeName",value:function(e){switch(e){case 35633:return"vertex-shader";case 35632:return"fragment-shader";default:return st(!1),"unknown"}}}]),r}(yt,Symbol.toStringTag),ur=function(e,t){nt()(r,e);var n=ar(r);function r(e,t){return l()(this,r),"string"==typeof t&&(t={source:t}),n.call(this,e,Object.assign({},t,{shaderType:35633}))}return h()(r,[{key:t,get:function(){return"VertexShader"}},{key:"_createHandle",value:function(){return this.gl.createShader(35633)}}]),r}(sr,Symbol.toStringTag),cr=function(e,t){nt()(r,e);var n=ar(r);function r(e,t){return l()(this,r),"string"==typeof t&&(t={source:t}),n.call(this,e,Object.assign({},t,{shaderType:35632}))}return h()(r,[{key:t,get:function(){return"FragmentShader"}},{key:"_createHandle",value:function(){return this.gl.createShader(35632)}}]),r}(sr,Symbol.toStringTag),lr=(or={},u()(or,5126,[5126,1,"float"]),u()(or,35664,[5126,2,"vec2"]),u()(or,35665,[5126,3,"vec3"]),u()(or,35666,[5126,4,"vec4"]),u()(or,5124,[5124,1,"int"]),u()(or,35667,[5124,2,"ivec2"]),u()(or,35668,[5124,3,"ivec3"]),u()(or,35669,[5124,4,"ivec4"]),u()(or,5125,[5125,1,"uint"]),u()(or,36294,[5125,2,"uvec2"]),u()(or,36295,[5125,3,"uvec3"]),u()(or,36296,[5125,4,"uvec4"]),u()(or,35670,[5126,1,"bool"]),u()(or,35671,[5126,2,"bvec2"]),u()(or,35672,[5126,3,"bvec3"]),u()(or,35673,[5126,4,"bvec4"]),u()(or,35674,[5126,8,"mat2"]),u()(or,35685,[5126,8,"mat2x3"]),u()(or,35686,[5126,8,"mat2x4"]),u()(or,35675,[5126,12,"mat3"]),u()(or,35687,[5126,12,"mat3x2"]),u()(or,35688,[5126,12,"mat3x4"]),u()(or,35676,[5126,16,"mat4"]),u()(or,35689,[5126,16,"mat4x2"]),u()(or,35690,[5126,16,"mat4x3"]),or);function fr(e){switch(e){case 0:return 0;case 1:case 3:case 2:return 1;case 4:case 5:case 6:return 4;default:return st(!1),0}}function hr(e){var t=lr[e];if(!t)return null;var n=ie()(t,2);return{type:n[0],components:n[1]}}function dr(e,t){switch(e){case 5120:case 5121:case 5122:case 5123:e=5126}for(var n in lr){var r=ie()(lr[n],3),i=r[0],a=r[1],o=r[2];if(i===e&&a===t)return{glType:n,name:o}}return null}var vr=function(){function e(t){l()(this,e),this.id=t.id,this.attributeInfos=[],this.attributeInfosByName={},this.attributeInfosByLocation=[],this.varyingInfos=[],this.varyingInfosByName={},Object.seal(this),this._readAttributesFromProgram(t),this._readVaryingsFromProgram(t)}return h()(e,[{key:"getAttributeInfo",value:function(e){var t=Number(e);return Number.isFinite(t)?this.attributeInfosByLocation[t]:this.attributeInfosByName[e]||null}},{key:"getAttributeLocation",value:function(e){var t=this.getAttributeInfo(e);return t?t.location:-1}},{key:"getAttributeAccessor",value:function(e){var t=this.getAttributeInfo(e);return t?t.accessor:null}},{key:"getVaryingInfo",value:function(e){var t=Number(e);return Number.isFinite(t)?this.varyingInfos[t]:this.varyingInfosByName[e]||null}},{key:"getVaryingIndex",value:function(e){var t=this.getVaryingInfo();return t?t.location:-1}},{key:"getVaryingAccessor",value:function(e){var t=this.getVaryingInfo();return t?t.accessor:null}},{key:"_readAttributesFromProgram",value:function(e){for(var t=e.gl,n=t.getProgramParameter(e.handle,35721),r=0;r<n;r++){var i=t.getActiveAttrib(e.handle,r),a=i.name,o=i.type,s=i.size,u=t.getAttribLocation(e.handle,a);u>=0&&this._addAttribute(u,a,o,s)}this.attributeInfos.sort((function(e,t){return e.location-t.location}))}},{key:"_readVaryingsFromProgram",value:function(e){var t=e.gl;if(D(t)){for(var n=t.getProgramParameter(e.handle,35971),r=0;r<n;r++){var i=t.getTransformFeedbackVarying(e.handle,r),a=i.name,o=i.type,s=i.size;this._addVarying(r,a,o,s)}this.varyingInfos.sort((function(e,t){return e.location-t.location}))}}},{key:"_addAttribute",value:function(e,t,n,r){var i=hr(n),a={type:i.type,size:r*i.components};this._inferProperties(e,t,a);var o={location:e,name:t,accessor:new St(a)};this.attributeInfos.push(o),this.attributeInfosByLocation[e]=o,this.attributeInfosByName[o.name]=o}},{key:"_inferProperties",value:function(e,t,n){/instance/i.test(t)&&(n.divisor=1)}},{key:"_addVarying",value:function(e,t,n,r){var i=hr(n),a=i.type,o=i.components,s={location:e,name:t,accessor:new St({type:a,size:r*o})};this.varyingInfos.push(s),this.varyingInfosByName[s.name]=s}}]),e}();function gr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return pr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function pr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function mr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var yr=["setVertexArray","setAttributes","setBuffers","unsetBuffers","use","getUniformCount","getUniformInfo","getUniformLocation","getUniformValue","getVarying","getFragDataLocation","getAttachedShaders","getAttributeCount","getAttributeLocation","getAttributeInfo"],_r=function(e,t){nt()(r,e);var n=mr(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),(t=n.call(this,e,i)).stubRemovedMethods("Program","v6.0",yr),t._isCached=!1,t.initialize(i),Object.seal(Ze()(t)),t._setId(i.id),t}return h()(r,[{key:t,get:function(){return"Program"}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.hash,n=e.vs,r=e.fs,i=e.varyings,a=e.bufferMode,o=void 0===a?35981:a;return this.hash=t||"",this.vs="string"==typeof n?new ur(this.gl,{id:"".concat(e.id,"-vs"),source:n}):n,this.fs="string"==typeof r?new cr(this.gl,{id:"".concat(e.id,"-fs"),source:r}):r,st(this.vs instanceof ur),st(this.fs instanceof cr),this.uniforms={},this._textureUniforms={},i&&i.length>0&&(U(this.gl),this.varyings=i,this.gl2.transformFeedbackVaryings(this.handle,i,o)),this._compileAndLink(),this._readUniformLocationsFromLinkedProgram(),this.configuration=new vr(this),this.setProps(e)}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isCached?this:et()(ot()(r.prototype),"delete",this).call(this,e)}},{key:"setProps",value:function(e){return"uniforms"in e&&this.setUniforms(e.uniforms),this}},{key:"draw",value:function(e){var t=this,n=e.logPriority,r=e.drawMode,i=void 0===r?4:r,a=e.vertexCount,o=e.offset,s=void 0===o?0:o,u=e.start,c=e.end,l=e.isIndexed,f=void 0!==l&&l,h=e.indexType,d=void 0===h?5123:h,v=e.instanceCount,g=void 0===v?0:v,p=e.isInstanced,m=void 0===p?g>0:p,y=e.vertexArray,_=void 0===y?null:y,b=e.transformFeedback,A=e.framebuffer,x=e.parameters,E=void 0===x?{}:x,T=e.uniforms,k=e.samplers;if((T||k)&&(B.deprecated("Program.draw({uniforms})","Program.setUniforms(uniforms)")(),this.setUniforms(T||{})),B.priority>=n){var w=A?A.id:"default",O="mode=".concat(ct(this.gl,i)," verts=").concat(a," ")+"instances=".concat(g," indexType=").concat(ct(this.gl,d)," ")+"isInstanced=".concat(m," isIndexed=").concat(f," ")+"Framebuffer=".concat(w);B.log(n,O)()}return st(_),this.gl.useProgram(this.handle),!(!this._areTexturesRenderable()||0===a||m&&0===g)&&(_.bindForDraw(a,g,(function(){if(void 0!==A&&(E=Object.assign({},E,{framebuffer:A})),b){var e=fr(i);b.begin(e)}t._bindTextures(),Le(t.gl,E,(function(){f&&m?t.gl2.drawElementsInstanced(i,a,d,s,g):f&&D(t.gl)&&!isNaN(u)&&!isNaN(c)?t.gl2.drawRangeElements(i,u,c,a,d,s):f?t.gl.drawElements(i,a,d,s):m?t.gl2.drawArraysInstanced(i,s,a,g):t.gl.drawArrays(i,s,a)})),b&&b.end()})),!0)}},{key:"setUniforms",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in B.priority>=2&&Kn(e,this.id,this._uniformSetters),this.gl.useProgram(this.handle),e){var n=e[t],r=this._uniformSetters[t];if(r){var i=n,a=!1;if(i instanceof Rn&&(i=i.texture),i instanceof qt)if(a=this.uniforms[t]!==n){void 0===r.textureIndex&&(r.textureIndex=this._textureIndexCounter++);var o=i,s=r.textureIndex;o.bind(s),i=s,this._textureUniforms[t]=o}else i=r.textureIndex;else this._textureUniforms[t]&&delete this._textureUniforms[t];(r(i)||a)&&Qn(this.uniforms,t,n)}}return this}},{key:"_areTexturesRenderable",value:function(){var e=!0;for(var t in this._textureUniforms){var n=this._textureUniforms[t];n.update(),e=e&&n.loaded}return e}},{key:"_bindTextures",value:function(){for(var e in this._textureUniforms){var t=this._uniformSetters[e].textureIndex;this._textureUniforms[e].bind(t)}}},{key:"_createHandle",value:function(){return this.gl.createProgram()}},{key:"_deleteHandle",value:function(){this.gl.deleteProgram(this.handle)}},{key:"_getOptionsFromHandle",value:function(e){var t,n={},r=gr(this.gl.getAttachedShaders(e));try{for(r.s();!(t=r.n()).done;){var i=t.value;switch(this.gl.getShaderParameter(this.handle,35663)){case 35633:n.vs=new ur({handle:i});break;case 35632:n.fs=new cr({handle:i})}}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"_getParameter",value:function(e){return this.gl.getProgramParameter(this.handle,e)}},{key:"_setId",value:function(e){if(!e){var t=this._getName();this.id=ft(t)}}},{key:"_getName",value:function(){var e=this.vs.getName()||this.fs.getName();return e=(e=e.replace(/shader/i,""))?"".concat(e,"-program"):"program"}},{key:"_compileAndLink",value:function(){var e=this.gl;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),B.time(4,"linkProgram for ".concat(this._getName()))(),e.linkProgram(this.handle),B.timeEnd(4,"linkProgram for ".concat(this._getName()))(),e.debug||B.level>0){if(!e.getProgramParameter(this.handle,35714))throw new Error("Error linking: ".concat(e.getProgramInfoLog(this.handle)));if(e.validateProgram(this.handle),!e.getProgramParameter(this.handle,35715))throw new Error("Error validating: ".concat(e.getProgramInfoLog(this.handle)))}}},{key:"_readUniformLocationsFromLinkedProgram",value:function(){var e=this.gl;this._uniformSetters={},this._uniformCount=this._getParameter(35718);for(var t=0;t<this._uniformCount;t++){var n=this.gl.getActiveUniform(this.handle,t),r=qn(n.name).name,i=e.getUniformLocation(this.handle,r);if(this._uniformSetters[r]=Xn(e,i,n),n.size>1)for(var a=0;a<n.size;a++)i=e.getUniformLocation(this.handle,"".concat(r,"[").concat(a,"]")),this._uniformSetters["".concat(r,"[").concat(a,"]")]=Xn(e,i,n)}this._textureIndexCounter=0}},{key:"getActiveUniforms",value:function(e,t){return this.gl2.getActiveUniforms(this.handle,e,t)}},{key:"getUniformBlockIndex",value:function(e){return this.gl2.getUniformBlockIndex(this.handle,e)}},{key:"getActiveUniformBlockParameter",value:function(e,t){return this.gl2.getActiveUniformBlockParameter(this.handle,e,t)}},{key:"uniformBlockBinding",value:function(e,t){this.gl2.uniformBlockBinding(this.handle,e,t)}}]),r}(yt,Symbol.toStringTag);function br(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Ar=function(e,t){nt()(r,e);var n=br(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),U(e),(t=n.call(this,e,i)).initialize(i),t.stubRemovedMethods("TransformFeedback","v6.0",["pause","resume"]),Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"TransformFeedback"}},{key:"initialize",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.buffers={},this.unused={},this.configuration=null,this.bindOnUse=!0,dt(this.buffers)||this.bind((function(){return e._unbindBuffers()})),this.setProps(t),this}},{key:"setProps",value:function(e){"program"in e&&(this.configuration=e.program&&e.program.configuration),"configuration"in e&&(this.configuration=e.configuration),"bindOnUse"in e&&(e=e.bindOnUse),"buffers"in e&&this.setBuffers(e.buffers)}},{key:"setBuffers",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.bind((function(){for(var n in t)e.setBuffer(n,t[n])})),this}},{key:"setBuffer",value:function(e,t){var n=this._getVaryingIndex(e),r=this._getBufferParams(t),i=r.buffer,a=r.byteSize,o=r.byteOffset;return n<0?(this.unused[e]=i,B.warn("".concat(this.id," unused varying buffer ").concat(e))(),this):(this.buffers[n]=t,this.bindOnUse||this._bindBuffer(n,i,o,a),this)}},{key:"begin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.gl.bindTransformFeedback(36386,this.handle),this._bindBuffers(),this.gl.beginTransformFeedback(e),this}},{key:"end",value:function(){return this.gl.endTransformFeedback(),this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null),this}},{key:"_getBufferParams",value:function(e){var t,n,r;return e instanceof Mt==!1?(r=e.buffer,n=e.byteSize,t=e.byteOffset):r=e,void 0===t&&void 0===n||(t=t||0,n=n||r.byteLength-t),{buffer:r,byteOffset:t,byteSize:n}}},{key:"_getVaryingInfo",value:function(e){return this.configuration&&this.configuration.getVaryingInfo(e)}},{key:"_getVaryingIndex",value:function(e){if(this.configuration)return this.configuration.getVaryingInfo(e).location;var t=Number(e);return Number.isFinite(t)?t:-1}},{key:"_bindBuffers",value:function(){if(this.bindOnUse)for(var e in this.buffers){var t=this._getBufferParams(this.buffers[e]),n=t.buffer,r=t.byteSize,i=t.byteOffset;this._bindBuffer(e,n,i,r)}}},{key:"_unbindBuffers",value:function(){if(this.bindOnUse)for(var e in this.buffers)this._bindBuffer(e,null)}},{key:"_bindBuffer",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t&&t.handle;return i&&void 0!==r?this.gl.bindBufferRange(35982,e,i,n,r):this.gl.bindBufferBase(35982,e,i),this}},{key:"_createHandle",value:function(){return this.gl.createTransformFeedback()}},{key:"_deleteHandle",value:function(){this.gl.deleteTransformFeedback(this.handle)}},{key:"_bindHandle",value:function(e){this.gl.bindTransformFeedback(36386,this.handle)}}],[{key:"isSupported",value:function(e){return D(e)}}]),r}(yt,Symbol.toStringTag);function xr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Er(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Tr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var kr=function(e,t){nt()(r,e);var n=Tr(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l()(this,r),(t=n.call(this,e,i)).target=null,t._queryPending=!1,t._pollingPromise=null,Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"Query"}},{key:"beginTimeElapsedQuery",value:function(){return this.begin(35007)}},{key:"beginOcclusionQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.conservative,n=void 0!==t&&t;return this.begin(n?36202:35887)}},{key:"beginTransformFeedbackQuery",value:function(){return this.begin(35976)}},{key:"begin",value:function(e){return this._queryPending||(this.target=e,this.gl2.beginQuery(this.target,this.handle)),this}},{key:"end",value:function(){return this._queryPending||this.target&&(this.gl2.endQuery(this.target),this.target=null,this._queryPending=!0),this}},{key:"isResultAvailable",value:function(){if(!this._queryPending)return!1;var e=this.gl2.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}},{key:"isTimerDisjoint",value:function(){return this.gl2.getParameter(36795)}},{key:"getResult",value:function(){return this.gl2.getQueryParameter(this.handle,34918)}},{key:"getTimerMilliseconds",value:function(){return this.getResult()/1e6}},{key:"createPoll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.POSITIVE_INFINITY;if(this._pollingPromise)return this._pollingPromise;var n=0;return this._pollingPromise=new Promise((function(r,i){requestAnimationFrame((function a(){e.isResultAvailable()?(r(e.getResult()),e._pollingPromise=null):n++>t?(i("Timed out"),e._pollingPromise=null):requestAnimationFrame(a)}))})),this._pollingPromise}},{key:"_createHandle",value:function(){return r.isSupported(this.gl)?this.gl2.createQuery():null}},{key:"_deleteHandle",value:function(){this.gl2.deleteQuery(this.handle)}}],[{key:"isSupported",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=D(e),i=On(e,Cn.TIMER_QUERY),a=r||i,o=xr(n);try{for(o.s();!(t=o.n()).done;){var s=t.value;switch(s){case"queries":a=a&&r;break;case"timers":a=a&&i;break;default:st(!1)}}}catch(e){o.e(e)}finally{o.f()}return a}}]),r}(yt,Symbol.toStringTag);var wr=Object(v.a)()&&"undefined"!=typeof document,Or=0,Sr=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,e);var n=t.onCreateContext,r=void 0===n?function(e){return je(e)}:n,i=t.onAddHTML,a=void 0===i?null:i,o=t.onInitialize,s=void 0===o?function(){}:o,u=t.onRender,c=void 0===u?function(){}:u,f=t.onFinalize,h=void 0===f?function(){}:f,d=t.onError,v=t.gl,g=void 0===v?null:v,p=t.glOptions,m=void 0===p?{}:p,y=t.debug,_=void 0!==y&&y,b=t.createFramebuffer,A=void 0!==b&&b,x=t.autoResizeViewport,E=void 0===x||x,T=t.autoResizeDrawingBuffer,k=void 0===T||T,w=t.stats,O=void 0===w?Qe.get("animation-loop-".concat(Or++)):w,S=t.useDevicePixels,L=void 0===S||S;"useDevicePixelRatio"in t&&(B.deprecated("useDevicePixelRatio","useDevicePixels")(),L=t.useDevicePixelRatio),this.props={onCreateContext:r,onAddHTML:a,onInitialize:s,onRender:c,onFinalize:h,onError:d,gl:g,glOptions:m,debug:_,createFramebuffer:A},this.gl=g,this.needsRedraw=null,this.timeline=null,this.stats=O,this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this._initialized=!1,this._running=!1,this._animationFrameId=null,this._nextFramePromise=null,this._resolveNextFrame=null,this._cpuStartTime=0,this.setProps({autoResizeViewport:E,autoResizeDrawingBuffer:k,useDevicePixels:L}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._pageLoadPromise=null,this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}var t;return h()(e,[{key:"delete",value:function(){this.stop(),this._setDisplay(null)}},{key:"setNeedsRedraw",value:function(e){return st("string"==typeof e),this.needsRedraw=this.needsRedraw||e,this}},{key:"setProps",value:function(e){return"autoResizeViewport"in e&&(this.autoResizeViewport=e.autoResizeViewport),"autoResizeDrawingBuffer"in e&&(this.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer),"useDevicePixels"in e&&(this.useDevicePixels=e.useDevicePixels),this}},{key:"start",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._running)return this;this._running=!0;var n=this._getPageLoadPromise().then((function(){return!e._running||e._initialized?null:(e._createWebGLContext(t),e._createFramebuffer(),e._startEventHandling(),e._initializeCallbackData(),e._updateCallbackData(),e._resizeCanvasDrawingBuffer(),e._resizeViewport(),e._gpuTimeQuery=kr.isSupported(e.gl,["timers"])?new kr(e.gl):null,e._initialized=!0,e.onInitialize(e.animationProps))})).then((function(t){e._running&&(e._addCallbackData(t||{}),!1!==t&&e._startLoop())}));return this.props.onError&&n.catch(this.props.onError),this}},{key:"redraw",value:function(){return this.isContextLost()||(this._beginTimers(),this._setupFrame(),this._updateCallbackData(),this._renderFrame(this.animationProps),this._clearNeedsRedraw(),this.offScreen&&this.gl.commit&&this.gl.commit(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endTimers()),this}},{key:"stop",value:function(){return this._running&&(this._finalizeCallbackData(),this._cancelAnimationFrame(this._animationFrameId),this._nextFramePromise=null,this._resolveNextFrame=null,this._animationFrameId=null,this._running=!1),this}},{key:"attachTimeline",value:function(e){return this.timeline=e,this.timeline}},{key:"detachTimeline",value:function(){this.timeline=null}},{key:"waitForRender",value:function(){var e=this;return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise((function(t){e._resolveNextFrame=t}))),this._nextFramePromise}},{key:"toDataURL",value:(t=cn()(fn.a.mark((function e(){return fn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setNeedsRedraw("toDataURL"),e.next=3,this.waitForRender();case 3:return e.abrupt("return",this.gl.canvas.toDataURL());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"isContextLost",value:function(){return this.gl.isContextLost()}},{key:"onCreateContext",value:function(){var e;return(e=this.props).onCreateContext.apply(e,arguments)}},{key:"onInitialize",value:function(){var e;return(e=this.props).onInitialize.apply(e,arguments)}},{key:"onRender",value:function(){var e;return(e=this.props).onRender.apply(e,arguments)}},{key:"onFinalize",value:function(){var e;return(e=this.props).onFinalize.apply(e,arguments)}},{key:"getHTMLControlValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=document.getElementById(e);return n?Number(n.value):t}},{key:"setViewParameters",value:function(){return B.removed("AnimationLoop.setViewParameters","AnimationLoop.setProps")(),this}},{key:"_startLoop",value:function(){var e=this;this._cancelAnimationFrame(this._animationFrameId),this._animationFrameId=this._requestAnimationFrame((function t(){e._running&&(e.redraw(),e._animationFrameId=e._requestAnimationFrame(t))}))}},{key:"_getPageLoadPromise",value:function(){return this._pageLoadPromise||(this._pageLoadPromise=wr?new Promise((function(e,t){wr&&"complete"===document.readyState?e(document):window.addEventListener("load",(function(){e(document)}))})):Promise.resolve({})),this._pageLoadPromise}},{key:"_setDisplay",value:function(e){this.display&&(this.display.delete(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}},{key:"_cancelAnimationFrame",value:function(e){return this.display&&this.display.cancelAnimationFrame?this.display.cancelAnimationFrame(e):(t=e,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(t):clearTimeout(t));var t}},{key:"_requestAnimationFrame",value:function(e){if(this._running)return this.display&&this.display.requestAnimationFrame?this.display.requestAnimationFrame(e):(t=e,"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,1e3/60));var t}},{key:"_renderFrame",value:function(){var e;this.display?(e=this.display)._renderFrame.apply(e,arguments):this.onRender.apply(this,arguments)}},{key:"_clearNeedsRedraw",value:function(){this.needsRedraw=null}},{key:"_setupFrame",value:function(){this._resizeCanvasDrawingBuffer(),this._resizeViewport(),this._resizeFramebuffer()}},{key:"_initializeCallbackData",value:function(){this.animationProps={gl:this.gl,stop:this.stop,canvas:this.gl.canvas,framebuffer:this.framebuffer,useDevicePixels:this.useDevicePixels,needsRedraw:null,startTime:Date.now(),engineTime:0,tick:0,tock:0,time:0,_timeline:this.timeline,_loop:this,_animationLoop:this,_mousePosition:null}}},{key:"_updateCallbackData",value:function(){var e=this._getSizeAndAspect(),t=e.width,n=e.height,r=e.aspect;t===this.animationProps.width&&n===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),r!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=n,this.animationProps.aspect=r,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime,this.animationProps._offScreen=this.offScreen}},{key:"_finalizeCallbackData",value:function(){this.onFinalize(this.animationProps)}},{key:"_addCallbackData",value:function(e){"object"===i()(e)&&null!==e&&(this.animationProps=Object.assign({},this.animationProps,e))}},{key:"_createWebGLContext",value:function(e){if(this.offScreen=e.canvas&&"undefined"!=typeof OffscreenCanvas&&e.canvas instanceof OffscreenCanvas,e=Object.assign({},e,this.props.glOptions),this.gl=this.props.gl?Ue(this.props.gl,e):this.onCreateContext(e),!N(this.gl))throw new Error("AnimationLoop.onCreateContext - illegal context returned");Se(this.gl),this._createInfoDiv()}},{key:"_createInfoDiv",value:function(){if(this.gl.canvas&&this.props.onAddHTML){var e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";var t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",e.appendChild(this.gl.canvas),e.appendChild(t);var n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}},{key:"_getSizeAndAspect",value:function(){var e=this.gl.drawingBufferWidth,t=this.gl.drawingBufferHeight,n=1,r=this.gl.canvas;return r&&r.clientHeight?n=r.clientWidth/r.clientHeight:e>0&&t>0&&(n=e/t),{width:e,height:t,aspect:n}}},{key:"_resizeViewport",value:function(){this.autoResizeViewport&&this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}},{key:"_resizeCanvasDrawingBuffer",value:function(){this.autoResizeDrawingBuffer&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.canvas){var n=Re(t.useDevicePixels);We(e,n,t)}else{var r=e.getExtension("STACKGL_resize_drawingbuffer");r&&"width"in t&&"height"in t&&r.resize(t.width,t.height)}}(this.gl,{useDevicePixels:this.useDevicePixels})}},{key:"_createFramebuffer",value:function(){this.props.createFramebuffer&&(this.framebuffer=new Rn(this.gl))}},{key:"_resizeFramebuffer",value:function(){this.framebuffer&&this.framebuffer.resize({width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight})}},{key:"_beginTimers",value:function(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this._gpuTimeQuery&&this._gpuTimeQuery.isResultAvailable()&&!this._gpuTimeQuery.isTimerDisjoint()&&this.stats.get("GPU Time").addTime(this._gpuTimeQuery.getTimerMilliseconds()),this._gpuTimeQuery&&this._gpuTimeQuery.beginTimeElapsedQuery(),this.cpuTime.timeStart()}},{key:"_endTimers",value:function(){this.cpuTime.timeEnd(),this._gpuTimeQuery&&this._gpuTimeQuery.end()}},{key:"_startEventHandling",value:function(){var e=this.gl.canvas;e&&(e.addEventListener("mousemove",this._onMousemove),e.addEventListener("mouseleave",this._onMouseleave))}},{key:"_onMousemove",value:function(e){this.animationProps._mousePosition=[e.offsetX,e.offsetY]}},{key:"_onMouseleave",value:function(e){this.animationProps._mousePosition=null}}]),e}();function Lr(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var Ir={number:{validate:function(e,t){return Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)}},array:{validate:function(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function Pr(e){var t=Rr(e);return"object"===t?e?"type"in e?Object.assign({},e,Ir[e.type]):"value"in e?(t=Rr(e.value),Object.assign({type:t},e,Ir[t])):{type:"object",value:e}:{type:"object",value:null}:Object.assign({type:t,value:e},Ir[t])}function Rr(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":i()(e)}var Fr=function(){function e(t){var n=t.name,r=t.vs,i=t.fs,a=t.dependencies,o=void 0===a?[]:a,s=t.uniforms,u=t.getUniforms,c=t.deprecations,f=void 0===c?[]:c,h=t.defines,d=void 0===h?{}:h,v=t.inject,g=void 0===v?{}:v,p=t.vertexShader,m=t.fragmentShader;l()(this,e),Lr("string"==typeof n),this.name=n,this.vs=r||p,this.fs=i||m,this.getModuleUniforms=u,this.dependencies=o,this.deprecations=this._parseDeprecationDefinitions(f),this.defines=d,this.injections=function(e){var t={vs:{},fs:{}};for(var n in e){var r=e[n],i=n.slice(0,2);"string"==typeof r&&(r={order:0,injection:r}),t[i][n]=r}return t}(g),s&&(this.uniforms=function(e){var t={};for(var n in e){var r=Pr(e[n]);t[n]=r}return t}(s))}return h()(e,[{key:"getModuleSource",value:function(e){var t;switch(e){case"vs":t=this.vs||"";break;case"fs":t=this.fs||"";break;default:Lr(!1)}return"#define MODULE_".concat(this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),"\n").concat(t,"// END MODULE_").concat(this.name,"\n\n")}},{key:"getUniforms",value:function(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):this.uniforms?this._defaultGetUniforms(e):{}}},{key:"getDefines",value:function(){return this.defines}},{key:"checkDeprecations",value:function(e,t){this.deprecations.forEach((function(n){n.regex.test(e)&&(n.deprecated?t.deprecated(n.old,n.new)():t.removed(n.old,n.new)())}))}},{key:"_parseDeprecationDefinitions",value:function(e){return e.forEach((function(e){switch(e.type){case"function":e.regex=new RegExp("\\b".concat(e.old,"\\("));break;default:e.regex=new RegExp("".concat(e.type," ").concat(e.old,";"))}})),e}},{key:"_defaultGetUniforms",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={},n=this.uniforms;for(var r in n){var i=n[r];r in e&&!i.private?(i.validate&&Lr(i.validate(e[r],i),"".concat(this.name,": invalid ").concat(r)),t[r]=e[r]):t[r]=i.value}return t}}]),e}();function Cr(e){if(!e.normalized&&(e.normalized=!0,e.uniforms&&!e.getUniforms)){var t=new Fr(e);e.getUniforms=t.getUniforms.bind(t)}return e}function Br(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Mr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Mr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Mr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Nr(e){return Dr(function e(t,n){return t.map((function(t){return t instanceof Fr||(Lr("string"!=typeof t,"Shader module use by name is deprecated. Import shader module '".concat(t,"' and use it directly.")),Lr(t.name,"shader module has no name"),(t=new Fr(t)).dependencies=e(t.dependencies)),t}))}(e))}function Dr(e){var t={},n={};return jr({modules:e,level:0,moduleMap:t,moduleDepth:n}),Object.keys(n).sort((function(e,t){return n[t]-n[e]})).map((function(e){return t[e]}))}function jr(e){var t=e.modules,n=e.level,r=e.moduleMap,i=e.moduleDepth;if(n>=5)throw new Error("Possible loop in shader dependency graph");var a,o=Br(t);try{for(o.s();!(a=o.n()).done;){var s=a.value;r[s.name]=s,(void 0===i[s.name]||i[s.name]<n)&&(i[s.name]=n)}}catch(e){o.e(e)}finally{o.f()}var u,c=Br(t);try{for(c.s();!(u=c.n()).done;){var l=u.value;l.dependencies&&jr({modules:l.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}}catch(e){c.e(e)}finally{c.f()}}function Ur(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="undefined"!=typeof window&&window.navigator||{},n=e.userAgent||t.userAgent||"",r=-1!==n.indexOf("MSIE "),i=-1!==n.indexOf("Trident/");return r||i}var Gr={GLSL_FRAG_DATA:["WEBGL_draw_buffers",!0],GLSL_FRAG_DEPTH:["EXT_frag_depth",!0],GLSL_DERIVATIVES:["OES_standard_derivatives",!0],GLSL_TEXTURE_LOD:["EXT_shader_texture_lod",!0]},Vr={};Object.keys(Gr).forEach((function(e){Vr[e]=e}));var zr={};function Hr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Gr[t];if(Lr(r,t),!Ur(n))return!0;if(t in zr)return zr[t];var i=r[0],a=n.behavior||"enable",o="#extension GL_".concat(i," : ").concat(a,"\nvoid main(void) {}"),s=e.createShader(35633);e.shaderSource(s,o),e.compileShader(s);var u=e.getShaderParameter(s,35713);return e.deleteShader(s),zr[t]=u,u}function Wr(e,t){var n=Gr[t];Lr(n,t);var r=function(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&2===e._version)}(e)&&n[1]||n[0],i="string"==typeof r?Boolean(e.getExtension(r)):r;return Lr(!1===i||!0===i),i}function Xr(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return Wr(e,t)}))}var qr,Kr=(qr={},u()(qr,"vs","#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n"),u()(qr,"fs","#ifdef MODULE_MATERIAL\n gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n"),qr),Yr=/void\s+main\s*\([^)]*\)\s*\{\n?/,Qr=/}\n?[^{}]*$/,$r=[];function Zr(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i="vs"===t,a=function(t){var r=n[t];r.sort((function(e,t){return e.order-t.order})),$r.length=r.length;for(var a=0,o=r.length;a<o;++a)$r[a]=r[a].injection;var s="".concat($r.join("\n"),"\n");switch(t){case"vs:#decl":i&&(e=e.replace("__LUMA_INJECT_DECLARATIONS__",s));break;case"vs:#main-start":i&&(e=e.replace(Yr,(function(e){return e+s})));break;case"vs:#main-end":i&&(e=e.replace(Qr,(function(e){return s+e})));break;case"fs:#decl":i||(e=e.replace("__LUMA_INJECT_DECLARATIONS__",s));break;case"fs:#main-start":i||(e=e.replace(Yr,(function(e){return e+s})));break;case"fs:#main-end":i||(e=e.replace(Qr,(function(e){return s+e})));break;default:e=e.replace(t,(function(e){return e+s}))}};for(var o in n)a(o);return e=e.replace("__LUMA_INJECT_DECLARATIONS__",""),r&&(e=e.replace(/\}\s*$/,(function(e){return e+Kr[t]}))),e}function Jr(e){var t={};return Lr(Array.isArray(e)&&e.length>1),e.forEach((function(e){for(var n in e)t[n]=t[n]?"".concat(t[n],"\n").concat(e[n]):e[n]})),t}function ei(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ti(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ti(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ti(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ni(e){return new RegExp("\\b".concat(e,"[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)"),"g")}var ri,ii=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],ai=[].concat(ii,[[ni("attribute"),"in $1"],[ni("varying"),"out $1"]]),oi=[].concat(ii,[[ni("varying"),"in $1"]]),si=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],ui=[].concat(si,[[ni("in"),"attribute $1"],[ni("out"),"varying $1"]]),ci=[].concat(si,[[ni("in"),"varying $1"]]),li=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,fi=/void\s+main\s*\([^)]*\)\s*\{\n?/;function hi(e,t,n){switch(t){case 300:return n?di(e,ai):function(e){var t=(e=di(e,oi)).match(li);if(t){var n=t[1];e=e.replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),n)}else{e=e.replace(fi,(function(e){return"out vec4 ".concat("fragmentColor",";\n").concat(e)})).replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),"fragmentColor")}return e}(e);case 100:return n?di(e,ui):function(e){var t=(e=di(e,ci)).match(li);if(t){var n=t[1];e=e.replace(li,"").replace(new RegExp("\\b".concat(n,"\\b"),"g"),"gl_FragColor")}return e}(e);default:throw new Error("unknown GLSL version ".concat(t))}}function di(e,t){var n,r=ei(t);try{for(r.s();!(n=r.n()).done;){var i=ie()(n.value,2),a=i[0],o=i[1];e=e.replace(a,o)}}catch(e){r.e(e)}finally{r.f()}return e}function vi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return gi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function gi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var pi="\n\n".concat("__LUMA_INJECT_DECLARATIONS__","\n\n"),mi=(ri={},u()(ri,"vs","vertex"),u()(ri,"fs","fragment"),ri);function yi(e,t){var n=t.vs,r=t.fs,i=Nr(t.modules||[]);return{gl:e,vs:_i(e,Object.assign({},t,{source:n,type:"vs",modules:i})),fs:_i(e,Object.assign({},t,{source:r,type:"fs",modules:i})),getUniforms:bi(i)}}function _i(e,t){var n=t.id,r=t.source,i=t.type,a=t.modules,o=t.defines,s=void 0===o?{}:o,u=t.hookFunctions,c=void 0===u?[]:u,l=t.inject,f=void 0===l?{}:l,h=t.transpileToGLSL100,d=void 0!==h&&h,v=t.prologue,g=void 0===v||v,p=t.log;Lr("string"==typeof r,"shader source must be a string");var m="vs"===i,y=r.split("\n"),_=100,b="",A=r;0===y[0].indexOf("#version ")?(_=300,b=y[0],A=y.slice(1).join("\n")):b="#version ".concat(_);var x={};a.forEach((function(e){Object.assign(x,e.getDefines())})),Object.assign(x,s);var E=g?"".concat(b,"\n").concat(function(e){var t=e.id,n=e.source,r=e.type;return t&&"string"==typeof t&&-1===n.indexOf("SHADER_NAME")?"\n#define SHADER_NAME ".concat(t,"_").concat(mi[r],"\n\n"):""}({id:n,source:r,type:i}),"\n").concat(function(e){var t=e.type;return"\n#define SHADER_TYPE_".concat(mi[t].toUpperCase(),"\n")}({type:i}),"\n").concat(function(e){switch(function(e){var t=e.getExtension("WEBGL_debug_renderer_info"),n=e.getParameter(t&&t.UNMASKED_VENDOR_WEBGL||7936),r=e.getParameter(t&&t.UNMASKED_RENDERER_WEBGL||7937);return{gpuVendor:function(e,t){if(e.match(/NVIDIA/i)||t.match(/NVIDIA/i))return"NVIDIA";if(e.match(/INTEL/i)||t.match(/INTEL/i))return"INTEL";if(e.match(/AMD/i)||t.match(/AMD/i)||e.match(/ATI/i)||t.match(/ATI/i))return"AMD";return"UNKNOWN GPU"}(n,r),vendor:n,renderer:r,version:e.getParameter(7938),shadingLanguageVersion:e.getParameter(35724)}}(e).gpuVendor.toLowerCase()){case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e),"\n").concat(function(e,t,n){var r="#if (__VERSION__ > 120)\n\n# define FEATURE_GLSL_DERIVATIVES\n# define FEATURE_GLSL_DRAW_BUFFERS\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FEATURE_GLSL_TEXTURE_LOD\n\n// DEPRECATED FLAGS, remove in v9\n# define FRAG_DEPTH\n# define DERIVATIVES\n# define DRAW_BUFFERS\n# define TEXTURE_LOD\n\n#endif // __VERSION\n";return Xr(e,Vr.GLSL_FRAG_DEPTH)&&(r+="\n// FRAG_DEPTH => gl_FragDepth is available\n#ifdef GL_EXT_frag_depth\n#extension GL_EXT_frag_depth : enable\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FRAG_DEPTH\n# define gl_FragDepth gl_FragDepthEXT\n#endif\n"),Xr(e,Vr.GLSL_DERIVATIVES)&&Hr(e,Vr.GLSL_DERIVATIVES)&&(r+="\n// DERIVATIVES => dxdF, dxdY and fwidth are available\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n# define FEATURE_GLSL_DERIVATIVES\n# define DERIVATIVES\n#endif\n"),Xr(e,Vr.GLSL_FRAG_DATA)&&Hr(e,Vr.GLSL_FRAG_DATA,{behavior:"require"})&&(r+="\n// DRAW_BUFFERS => gl_FragData[] is available\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers : require\n#define FEATURE_GLSL_DRAW_BUFFERS\n#define DRAW_BUFFERS\n#endif\n"),Xr(e,Vr.GLSL_TEXTURE_LOD)&&(r+="// TEXTURE_LOD => texture2DLod etc are available\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod : enable\n\n# define FEATURE_GLSL_TEXTURE_LOD\n# define TEXTURE_LOD\n\n#endif\n"),r}(e),"\n").concat(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=0,n="";for(var r in e){0===t&&(n+="\n// APPLICATION DEFINES\n"),t++;var i=e[r];(i||Number.isFinite(i))&&(n+="#define ".concat(r.toUpperCase()," ").concat(e[r],"\n"))}0===t&&(n+="\n");return n}(x),"\n").concat(m?"":"precision highp float;\n\n","\n"):"".concat(b,"\n"),T=function(e){var t={vs:{},fs:{}};return e.forEach((function(e){var n;"string"!=typeof e?e=(n=e).hook:n={};var r=(e=e.trim()).split(":"),i=ie()(r,2),a=i[0],o=i[1],s=e.replace(/\(.+/,"");t[a][s]=Object.assign(n,{signature:o})})),t}(c),k={},w={},O={};for(var S in f){var L="string"==typeof f[S]?{injection:f[S],order:0}:f[S],I=S.match(/^(v|f)s:(#)?([\w-]+)$/);if(I){var P=I[2],R=I[3];P?"decl"===R?w[S]=[L]:O[S]=[L]:k[S]=[L]}else O[S]=[L]}var F,C=vi(a);try{for(C.s();!(F=C.n()).done;){var B=F.value;p&&B.checkDeprecations(A,p),E+=B.getModuleSource(i,_);var M=B.injections[i];for(var N in M){var D=N.match(/^(v|f)s:#([\w-]+)$/);if(D){var j="decl"===D[2]?w:O;j[N]=j[N]||[],j[N].push(M[N])}else k[N]=k[N]||[],k[N].push(M[N])}}}catch(e){C.e(e)}finally{C.f()}return E=Zr(E+=pi,i,w),E+=function(e,t){var n="";for(var r in e){var i=e[r];if(n+="void ".concat(i.signature," {\n"),i.header&&(n+=" ".concat(i.header)),t[r]){var a=t[r];a.sort((function(e,t){return e.order-t.order}));var o,s=vi(a);try{for(s.s();!(o=s.n()).done;){var u=o.value;n+=" ".concat(u.injection,"\n")}}catch(e){s.e(e)}finally{s.f()}}i.footer&&(n+=" ".concat(i.footer)),n+="}\n"}return n}(T[i],k),E=hi(E=Zr(E+=A,i,O),d?100:_,m)}function bi(e){return function(t){var n,r={},i=vi(e);try{for(i.s();!(n=i.n()).done;){var a=n.value.getUniforms(t,r);Object.assign(r,a)}}catch(e){i.e(e)}finally{i.f()}return r}}function Ai(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return xi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function xi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ei=function(){function e(t){l()(this,e),this.gl=t,this._programCache={},this._getUniforms={},this._registeredModules={},this._hookFunctions=[],this._defaultModules=[],this._hashes={},this._hashCounter=0,this.stateHash=0,this._useCounts={}}return h()(e,[{key:"addDefaultModule",value:function(e){this._defaultModules.find((function(t){return t.name===e.name}))||this._defaultModules.push(e),this.stateHash++}},{key:"removeDefaultModule",value:function(e){var t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter((function(e){return e.name!==t})),this.stateHash++}},{key:"addShaderHook",value:function(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e),this.stateHash++}},{key:"get",value:function(){var e,t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.vs,i=void 0===r?"":r,a=n.fs,o=void 0===a?"":a,s=n.defines,u=void 0===s?{}:s,c=n.inject,l=void 0===c?{}:c,f=n.varyings,h=void 0===f?[]:f,d=n.bufferMode,v=void 0===d?35981:d,g=n.transpileToGLSL100,p=void 0!==g&&g,m=this._getModuleList(n.modules),y=this._getHash(i),_=this._getHash(o),b=m.map((function(e){return t._getHash(e.name)})).sort(),A=h.map((function(e){return t._getHash(e)})),x=Object.keys(u).sort(),E=Object.keys(l).sort(),T=[],k=[],w=Ai(x);try{for(w.s();!(e=w.n()).done;){var O=e.value;T.push(this._getHash(O)),T.push(this._getHash(u[O]))}}catch(e){w.e(e)}finally{w.f()}var S,L=Ai(E);try{for(L.s();!(S=L.n()).done;){var I=S.value;k.push(this._getHash(I)),k.push(this._getHash(l[I]))}}catch(e){L.e(e)}finally{L.f()}var P="".concat(y,"/").concat(_,"D").concat(T.join("/"),"M").concat(b.join("/"),"I").concat(k.join("/"),"V").concat(A.join("/"),"H").concat(this.stateHash,"B").concat(v).concat(p?"T":"");if(!this._programCache[P]){var R=yi(this.gl,{vs:i,fs:o,modules:m,inject:l,defines:u,hookFunctions:this._hookFunctions,transpileToGLSL100:p});this._programCache[P]=new _r(this.gl,{hash:P,vs:R.vs,fs:R.fs,varyings:h,bufferMode:v}),this._getUniforms[P]=R.getUniforms||function(e){},this._useCounts[P]=0}return this._useCounts[P]++,this._programCache[P]}},{key:"getUniforms",value:function(e){return this._getUniforms[e.hash]||null}},{key:"release",value:function(e){var t=e.hash;this._useCounts[t]--,0===this._useCounts[t]&&(this._programCache[t].delete(),delete this._programCache[t],delete this._getUniforms[t],delete this._useCounts[t])}},{key:"_getHash",value:function(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},{key:"_getModuleList",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=new Array(this._defaultModules.length+e.length),n={},r=0,i=0,a=this._defaultModules.length;i<a;++i){var o=this._defaultModules[i],s=o.name;t[r++]=o,n[s]=!0}for(var u=0,c=e.length;u<c;++u){var l=e[u],f=l.name;n[f]||(t[r++]=l,n[f]=!0)}return t.length=r,t}}],[{key:"getDefaultProgramManager",value:function(t){return t.luma=t.luma||{},t.luma.defaultProgramManager=t.luma.defaultProgramManager||new e(t),t.luma.defaultProgramManager}}]),e}(),Ti=null;function ki(e,t){var n;return new e((n=e.BYTES_PER_ELEMENT*t,(!Ti||Ti.byteLength<n)&&(Ti=new ArrayBuffer(n)),Ti),0,t)}var wi=n(20),Oi=globalThis;function Si(e){if(!e&&!Object(v.a)())return"Node";if(Object(wi.a)(e))return"Electron";var t="undefined"!=typeof navigator?navigator:{},n=e||t.userAgent||"";if(n.indexOf("Edge")>-1)return"Edge";var r=-1!==n.indexOf("MSIE "),i=-1!==n.indexOf("Trident/");return r||i?"IE":Oi.chrome?"Chrome":Oi.safari?"Safari":Oi.mozInnerScreenX?"Firefox":"Unknown"}function Li(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Ii="elements must be GL.ELEMENT_ARRAY_BUFFER",Pi=function(e,t){nt()(r,e);var n=Li(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,r);var a=i.id||i.program&&i.program.id;return(t=n.call(this,e,Object.assign({},i,{id:a}))).buffer=null,t.bufferValue=null,t.isDefaultArray=i.isDefaultArray||!1,t.gl2=e,t.initialize(i),Object.seal(Ze()(t)),t}return h()(r,[{key:t,get:function(){return"VertexArrayObject"}},{key:"delete",value:function(){return et()(ot()(r.prototype),"delete",this).call(this),this.buffer&&this.buffer.delete(),this}},{key:"MAX_ATTRIBUTES",get:function(){return r.getMaxAttributes(this.gl)}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setProps(e)}},{key:"setProps",value:function(e){return this}},{key:"setElementBuffer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return st(!t||34963===t.target,Ii),this.bind((function(){e.gl.bindBuffer(34963,t?t.handle:null)})),this}},{key:"setBuffer",value:function(e,t,n){if(34963===t.target)return this.setElementBuffer(t,n);var r=n.size,i=n.type,a=n.stride,o=n.offset,s=n.normalized,u=n.integer,c=n.divisor,l=this.gl,f=this.gl2;return e=Number(e),this.bind((function(){l.bindBuffer(34962,t.handle),u?(st(D(l)),f.vertexAttribIPointer(e,r,i,a,o)):l.vertexAttribPointer(e,r,i,s,a,o),l.enableVertexAttribArray(e),f.vertexAttribDivisor(e,c||0)})),this}},{key:"enable",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!n&&0===e&&!r.isSupported(this.gl,{constantAttributeZero:!0});return i||(e=Number(e),this.bind((function(){return n?t.gl.enableVertexAttribArray(e):t.gl.disableVertexAttribArray(e)}))),this}},{key:"getConstantBuffer",value:function(e,t){var n=this._normalizeConstantArrayValue(t),r=n.byteLength*e,i=n.length*e,a=!this.buffer;if(this.buffer=this.buffer||new Mt(this.gl,r),a=(a=a||this.buffer.reallocate(r))||!this._compareConstantArrayValues(n,this.bufferValue)){var o=ki(t.constructor,i);!function(e){for(var t=e.target,n=e.source,r=e.start,i=void 0===r?0:r,a=e.count,o=void 0===a?1:a,s=n.length,u=o*s,c=0,l=i;c<s;c++)t[l++]=n[c];for(;c<u;)c<u-c?(t.copyWithin(i+c,i,i+c),c*=2):(t.copyWithin(i+c,i,i+u-c),c=u)}({target:o,source:n,start:0,count:i}),this.buffer.subData(o),this.bufferValue=t}return this.buffer}},{key:"_normalizeConstantArrayValue",value:function(e){return Array.isArray(e)?new Float32Array(e):e}},{key:"_compareConstantArrayValues",value:function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}},{key:"_createHandle",value:function(){return this.gl.createVertexArray()}},{key:"_deleteHandle",value:function(e){return this.gl2.deleteVertexArray(e),[this.elements]}},{key:"_bindHandle",value:function(e){this.gl2.bindVertexArray(e)}},{key:"_getParameter",value:function(e,t){var n=this,r=t.location;return st(Number.isFinite(r)),this.bind((function(){switch(e){case 34373:return n.gl.getVertexAttribOffset(r,e);default:return n.gl.getVertexAttrib(r,e)}}))}}],[{key:"isSupported",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!t.constantAttributeZero||(D(e)||"Chrome"===Si())}},{key:"getDefaultArray",value:function(e){return e.luma=e.luma||{},e.luma.defaultVertexArray||(e.luma.defaultVertexArray=new r(e,{handle:null,isDefaultArray:!0})),e.luma.defaultVertexArray}},{key:"getMaxAttributes",value:function(e){return r.MAX_ATTRIBUTES=r.MAX_ATTRIBUTES||e.getParameter(34921),r.MAX_ATTRIBUTES}},{key:"setConstant",value:function(e,t,n){switch(n.constructor){case Float32Array:r._setConstantFloatArray(e,t,n);break;case Int32Array:r._setConstantIntArray(e,t,n);break;case Uint32Array:r._setConstantUintArray(e,t,n);break;default:st(!1)}}},{key:"_setConstantFloatArray",value:function(e,t,n){switch(n.length){case 1:e.vertexAttrib1fv(t,n);break;case 2:e.vertexAttrib2fv(t,n);break;case 3:e.vertexAttrib3fv(t,n);break;case 4:e.vertexAttrib4fv(t,n);break;default:st(!1)}}},{key:"_setConstantIntArray",value:function(e,t,n){switch(st(D(e)),n.length){case 1:e.vertexAttribI1iv(t,n);break;case 2:e.vertexAttribI2iv(t,n);break;case 3:e.vertexAttribI3iv(t,n);break;case 4:e.vertexAttribI4iv(t,n);break;default:st(!1)}}},{key:"_setConstantUintArray",value:function(e,t,n){switch(st(D(e)),n.length){case 1:e.vertexAttribI1uiv(t,n);break;case 2:e.vertexAttribI2uiv(t,n);break;case 3:e.vertexAttribI3uiv(t,n);break;case 4:e.vertexAttribI4uiv(t,n);break;default:st(!1)}}}]),r}(yt,Symbol.toStringTag),Ri=/^(.+)__LOCATION_([0-9]+)$/,Fi=["setBuffers","setGeneric","clearBindings","setLocations","setGenericValues","setDivisor","enable","disable"],Ci=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e);var r=n.id||n.program&&n.program.id;this.id=r,this.gl=t,this.configuration=null,this.elements=null,this.elementsAccessor=null,this.values=null,this.accessors=null,this.unused=null,this.drawParams=null,this.buffer=null,this.attributes={},this.vertexArrayObject=new Pi(t),vt(this,"VertexArray","v6.0",Fi),this.initialize(n),Object.seal(this)}return h()(e,[{key:"delete",value:function(){this.buffer&&this.buffer.delete(),this.vertexArrayObject.delete()}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.reset(),this.configuration=null,this.bindOnUse=!1,this.setProps(e)}},{key:"reset",value:function(){this.elements=null,this.elementsAccessor=null;var e=this.vertexArrayObject.MAX_ATTRIBUTES;return this.values=new Array(e).fill(null),this.accessors=new Array(e).fill(null),this.unused={},this.drawParams=null,this}},{key:"setProps",value:function(e){return"program"in e&&(this.configuration=e.program&&e.program.configuration),"configuration"in e&&(this.configuration=e.configuration),"attributes"in e&&this.setAttributes(e.attributes),"elements"in e&&this.setElementBuffer(e.elements),"bindOnUse"in e&&(e=e.bindOnUse),this}},{key:"clearDrawParams",value:function(){this.drawParams=null}},{key:"getDrawParams",value:function(){return this.drawParams=this.drawParams||this._updateDrawParams(),this.drawParams}},{key:"setAttributes",value:function(e){var t=this;return Object.assign(this.attributes,e),this.vertexArrayObject.bind((function(){for(var n in e){var r=e[n];t._setAttribute(n,r)}t.gl.bindBuffer(34962,null)})),this}},{key:"setElementBuffer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.elements=e,this.elementsAccessor=t,this.clearDrawParams(),this.vertexArrayObject.setElementBuffer(e,t),this}},{key:"setBuffer",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(34963===t.target)return this.setElementBuffer(t,n);var r=this._resolveLocationAndAccessor(e,t,t.accessor,n),i=r.location,a=r.accessor;return i>=0&&(this.values[i]=t,this.accessors[i]=a,this.clearDrawParams(),this.vertexArrayObject.setBuffer(i,t,a)),this}},{key:"setConstant",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this._resolveLocationAndAccessor(e,t,Object.assign({size:t.length},n)),i=r.location,a=r.accessor;return i>=0&&(t=this.vertexArrayObject._normalizeConstantArrayValue(t),this.values[i]=t,this.accessors[i]=a,this.clearDrawParams(),this.vertexArrayObject.enable(i,!1)),this}},{key:"unbindBuffers",value:function(){var e=this;return this.vertexArrayObject.bind((function(){e.elements&&e.vertexArrayObject.setElementBuffer(null),e.buffer=e.buffer||new Mt(e.gl,{accessor:{size:4}});for(var t=0;t<e.vertexArrayObject.MAX_ATTRIBUTES;t++)e.values[t]instanceof Mt&&(e.gl.disableVertexAttribArray(t),e.gl.bindBuffer(34962,e.buffer.handle),e.gl.vertexAttribPointer(t,1,5126,!1,0,0))})),this}},{key:"bindBuffers",value:function(){var e=this;return this.vertexArrayObject.bind((function(){e.elements&&e.setElementBuffer(e.elements);for(var t=0;t<e.vertexArrayObject.MAX_ATTRIBUTES;t++){var n=e.values[t];n instanceof Mt&&e.setBuffer(t,n)}})),this}},{key:"bindForDraw",value:function(e,t,n){var r,i=this;return this.vertexArrayObject.bind((function(){i._setConstantAttributes(e,t),r=n()})),r}},{key:"_resolveLocationAndAccessor",value:function(e,t,n,r){var i=this,a={location:-1,accessor:null},o=this._getAttributeIndex(e),s=o.location,u=o.name;if(!Number.isFinite(s)||s<0)return this.unused[e]=t,B.once(3,(function(){return"unused value ".concat(e," in ").concat(i.id)}))(),a;var c=this._getAttributeInfo(u||s);if(!c)return a;var l=this.accessors[s]||{},f=St.resolve(c.accessor,l,n,r),h=f.size,d=f.type;return st(Number.isFinite(h)&&Number.isFinite(d)),{location:s,accessor:f}}},{key:"_getAttributeInfo",value:function(e){return this.configuration&&this.configuration.getAttributeInfo(e)}},{key:"_getAttributeIndex",value:function(e){var t=Number(e);if(Number.isFinite(t))return{location:t};var n=Ri.exec(e),r=n?n[1]:e,i=n?Number(n[2]):0;return this.configuration?{location:this.configuration.getAttributeLocation(r)+i,name:r}:{location:-1}}},{key:"_setAttribute",value:function(e,t){if(t instanceof Mt)this.setBuffer(e,t);else if(Array.isArray(t)&&t.length&&t[0]instanceof Mt){var n=t[0],r=t[1];this.setBuffer(e,n,r)}else if(ArrayBuffer.isView(t)||Array.isArray(t)){var i=t;this.setConstant(e,i)}else{if(!(t.buffer instanceof Mt))throw new Error("VertexArray: attributes must be Buffers or constants (i.e. typed array)");var a=t;this.setBuffer(e,a.buffer,a)}}},{key:"_setConstantAttributes",value:function(e,t){var n=Math.max(0|e,0|t),r=this.values[0];ArrayBuffer.isView(r)&&this._setConstantAttributeZero(r,n);for(var i=1;i<this.vertexArrayObject.MAX_ATTRIBUTES;i++)r=this.values[i],ArrayBuffer.isView(r)&&this._setConstantAttribute(i,r)}},{key:"_setConstantAttributeZero",value:function(e,t){if(Pi.isSupported(this.gl,{constantAttributeZero:!0}))this._setConstantAttribute(0,e);else{var n=this.vertexArrayObject.getConstantBuffer(t,e);this.vertexArrayObject.setBuffer(0,n,this.accessors[0])}}},{key:"_setConstantAttribute",value:function(e,t){Pi.setConstant(this.gl,e,t)}},{key:"_updateDrawParams",value:function(){for(var e={isIndexed:!1,isInstanced:!1,indexCount:1/0,vertexCount:1/0,instanceCount:1/0},t=0;t<this.vertexArrayObject.MAX_ATTRIBUTES;t++)this._updateDrawParamsForLocation(e,t);return this.elements&&(e.elementCount=this.elements.getElementCount(this.elements.accessor),e.isIndexed=!0,e.indexType=this.elementsAccessor.type||this.elements.accessor.type,e.indexOffset=this.elementsAccessor.offset||0),e.indexCount===1/0&&(e.indexCount=0),e.vertexCount===1/0&&(e.vertexCount=0),e.instanceCount===1/0&&(e.instanceCount=0),e}},{key:"_updateDrawParamsForLocation",value:function(e,t){var n=this.values[t],r=this.accessors[t];if(n){var i=r.divisor>0;if(e.isInstanced=e.isInstanced||i,n instanceof Mt){var a=n;if(i){var o=a.getVertexCount(r);e.instanceCount=Math.min(e.instanceCount,o)}else{var s=a.getVertexCount(r);e.vertexCount=Math.min(e.vertexCount,s)}}}}},{key:"setElements",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return B.deprecated("setElements","setElementBuffer")(),this.setElementBuffer(e,t)}}]),e}();function Bi(e,t){for(var n=t.maxElts,r=void 0===n?16:n,i=t.size,a=void 0===i?1:i,o="[",s=0;s<e.length&&s<r;++s)s>0&&(o+=",".concat(s%a==0?" ":"")),o+=Mi(e[s],t);var u=e.length>r?"...":"]";return"".concat(o).concat(u)}function Mi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=1e-16,r=t.isInteger,i=void 0!==r&&r;if(Array.isArray(e)||ArrayBuffer.isView(e))return Bi(e,t);if(!Number.isFinite(e))return String(e);if(Math.abs(e)<n)return i?"0":"0.";if(i)return e.toFixed(0);if(Math.abs(e)>100&&Math.abs(e)<1e4)return e.toFixed(0);var a=e.toPrecision(2),o=a.indexOf(".0");return o===a.length-2?a.slice(0,-1):a}function Ni(e,t,n,r){var i,a,o=e.gl;if(!t)return a={},u()(a,r,"null"),u()(a,"Format ","N/A"),a;var s,c,l,f="NOT PROVIDED",h=1,d=0,v=0;if(n&&(f=n.type,h=n.size,s=-1!==(f=String(f).replace("Array","")).indexOf("nt")),t instanceof Mt){var g,p,m=t,y=m.getDebugData(),_=y.data;if(c=y.changed?"*":"",l=_,d=(v=m.byteLength)/_.BYTES_PER_ELEMENT/h,n){var b=n.divisor>0;p="".concat(b?"I ":"P "," ").concat(d," (x").concat(h,"=").concat(v," bytes ").concat(ct(o,f),")")}else s=!0,p="".concat(v," bytes");return g={},u()(g,r,"".concat(c).concat(Mi(l,{size:h,isInteger:s}))),u()(g,"Format ",p),g}return l=t,h=t.length,s=-1!==(f=String(t.constructor.name).replace("Array","")).indexOf("nt"),i={},u()(i,r,"".concat(Mi(l,{size:h,isInteger:s})," (constant)")),u()(i,"Format ","".concat(h,"x").concat(f," (constant)")),i}function Di(e,t){var n=dr(t.type,t.size);return n?"".concat(e," (").concat(n.name,")"):e}function ji(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ui(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ui(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Ui(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Gi(e){var t=e.header,n=void 0===t?"Uniforms":t,r=e.program,i=e.uniforms,a=e.undefinedOnly,o=void 0!==a&&a;st(r);var s,c=r._uniformSetters,l={},f=Object.keys(c).sort(),h=0,d=ji(f);try{for(d.s();!(s=d.n()).done;){var v=s.value;v.match(".*_.*")||v.match(".*Matrix")||Vi({table:l,header:n,uniforms:i,uniformName:v,undefinedOnly:o})&&h++}}catch(e){d.e(e)}finally{d.f()}var g,p=ji(f);try{for(p.s();!(g=p.n()).done;){var m=g.value;m.match(".*Matrix")&&Vi({table:l,header:n,uniforms:i,uniformName:m,undefinedOnly:o})&&h++}}catch(e){p.e(e)}finally{p.f()}var y,_=ji(f);try{for(_.s();!(y=_.n()).done;){var b=y.value;l[b]||Vi({table:l,header:n,uniforms:i,uniformName:b,undefinedOnly:o})&&h++}}catch(e){_.e(e)}finally{_.f()}var A=0,x={};if(!o)for(var E in i){var T=i[E];l[E]||(A++,x[E]=u()({Type:"NOT USED: ".concat(T)},n,Mi(T)))}return{table:l,count:h,unusedTable:x,unusedCount:A}}function Vi(e){var t,n=e.table,r=e.header,i=e.uniforms,a=e.uniformName,o=e.undefinedOnly,s=i[a],c=function(e){return null!=e}(s);return(!o||!c)&&(n[a]=(t={},u()(t,r,c?Mi(s):"N/A"),u()(t,"Uniform Type",c?s:"NOT PROVIDED"),t),!0)}function zi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Hi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Hi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Hi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Wi(e){var t=e.accessor,n=dr(t.type,t.size);return n?"".concat(n.name," ").concat(e.name):e.name}function Xi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function qi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xi(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ki={POSITION:"positions",NORMAL:"normals",COLOR_0:"colors",TEXCOORD_0:"texCoords",TEXCOORD_1:"texCoords1",TEXCOORD_2:"texCoords2"};function Yi(e,t){var n=(t||{}).attributeMap,r=void 0===n?Ki:n;return r&&r[e]||e}function Qi(e,t){var n;switch(e){case"texCoords":case"texCoord1":case"texCoord2":case"texCoord3":n="uvs";break;case"vertices":case"positions":case"normals":case"pickingColors":n="vectors"}switch(n){case"vectors":t.size=t.size||3;break;case"uvs":t.size=t.size||2}st(Number.isFinite(t.size),"attribute ".concat(e," needs size"))}var $i=function(){},Zi={},Ji=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e);var r=n.id,i=void 0===r?ft("model"):r;st(N(t)),this.id=i,this.gl=t,this.id=n.id||ft("Model"),this.lastLogTime=0,this.animated=!1,this.initialize(n)}return h()(e,[{key:"initialize",value:function(e){this.props={},this.programManager=e.programManager||Ei.getDefaultProgramManager(this.gl),this._programManagerState=-1,this._managedProgram=!1;var t=e.program,n=void 0===t?null:t,r=e.vs,i=e.fs,a=e.modules,o=e.defines,s=e.inject,u=e.varyings,c=e.bufferMode,l=e.transpileToGLSL100;this.programProps={program:n,vs:r,fs:i,modules:a,defines:o,inject:s,varyings:u,bufferMode:c,transpileToGLSL100:l},this.program=null,this.vertexArray=null,this._programDirty=!0,this.userData={},this.needsRedraw=!0,this._attributes={},this.attributes={},this.uniforms={},this.pickable=!0,this._checkProgram(),this.setUniforms(Object.assign({},this.getModuleUniforms(e.moduleSettings))),this.drawMode=void 0!==e.drawMode?e.drawMode:4,this.vertexCount=e.vertexCount||0,this.geometryBuffers={},this.isInstanced=e.isInstanced||e.instanced||e.instanceCount>0,this._setModelProps(e),this.geometry={},st(void 0!==this.drawMode&&Number.isFinite(this.vertexCount),"Model needs drawMode and vertexCount")}},{key:"setProps",value:function(e){this._setModelProps(e)}},{key:"delete",value:function(){for(var e in this._attributes)this._attributes[e]!==this.attributes[e]&&this._attributes[e].delete();this._managedProgram&&(this.programManager.release(this.program),this._managedProgram=!1),this.vertexArray.delete(),this._deleteGeometryBuffers()}},{key:"getDrawMode",value:function(){return this.drawMode}},{key:"getVertexCount",value:function(){return this.vertexCount}},{key:"getInstanceCount",value:function(){return this.instanceCount}},{key:"getAttributes",value:function(){return this.attributes}},{key:"getProgram",value:function(){return this.program}},{key:"setProgram",value:function(e){var t=e.program,n=e.vs,r=e.fs,i=e.modules,a=e.defines,o=e.inject,s=e.varyings,u=e.bufferMode,c=e.transpileToGLSL100;this.programProps={program:t,vs:n,fs:r,modules:i,defines:a,inject:o,varyings:s,bufferMode:u,transpileToGLSL100:c},this._programDirty=!0}},{key:"getUniforms",value:function(){return this.uniforms}},{key:"setDrawMode",value:function(e){return this.drawMode=e,this}},{key:"setVertexCount",value:function(e){return st(Number.isFinite(e)),this.vertexCount=e,this}},{key:"setInstanceCount",value:function(e){return st(Number.isFinite(e)),this.instanceCount=e,this}},{key:"setGeometry",value:function(e){return this.drawMode=e.drawMode,this.vertexCount=e.getVertexCount(),this._deleteGeometryBuffers(),this.geometryBuffers=function(e,t,n){var r={},i=t.indices;for(var a in t.attributes){var o=t.attributes[a],s=Yi(a,n);if("indices"===a)i=o;else if(o.constant)r[s]=o.value;else{var u=o.value,c=qi({},o);delete c.value,r[s]=[new Mt(e,u),c],Qi(a,c)}}if(i){var l=i.value||i;st(l instanceof Uint16Array||l instanceof Uint32Array,'attribute array for "indices" must be of integer type');var f={size:1,isIndexed:void 0===i.isIndexed||i.isIndexed};r.indices=[new Mt(e,{data:l,target:34963}),f]}return r}(this.gl,e),this.vertexArray.setAttributes(this.geometryBuffers),this}},{key:"setAttributes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(dt(e))return this;var t={};for(var n in e){var r=e[n];t[n]=r.getValue?r.getValue():r}return this.vertexArray.setAttributes(t),this}},{key:"setUniforms",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(this.uniforms,e),this}},{key:"getModuleUniforms",value:function(e){this._checkProgram();var t=this.programManager.getUniforms(this.program);return t?t(e):{}}},{key:"updateModuleSettings",value:function(e){var t=this.getModuleUniforms(e||{});return this.setUniforms(t)}},{key:"clear",value:function(e){return an(this.program.gl,e),this}},{key:"draw",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._checkProgram();var t,n=e.moduleSettings,r=void 0===n?null:n,i=e.framebuffer,a=e.uniforms,o=void 0===a?{}:a,s=e.attributes,u=void 0===s?{}:s,c=e.transformFeedback,l=void 0===c?this.transformFeedback:c,f=e.parameters,h=void 0===f?{}:f,d=e.vertexArray,v=void 0===d?this.vertexArray:d;this.setAttributes(u),this.updateModuleSettings(r),this.setUniforms(o),B.priority>=2&&(t=this._logDrawCallStart(2));var g=this.vertexArray.getDrawParams(),p=this.props,m=p.isIndexed,y=void 0===m?g.isIndexed:m,_=p.indexType,b=void 0===_?g.indexType:_,A=p.indexOffset,x=void 0===A?g.indexOffset:A,E=p.vertexArrayInstanced,T=void 0===E?g.isInstanced:E;T&&!this.isInstanced&&B.warn("Found instanced attributes on non-instanced model",this.id)();var k=this.isInstanced,w=this.instanceCount,O=this.props,S=O.onBeforeRender,L=void 0===S?$i:S,I=O.onAfterRender,P=void 0===I?$i:I;L(),this.program.setUniforms(this.uniforms);var R=this.program.draw(Object.assign(Zi,e,{logPriority:t,uniforms:null,framebuffer:i,parameters:h,drawMode:this.getDrawMode(),vertexCount:this.getVertexCount(),vertexArray:v,transformFeedback:l,isIndexed:y,indexType:b,isInstanced:k,instanceCount:w,offset:y?x:0}));return P(),B.priority>=2&&this._logDrawCallEnd(t,v,i),R}},{key:"transform",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.discard,n=void 0===t||t,r=e.feedbackBuffers,i=e.unbindModels,a=void 0===i?[]:i,o=e.parameters;r&&this._setFeedbackBuffers(r),n&&(o=Object.assign({},o,u()({},35977,n))),a.forEach((function(e){return e.vertexArray.unbindBuffers()}));try{this.draw(Object.assign({},e,{parameters:o}))}finally{a.forEach((function(e){return e.vertexArray.bindBuffers()}))}return this}},{key:"render",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return B.warn("Model.render() is deprecated. Use Model.setUniforms() and Model.draw()")(),this.setUniforms(e).draw()}},{key:"_setModelProps",value:function(e){Object.assign(this.props,e),"uniforms"in e&&this.setUniforms(e.uniforms),"pickable"in e&&(this.pickable=e.pickable),"instanceCount"in e&&(this.instanceCount=e.instanceCount),"geometry"in e&&this.setGeometry(e.geometry),"attributes"in e&&this.setAttributes(e.attributes),"_feedbackBuffers"in e&&this._setFeedbackBuffers(e._feedbackBuffers)}},{key:"_checkProgram",value:function(){if(this._programDirty||this.programManager.stateHash!==this._programManagerState){var e=this.programProps.program;if(e)this._managedProgram=!1;else{var t=this.programProps,n=t.vs,r=t.fs,i=t.modules,a=t.inject,o=t.defines,s=t.varyings,u=t.bufferMode,c=t.transpileToGLSL100;e=this.programManager.get({vs:n,fs:r,modules:i,inject:a,defines:o,varyings:s,bufferMode:u,transpileToGLSL100:c}),this.program&&this._managedProgram&&this.programManager.release(this.program),this._programManagerState=this.programManager.stateHash,this._managedProgram=!0}st(e instanceof _r,"Model needs a program"),this._programDirty=!1,e!==this.program&&(this.program=e,this.vertexArray?this.vertexArray.setProps({program:this.program,attributes:this.vertexArray.attributes}):this.vertexArray=new Ci(this.gl,{program:this.program}),this.setUniforms(Object.assign({},this.getModuleUniforms())))}}},{key:"_deleteGeometryBuffers",value:function(){for(var e in this.geometryBuffers){var t=this.geometryBuffers[e][0]||this.geometryBuffers[e];t instanceof Mt&&t.delete()}}},{key:"_setAnimationProps",value:function(e){this.animated&&st(e,"Model.draw(): animated uniforms but no animationProps")}},{key:"_setFeedbackBuffers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(dt(e))return this;var t=this.program.gl;return this.transformFeedback=this.transformFeedback||new Ar(t,{program:this.program}),this.transformFeedback.setBuffers(e),this}},{key:"_logDrawCallStart",value:function(e){var t=e>3?0:1e4;if(!(Date.now()-this.lastLogTime<t))return this.lastLogTime=Date.now(),B.group(2,">>> DRAWING MODEL ".concat(this.id),{collapsed:B.level<=2})(),e}},{key:"_logDrawCallEnd",value:function(e,t,n,r){if(void 0!==e){var i=function(e){var t=e.vertexArray,n=e.header,r=void 0===n?"Attributes":n;if(!t.configuration)return{};var i={};t.elements&&(i.ELEMENT_ARRAY_BUFFER=Ni(t,t.elements,null,r));var a=t.values;for(var o in a){var s=t._getAttributeInfo(o);if(s){var u="".concat(o,": ").concat(s.name),c=t.accessors[s.location];c&&(u="".concat(o,": ").concat(Di(s.name,c))),i[u]=Ni(t,a[o],c,r)}}return i}({vertexArray:t,header:"".concat(this.id," attributes"),attributes:this._attributes}),a=Gi({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,n)}),o=a.table,s=a.unusedTable,c=a.unusedCount,l=Gi({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,n),undefinedOnly:!0}),f=l.table;l.count>0&&B.log("MISSING UNIFORMS",Object.keys(f))(),c>0&&B.log("UNUSED UNIFORMS",Object.keys(s))();var h=function(e){var t,n={},r="Accessors for ".concat(e.id),i=zi(e.attributeInfos);try{for(i.s();!(t=i.n()).done;){var a=t.value;if(a){var o=Wi(a);n["in ".concat(o)]=u()({},r,JSON.stringify(a.accessor))}}}catch(e){i.e(e)}finally{i.f()}var s,c=zi(e.varyingInfos);try{for(c.s();!(s=c.n()).done;){var l=s.value;if(l){var f=Wi(l);n["out ".concat(f)]=u()({},r,JSON.stringify(l.accessor))}}}catch(e){c.e(e)}finally{c.f()}return n}(this.vertexArray.configuration);B.table(e,i)(),B.table(e,o)(),B.table(e+1,h)(),r&&r.log({logLevel:2,message:"Rendered to ".concat(r.id)}),B.groupEnd(2)()}}}]),e}(),ea="void main() {gl_FragColor = vec4(0);}",ta="out vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}",na="#version 300 es\n".concat(ta);function ra(e,t){t=Array.isArray(t)?t:[t];var n=e.replace(/^\s+/,"").split(/\s+/),r=ie()(n,3),i=r[0],a=r[1],o=r[2];return t.includes(i)&&a&&o?{qualifier:i,type:a,name:o.split(";")[0]}:null}function ia(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.version,n=void 0===t?100:t,r=e.input,i=e.inputType,a=e.output;if(!r)return 300===n?na:n>300?"#version ".concat(n,"\n").concat(ta):ea;var o=oa(r,i);return n>=300?"#version ".concat(n," ").concat(300===n?"es":"","\nin ").concat(i," ").concat(r,";\nout vec4 ").concat(a,";\nvoid main() {\n ").concat(a," = ").concat(o,";\n}"):"varying ".concat(i," ").concat(r,";\nvoid main() {\n gl_FragColor = ").concat(o,";\n}")}function aa(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:return Lr(!1),null}}function oa(e,t){switch(t){case"float":return"vec4(".concat(e,", 0.0, 0.0, 1.0)");case"vec2":return"vec4(".concat(e,", 0.0, 1.0)");case"vec3":return"vec4(".concat(e,", 1.0)");case"vec4":return e;default:return Lr(!1),null}}function sa(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ua(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ua(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ua(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ca=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e),this.gl=t,this.currentIndex=0,this.feedbackMap={},this.varyings=null,this.bindings=[],this.resources={},this._initialize(n),Object.seal(this)}return h()(e,[{key:"setupResources",value:function(e){var t,n=sa(this.bindings);try{for(n.s();!(t=n.n()).done;){var r=t.value;this._setupTransformFeedback(r,e)}}catch(e){n.e(e)}finally{n.f()}}},{key:"updateModelProps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.varyings;return t.length>0&&(e=Object.assign({},e,{varyings:t})),e}},{key:"getDrawOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.bindings[this.currentIndex],n=t.sourceBuffers,r=t.transformFeedback,i=Object.assign({},n,e.attributes);return{attributes:i,transformFeedback:r}}},{key:"swap",value:function(){return!!this.feedbackMap&&(this.currentIndex=this._getNextIndex(),!0)}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(e)}},{key:"getBuffer",value:function(e){var t=this.bindings[this.currentIndex].feedbackBuffers,n=e?t[e]:null;return n?n instanceof Mt?n:n.buffer:null}},{key:"getData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.varyingName,n=this.getBuffer(t);return n?n.getData():null}},{key:"delete",value:function(){for(var e in this.resources)this.resources[e].delete()}},{key:"_initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(e),this.varyings=e.varyings||Object.keys(this.bindings[this.currentIndex].feedbackBuffers),this.varyings.length>0&&st(D(this.gl))}},{key:"_getFeedbackBuffers",value:function(e){var t=e.sourceBuffers,n=void 0===t?{}:t,r={};if(this.bindings[this.currentIndex]&&Object.assign(r,this.bindings[this.currentIndex].feedbackBuffers),this.feedbackMap)for(var i in this.feedbackMap){var a=this.feedbackMap[i];i in n&&(r[a]=i)}for(var o in Object.assign(r,e.feedbackBuffers),r){var s=r[o];if("string"==typeof s){var u=n[s],c=u.byteLength,l=u.usage,f=u.accessor;r[o]=this._createNewBuffer(o,{byteLength:c,usage:l,accessor:f})}}return r}},{key:"_setupBuffers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.sourceBuffers,n=void 0===t?null:t;Object.assign(this.feedbackMap,e.feedbackMap);var r=this._getFeedbackBuffers(e);this._updateBindings({sourceBuffers:n,feedbackBuffers:r})}},{key:"_setupTransformFeedback",value:function(e,t){var n=t.model.program;e.transformFeedback=new Ar(this.gl,{program:n,buffers:e.feedbackBuffers})}},{key:"_updateBindings",value:function(e){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e),this.feedbackMap){var t=this._swapBuffers(this.bindings[this.currentIndex]),n=t.sourceBuffers,r=t.feedbackBuffers,i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceBuffers:n,feedbackBuffers:r})}}},{key:"_updateBinding",value:function(e,t){return e?(Object.assign(e.sourceBuffers,t.sourceBuffers),Object.assign(e.feedbackBuffers,t.feedbackBuffers),e.transformFeedback&&e.transformFeedback.setBuffers(e.feedbackBuffers),e):{sourceBuffers:Object.assign({},t.sourceBuffers),feedbackBuffers:Object.assign({},t.feedbackBuffers)}}},{key:"_swapBuffers",value:function(e){if(!this.feedbackMap)return null;var t=Object.assign({},e.sourceBuffers),n=Object.assign({},e.feedbackBuffers);for(var r in this.feedbackMap){var i=this.feedbackMap[r];t[r]=e.feedbackBuffers[i],n[i]=e.sourceBuffers[r],st(n[i]instanceof Mt)}return{sourceBuffers:t,feedbackBuffers:n}}},{key:"_createNewBuffer",value:function(e,t){var n=new Mt(this.gl,t);return this.resources[e]&&this.resources[e].delete(),this.resources[e]=n,n}},{key:"_getNextIndex",value:function(){return(this.currentIndex+1)%2}}]),e}();function la(e){var t=100,n=e.match(/[^\s]+/g);if(n.length>=2&&"#version"===n[0]){var r=parseInt(n[1],10);Number.isFinite(r)&&(t=r)}return t}var fa,ha={name:"transform",vs:"attribute float transform_elementID;\n\n// returns half of pixel size, used to move the pixel position to center of the pixel.\nvec2 transform_getPixelSizeHalf(vec2 size) {\n return vec2(1.) / (2. * size);\n}\n\n// returns current elements pixel indeces [x, y],\n// where x ranges in [0 to texSize-1] and y ranges in [0 to texSize-1]\nvec2 transform_getPixelIndices(vec2 texSize, vec2 pixelSizeHalf) {\n // Add safe offset (half of pixel height) before doing floor\n float yIndex = floor((transform_elementID / texSize[0]) + pixelSizeHalf[1]);\n float xIndex = transform_elementID - (yIndex * texSize[0]);\n return vec2(xIndex, yIndex);\n}\n\n// returns current elementID's texture co-ordianate\nvec2 transform_getTexCoord(vec2 size) {\n vec2 pixelSizeHalf = transform_getPixelSizeHalf(size);\n vec2 indices = transform_getPixelIndices(size, pixelSizeHalf);\n vec2 coord = indices / size + pixelSizeHalf;\n return coord;\n}\n\n// returns current elementID's position\nvec2 transform_getPos(vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n // Change from [0 1] range to [-1 1]\n vec2 pos = (texCoord * (2.0, 2.0)) - (1., 1.);\n return pos;\n}\n\n// returns current elementID's pixel value\nvec4 transform_getInput(sampler2D texSampler, vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n vec4 textureColor = texture2D(texSampler, texCoord);\n return textureColor;\n}\n",fs:null};function da(e){var t=e.vs,n=e.sourceTextureMap,r=e.targetTextureVarying,i=e.targetTexture,a=Object.keys(n).length,o=null,s={},u=t,c={};if(a>0||r){var l=u.split("\n"),f=l.slice();if(l.forEach((function(e,t,i){if(a>0){var u=function(e,t){var n={},r=function(e){return ra(e,["attribute","in"])}(e);if(!r)return null;var i=r.type,a=r.name;if(a&&t[a]){var o="// ".concat(e," => Replaced by Transform with a sampler"),s=function(e){var t="".concat("transform_uSampler_").concat(e),n="".concat("transform_uSize_").concat(e),r=" uniform sampler2D ".concat(t,";\n uniform vec2 ").concat(n,";");return{samplerName:t,sizeName:n,uniformDeclerations:r}}(a),u=s.samplerName,c=s.sizeName,l=s.uniformDeclerations,f=function(e){switch(e){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:return Lr(!1),null}}(i),h=" ".concat(i," ").concat(a," = transform_getInput(").concat(u,", ").concat(c,").").concat(f,";\n");return n[u]=a,{updatedLine:o,inject:{"vs:#decl":l,"vs:#main-start":h},samplerTextureMap:n}}return null}(e,n);if(u){var l=u.updatedLine,h=u.inject;f[t]=l,c=Jr([c,h]),Object.assign(s,u.samplerTextureMap),a--}}r&&!o&&(o=function(e,t){var n=ra(e,["varying","out"]);if(!n)return null;return n.name===t?n.type:null}(e,r))})),r){st(i);var h="".concat("transform_uSize_").concat(r),d="uniform vec2 ".concat(h,";\n"),v=" vec2 ".concat("transform_position"," = transform_getPos(").concat(h,");\n gl_Position = vec4(").concat("transform_position",", 0, 1.);\n");c=Jr([c,{"vs:#decl":d,"vs:#main-start":v}])}u=f.join("\n")}return{vs:u,targetTextureType:o,inject:c,samplerTextureMap:s}}function va(e){var t,n,r=e.sourceTextureMap,i=e.targetTextureVarying,a=e.targetTexture,o={};for(var s in i&&(t=a.width,n=a.height,o["".concat("transform_uSize_").concat(i)]=[t,n]),r){var u=r[s];t=u.width,n=u.height,o["".concat("transform_uSize_").concat(s)]=[t,n]}return o}var ga=(fa={},u()(fa,10241,9728),u()(fa,10240,9728),u()(fa,10242,33071),u()(fa,10243,33071),fa),pa=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e),this.gl=t,this.id=this.currentIndex=0,this._swapTexture=null,this.targetTextureVarying=null,this.targetTextureType=null,this.samplerTextureMap=null,this.bindings=[],this.resources={},this._initialize(n),Object.seal(this)}return h()(e,[{key:"updateModelProps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this._processVertexShader(e);return Object.assign({},e,t)}},{key:"getDrawOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.bindings[this.currentIndex],n=t.sourceBuffers,r=t.sourceTextures,i=t.framebuffer,a=t.targetTexture,o=Object.assign({},n,e.attributes),s=Object.assign({},e.uniforms),u=Object.assign({},e.parameters),c=e.discard;if(this.hasSourceTextures||this.hasTargetTexture){for(var l in o.transform_elementID=this.elementIDBuffer,this.samplerTextureMap){var f=this.samplerTextureMap[l];s[l]=r[f]}this._setSourceTextureParameters();var h=va({sourceTextureMap:r,targetTextureVarying:this.targetTextureVarying,targetTexture:a});Object.assign(s,h)}return this.hasTargetTexture&&(c=!1,u.viewport=[0,0,i.width,i.height]),{attributes:o,framebuffer:i,uniforms:s,discard:c,parameters:u}}},{key:"swap",value:function(){return!!this._swapTexture&&(this.currentIndex=this._getNextIndex(),!0)}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupTextures(e)}},{key:"getTargetTexture",value:function(){return this.bindings[this.currentIndex].targetTexture}},{key:"getData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.packed,n=void 0!==t&&t,r=this.bindings[this.currentIndex].framebuffer,i=yn(r);if(!n)return i;for(var a=i.constructor,o=aa(this.targetTextureType),s=new a(i.length*o/4),u=0,c=0;c<i.length;c+=4)for(var l=0;l<o;l++)s[u++]=i[c+l];return s}},{key:"getFramebuffer",value:function(){return this.bindings[this.currentIndex].framebuffer}},{key:"delete",value:function(){this.ownTexture&&this.ownTexture.delete(),this.elementIDBuffer&&this.elementIDBuffer.delete()}},{key:"_initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e._targetTextureVarying,n=e._swapTexture;this._swapTexture=n,this.targetTextureVarying=t,this.hasTargetTexture=t,this._setupTextures(e)}},{key:"_createTargetTexture",value:function(e){var t=e.sourceTextures,n=e.textureOrReference;if(n instanceof Zt)return n;var r=t[n];return r?(this._targetRefTexName=n,this._createNewTexture(r)):null}},{key:"_setupTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.sourceBuffers,n=e._sourceTextures,r=void 0===n?{}:n,i=e._targetTexture,a=this._createTargetTexture({sourceTextures:r,textureOrReference:i});this.hasSourceTextures=this.hasSourceTextures||r&&Object.keys(r).length>0,this._updateBindings({sourceBuffers:t,sourceTextures:r,targetTexture:a}),"elementCount"in e&&this._updateElementIDBuffer(e.elementCount)}},{key:"_updateElementIDBuffer",value:function(e){if(!("number"!=typeof e||this.elementCount>=e)){var t=new Float32Array(e);t.forEach((function(e,t,n){n[t]=t})),this.elementIDBuffer?this.elementIDBuffer.setData({data:t}):this.elementIDBuffer=new Mt(this.gl,{data:t,accessor:{size:1}}),this.elementCount=e}}},{key:"_updateBindings",value:function(e){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e),this._swapTexture){var t=this._swapTextures(this.bindings[this.currentIndex]),n=t.sourceTextures,r=t.targetTexture,i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceTextures:n,targetTexture:r})}}},{key:"_updateBinding",value:function(e,t){var n=t.sourceBuffers,r=t.sourceTextures,i=t.targetTexture;if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,r),Object.assign(e.sourceBuffers,n),i){e.targetTexture=i;var a=i.width,o=i.height,s=e.framebuffer;s?(s.update({attachments:u()({},36064,i),resizeAttachments:!1}),s.resize({width:a,height:o})):e.framebuffer=new Rn(this.gl,{id:"transform-framebuffer",width:a,height:o,attachments:u()({},36064,i)})}return e}},{key:"_setSourceTextureParameters",value:function(){var e=this.currentIndex,t=this.bindings[e].sourceTextures;for(var n in t)t[n].setParameters(ga)}},{key:"_swapTextures",value:function(e){if(!this._swapTexture)return null;var t=Object.assign({},e.sourceTextures);return t[this._swapTexture]=e.targetTexture,{sourceTextures:t,targetTexture:e.sourceTextures[this._swapTexture]}}},{key:"_createNewTexture",value:function(e){var t,n=mn(e,{parameters:(t={},u()(t,10241,9728),u()(t,10240,9728),u()(t,10242,33071),u()(t,10243,33071),t),pixelStore:u()({},37440,!1)});return this.ownTexture&&this.ownTexture.delete(),this.ownTexture=n,n}},{key:"_getNextIndex",value:function(){return(this.currentIndex+1)%2}},{key:"_processVertexShader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.bindings[this.currentIndex],n=t.sourceTextures,r=t.targetTexture,i=da({vs:e.vs,sourceTextureMap:n,targetTextureVarying:this.targetTextureVarying,targetTexture:r}),a=i.vs,o=i.uniforms,s=i.targetTextureType,u=i.inject,c=i.samplerTextureMap,l=Jr([e.inject||{},u]);this.targetTextureType=s,this.samplerTextureMap=c;var f=e._fs||ia({version:la(a),input:this.targetTextureVarying,inputType:s,output:"transform_output"}),h=this.hasSourceTextures||this.targetTextureVarying?[ha].concat(e.modules||[]):e.modules;return{vs:a,fs:f,modules:h,uniforms:o,inject:l}}}]),e}();function ma(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ya(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ya(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ya(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var _a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l()(this,e),this.gl=t,this.model=null,this.elementCount=0,this.bufferTransform=null,this.textureTransform=null,this.elementIDBuffer=null,this._initialize(n),Object.seal(this)}return h()(e,[{key:"delete",value:function(){var e=this.model,t=this.bufferTransform,n=this.textureTransform;e&&e.delete(),t&&t.delete(),n&&n.delete()}},{key:"run",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.clearRenderTarget,n=void 0===t||t,r=this._updateDrawOptions(e);n&&r.framebuffer&&r.framebuffer.clear({color:!0}),this.model.transform(r)}},{key:"swap",value:function(){var e,t=!1,n=ma([this.bufferTransform,this.textureTransform].filter(Boolean));try{for(n.s();!(e=n.n()).done;){var r=e.value;t=t||r.swap()}}catch(e){n.e(e)}finally{n.f()}st(t,"Nothing to swap")}},{key:"getBuffer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.bufferTransform&&this.bufferTransform.getBuffer(e)}},{key:"getData",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=[this.bufferTransform,this.textureTransform].filter(Boolean),r=ma(n);try{for(r.s();!(e=r.n()).done;){var i=e.value,a=i.getData(t);if(a)return a}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"getFramebuffer",value:function(){return this.textureTransform&&this.textureTransform.getFramebuffer()}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"elementCount"in e&&this.model.setVertexCount(e.elementCount);var t,n=[this.bufferTransform,this.textureTransform].filter(Boolean),r=ma(n);try{for(r.s();!(t=r.n()).done;){var i=t.value;i.update(e)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.gl;this._buildResourceTransforms(t,e),e=this._updateModelProps(e),this.model=new Ji(t,Object.assign({},e,{fs:e.fs||ia({version:la(e.vs)}),id:e.id||"transform-model",drawMode:e.drawMode||0,vertexCount:e.elementCount})),this.bufferTransform&&this.bufferTransform.setupResources({model:this.model})}},{key:"_updateModelProps",value:function(e){var t,n=Object.assign({},e),r=ma([this.bufferTransform,this.textureTransform].filter(Boolean));try{for(r.s();!(t=r.n()).done;){n=t.value.updateModelProps(n)}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"_buildResourceTransforms",value:function(e,t){(function(e){if(!dt(e.feedbackBuffers)||!dt(e.feedbackMap)||e.varyings&&e.varyings.length>0)return!0;return!1})(t)&&(this.bufferTransform=new ca(e,t)),function(e){if(!dt(e._sourceTextures)||e._targetTexture||e._targetTextureVarying)return!0;return!1}(t)&&(this.textureTransform=new pa(e,t)),st(this.bufferTransform||this.textureTransform,"must provide source/feedback buffers or source/target textures")}},{key:"_updateDrawOptions",value:function(e){var t,n=Object.assign({},e),r=ma([this.bufferTransform,this.textureTransform].filter(Boolean));try{for(r.s();!(t=r.n()).done;){var i=t.value;n=Object.assign(n,i.getDrawOptions(n))}}catch(e){r.e(e)}finally{r.f()}return n}}],[{key:"isSupported",value:function(e){return D(e)}}]),e}();function ba(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Aa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Aa(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Aa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var xa=1,Ea=1,Ta=function(){function e(){l()(this,e),this.time=0,this.channels=new Map,this.animations=new Map,this.playing=!1,this.lastEngineTime=-1}return h()(e,[{key:"addChannel",value:function(e){var t=e.delay,n=void 0===t?0:t,r=e.duration,i=void 0===r?Number.POSITIVE_INFINITY:r,a=e.rate,o=void 0===a?1:a,s=e.repeat,u=xa++,c={time:0,delay:n,duration:i,rate:o,repeat:void 0===s?1:s};return this._setChannelTime(c,this.time),this.channels.set(u,c),u}},{key:"removeChannel",value:function(e){this.channels.delete(e);var t,n=ba(this.animations);try{for(n.s();!(t=n.n()).done;){var r=ie()(t.value,2),i=r[0];r[1].channel===e&&this.detachAnimation(i)}}catch(e){n.e(e)}finally{n.f()}}},{key:"isFinished",value:function(e){var t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}},{key:"getTime",value:function(e){if(void 0===e)return this.time;var t=this.channels.get(e);return void 0===t?-1:t.time}},{key:"setTime",value:function(e){this.time=Math.max(0,e);var t,n=ba(this.channels.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;this._setChannelTime(r,this.time)}}catch(e){n.e(e)}finally{n.f()}var i,a=ba(this.animations.values());try{for(a.s();!(i=a.n()).done;){var o=i.value,s=o.animation,u=o.channel;s.setTime(this.getTime(u))}}catch(e){a.e(e)}finally{a.f()}}},{key:"play",value:function(){this.playing=!0}},{key:"pause",value:function(){this.playing=!1,this.lastEngineTime=-1}},{key:"reset",value:function(){this.setTime(0)}},{key:"attachAnimation",value:function(e,t){var n=Ea++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}},{key:"detachAnimation",value:function(e){this.animations.delete(e)}},{key:"update",value:function(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}},{key:"_setChannelTime",value:function(e,t){var n=t-e.delay;n>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}}]),e}();function ka(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var wa={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Oa=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,e);var n=t.id,r=void 0===n?ft("geometry"):n,i=t.drawMode,a=void 0===i?wa.TRIANGLES:i,o=t.attributes,s=void 0===o?{}:o,u=t.indices,c=void 0===u?null:u,f=t.vertexCount,h=void 0===f?null:f;this.id=r,this.drawMode=0|a,this.attributes={},this.userData={},this._setAttributes(s,c),this.vertexCount=h||this._calculateVertexCount(this.attributes,this.indices)}return h()(e,[{key:"mode",get:function(){return this.drawMode}},{key:"getVertexCount",value:function(){return this.vertexCount}},{key:"getAttributes",value:function(){return this.indices?function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ka(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ka(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({indices:this.indices},this.attributes):this.attributes}},{key:"_print",value:function(e){return"Geometry ".concat(this.id," attribute ").concat(e)}},{key:"_setAttributes",value:function(e,t){for(var n in t&&(this.indices=ArrayBuffer.isView(t)?{value:t,size:1}:t),e){var r=e[n];r=ArrayBuffer.isView(r)?{value:r}:r,st(ArrayBuffer.isView(r.value),"".concat(this._print(n),": must be typed array or object with value as typed array")),"POSITION"!==n&&"positions"!==n||r.size||(r.size=3),"indices"===n?(st(!this.indices),this.indices=r):this.attributes[n]=r}return this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this}},{key:"_calculateVertexCount",value:function(e,t){if(t)return t.value.length;var n=1/0;for(var r in e){var i=e[r],a=i.value,o=i.size;!i.constant&&a&&o>=1&&(n=Math.min(n,a.length/o))}return st(Number.isFinite(n)),n}}],[{key:"DRAW_MODE",get:function(){return wa}}]),e}();function Sa(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var La=[-1,-1,1,-1,-1,1,1,1],Ia=function(e){nt()(n,e);var t=Sa(n);function n(e,r){var i;l()(this,n);var a=La.map((function(e){return-1===e?0:e}));return(i=t.call(this,e,Object.assign({},r,{vs:"attribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n",geometry:new Oa({drawMode:5,vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(La)},aTexCoord:{size:2,value:new Float32Array(a)},aCoordinate:{size:2,value:new Float32Array(a)}}})}))).setVertexCount(4),i}return h()(n)}(Ji);function Pa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ra(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Pa(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Fa(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Ca={x:[2,0,1],y:[0,1,2],z:[1,2,0]},Ba=function(e){nt()(n,e);var t=Fa(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?ft("truncated-code-geometry"):r,a=Ma(e),o=a.indices,s=a.attributes;return t.call(this,Ra(Ra({},e),{},{id:i,indices:o,attributes:Ra(Ra({},s),e.attributes)}))}return h()(n)}(Oa);function Ma(e){for(var t=e.bottomRadius,n=void 0===t?0:t,r=e.topRadius,i=void 0===r?0:r,a=e.height,o=void 0===a?1:a,s=e.nradial,u=void 0===s?10:s,c=e.nvertical,l=void 0===c?10:c,f=e.verticalAxis,h=void 0===f?"y":f,d=e.topCap,v=void 0!==d&&d,g=e.bottomCap,p=void 0!==g&&g,m=(v?2:0)+(p?2:0),y=(u+1)*(l+1+m),_=Math.atan2(n-i,o),b=Math.sin,A=Math.cos,x=Math.PI,E=A(_),T=b(_),k=v?-2:0,w=l+(p?2:0),O=u+1,S=new Uint16Array(u*(l+m)*6),L=Ca[h],I=new Float32Array(3*y),P=new Float32Array(3*y),R=new Float32Array(2*y),F=0,C=0,B=k;B<=w;B++){var M=B/l,N=o*M,D=void 0;B<0?(N=0,M=1,D=n):B>l?(N=o,M=1,D=i):D=n+B/l*(i-n),-2!==B&&B!==l+2||(D=0,M=0),N-=o/2;for(var j=0;j<O;j++){var U=b(j*x*2/u),G=A(j*x*2/u);I[F+L[0]]=U*D,I[F+L[1]]=N,I[F+L[2]]=G*D,P[F+L[0]]=B<0||B>l?0:U*E,P[F+L[1]]=B<0?-1:B>l?1:T,P[F+L[2]]=B<0||B>l?0:G*E,R[C+0]=j/u,R[C+1]=M,C+=2,F+=3}}for(var V=0;V<l+m;V++)for(var z=0;z<u;z++){var H=6*(V*u+z);S[H+0]=O*(V+0)+0+z,S[H+1]=O*(V+0)+1+z,S[H+2]=O*(V+1)+1+z,S[H+3]=O*(V+0)+0+z,S[H+4]=O*(V+1)+1+z,S[H+5]=O*(V+1)+0+z}return{indices:S,attributes:{POSITION:{size:3,value:I},NORMAL:{size:3,value:P},TEXCOORD_0:{size:2,value:R}}}}function Na(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Da(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Na(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Na(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ja(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Ua=function(e){nt()(n,e);var t=ja(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?ft("cone-geometry"):r,a=e.radius,o=void 0===a?1:a,s=e.cap,u=void 0===s||s;return t.call(this,Da(Da({},e),{},{id:i,topRadius:0,topCap:Boolean(u),bottomCap:Boolean(u),bottomRadius:o}))}return h()(n)}(Ba);function Ga(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Va(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ga(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ga(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function za(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Ha=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),Wa=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),Xa=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),qa=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),Ka={POSITION:{size:3,value:new Float32Array(Wa)},NORMAL:{size:3,value:new Float32Array(Xa)},TEXCOORD_0:{size:2,value:new Float32Array(qa)}},Ya=function(e){nt()(n,e);var t=za(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?ft("cube-geometry"):r;return t.call(this,Va(Va({},e),{},{id:i,indices:{size:1,value:new Uint16Array(Ha)},attributes:Va(Va({},Ka),e.attributes)}))}return h()(n)}(Oa);function Qa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qa(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Za(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Ja=function(e){nt()(n,e);var t=Za(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?ft("cylinder-geometry"):r,a=e.radius,o=void 0===a?1:a;return t.call(this,$a($a({},e),{},{id:i,bottomRadius:o,topRadius:o}))}return h()(n)}(Ba);function eo(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}Math.PI,Math.PI;var to={};function no(e){return Math.round(e/to.EPSILON)*to.EPSILON}function ro(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.precision,r=void 0===n?to.precision||4:n;return e=no(e),"".concat(parseFloat(e.toPrecision(r)))}function io(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ao(e,t,n){var r=to.EPSILON;n&&(to.EPSILON=n);try{if(e===t)return!0;if(io(e)&&io(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!ao(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):!(!Number.isFinite(e)||!Number.isFinite(t))&&Math.abs(e-t)<=to.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{to.EPSILON=r}}function oo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}to.EPSILON=1e-12,to.debug=!1,to.precision=4,to.printTypes=!1,to.printDegrees=!1,to.printRowMajor=!0;var so=function(e){nt()(n,e);var t=oo(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return eo(!1),0}},{key:"clone",value:function(){return(new this.constructor).copy(this)}},{key:"from",value:function(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}},{key:"fromArray",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}},{key:"to",value:function(e){return e===this?this:io(e)?this.toArray(e):this.toObject(e)}},{key:"toTarget",value:function(e){return e?this.to(e):this}},{key:"toArray",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}},{key:"toFloat32Array",value:function(){return new Float32Array(this)}},{key:"toString",value:function(){return this.formatString(to)}},{key:"formatString",value:function(e){for(var t="",n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+ro(this[n],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}},{key:"equals",value:function(e){if(!e||this.length!==e.length)return!1;for(var t=0;t<this.ELEMENTS;++t)if(!ao(this[t],e[t]))return!1;return!0}},{key:"exactEquals",value:function(e){if(!e||this.length!==e.length)return!1;for(var t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}},{key:"negate",value:function(){for(var e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}},{key:"lerp",value:function(e,t,n){void 0===n&&(n=t,t=e,e=this);for(var r=0;r<this.ELEMENTS;++r){var i=e[r];this[r]=i+n*(t[r]-i)}return this.check()}},{key:"min",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}},{key:"max",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}},{key:"clamp",value:function(e,t){for(var n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}},{key:"add",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]+=a[o];return this.check()}},{key:"subtract",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]-=a[o];return this.check()}},{key:"scale",value:function(e){if(Array.isArray(e))return this.multiply(e);for(var t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}},{key:"sub",value:function(e){return this.subtract(e)}},{key:"setScalar",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}},{key:"addScalar",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}},{key:"subScalar",value:function(e){return this.addScalar(-e)}},{key:"multiplyScalar",value:function(e){for(var t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}},{key:"divideScalar",value:function(e){return this.scale(1/e)}},{key:"clampScalar",value:function(e,t){for(var n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}},{key:"multiplyByScalar",value:function(e){return this.scale(e)}},{key:"elements",get:function(){return this}},{key:"check",value:function(){if(to.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}},{key:"validate",value:function(){for(var e=this.length===this.ELEMENTS,t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}}]),n}(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array));function uo(e,t){if(e.length!==t)return!1;for(var n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function co(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function lo(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(to.debug&&!uo(e,t))throw new Error("math.gl: ".concat(n," some fields set to invalid numbers'"));return e}var fo={};function ho(e,t){fo[e]||(fo[e]=!0,console.warn("".concat(e," has been removed in version ").concat(t,", see upgrade guide for more information")))}function vo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var go=function(e){nt()(n,e);var t=vo(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return eo(!1),0}},{key:"copy",value:function(e){return eo(!1),this}},{key:"x",get:function(){return this[0]},set:function(e){this[0]=co(e)}},{key:"y",get:function(){return this[1]},set:function(e){this[1]=co(e)}},{key:"len",value:function(){return Math.sqrt(this.lengthSquared())}},{key:"magnitude",value:function(){return this.len()}},{key:"lengthSquared",value:function(){for(var e=0,t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}},{key:"magnitudeSquared",value:function(){return this.lengthSquared()}},{key:"distance",value:function(e){return Math.sqrt(this.distanceSquared(e))}},{key:"distanceSquared",value:function(e){for(var t=0,n=0;n<this.ELEMENTS;++n){var r=this[n]-e[n];t+=r*r}return co(t)}},{key:"dot",value:function(e){for(var t=0,n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return co(t)}},{key:"normalize",value:function(){var e=this.magnitude();if(0!==e)for(var t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}},{key:"multiply",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]*=a[o];return this.check()}},{key:"divide",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=0,i=t;r<i.length;r++)for(var a=i[r],o=0;o<this.ELEMENTS;++o)this[o]/=a[o];return this.check()}},{key:"lengthSq",value:function(){return this.lengthSquared()}},{key:"distanceTo",value:function(e){return this.distance(e)}},{key:"distanceToSquared",value:function(e){return this.distanceSquared(e)}},{key:"getComponent",value:function(e){return eo(e>=0&&e<this.ELEMENTS,"index is out of range"),co(this[e])}},{key:"setComponent",value:function(e,t){return eo(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}},{key:"addVectors",value:function(e,t){return this.copy(e).add(t)}},{key:"subVectors",value:function(e,t){return this.copy(e).subtract(t)}},{key:"multiplyVectors",value:function(e,t){return this.copy(e).multiply(t)}},{key:"addScaledVector",value:function(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}]),n}(so),po=1e-6,mo="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function yo(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var _o,bo;_o=new mo(3),mo!=Float32Array&&(_o[0]=0,_o[1]=0,_o[2]=0),bo=_o;function Ao(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a||1;return e[0]=(n[0]*r+n[4]*i+n[8]*a)/o,e[1]=(n[1]*r+n[5]*i+n[9]*a)/o,e[2]=(n[2]*r+n[6]*i+n[10]*a)/o,e}function xo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Eo=[0,0,0],To={},ko=function(e){nt()(n,e);var t=xo(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return l()(this,n),e=t.call(this,-0,-0,-0),1===arguments.length&&io(r)?e.copy(r):(to.debug&&(co(r),co(i),co(a)),e[0]=r,e[1]=i,e[2]=a),e}return h()(n,[{key:"set",value:function(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}},{key:"copy",value:function(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}},{key:"fromObject",value:function(e){return to.debug&&(co(e.x),co(e.y),co(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}},{key:"toObject",value:function(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}},{key:"ELEMENTS",get:function(){return 3}},{key:"z",get:function(){return this[2]},set:function(e){this[2]=co(e)}},{key:"angle",value:function(e){return n=e,r=(t=this)[0],i=t[1],a=t[2],o=n[0],s=n[1],u=n[2],c=Math.sqrt(r*r+i*i+a*a)*Math.sqrt(o*o+s*s+u*u),l=c&&function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}(t,n)/c,Math.acos(Math.min(Math.max(l,-1),1));var t,n,r,i,a,o,s,u,c,l}},{key:"cross",value:function(e){return function(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],u=n[2];e[0]=i*u-a*s,e[1]=a*o-r*u,e[2]=r*s-i*o}(this,this,e),this.check()}},{key:"rotateX",value:function(e){var t=e.radians,n=e.origin;return function(e,t,n,r){var i=[],a=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2]}(this,this,void 0===n?Eo:n,t),this.check()}},{key:"rotateY",value:function(e){var t=e.radians,n=e.origin;return function(e,t,n,r){var i=[],a=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2]}(this,this,void 0===n?Eo:n,t),this.check()}},{key:"rotateZ",value:function(e){var t=e.radians,n=e.origin;return function(e,t,n,r){var i=[],a=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2]}(this,this,void 0===n?Eo:n,t),this.check()}},{key:"transform",value:function(e){return this.transformAsPoint(e)}},{key:"transformAsPoint",value:function(e){return yo(this,this,e),this.check()}},{key:"transformAsVector",value:function(e){return Ao(this,this,e),this.check()}},{key:"transformByMatrix3",value:function(e){return function(e,t,n){var r=t[0],i=t[1],a=t[2];e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8]}(this,this,e),this.check()}},{key:"transformByMatrix2",value:function(e){return function(e,t,n){var r=t[0],i=t[1];e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2]}(this,this,e),this.check()}},{key:"transformByQuaternion",value:function(e){return function(e,t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],u=t[1],c=t[2],l=i*c-a*u,f=a*s-r*c,h=r*u-i*s,d=i*h-a*f,v=a*l-r*h,g=r*f-i*l,p=2*o;l*=p,f*=p,h*=p,d*=2,v*=2,g*=2,e[0]=s+l+d,e[1]=u+f+v,e[2]=c+h+g}(this,this,e),this.check()}}],[{key:"ZERO",get:function(){return To.ZERO=To.ZERO||Object.freeze(new n(0,0,0,0))}}]),n}(go);function wo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Oo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wo(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function So(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Lo=[-1,0,0,0,1,0,0,0,-1,0,0,1,0,-1,0,1,0,0],Io=[3,4,5,3,5,1,3,1,0,3,0,4,4,0,2,4,2,5,2,0,1,5,2,1],Po=function(e){nt()(n,e);var t=So(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?ft("ico-sphere-geometry"):r,a=Ro(e),o=a.indices,s=a.attributes;return t.call(this,Oo(Oo({},e),{},{id:i,indices:o,attributes:Oo(Oo({},s),e.attributes)}))}return h()(n)}(Oa);function Ro(e){var t=e.iterations,n=void 0===t?0:t,r=Math.PI,i=2*r,a=[].concat(Lo),o=[].concat(Io);a.push(),o.push();for(var s,u=(s={},function(e,t){var n=(e*=3)>(t*=3)?e:t,r="".concat(e<t?e:t,"|").concat(n);if(r in s)return s[r];var i=a[e],o=a[e+1],u=a[e+2],c=(i+a[t])/2,l=(o+a[t+1])/2,f=(u+a[t+2])/2,h=Math.sqrt(c*c+l*l+f*f);return c/=h,l/=h,f/=h,a.push(c,l,f),s[r]=a.length/3-1}),c=0;c<n;c++){for(var l=[],f=0;f<o.length;f+=3){var h=u(o[f+0],o[f+1]),d=u(o[f+1],o[f+2]),v=u(o[f+2],o[f+0]);l.push(v,o[f+0],h,h,o[f+1],d,d,o[f+2],v,h,d,v)}o=l}for(var g=new Array(a.length),p=new Array(a.length/3*2),m=o.length-3;m>=0;m-=3){var y=o[m+0],_=o[m+1],b=o[m+2],A=3*y,x=3*_,E=3*b,T=2*y,k=2*_,w=2*b,O=a[A+0],S=a[A+1],L=a[A+2],I=Math.acos(L/Math.sqrt(O*O+S*S+L*L))/r,P=1-(Math.atan2(S,O)+r)/i,R=a[x+0],F=a[x+1],C=a[x+2],B=Math.acos(C/Math.sqrt(R*R+F*F+C*C))/r,M=1-(Math.atan2(F,R)+r)/i,N=a[E+0],D=a[E+1],j=a[E+2],U=Math.acos(j/Math.sqrt(N*N+D*D+j*j))/r,G=1-(Math.atan2(D,N)+r)/i,V=[O-R,S-F,L-C],z=new ko([N-R,D-F,j-C]).cross(V).normalize(),H=void 0;(0===P||0===M||0===G)&&(0===P||P>.5)&&(0===M||M>.5)&&(0===G||G>.5)&&(a.push(a[A+0],a[A+1],a[A+2]),H=a.length/3-1,o.push(H),p[2*H+0]=1,p[2*H+1]=I,g[3*H+0]=z.x,g[3*H+1]=z.y,g[3*H+2]=z.z,a.push(a[x+0],a[x+1],a[x+2]),H=a.length/3-1,o.push(H),p[2*H+0]=1,p[2*H+1]=B,g[3*H+0]=z.x,g[3*H+1]=z.y,g[3*H+2]=z.z,a.push(a[E+0],a[E+1],a[E+2]),H=a.length/3-1,o.push(H),p[2*H+0]=1,p[2*H+1]=U,g[3*H+0]=z.x,g[3*H+1]=z.y,g[3*H+2]=z.z),g[A+0]=g[x+0]=g[E+0]=z.x,g[A+1]=g[x+1]=g[E+1]=z.y,g[A+2]=g[x+2]=g[E+2]=z.z,p[T+0]=P,p[T+1]=I,p[k+0]=M,p[k+1]=B,p[w+0]=G,p[w+1]=U}return{indices:{size:1,value:new Uint16Array(o)},attributes:{POSITION:{size:3,value:new Float32Array(a)},NORMAL:{size:3,value:new Float32Array(g)},TEXCOORD_0:{size:2,value:new Float32Array(p)}}}}function Fo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Co(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fo(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Bo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Mo=function(e){nt()(n,e);var t=Bo(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?ft("plane-geometry"):r,a=No(e),o=a.indices,s=a.attributes;return t.call(this,Co(Co({},e),{},{id:i,indices:o,attributes:Co(Co({},s),e.attributes)}))}return h()(n)}(Oa);function No(e){var t=e.type,n=void 0===t?"x,y":t,r=e.offset,i=void 0===r?0:r,a=e.flipCull,o=void 0!==a&&a,s=e.unpack,u=void 0!==s&&s,c=n.split(","),l=e["".concat(c[0],"len")]||1,f=e["".concat(c[1],"len")]||1,h=e["n".concat(c[0])]||1,d=e["n".concat(c[1])]||1,v=(h+1)*(d+1),g=new Float32Array(3*v),p=new Float32Array(3*v),m=new Float32Array(2*v);o&&(l=-l);for(var y=0,_=0,b=0;b<=d;b++)for(var A=0;A<=h;A++){var x=A/h,E=b/d;switch(m[y+0]=o?1-x:x,m[y+1]=E,n){case"x,y":g[_+0]=l*x-.5*l,g[_+1]=f*E-.5*f,g[_+2]=i,p[_+0]=0,p[_+1]=0,p[_+2]=o?1:-1;break;case"x,z":g[_+0]=l*x-.5*l,g[_+1]=i,g[_+2]=f*E-.5*f,p[_+0]=0,p[_+1]=o?1:-1,p[_+2]=0;break;case"y,z":g[_+0]=i,g[_+1]=l*x-.5*l,g[_+2]=f*E-.5*f,p[_+0]=o?1:-1,p[_+1]=0,p[_+2]=0;break;default:throw new Error("PlaneGeometry: unknown type")}y+=2,_+=3}for(var T=h+1,k=new Uint16Array(h*d*6),w=0;w<d;w++)for(var O=0;O<h;O++){var S=6*(w*h+O);k[S+0]=(w+0)*T+O,k[S+1]=(w+1)*T+O,k[S+2]=(w+0)*T+O+1,k[S+3]=(w+1)*T+O,k[S+4]=(w+1)*T+O+1,k[S+5]=(w+0)*T+O+1}var L={indices:{size:1,value:k},attributes:{POSITION:{size:3,value:g},NORMAL:{size:3,value:p},TEXCOORD_0:{size:2,value:m}}};return u?function(e){var t=e.indices,n=e.attributes;if(!t)return e;var r=t.value.length,i={};for(var a in n){var o=n[a],s=o.constant,u=o.value,c=o.size;if(!s&&c){for(var l=new u.constructor(r*c),f=0;f<r;++f)for(var h=t.value[f],d=0;d<c;d++)l[f*c+d]=u[h*c+d];i[a]={size:c,value:l}}}return{attributes:Object.assign({},n,i)}}(L):L}function Do(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function jo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Do(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Do(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Uo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Go=function(e){nt()(n,e);var t=Uo(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l()(this,n);var r=e.id,i=void 0===r?ft("sphere-geometry"):r,a=Vo(e),o=a.indices,s=a.attributes;return t.call(this,jo(jo({},e),{},{id:i,indices:o,attributes:jo(jo({},s),e.attributes)}))}return h()(n)}(Oa);function Vo(e){var t=e.nlat,n=void 0===t?10:t,r=e.nlong,i=void 0===r?10:r,a=e.radius,o=void 0===a?1:a,s=Math.PI-0,u=2*Math.PI-0,c=(n+1)*(i+1);if("number"==typeof o){var l=o;o=function(e,t,n,r,i){return l}}for(var f=new Float32Array(3*c),h=new Float32Array(3*c),d=new Float32Array(2*c),v=new(c>65535?Uint32Array:Uint16Array)(n*i*6),g=0;g<=n;g++)for(var p=0;p<=i;p++){var m=p/i,y=g/n,_=p+g*(i+1),b=2*_,A=3*_,x=u*m,E=s*y,T=Math.sin(x),k=Math.cos(x),w=Math.sin(E),O=k*w,S=Math.cos(E),L=T*w,I=o(O,S,L,m,y);f[A+0]=I*O,f[A+1]=I*S,f[A+2]=I*L,h[A+0]=O,h[A+1]=S,h[A+2]=L,d[b+0]=m,d[b+1]=1-y}for(var P=i+1,R=0;R<i;R++)for(var F=0;F<n;F++){var C=6*(R*n+F);v[C+0]=F*P+R,v[C+1]=F*P+R+1,v[C+2]=(F+1)*P+R,v[C+3]=(F+1)*P+R,v[C+4]=F*P+R+1,v[C+5]=(F+1)*P+R+1}return{indices:{size:1,value:v},attributes:{POSITION:{size:3,value:f},NORMAL:{size:3,value:h},TEXCOORD_0:{size:2,value:d}}}}var zo={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n\n// All these functions are for substituting tan() function from Intel GPU only\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\n\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\n\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\n\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!\n\nfloat sin_taylor_fp32(float a) {\n float r, s, t, x;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n x = -a * a;\n s = a;\n r = a;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_3;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_5;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_7;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_9;\n s = s + t;\n\n return s;\n}\n\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\n if (a == 0.0) {\n sin_t = 0.0;\n cos_t = 1.0;\n }\n sin_t = sin_taylor_fp32(a);\n cos_t = sqrt(1.0 - sin_t * sin_t);\n}\n\nfloat tan_taylor_fp32(float a) {\n float sin_a;\n float cos_a;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n // 2pi range reduction\n float z = floor(a / TWO_PI);\n float r = a - TWO_PI * z;\n\n float t;\n float q = floor(r / PI_2 + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return 1.0 / 0.0;\n }\n\n t = r - PI_2 * q;\n\n q = floor(t / PI_16 + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return 1.0 / 0.0;\n } else {\n t = t - PI_16 * q;\n }\n\n float u = 0.0;\n float v = 0.0;\n\n float sin_t, cos_t;\n float s, c;\n sincos_taylor_fp32(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0;\n v = SIN_TABLE_0;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1;\n v = SIN_TABLE_1;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2;\n v = SIN_TABLE_2;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3;\n v = SIN_TABLE_3;\n }\n if (k > 0) {\n s = u * sin_t + v * cos_t;\n c = u * cos_t - v * sin_t;\n } else {\n s = u * sin_t - v * cos_t;\n c = u * cos_t + v * sin_t;\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return sin_a / cos_a;\n}\n#endif\n\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n return tan_taylor_fp32(a);\n#else\n return tan(a);\n#endif\n}\n",fs:null};function Ho(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=Math.fround(e),i=e-r;return t[n]=r,t[n+1]=i,t}function Wo(e){return e-Math.fround(e)}function Xo(e){for(var t=new Float32Array(32),n=0;n<4;++n)for(var r=0;r<4;++r){var i=4*n+r;Ho(e[4*r+n],t,2*i)}return t}var qo={ONE:1};var Ko={name:"fp64",vs:"const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);\nconst vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);\nconst vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);\nconst vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);\nconst vec2 PI_2_FP64 = vec2(1.5707963705062866, -4.371139006309477e-8);\nconst vec2 PI_4_FP64 = vec2(0.7853981852531433, -2.1855695031547384e-8);\nconst vec2 PI_16_FP64 = vec2(0.19634954631328583, -5.463923757886846e-9);\nconst vec2 PI_16_2_FP64 = vec2(0.39269909262657166, -1.0927847515773692e-8);\nconst vec2 PI_16_3_FP64 = vec2(0.5890486240386963, -1.4906100798128818e-9);\nconst vec2 PI_180_FP64 = vec2(0.01745329238474369, 1.3519960498364902e-10);\n\nconst vec2 SIN_TABLE_0_FP64 = vec2(0.19509032368659973, -1.6704714833615242e-9);\nconst vec2 SIN_TABLE_1_FP64 = vec2(0.3826834261417389, 6.22335089017767e-9);\nconst vec2 SIN_TABLE_2_FP64 = vec2(0.5555702447891235, -1.1769521357507529e-8);\nconst vec2 SIN_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617041793133e-8);\n\nconst vec2 COS_TABLE_0_FP64 = vec2(0.9807852506637573, 2.9739473106360492e-8);\nconst vec2 COS_TABLE_1_FP64 = vec2(0.9238795042037964, 2.8307490351764386e-8);\nconst vec2 COS_TABLE_2_FP64 = vec2(0.8314695954322815, 1.6870263741530778e-8);\nconst vec2 COS_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617152815436e-8);\n\nconst vec2 INVERSE_FACTORIAL_3_FP64 = vec2(1.666666716337204e-01, -4.967053879312289e-09);\nconst vec2 INVERSE_FACTORIAL_4_FP64 = vec2(4.16666679084301e-02, -1.2417634698280722e-09);\nconst vec2 INVERSE_FACTORIAL_5_FP64 = vec2(8.333333767950535e-03, -4.34617203337595e-10);\nconst vec2 INVERSE_FACTORIAL_6_FP64 = vec2(1.3888889225199819e-03, -3.3631094437103215e-11);\nconst vec2 INVERSE_FACTORIAL_7_FP64 = vec2(1.9841270113829523e-04, -2.725596874933456e-12);\nconst vec2 INVERSE_FACTORIAL_8_FP64 = vec2(2.4801587642286904e-05, -3.406996025904184e-13);\nconst vec2 INVERSE_FACTORIAL_9_FP64 = vec2(2.75573188446287533e-06, 3.7935713937038186e-14);\nconst vec2 INVERSE_FACTORIAL_10_FP64 = vec2(2.755731998149713e-07, -7.575112367869873e-15);\n\nfloat nint(float d) {\n if (d == floor(d)) return d;\n return floor(d + 0.5);\n}\n\nvec2 nint_fp64(vec2 a) {\n float hi = nint(a.x);\n float lo;\n vec2 tmp;\n if (hi == a.x) {\n lo = nint(a.y);\n tmp = quickTwoSum(hi, lo);\n } else {\n lo = 0.0;\n if (abs(hi - a.x) == 0.5 && a.y < 0.0) {\n hi -= 1.0;\n }\n tmp = vec2(hi, lo);\n }\n return tmp;\n}\n\nvec2 exp_fp64(vec2 a) {\n\n const int k_power = 4;\n const float k = 16.0;\n\n const float inv_k = 1.0 / k;\n\n if (a.x <= -88.0) return vec2(0.0, 0.0);\n if (a.x >= 88.0) return vec2(1.0 / 0.0, 1.0 / 0.0);\n if (a.x == 0.0 && a.y == 0.0) return vec2(1.0, 0.0);\n if (a.x == 1.0 && a.y == 0.0) return E_FP64;\n\n float m = floor(a.x / LOG2_FP64.x + 0.5);\n vec2 r = sub_fp64(a, mul_fp64(LOG2_FP64, vec2(m, 0.0))) * inv_k;\n vec2 s, t, p;\n\n p = mul_fp64(r, r);\n s = sum_fp64(r, p * 0.5);\n p = mul_fp64(p, r);\n t = mul_fp64(p, INVERSE_FACTORIAL_3_FP64);\n\n s = sum_fp64(s, t);\n p = mul_fp64(p, r);\n t = mul_fp64(p, INVERSE_FACTORIAL_4_FP64);\n\n s = sum_fp64(s, t);\n p = mul_fp64(p, r);\n t = mul_fp64(p, INVERSE_FACTORIAL_5_FP64);\n\n\n\n\n\n\n s = sum_fp64(s, t);\n for (int i = 0; i < k_power; i++) {\n s = sum_fp64(s * 2.0, mul_fp64(s, s));\n }\n\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n s = sum_fp64(s, vec2(ONE, 0.0));\n#else\n s = sum_fp64(s, vec2(1.0, 0.0));\n#endif\n\n return s * pow(2.0, m);\n}\n\nvec2 log_fp64(vec2 a)\n{\n if (a.x == 1.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x <= 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n vec2 x = vec2(log(a.x), 0.0);\n vec2 s;\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n s = vec2(ONE, 0.0);\n#else\n s = vec2(1.0, 0.0);\n#endif\n\n x = sub_fp64(sum_fp64(x, mul_fp64(a, exp_fp64(-x))), s);\n return x;\n}\n\nvec2 sin_taylor_fp64(vec2 a) {\n vec2 r, s, t, x;\n\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(0.0, 0.0);\n }\n\n x = -mul_fp64(a, a);\n s = a;\n r = a;\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_3_FP64);\n s = sum_fp64(s, t);\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_5_FP64);\n s = sum_fp64(s, t);\n\n\n\n\n\n\n return s;\n}\n\nvec2 cos_taylor_fp64(vec2 a) {\n vec2 r, s, t, x;\n\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(1.0, 0.0);\n }\n\n x = -mul_fp64(a, a);\n r = x;\n s = sum_fp64(vec2(1.0, 0.0), r * 0.5);\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_4_FP64);\n s = sum_fp64(s, t);\n\n r = mul_fp64(r, x);\n t = mul_fp64(r, INVERSE_FACTORIAL_6_FP64);\n s = sum_fp64(s, t);\n\n\n\n\n\n\n return s;\n}\n\nvoid sincos_taylor_fp64(vec2 a, out vec2 sin_t, out vec2 cos_t) {\n if (a.x == 0.0 && a.y == 0.0) {\n sin_t = vec2(0.0, 0.0);\n cos_t = vec2(1.0, 0.0);\n }\n\n sin_t = sin_taylor_fp64(a);\n cos_t = sqrt_fp64(sub_fp64(vec2(1.0, 0.0), mul_fp64(sin_t, sin_t)));\n}\n\nvec2 sin_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(0.0, 0.0);\n }\n vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));\n vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));\n\n vec2 t;\n float q = floor(r.x / PI_2_FP64.x + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n }\n\n t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));\n\n q = floor(t.x / PI_16_FP64.x + 0.5);\n int k = int(q);\n\n if (k == 0) {\n if (j == 0) {\n return sin_taylor_fp64(t);\n } else if (j == 1) {\n return cos_taylor_fp64(t);\n } else if (j == -1) {\n return -cos_taylor_fp64(t);\n } else {\n return -sin_taylor_fp64(t);\n }\n }\n\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n } else {\n t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));\n }\n\n vec2 u = vec2(0.0, 0.0);\n vec2 v = vec2(0.0, 0.0);\n\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#else\n if (abs_k == 1) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs_k == 2) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs_k == 3) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs_k == 4) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#endif\n\n vec2 sin_t, cos_t;\n sincos_taylor_fp64(t, sin_t, cos_t);\n\n\n\n vec2 result = vec2(0.0, 0.0);\n if (j == 0) {\n if (k > 0) {\n result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n }\n } else if (j == 1) {\n if (k > 0) {\n result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n } else {\n result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n } else if (j == -1) {\n if (k > 0) {\n result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));\n } else {\n result = -sum_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));\n }\n } else {\n if (k > 0) {\n result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));\n }\n }\n\n return result;\n}\n\nvec2 cos_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(1.0, 0.0);\n }\n vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));\n vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));\n\n vec2 t;\n float q = floor(r.x / PI_2_FP64.x + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n }\n\n t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));\n\n q = floor(t.x / PI_16_FP64.x + 0.5);\n int k = int(q);\n\n if (k == 0) {\n if (j == 0) {\n return cos_taylor_fp64(t);\n } else if (j == 1) {\n return -sin_taylor_fp64(t);\n } else if (j == -1) {\n return sin_taylor_fp64(t);\n } else {\n return -cos_taylor_fp64(t);\n }\n }\n\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n } else {\n t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));\n }\n\n vec2 u = vec2(0.0, 0.0);\n vec2 v = vec2(0.0, 0.0);\n\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#else\n if (abs_k == 1) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs_k == 2) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs_k == 3) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs_k == 4) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#endif\n\n vec2 sin_t, cos_t;\n sincos_taylor_fp64(t, sin_t, cos_t);\n\n vec2 result = vec2(0.0, 0.0);\n if (j == 0) {\n if (k > 0) {\n result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n } else {\n result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n } else if (j == 1) {\n if (k > 0) {\n result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));\n }\n } else if (j == -1) {\n if (k > 0) {\n result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n } else {\n result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n }\n } else {\n if (k > 0) {\n result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));\n } else {\n result = -sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n }\n\n return result;\n}\n\nvec2 tan_fp64(vec2 a) {\n vec2 sin_a;\n vec2 cos_a;\n\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2(0.0, 0.0);\n }\n vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));\n vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));\n\n vec2 t;\n float q = floor(r.x / PI_2_FP64.x + 0.5);\n int j = int(q);\n\n\n if (j < -2 || j > 2) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n }\n\n t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));\n\n q = floor(t.x / PI_16_FP64.x + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return vec2(0.0 / 0.0, 0.0 / 0.0);\n } else {\n t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));\n }\n\n\n vec2 u = vec2(0.0, 0.0);\n vec2 v = vec2(0.0, 0.0);\n\n vec2 sin_t, cos_t;\n vec2 s, c;\n sincos_taylor_fp64(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#else\n if (abs_k == 1) {\n u = COS_TABLE_0_FP64;\n v = SIN_TABLE_0_FP64;\n } else if (abs_k == 2) {\n u = COS_TABLE_1_FP64;\n v = SIN_TABLE_1_FP64;\n } else if (abs_k == 3) {\n u = COS_TABLE_2_FP64;\n v = SIN_TABLE_2_FP64;\n } else if (abs_k == 4) {\n u = COS_TABLE_3_FP64;\n v = SIN_TABLE_3_FP64;\n }\n#endif\n if (k > 0) {\n s = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n c = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n } else {\n s = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));\n c = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return div_fp64(sin_a, cos_a);\n}\n\nvec2 radians_fp64(vec2 degree) {\n return mul_fp64(degree, PI_180_FP64);\n}\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid vec2_sum_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = sum_fp64(a[0], b[0]);\n out_val[1] = sum_fp64(a[1], b[1]);\n}\n\nvoid vec2_sub_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = sub_fp64(a[0], b[0]);\n out_val[1] = sub_fp64(a[1], b[1]);\n}\n\nvoid vec2_mul_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = mul_fp64(a[0], b[0]);\n out_val[1] = mul_fp64(a[1], b[1]);\n}\n\nvoid vec2_div_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {\n out_val[0] = div_fp64(a[0], b[0]);\n out_val[1] = div_fp64(a[1], b[1]);\n}\n\nvoid vec2_mix_fp64(vec2 x[2], vec2 y[2], float a, out vec2 out_val[2]) {\n vec2 range[2];\n vec2_sub_fp64(y, x, range);\n vec2 portion[2];\n portion[0] = range[0] * a;\n portion[1] = range[1] * a;\n vec2_sum_fp64(x, portion, out_val);\n}\n\nvec2 vec2_length_fp64(vec2 x[2]) {\n return sqrt_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])));\n}\n\nvoid vec2_normalize_fp64(vec2 x[2], out vec2 out_val[2]) {\n vec2 length = vec2_length_fp64(x);\n vec2 length_vec2[2];\n length_vec2[0] = length;\n length_vec2[1] = length;\n\n vec2_div_fp64(x, length_vec2, out_val);\n}\n\nvec2 vec2_distance_fp64(vec2 x[2], vec2 y[2]) {\n vec2 diff[2];\n vec2_sub_fp64(x, y, diff);\n return vec2_length_fp64(diff);\n}\n\nvec2 vec2_dot_fp64(vec2 a[2], vec2 b[2]) {\n vec2 v[2];\n\n v[0] = mul_fp64(a[0], b[0]);\n v[1] = mul_fp64(a[1], b[1]);\n\n return sum_fp64(v[0], v[1]);\n}\nvoid vec3_sub_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {\n for (int i = 0; i < 3; i++) {\n out_val[i] = sum_fp64(a[i], b[i]);\n }\n}\n\nvoid vec3_sum_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {\n for (int i = 0; i < 3; i++) {\n out_val[i] = sum_fp64(a[i], b[i]);\n }\n}\n\nvec2 vec3_length_fp64(vec2 x[3]) {\n return sqrt_fp64(sum_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])),\n mul_fp64(x[2], x[2])));\n}\n\nvec2 vec3_distance_fp64(vec2 x[3], vec2 y[3]) {\n vec2 diff[3];\n vec3_sub_fp64(x, y, diff);\n return vec3_length_fp64(diff);\n}\nvoid vec4_fp64(vec4 a, out vec2 out_val[4]) {\n out_val[0].x = a[0];\n out_val[0].y = 0.0;\n\n out_val[1].x = a[1];\n out_val[1].y = 0.0;\n\n out_val[2].x = a[2];\n out_val[2].y = 0.0;\n\n out_val[3].x = a[3];\n out_val[3].y = 0.0;\n}\n\nvoid vec4_scalar_mul_fp64(vec2 a[4], vec2 b, out vec2 out_val[4]) {\n out_val[0] = mul_fp64(a[0], b);\n out_val[1] = mul_fp64(a[1], b);\n out_val[2] = mul_fp64(a[2], b);\n out_val[3] = mul_fp64(a[3], b);\n}\n\nvoid vec4_sum_fp64(vec2 a[4], vec2 b[4], out vec2 out_val[4]) {\n for (int i = 0; i < 4; i++) {\n out_val[i] = sum_fp64(a[i], b[i]);\n }\n}\n\nvoid vec4_dot_fp64(vec2 a[4], vec2 b[4], out vec2 out_val) {\n vec2 v[4];\n\n v[0] = mul_fp64(a[0], b[0]);\n v[1] = mul_fp64(a[1], b[1]);\n v[2] = mul_fp64(a[2], b[2]);\n v[3] = mul_fp64(a[3], b[3]);\n\n out_val = sum_fp64(sum_fp64(v[0], v[1]), sum_fp64(v[2], v[3]));\n}\n\nvoid mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {\n vec2 tmp[4];\n\n for (int i = 0; i < 4; i++)\n {\n for (int j = 0; j < 4; j++)\n {\n tmp[j] = b[j + i * 4];\n }\n vec4_dot_fp64(a, tmp, out_val[i]);\n }\n}\n",fs:null,dependencies:[{name:"fp64-arithmetic",vs:"uniform float ONE;\nvec2 split(float a) {\n const float SPLIT = 4097.0;\n float t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float a_hi = t * ONE - (t - a);\n float a_lo = a * ONE - a_hi;\n#else\n float a_hi = t - (t - a);\n float a_lo = a - a_hi;\n#endif\n return vec2(a_hi, a_lo);\n}\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * ONE;\n float err = b - (sum - a) * ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * ONE - a) * ONE;\n float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * ONE - a) * ONE;\n float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *\n a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\n a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",fs:null,getUniforms:function(){return qo},fp64ify:Ho,fp64LowPart:Wo,fp64ifyMatrix4:Xo}],fp64ify:Ho,fp64LowPart:Wo,fp64ifyMatrix4:Xo};function Yo(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var Qo=function(e){nt()(n,e);var t=Yo(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return eo(!1),0}},{key:"RANK",get:function(){return eo(!1),0}},{key:"toString",value:function(){var e="[";if(to.printRowMajor){e+="row-major:";for(var t=0;t<this.RANK;++t)for(var n=0;n<this.RANK;++n)e+=" ".concat(this[n*this.RANK+t])}else{e+="column-major:";for(var r=0;r<this.ELEMENTS;++r)e+=" ".concat(this[r])}return e+="]"}},{key:"getElementIndex",value:function(e,t){return t*this.RANK+e}},{key:"getElement",value:function(e,t){return this[t*this.RANK+e]}},{key:"setElement",value:function(e,t,n){return this[t*this.RANK+e]=co(n),this}},{key:"getColumn",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Array(this.RANK).fill(-0),n=e*this.RANK,r=0;r<this.RANK;++r)t[r]=this[n+r];return t}},{key:"setColumn",value:function(e,t){for(var n=e*this.RANK,r=0;r<this.RANK;++r)this[n+r]=t[r];return this}}]),n}(so);function $o(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],f=t[8],h=t[9],d=t[10],v=t[11],g=t[12],p=t[13],m=t[14],y=t[15],_=n[0],b=n[1],A=n[2],x=n[3];return e[0]=_*r+b*s+A*f+x*g,e[1]=_*i+b*u+A*h+x*p,e[2]=_*a+b*c+A*d+x*m,e[3]=_*o+b*l+A*v+x*y,_=n[4],b=n[5],A=n[6],x=n[7],e[4]=_*r+b*s+A*f+x*g,e[5]=_*i+b*u+A*h+x*p,e[6]=_*a+b*c+A*d+x*m,e[7]=_*o+b*l+A*v+x*y,_=n[8],b=n[9],A=n[10],x=n[11],e[8]=_*r+b*s+A*f+x*g,e[9]=_*i+b*u+A*h+x*p,e[10]=_*a+b*c+A*d+x*m,e[11]=_*o+b*l+A*v+x*y,_=n[12],b=n[13],A=n[14],x=n[15],e[12]=_*r+b*s+A*f+x*g,e[13]=_*i+b*u+A*h+x*p,e[14]=_*a+b*c+A*d+x*m,e[15]=_*o+b*l+A*v+x*y,e}function Zo(e,t,n){var r=n[0],i=n[1],a=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Jo(e,t,n,r,i){var a,o=1/Math.tan(t/2);return e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(a=1/(r-i),e[10]=(i+r)*a,e[14]=2*i*r*a):(e[10]=-1,e[14]=-2*r),e}function es(e,t,n,r){var i,a,o,s,u,c,l,f,h,d,v=t[0],g=t[1],p=t[2],m=r[0],y=r[1],_=r[2],b=n[0],A=n[1],x=n[2];return Math.abs(v-b)<po&&Math.abs(g-A)<po&&Math.abs(p-x)<po?function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(e):(l=v-b,f=g-A,h=p-x,i=y*(h*=d=1/Math.hypot(l,f,h))-_*(f*=d),a=_*(l*=d)-m*h,o=m*f-y*l,(d=Math.hypot(i,a,o))?(i*=d=1/d,a*=d,o*=d):(i=0,a=0,o=0),s=f*o-h*a,u=h*i-l*o,c=l*a-f*i,(d=Math.hypot(s,u,c))?(s*=d=1/d,u*=d,c*=d):(s=0,u=0,c=0),e[0]=i,e[1]=s,e[2]=l,e[3]=0,e[4]=a,e[5]=u,e[6]=f,e[7]=0,e[8]=o,e[9]=c,e[10]=h,e[11]=0,e[12]=-(i*v+a*g+o*p),e[13]=-(s*v+u*g+c*p),e[14]=-(l*v+f*g+h*p),e[15]=1,e)}!function(){var e=function(){var e=new mo(2);return mo!=Float32Array&&(e[0]=0,e[1]=0),e}()}();!function(){var e=function(){var e=new mo(4);return mo!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();function ts(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ot()(e);if(t){var i=ot()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return it()(this,n)}}var ns=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),rs=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),is=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL0ROW3:3,COL1ROW0:4,COL1ROW1:5,COL1ROW2:6,COL1ROW3:7,COL2ROW0:8,COL2ROW1:9,COL2ROW2:10,COL2ROW3:11,COL3ROW0:12,COL3ROW1:13,COL3ROW2:14,COL3ROW3:15}),as={},os=function(e){nt()(n,e);var t=ts(n);function n(e){var r;return l()(this,n),r=t.call(this,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?r.copy(e):r.identity(),r}return h()(n,[{key:"INDICES",get:function(){return is}},{key:"ELEMENTS",get:function(){return 16}},{key:"RANK",get:function(){return 4}},{key:"copy",value:function(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}},{key:"set",value:function(e,t,n,r,i,a,o,s,u,c,l,f,h,d,v,g){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=u,this[9]=c,this[10]=l,this[11]=f,this[12]=h,this[13]=d,this[14]=v,this[15]=g,this.check()}},{key:"setRowMajor",value:function(e,t,n,r,i,a,o,s,u,c,l,f,h,d,v,g){return this[0]=e,this[1]=i,this[2]=u,this[3]=h,this[4]=t,this[5]=a,this[6]=c,this[7]=d,this[8]=n,this[9]=o,this[10]=l,this[11]=v,this[12]=r,this[13]=s,this[14]=f,this[15]=g,this.check()}},{key:"toRowMajor",value:function(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}},{key:"identity",value:function(){return this.copy(ns)}},{key:"fromQuaternion",value:function(e){return function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,u=i+i,c=n*o,l=r*o,f=r*s,h=i*o,d=i*s,v=i*u,g=a*o,p=a*s,m=a*u;e[0]=1-f-v,e[1]=l+m,e[2]=h-p,e[3]=0,e[4]=l-m,e[5]=1-c-v,e[6]=d+g,e[7]=0,e[8]=h+p,e[9]=d-g,e[10]=1-c-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}},{key:"frustum",value:function(e){var t=e.left,r=e.right,i=e.bottom,a=e.top,o=e.near,s=e.far;return s===1/0?n._computeInfinitePerspectiveOffCenter(this,t,r,i,a,o):function(e,t,n,r,i,a,o){var s=1/(n-t),u=1/(i-r),c=1/(a-o);e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*u,e[10]=(o+a)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*c,e[15]=0}(this,t,r,i,a,o,s),this.check()}},{key:"lookAt",value:function(e,t,n){if(1===arguments.length){var r=e;e=r.eye,t=r.center,n=r.up}return es(this,e,t=t||[0,0,0],n=n||[0,1,0]),this.check()}},{key:"ortho",value:function(e){var t=e.left,n=e.right,r=e.bottom,i=e.top,a=e.near,o=void 0===a?.1:a,s=e.far;return function(e,t,n,r,i,a,o){var s=1/(t-n),u=1/(r-i),c=1/(a-o);e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*u,e[14]=(o+a)*c,e[15]=1}(this,t,n,r,i,o,void 0===s?500:s),this.check()}},{key:"orthographic",value:function(e){var t=e.fovy,r=void 0===t?45*Math.PI/180:t,i=e.aspect,a=void 0===i?1:i,o=e.focalDistance,s=void 0===o?1:o,u=e.near,c=void 0===u?.1:u,l=e.far,f=void 0===l?500:l;if(r>2*Math.PI)throw Error("radians");var h=r/2,d=s*Math.tan(h),v=d*a;return(new n).ortho({left:-v,right:v,bottom:-d,top:d,near:c,far:f})}},{key:"perspective",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.fovy,n=void 0===t?void 0:t,r=e.fov,i=void 0===r?45*Math.PI/180:r,a=e.aspect,o=void 0===a?1:a,s=e.near,u=void 0===s?.1:s,c=e.far,l=void 0===c?500:c;if((n=n||i)>2*Math.PI)throw Error("radians");return Jo(this,n,o,u,l),this.check()}},{key:"determinant",value:function(){return t=(e=this)[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],c=e[8],l=e[9],f=e[10],h=e[11],d=e[12],v=e[13],g=e[14],p=e[15],(t*o-n*a)*(f*p-h*g)-(t*s-r*a)*(l*p-h*v)+(t*u-i*a)*(l*g-f*v)+(n*s-r*o)*(c*p-h*d)-(n*u-i*o)*(c*g-f*d)+(r*u-i*s)*(c*v-l*d);var e,t,n,r,i,a,o,s,u,c,l,f,h,d,v,g,p}},{key:"getScale",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0];return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}},{key:"getTranslation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0];return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}},{key:"getRotation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getScale(t||[-0,-0,-0]),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}},{key:"getRotationMatrix3",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getScale(t||[-0,-0,-0]),r=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*a,e}},{key:"transpose",value:function(){return function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15]}(this,this),this.check()}},{key:"invert",value:function(){return function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],c=t[7],l=t[8],f=t[9],h=t[10],d=t[11],v=t[12],g=t[13],p=t[14],m=t[15],y=n*s-r*o,_=n*u-i*o,b=n*c-a*o,A=r*u-i*s,x=r*c-a*s,E=i*c-a*u,T=l*g-f*v,k=l*p-h*v,w=l*m-d*v,O=f*p-h*g,S=f*m-d*g,L=h*m-d*p,I=y*L-_*S+b*O+A*w-x*k+E*T;I&&(I=1/I,e[0]=(s*L-u*S+c*O)*I,e[1]=(i*S-r*L-a*O)*I,e[2]=(g*E-p*x+m*A)*I,e[3]=(h*x-f*E-d*A)*I,e[4]=(u*w-o*L-c*k)*I,e[5]=(n*L-i*w+a*k)*I,e[6]=(p*b-v*E-m*_)*I,e[7]=(l*E-h*b+d*_)*I,e[8]=(o*S-s*w+c*T)*I,e[9]=(r*w-n*S-a*T)*I,e[10]=(v*x-g*b+m*y)*I,e[11]=(f*b-l*x-d*y)*I,e[12]=(s*k-o*O-u*T)*I,e[13]=(n*O-r*k+i*T)*I,e[14]=(g*_-v*A-p*y)*I,e[15]=(l*A-f*_+h*y)*I)}(this,this),this.check()}},{key:"multiplyLeft",value:function(e){return $o(this,e,this),this.check()}},{key:"multiplyRight",value:function(e){return $o(this,this,e),this.check()}},{key:"rotateX",value:function(e){return function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],u=t[7],c=t[8],l=t[9],f=t[10],h=t[11];t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*i+c*r,e[5]=o*i+l*r,e[6]=s*i+f*r,e[7]=u*i+h*r,e[8]=c*i-a*r,e[9]=l*i-o*r,e[10]=f*i-s*r,e[11]=h*i-u*r}(this,this,e),this.check()}},{key:"rotateY",value:function(e){return function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],u=t[3],c=t[8],l=t[9],f=t[10],h=t[11];t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i-c*r,e[1]=o*i-l*r,e[2]=s*i-f*r,e[3]=u*i-h*r,e[8]=a*r+c*i,e[9]=o*r+l*i,e[10]=s*r+f*i,e[11]=u*r+h*i}(this,this,e),this.check()}},{key:"rotateZ",value:function(e){return function(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],u=t[3],c=t[4],l=t[5],f=t[6],h=t[7];t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i+c*r,e[1]=o*i+l*r,e[2]=s*i+f*r,e[3]=u*i+h*r,e[4]=c*i-a*r,e[5]=l*i-o*r,e[6]=f*i-s*r,e[7]=h*i-u*r}(this,this,e),this.check()}},{key:"rotateXYZ",value:function(e){var t=ie()(e,3),n=t[0],r=t[1],i=t[2];return this.rotateX(n).rotateY(r).rotateZ(i)}},{key:"rotateAxis",value:function(e,t){return function(e,t,n,r){var i,a,o,s,u,c,l,f,h,d,v,g,p,m,y,_,b,A,x,E,T,k,w,O,S=r[0],L=r[1],I=r[2],P=Math.hypot(S,L,I);P<po||(S*=P=1/P,L*=P,I*=P,i=Math.sin(n),o=1-(a=Math.cos(n)),s=t[0],u=t[1],c=t[2],l=t[3],f=t[4],h=t[5],d=t[6],v=t[7],g=t[8],p=t[9],m=t[10],y=t[11],_=S*S*o+a,b=L*S*o+I*i,A=I*S*o-L*i,x=S*L*o-I*i,E=L*L*o+a,T=I*L*o+S*i,k=S*I*o+L*i,w=L*I*o-S*i,O=I*I*o+a,e[0]=s*_+f*b+g*A,e[1]=u*_+h*b+p*A,e[2]=c*_+d*b+m*A,e[3]=l*_+v*b+y*A,e[4]=s*x+f*E+g*T,e[5]=u*x+h*E+p*T,e[6]=c*x+d*E+m*T,e[7]=l*x+v*E+y*T,e[8]=s*k+f*w+g*O,e[9]=u*k+h*w+p*O,e[10]=c*k+d*w+m*O,e[11]=l*k+v*w+y*O,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}},{key:"scale",value:function(e){return Array.isArray(e)?Zo(this,this,e):Zo(this,this,[e,e,e]),this.check()}},{key:"translate",value:function(e){return function(e,t,n){var r,i,a,o,s,u,c,l,f,h,d,v,g=n[0],p=n[1],m=n[2];t===e?(e[12]=t[0]*g+t[4]*p+t[8]*m+t[12],e[13]=t[1]*g+t[5]*p+t[9]*m+t[13],e[14]=t[2]*g+t[6]*p+t[10]*m+t[14],e[15]=t[3]*g+t[7]*p+t[11]*m+t[15]):(r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],f=t[8],h=t[9],d=t[10],v=t[11],e[0]=r,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=u,e[6]=c,e[7]=l,e[8]=f,e[9]=h,e[10]=d,e[11]=v,e[12]=r*g+s*p+f*m+t[12],e[13]=i*g+u*p+h*m+t[13],e[14]=a*g+c*p+d*m+t[14],e[15]=o*g+l*p+v*m+t[15])}(this,this,e),this.check()}},{key:"transform",value:function(e,t){return 4===e.length?(lo(t=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}},{key:"transformAsPoint",value:function(e,t){switch(e.length){case 2:t=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e}(t||[-0,-0],e,this);break;case 3:t=yo(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return lo(t,e.length),t}},{key:"transformAsVector",value:function(e,t){switch(e.length){case 2:t=function(e,t,n){var r=t[0],i=t[1],a=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/a,e[1]=(n[1]*r+n[5]*i)/a,e}(t||[-0,-0],e,this);break;case 3:t=Ao(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return lo(t,e.length),t}},{key:"makeRotationX",value:function(e){return this.identity().rotateX(e)}},{key:"makeTranslation",value:function(e,t,n){return this.identity().translate([e,t,n])}},{key:"transformPoint",value:function(e,t){return ho("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}},{key:"transformVector",value:function(e,t){return ho("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}},{key:"transformDirection",value:function(e,t){return ho("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}],[{key:"IDENTITY",get:function(){return as.IDENTITY=as.IDENTITY||Object.freeze(new n(ns)),as.IDENTITY}},{key:"ZERO",get:function(){return as.ZERO=as.ZERO||Object.freeze(new n(rs)),as.ZERO}},{key:"_computeInfinitePerspectiveOffCenter",value:function(e,t,n,r,i,a){var o=2*a/(n-t),s=2*a/(i-r),u=(n+t)/(n-t),c=(i+r)/(i-r),l=-2*a;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=u,e[9]=c,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=l,e[15]=0,e}}]),n}(Qo),ss=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],us={modelMatrix:ss,viewMatrix:ss,projectionMatrix:ss,cameraPositionWorld:[0,0,0]};var cs="varying vec4 project_vPositionWorld;\nvarying vec3 project_vNormalWorld;\n\nvec4 project_getPosition_World() {\n return project_vPositionWorld;\n}\n\nvec3 project_getNormal_World() {\n return project_vNormalWorld;\n}\n",ls={name:"project",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:us,t={};return void 0!==e.modelMatrix&&(t.modelMatrix=e.modelMatrix),void 0!==e.viewMatrix&&(t.viewMatrix=e.viewMatrix),void 0!==e.projectionMatrix&&(t.projectionMatrix=e.projectionMatrix),void 0!==e.cameraPositionWorld&&(t.cameraPositionWorld=e.cameraPositionWorld),void 0===e.projectionMatrix&&void 0===e.viewMatrix||(t.viewProjectionMatrix=new os(e.projectionMatrix).multiplyRight(e.viewMatrix)),t},vs:"".concat(cs,"\n\n// Unprefixed uniforms\nuniform mat4 modelMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewProjectionMatrix;\nuniform vec3 cameraPositionWorld;\n\nstruct World {\n vec3 position;\n vec3 normal;\n};\n\nWorld world;\n\nvoid project_setPosition(vec4 position) {\n project_vPositionWorld = position;\n}\n\nvoid project_setNormal(vec3 normal) {\n project_vNormalWorld = normal;\n}\n\nvoid project_setPositionAndNormal_World(vec3 position, vec3 normal) {\n world.position = position;\n world.normal = normal;\n}\n\nvoid project_setPositionAndNormal_Model(vec3 position, vec3 normal) {\n world.position = (modelMatrix * vec4(position, 1.)).xyz;\n world.normal = mat3(modelMatrix) * normal;\n}\n\nvec4 project_model_to_clipspace(vec4 position) {\n return viewProjectionMatrix * modelMatrix * position;\n}\n\nvec4 project_model_to_clipspace(vec3 position) {\n return viewProjectionMatrix * modelMatrix * vec4(position, 1.);\n}\n\nvec4 project_world_to_clipspace(vec3 position) {\n return viewProjectionMatrix * vec4(position, 1.);\n}\n\nvec4 project_view_to_clipspace(vec3 position) {\n return projectionMatrix * vec4(position, 1.);\n}\n\nvec4 project_to_clipspace(vec3 position) {\n return viewProjectionMatrix * vec4(position, 1.);\n}\n"),fs:"\n".concat(cs)},fs={lightDirection:new Float32Array([1,1,2])};var hs={name:"dirlight",vs:null,fs:"uniform vec3 dirlight_uLightDirection;\n\n/*\n * Returns color attenuated by angle from light source\n */\nvec4 dirlight_filterColor(vec4 color) {\n vec3 normal = project_getNormal_World();\n float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));\n return vec4(color.rgb * d, color.a);\n}\n",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:fs,t={};return e.lightDirection&&(t.dirlight_uLightDirection=e.lightDirection),t},dependencies:[ls]},ds={pickingSelectedColor:null,pickingHighlightColor:new Uint8Array([0,255,255,255]),pickingActive:!1,pickingAttribute:!1};var vs={name:"picking",vs:"uniform bool picking_uActive;\nuniform bool picking_uAttribute;\nuniform vec3 picking_uSelectedColor;\nuniform bool picking_uSelectedColorValid;\n\nout vec4 picking_vRGBcolor_Avalid;\n\nconst float COLOR_SCALE = 1. / 255.;\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.001;\n}\n\nbool isVertexPicked(vec3 vertexColor) {\n return\n picking_uSelectedColorValid &&\n !picking_isColorValid(abs(vertexColor - picking_uSelectedColor));\n}\n\nvoid picking_setPickingColor(vec3 pickingColor) {\n if (picking_uActive) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!picking_uAttribute) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor * COLOR_SCALE;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexPicked(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\nvoid picking_setPickingAttribute(vec2 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\nvoid picking_setPickingAttribute(vec3 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"uniform bool picking_uActive;\nuniform vec3 picking_uSelectedColor;\nuniform vec4 picking_uHighlightColor;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n if (picking_uActive) {\n return color;\n }\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n float highLightAlpha = picking_uHighlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking_uHighlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (picking_uActive) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highightColor);\n}\n\n",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ds,t={};if(void 0!==e.pickingSelectedColor)if(e.pickingSelectedColor){var n=e.pickingSelectedColor.slice(0,3);t.picking_uSelectedColorValid=1,t.picking_uSelectedColor=n}else t.picking_uSelectedColorValid=0;if(e.pickingHighlightColor){var r=Array.from(e.pickingHighlightColor,(function(e){return e/255}));Number.isFinite(r[3])||(r[3]=1),t.picking_uHighlightColor=r}return void 0!==e.pickingActive&&(t.picking_uActive=Boolean(e.pickingActive),t.picking_uAttribute=Boolean(e.pickingAttribute)),t}},gs="#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n";function ps(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ms(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ms(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ms(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ys={lightSources:{}};function _s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.color,n=void 0===t?[0,0,0]:t,r=e.intensity,i=void 0===r?1:r;return n.map((function(e){return e*i/255}))}function bs(e){var t=e.ambientLight,n=e.pointLights,r=void 0===n?[]:n,i=e.directionalLights,a=void 0===i?[]:i,o={};return o["lighting_uAmbientLight.color"]=t?_s(t):[0,0,0],r.forEach((function(e,t){o["lighting_uPointLight[".concat(t,"].color")]=_s(e),o["lighting_uPointLight[".concat(t,"].position")]=e.position,o["lighting_uPointLight[".concat(t,"].attenuation")]=e.attenuation||[1,0,0]})),o.lighting_uPointLightCount=r.length,a.forEach((function(e,t){o["lighting_uDirectionalLight[".concat(t,"].color")]=_s(e),o["lighting_uDirectionalLight[".concat(t,"].direction")]=e.direction})),o.lighting_uDirectionalLightCount=a.length,o}var As={name:"lights",vs:gs,fs:gs,getUniforms:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ys;if("lightSources"in t){var n=t.lightSources||{},r=n.ambientLight,i=n.pointLights,a=n.directionalLights,o=r||i&&i.length>0||a&&a.length>0;return o?Object.assign({},bs({ambientLight:r,pointLights:i,directionalLights:a}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){var s,u={pointLights:[],directionalLights:[]},c=ps(t.lights||[]);try{for(c.s();!(s=c.n()).done;){var l=s.value;switch(l.type){case"ambient":u.ambientLight=l;break;case"directional":u.directionalLights.push(l);break;case"point":u.pointLights.push(l)}}}catch(e){c.e(e)}finally{c.f()}return e({lightSources:u})}return{}},defines:{MAX_LIGHTS:3}},xs="\nuniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, lighting_uShininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n",Es={};function Ts(e){var t=e.ambient,n=void 0===t?.35:t,r=e.diffuse,i=void 0===r?.6:r,a=e.shininess,o=void 0===a?32:a,s=e.specularColor;return{lighting_uAmbient:n,lighting_uDiffuse:i,lighting_uShininess:o,lighting_uSpecularColor:(void 0===s?[30,30,30]:s).map((function(e){return e/255}))}}function ks(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Es;if(!("material"in e))return{};var t=e.material;return t?Ts(t):{lighting_uEnabled:!1}}var ws={name:"gouraud-lighting",dependencies:[As],vs:xs,defines:{LIGHTING_VERTEX:1},getUniforms:ks},Os={name:"phong-lighting",dependencies:[As],fs:xs,defines:{LIGHTING_FRAGMENT:1},getUniforms:ks},Ss={name:"pbr",vs:"uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n",fs:"#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)\n# error PBR fragment shader: Texture LOD is not available\n#endif\n\n#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)\n# error PBR fragment shader: Derivatives are not available\n#endif\n\n\n#if (__VERSION__ < 300)\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)\n#else\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)\n#endif\n\nprecision highp float;\n\nuniform bool pbr_uUnlit;\n\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\n\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\n\nuniform vec3 u_Camera;\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\n\nvarying vec3 pbr_vPosition;\n\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n#else\nvarying vec3 pbr_vNormal;\n#endif\n#endif\n\n\nstruct PBRInfo\n{\n float NdotL;\n float NdotV;\n float NdotH;\n float LdotH;\n float VdotH;\n float perceptualRoughness;\n float metalness;\n vec3 reflectance0;\n vec3 reflectance90;\n float alphaRoughness;\n vec3 diffuseColor;\n vec3 specularColor;\n vec3 n;\n vec3 v;\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif\n return vec4(linOut,srgbIn.w);;\n#else\n return srgbIn;\n#endif\n}\n\nvec3 getNormal()\n{\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\n vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else\n mat3 tbn = pbr_vTBN;\n#endif\n\n#ifdef HAS_NORMALMAP\n vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;\n n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n return n;\n}\n\n\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0;\n float lod = (pbrInputs.perceptualRoughness * mipCount);\n vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,\n vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\n vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\n diffuse *= u_ScaleIBLAmbient.x;\n specular *= u_ScaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n\nvec3 diffuse(PBRInfo pbrInputs)\n{\n return pbrInputs.diffuseColor / M_PI;\n}\n\nvec3 specularReflection(PBRInfo pbrInputs)\n{\n return pbrInputs.reflectance0 +\n (pbrInputs.reflectance90 - pbrInputs.reflectance0) *\n pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\n\n\n\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\n float NdotL = pbrInputs.NdotL;\n float NdotV = pbrInputs.NdotV;\n float r = pbrInputs.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n\n\n\n\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\n float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\n pbrInputs.NdotL = 1.0;\n pbrInputs.NdotH = 0.0;\n pbrInputs.LdotH = 0.0;\n pbrInputs.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\n vec3 n = pbrInputs.n;\n vec3 v = pbrInputs.v;\n vec3 l = normalize(lightDirection);\n vec3 h = normalize(l+v);\n\n pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\n vec3 F = specularReflection(pbrInputs);\n float G = geometricOcclusion(pbrInputs);\n float D = microfacetDistribution(pbrInputs);\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\n vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\n return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\n vec4 baseColor = u_BaseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < u_AlphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n if(pbr_uUnlit){\n color.rgb = baseColor.rgb;\n }\n else{\n\n\n float perceptualRoughness = u_MetallicRoughnessValues.y;\n float metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n\n vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n\n\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n\n vec3 n = getNormal();\n vec3 v = normalize(u_Camera - pbr_vPosition);\n\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInputs = PBRInfo(\n 0.0,\n NdotV,\n 0.0,\n 0.0,\n 0.0,\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n#ifdef USE_LIGHTS\n PBRInfo_setAmbientLight(pbrInputs);\n color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {\n if (i < lighting_uDirectionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\n color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n }\n }\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {\n if (i < lighting_uPointLightCount) {\n PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\n float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\n color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n }\n }\n#endif\n#ifdef USE_IBL\n color += getIBLContribution(pbrInputs, n, reflection);\n#endif\n#ifdef HAS_OCCLUSIONMAP\n float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;\n color = mix(color, color * ao, u_OcclusionStrength);\n#endif\n\n#ifdef HAS_EMISSIVEMAP\n vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\n color += emissive;\n#endif\n\n#ifdef PBR_DEBUG\n\n\n\n\n\n color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n\n }\n\n return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n",defines:{LIGHTING_FRAGMENT:1},dependencies:[As]}}])}));