@luma.gl/core 8.5.19 → 8.5.21

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=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 Ye})),n.d(t,"FEATURES",(function(){return Fn})),n.d(t,"hasFeature",(function(){return kn})),n.d(t,"hasFeatures",(function(){return wn})),n.d(t,"Buffer",(function(){return Bt})),n.d(t,"Program",(function(){return yr})),n.d(t,"Framebuffer",(function(){return Pn})),n.d(t,"Renderbuffer",(function(){return nn})),n.d(t,"Texture2D",(function(){return $t})),n.d(t,"TextureCube",(function(){return dn})),n.d(t,"VertexShader",(function(){return sr})),n.d(t,"FragmentShader",(function(){return ur})),n.d(t,"clear",(function(){return rn})),n.d(t,"readPixelsToArray",(function(){return mn})),n.d(t,"readPixelsToBuffer",(function(){return yn})),n.d(t,"cloneTextureFrom",(function(){return pn})),n.d(t,"copyToTexture",(function(){return bn})),n.d(t,"Texture3D",(function(){return gn})),n.d(t,"TransformFeedback",(function(){return br})),n.d(t,"AnimationLoop",(function(){return Or})),n.d(t,"Model",(function(){return Zi})),n.d(t,"Transform",(function(){return ya})),n.d(t,"ProgramManager",(function(){return xi})),n.d(t,"Timeline",(function(){return Ea})),n.d(t,"Geometry",(function(){return wa})),n.d(t,"ClipSpace",(function(){return La})),n.d(t,"ConeGeometry",(function(){return ja})),n.d(t,"CubeGeometry",(function(){return Ka})),n.d(t,"CylinderGeometry",(function(){return Za})),n.d(t,"IcoSphereGeometry",(function(){return Io})),n.d(t,"PlaneGeometry",(function(){return Bo})),n.d(t,"SphereGeometry",(function(){return Uo})),n.d(t,"TruncatedConeGeometry",(function(){return Ca})),n.d(t,"normalizeShaderModule",(function(){return Fr})),n.d(t,"fp32",(function(){return Vo})),n.d(t,"fp64",(function(){return qo})),n.d(t,"project",(function(){return cs})),n.d(t,"dirlight",(function(){return fs})),n.d(t,"picking",(function(){return ds})),n.d(t,"gouraudLighting",(function(){return ks})),n.d(t,"phongLighting",(function(){return ws})),n.d(t,"pbr",(function(){return Os})),n.d(t,"log",(function(){return B})),n.d(t,"assert",(function(){return ot})),n.d(t,"uid",(function(){return lt}));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.18"),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.18");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=new(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}());if(globalThis.luma&&"8.5.18"!==globalThis.luma.VERSION)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat("8.5.18"));globalThis.luma||(Object(v.a)()&&B.log(1,"luma.gl ".concat("8.5.18"," - ").concat("set luma.log.level=1 (or higher) to trace rendering"))(),globalThis.luma=globalThis.luma||{VERSION:"8.5.18",version:"8.5.18",log:B,stats:Ye,globals:{modules:{},nodeIO:{}}});globalThis.luma;var Qe=n(8),$e=n.n(Qe),Ze=n(13),Je=n.n(Ze),et=n(4),tt=n.n(et),nt=n(5),rt=n.n(nt),it=n(3),at=n.n(it);function ot(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function st(e,t){if("string"!=typeof t)return t;var n=Number(t);if(!isNaN(n))return n;var r=e[t=t.replace(/^.*\./,"")];return ot(void 0!==r,"Accessing undefined constant GL.".concat(t)),r}function ut(e,t){for(var n in t=Number(t),e)if(e[n]===t)return"GL.".concat(n);return String(t)}var ct={};function lt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";ct[e]=ct[e]||1;var t=ct[e]++;return"".concat(e,"-").concat(t)}function ft(e){return ot("number"==typeof e,"Input must be a number"),e&&0==(e&e-1)}function ht(e){var t=!0;for(var n in e){t=!1;break}return t}function dt(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 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 gt(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 gt(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 gt(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 pt="Resource subclass must define virtual methods",mt=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||lt(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._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]:{};ot(e=st(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=vt(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?ut(this.gl,c):c;o[h]=this.getParameter(c,t),r&&"GLenum"===l.type&&(o[h]=ut(this.gl,o[h]))}}}catch(e){u.e(e)}finally{u.f()}return o}},{key:"setParameter",value:function(e,t){ot(e=st(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=st(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 dt(this,e,t,n)}},{key:"initialize",value:function(e){}},{key:"_createHandle",value:function(){throw new Error(pt)}},{key:"_deleteHandle",value:function(){throw new Error(pt)}},{key:"_bindHandle",value:function(e){throw new Error(pt)}},{key:"_getOptsFromHandle",value:function(){throw new Error(pt)}},{key:"_getParameter",value:function(e,t){throw new Error(pt)}},{key:"_setParameter",value:function(e,t){throw new Error(pt)}},{key:"_context",value:function(){return this.gl.luma=this.gl.luma||{},this.gl.luma}},{key:"_addStats",value:function(){var e=this[Symbol.toStringTag],t=Ye.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];Ye.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._trackAllocatedMemoryForContext(e,t),this._trackAllocatedMemoryForContext(e,t,this.gl.canvas&&this.gl.canvas.id),this.byteLength=e}},{key:"_trackAllocatedMemoryForContext",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]:"",r=Ye.get("Memory Usage".concat(n));r.get("GPU Memory").addCount(e),r.get("".concat(t," Memory")).addCount(e)}},{key:"_trackDeallocatedMemory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];this._trackDeallocatedMemoryForContext(e),this._trackDeallocatedMemoryForContext(e,this.gl.canvas&&this.gl.canvas.id),this.byteLength=0}},{key:"_trackDeallocatedMemoryForContext",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]:"",n=Ye.get("Memory Usage".concat(t));n.get("GPU Memory").subtractCount(this.byteLength),n.get("".concat(e," Memory")).subtractCount(this.byteLength)}}]),t}(Symbol.toStringTag),yt=n(21),_t=n.n(yt);function bt(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 At(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 xt(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 Et(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 Tt(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 kt={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},wt={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},Ot=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=Tt("Accessor",e,wt)).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 At(e.type||5126).BYTES_PER_ELEMENT}},{key:"getBytesPerVertex",value:function(e){return ot(e.size),At(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 _t()(e,[kt].concat(n))}}]),e}();function St(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Lt,It,Pt,Rt={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"},Ft={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:Rt},Ct={removedProps:Rt},Bt=function(e,t){tt()(r,e);var n=St(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($e()(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/Ot.getBytesPerElement(e))}},{key:"getVertexCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/Ot.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=Tt("Buffer",e,Ft),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=Tt("Buffer",e,Ct))&&this.setAccessor(e.accessor),this}},{key:"setAccessor",value:function(e){return delete(e=Object.assign({},e)).buffer,this.accessor=new Ot(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;ot(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=At(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 ot((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):(ot(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;ot(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=bt(e);return ot(i),this.setAccessor(new Ot(this.accessor,{type:i})),this}},{key:"_setByteLength",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.usage;ot(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/At(this.accessor.type||5126,{clamped:!1}).BYTES_PER_ELEMENT;return this.getElementCount()-t}},{key:"_inferType",value:function(e){this.accessor.type||this.setAccessor(new Ot(this.accessor,{type:bt(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 Ot(this.accessor,e),this}}]),r}(mt,Symbol.toStringTag),Mt=(Lt={},u()(Lt,6407,{dataFormat:6407,types:[5121,33635]}),u()(Lt,6408,{dataFormat:6408,types:[5121,32819,32820]}),u()(Lt,6406,{dataFormat:6406,types:[5121]}),u()(Lt,6409,{dataFormat:6409,types:[5121]}),u()(Lt,6410,{dataFormat:6410,types:[5121]}),u()(Lt,33326,{dataFormat:6403,types:[5126],gl2:!0}),u()(Lt,33328,{dataFormat:33319,types:[5126],gl2:!0}),u()(Lt,34837,{dataFormat:6407,types:[5126],gl2:!0}),u()(Lt,34836,{dataFormat:6408,types:[5126],gl2:!0}),Lt),Nt=(It={},u()(It,6403,1),u()(It,36244,1),u()(It,33319,2),u()(It,33320,2),u()(It,6407,3),u()(It,36248,3),u()(It,6408,4),u()(It,36249,4),u()(It,6402,1),u()(It,34041,1),u()(It,6406,1),u()(It,6409,1),u()(It,6410,2),It),Dt=(Pt={},u()(Pt,5126,4),u()(Pt,5125,4),u()(Pt,5124,4),u()(Pt,5123,2),u()(Pt,5122,2),u()(Pt,5131,2),u()(Pt,5120,1),u()(Pt,5121,1),Pt);function jt(e,t){var n=Mt[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 Ut(e,t){var n=Mt[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 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 Vt(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 Vt(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 Vt(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 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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Ht=[9729,9728],Wt=globalThis.WebGLBuffer||function(){},Xt=function(e,t){tt()(r,e);var n=zt(r);function r(e,t){var i;l()(this,r);var a=t.id,o=void 0===a?lt("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=Gt(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:ot(!1,"Unknown image data type")}})),"compressed"===L)this._trackAllocatedMemory(R,"Texture");else if(p&&p.byteLength)this._trackAllocatedMemory(p.byteLength,"Texture");else{var F=Nt[this.dataFormat]||4,C=Dt[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,ot(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),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 Wt){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 Bt?{data:t.handle,dataType:"buffer"}:t instanceof Wt?{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=Mt[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 ot(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"),ot(void 0===t||r.width===t,"Deduced texture width does not match supplied width"),ot(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:ot(!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)&&(!ft(this.width)||!ft(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===Ht.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&&jt(e,n))&&(!r||Ut(e,n))),i}}]),r}(mt,Symbol.toStringTag),qt="";function Kt(e,t){return ot("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 Yt(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Qt,$t=function(e,t){tt()(r,e);var n=Yt(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:Kt(i.data)})),(t=n.call(this,e,Object.assign({},i,{target:3553}))).initialize(i),Object.seal($e()(t)),t}return h()(r,[{key:t,get:function(){return"Texture2D"}}],[{key:"isSupported",value:function(e,t){return Xt.isSupported(e,t)}}]),r}(Xt,Symbol.toStringTag),Zt="EXT_color_buffer_float",Jt=(Qt={},u()(Qt,33189,{bpp:2}),u()(Qt,33190,{gl2:!0,bpp:3}),u()(Qt,36012,{gl2:!0,bpp:4}),u()(Qt,36168,{bpp:1}),u()(Qt,34041,{bpp:4}),u()(Qt,35056,{gl2:!0,bpp:4}),u()(Qt,36013,{gl2:!0,bpp:5}),u()(Qt,32854,{bpp:2}),u()(Qt,36194,{bpp:2}),u()(Qt,32855,{bpp:2}),u()(Qt,33321,{gl2:!0,bpp:1}),u()(Qt,33330,{gl2:!0,bpp:1}),u()(Qt,33329,{gl2:!0,bpp:1}),u()(Qt,33332,{gl2:!0,bpp:2}),u()(Qt,33331,{gl2:!0,bpp:2}),u()(Qt,33334,{gl2:!0,bpp:4}),u()(Qt,33333,{gl2:!0,bpp:4}),u()(Qt,33323,{gl2:!0,bpp:2}),u()(Qt,33336,{gl2:!0,bpp:2}),u()(Qt,33335,{gl2:!0,bpp:2}),u()(Qt,33338,{gl2:!0,bpp:4}),u()(Qt,33337,{gl2:!0,bpp:4}),u()(Qt,33340,{gl2:!0,bpp:8}),u()(Qt,33339,{gl2:!0,bpp:8}),u()(Qt,32849,{gl2:!0,bpp:3}),u()(Qt,32856,{gl2:!0,bpp:4}),u()(Qt,32857,{gl2:!0,bpp:4}),u()(Qt,36220,{gl2:!0,bpp:4}),u()(Qt,36238,{gl2:!0,bpp:4}),u()(Qt,36975,{gl2:!0,bpp:4}),u()(Qt,36214,{gl2:!0,bpp:8}),u()(Qt,36232,{gl2:!0,bpp:8}),u()(Qt,36226,{gl2:!0,bpp:16}),u()(Qt,36208,{gl2:!0,bpp:16}),u()(Qt,33325,{gl2:Zt,bpp:2}),u()(Qt,33327,{gl2:Zt,bpp:4}),u()(Qt,34842,{gl2:Zt,bpp:8}),u()(Qt,33326,{gl2:Zt,bpp:4}),u()(Qt,33328,{gl2:Zt,bpp:8}),u()(Qt,34836,{gl2:Zt,bpp:16}),u()(Qt,35898,{gl2:Zt,bpp:4}),Qt);function en(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}function tn(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 nn=function(e,t){tt()(r,e);var n=en(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($e()(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 ot(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)*Jt[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||tn(e,n,Jt)}},{key:"getSamplesForFormat",value:function(e,t){var n=t.format;return e.getInternalformatParameter(36161,n,32937)}}]),r}(mt,Symbol.toStringTag);function rn(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)),ot(0!==f,"clear: bad arguments"),Le(e,l,(function(){e.clear(f)}))}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.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:ot(!1,"clear: bad arguments")}}))}function on(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 ot(!1),0}}var sn=n(22),un=n.n(sn),cn=n(14),ln=n.n(cn);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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var hn=[34069,34070,34071,34072,34073,34074],dn=function(e,t){tt()(i,e);var n,r=fn(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($e()(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=un()(ln.a.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,h,d,v,g=this;return ln.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(hn.map((function(e){var t=d[e];return Promise.all(Array.isArray(t)?t:[t])})));case 5:v=e.sent,this.bind(),hn.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}(Xt,Symbol.toStringTag);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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}dn.FACES=hn;var gn=function(e,t){tt()(r,e);var n=vn(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($e()(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 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=Nt[this.dataFormat]||4,A=Dt[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}(Xt,Symbol.toStringTag);function pn(e,t){ot(e instanceof $t||e instanceof dn||e instanceof gn);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 mn(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=An(e),p=g.framebuffer,m=g.deleteFramebuffer;ot(p);var y=p.gl,_=p.handle,b=p.attachments;h=h||p.width,d=d||p.height,36064===c&&null===_&&(c=1028),ot(b[c]),f=xn(f,v=v||b[c].type,s,h,d),v=v||bt(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 yn(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=An(e),p=g.framebuffer,m=g.deleteFramebuffer;ot(p),h=h||p.width,d=d||p.height;var y=U(p.gl);if(v=v||(c?c.type:5121),!c){var _=on(s),b=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return ot(!1),0}}(v);c=new Bt(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 _n(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=mn(e,{sourceAttachment:r}),s=e.width,u=e.height;u>a;){var c=Et({data:o,width:s,height:u});o=c.data,s=c.width,u=c.height}xt({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 bn(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=An(e),m=p.framebuffer,y=p.deleteFramebuffer;ot(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);ot(t);var E=null;if(t instanceof Xt&&(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 An(e){return e instanceof Pn?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:(t=e,r=t.gl,i=t.width,a=t.height,o=t.id,new Pn(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 xn(e,t,n,r,i){return e||new(At(t=t||5121,{clamped:!1}))(r*i*on(n))}function En(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 Tn(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 Tn(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 Tn(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 kn(e,t){return wn(e,t)}function wn(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return On(e,t)}))}function On(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];ot(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=En(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:ot(!1);return n}(e,t)),e.luma.caps[t]||B.log(2,"Feature: ".concat(t," not supported"))(),e.luma.caps[t]}function Sn(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 Ln(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 Ln(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 Ln(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 In(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Pn=function(e,t){tt()(r,e);var n=In(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($e()(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(ot(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=Sn(this.ownResources);try{for(t.s();!(e=t.n()).done;){e.value.delete()}}catch(e){t.e(e)}finally{t.f()}return Je()(at()(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 ot(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){ot(void 0!==c,"Misspelled framebuffer binding point?");var l=Number(c),f=s[l],h=f;if(h)if(h instanceof nn)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(Pn.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)&&rn(this.gl,{color:n,depth:r,stencil:i}),o.forEach((function(t,n){an(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=ut(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=Sn(r);try{for(a.s();!(e=a.n()).done;){var o=e.value,s=n?ut(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?ut(this.gl,o):o;n[s]=this.getAttachmentParameters(o,e)}return n}},{key:"show",value:function(){return"undefined"!=typeof window&&window.open(_n(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=_n(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 $t(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 nn(this.gl,{id:"".concat(this.id,"-depth-stencil"),format:35056,width:r,height:111}),this.ownResources.push(o[33306])):t?((o=o||{})[36096]=new nn(this.gl,{id:"".concat(this.id,"-depth"),format:33189,width:r,height:i}),this.ownResources.push(o[36096])):n&&ot(!1),o}},{key:"_unattach",value:function(e){var t=this.attachments[e];t&&(t instanceof nn?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:ot(!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):ot(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):ot(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]=On(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}(mt,Symbol.toStringTag);var Rn;Pn.ATTACHMENT_PARAMETERS=[36049,36048,33296,33298,33299,33300,33301,33302,33303];var Fn={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 Cn,Bn=(Rn={},u()(Rn,Fn.WEBGL2,[!1,!0]),u()(Rn,Fn.VERTEX_ARRAY_OBJECT,["OES_vertex_array_object",!0]),u()(Rn,Fn.TIMER_QUERY,["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"]),u()(Rn,Fn.INSTANCED_RENDERING,["ANGLE_instanced_arrays",!0]),u()(Rn,Fn.MULTIPLE_RENDER_TARGETS,["WEBGL_draw_buffers",!0]),u()(Rn,Fn.ELEMENT_INDEX_UINT32,["OES_element_index_uint",!0]),u()(Rn,Fn.BLEND_EQUATION_MINMAX,["EXT_blend_minmax",!0]),u()(Rn,Fn.FLOAT_BLEND,["EXT_float_blend"]),u()(Rn,Fn.COLOR_ENCODING_SRGB,["EXT_sRGB",!0]),u()(Rn,Fn.TEXTURE_DEPTH,["WEBGL_depth_texture",!0]),u()(Rn,Fn.TEXTURE_FLOAT,["OES_texture_float",!0]),u()(Rn,Fn.TEXTURE_HALF_FLOAT,["OES_texture_half_float",!0]),u()(Rn,Fn.TEXTURE_FILTER_LINEAR_FLOAT,["OES_texture_float_linear"]),u()(Rn,Fn.TEXTURE_FILTER_LINEAR_HALF_FLOAT,["OES_texture_half_float_linear"]),u()(Rn,Fn.TEXTURE_FILTER_ANISOTROPIC,["EXT_texture_filter_anisotropic"]),u()(Rn,Fn.COLOR_ATTACHMENT_RGBA32F,[function(e){var t=new $t(e,{format:6408,type:5126,dataFormat:6408}),n=new Pn(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()(Rn,Fn.COLOR_ATTACHMENT_FLOAT,[!1,"EXT_color_buffer_float"]),u()(Rn,Fn.COLOR_ATTACHMENT_HALF_FLOAT,["EXT_color_buffer_half_float"]),u()(Rn,Fn.GLSL_FRAG_DATA,["WEBGL_draw_buffers",!0]),u()(Rn,Fn.GLSL_FRAG_DEPTH,["EXT_frag_depth",!0]),u()(Rn,Fn.GLSL_DERIVATIVES,["OES_standard_derivatives",!0]),u()(Rn,Fn.GLSL_TEXTURE_LOD,["EXT_shader_texture_lod",!0]),Rn),Mn=(Cn={},u()(Cn,5126,$n.bind(null,"uniform1fv",Vn,1,Zn)),u()(Cn,35664,$n.bind(null,"uniform2fv",Vn,2,Zn)),u()(Cn,35665,$n.bind(null,"uniform3fv",Vn,3,Zn)),u()(Cn,35666,$n.bind(null,"uniform4fv",Vn,4,Zn)),u()(Cn,5124,$n.bind(null,"uniform1iv",zn,1,Zn)),u()(Cn,35667,$n.bind(null,"uniform2iv",zn,2,Zn)),u()(Cn,35668,$n.bind(null,"uniform3iv",zn,3,Zn)),u()(Cn,35669,$n.bind(null,"uniform4iv",zn,4,Zn)),u()(Cn,35670,$n.bind(null,"uniform1iv",zn,1,Zn)),u()(Cn,35671,$n.bind(null,"uniform2iv",zn,2,Zn)),u()(Cn,35672,$n.bind(null,"uniform3iv",zn,3,Zn)),u()(Cn,35673,$n.bind(null,"uniform4iv",zn,4,Zn)),u()(Cn,35674,$n.bind(null,"uniformMatrix2fv",Vn,4,Jn)),u()(Cn,35675,$n.bind(null,"uniformMatrix3fv",Vn,9,Jn)),u()(Cn,35676,$n.bind(null,"uniformMatrix4fv",Vn,16,Jn)),u()(Cn,35678,Qn),u()(Cn,35680,Qn),u()(Cn,5125,$n.bind(null,"uniform1uiv",Hn,1,Zn)),u()(Cn,36294,$n.bind(null,"uniform2uiv",Hn,2,Zn)),u()(Cn,36295,$n.bind(null,"uniform3uiv",Hn,3,Zn)),u()(Cn,36296,$n.bind(null,"uniform4uiv",Hn,4,Zn)),u()(Cn,35685,$n.bind(null,"uniformMatrix2x3fv",Vn,6,Jn)),u()(Cn,35686,$n.bind(null,"uniformMatrix2x4fv",Vn,8,Jn)),u()(Cn,35687,$n.bind(null,"uniformMatrix3x2fv",Vn,6,Jn)),u()(Cn,35688,$n.bind(null,"uniformMatrix3x4fv",Vn,12,Jn)),u()(Cn,35689,$n.bind(null,"uniformMatrix4x2fv",Vn,8,Jn)),u()(Cn,35690,$n.bind(null,"uniformMatrix4x3fv",Vn,12,Jn)),u()(Cn,35678,Qn),u()(Cn,35680,Qn),u()(Cn,35679,Qn),u()(Cn,35682,Qn),u()(Cn,36289,Qn),u()(Cn,36292,Qn),u()(Cn,36293,Qn),u()(Cn,36298,Qn),u()(Cn,36299,Qn),u()(Cn,36300,Qn),u()(Cn,36303,Qn),u()(Cn,36306,Qn),u()(Cn,36307,Qn),u()(Cn,36308,Qn),u()(Cn,36311,Qn),Cn),Nn={},Dn={},jn={},Un=[0];function Gn(e,t,n,r){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Un[0]=e,e=Un);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 Vn(e,t){return Gn(e,t,Float32Array,Nn)}function zn(e,t){return Gn(e,t,Int32Array,Dn)}function Hn(e,t){return Gn(e,t,Uint32Array,jn)}function Wn(e,t,n){var r=Mn[n.type];if(!r)throw new Error("Unknown GLSL uniform type ".concat(n.type));return r().bind(null,e,t)}function Xn(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]))&&!Kn(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 Kn(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 Xt||(e instanceof nn||e instanceof Pn&&Boolean(e.texture))))}function Yn(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 Qn(){var e=null;return function(t,n,r){var i=e!==r;return i&&(t.uniform1i(n,r),e=r),i}}function $n(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{ot(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 Zn(e,t,n,r){e[t](n,r)}function Jn(e,t,n,r){e[t](n,!1,r)}function er(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 tr(e,t,n,r){for(var i=e.split(/\r?\n/),a={},o={},s=r||er(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 rr(a,i-o)+n+e}))}(t);return{shaderName:u,errors:nr(a,v),warnings:nr(o,v)}}function nr(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+=rr("^^^ ".concat(s,": ").concat(c,"\n\n"),u)}}return n}function rr(e,t){for(var n="",r=0;r<t;++r)n+=" ";return"".concat(n).concat(e)}function ir(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var ar,or=function(e,t){tt()(r,e);var n=ir(r);function r(e,t){var i;l()(this,r),j(e),ot("string"==typeof t.source,"Shader: GLSL source code must be a JavaScript string");var a=er(t.source,null)||t.id||lt("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=er(t,null);n&&(this.id=lt(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 er(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=tr(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 ot(!1),"unknown"}}}]),r}(mt,Symbol.toStringTag),sr=function(e,t){tt()(r,e);var n=ir(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}(or,Symbol.toStringTag),ur=function(e,t){tt()(r,e);var n=ir(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}(or,Symbol.toStringTag),cr=(ar={},u()(ar,5126,[5126,1,"float"]),u()(ar,35664,[5126,2,"vec2"]),u()(ar,35665,[5126,3,"vec3"]),u()(ar,35666,[5126,4,"vec4"]),u()(ar,5124,[5124,1,"int"]),u()(ar,35667,[5124,2,"ivec2"]),u()(ar,35668,[5124,3,"ivec3"]),u()(ar,35669,[5124,4,"ivec4"]),u()(ar,5125,[5125,1,"uint"]),u()(ar,36294,[5125,2,"uvec2"]),u()(ar,36295,[5125,3,"uvec3"]),u()(ar,36296,[5125,4,"uvec4"]),u()(ar,35670,[5126,1,"bool"]),u()(ar,35671,[5126,2,"bvec2"]),u()(ar,35672,[5126,3,"bvec3"]),u()(ar,35673,[5126,4,"bvec4"]),u()(ar,35674,[5126,8,"mat2"]),u()(ar,35685,[5126,8,"mat2x3"]),u()(ar,35686,[5126,8,"mat2x4"]),u()(ar,35675,[5126,12,"mat3"]),u()(ar,35687,[5126,12,"mat3x2"]),u()(ar,35688,[5126,12,"mat3x4"]),u()(ar,35676,[5126,16,"mat4"]),u()(ar,35689,[5126,16,"mat4x2"]),u()(ar,35690,[5126,16,"mat4x3"]),ar);function lr(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 ot(!1),0}}function fr(e){var t=cr[e];if(!t)return null;var n=ie()(t,2);return{type:n[0],components:n[1]}}function hr(e,t){switch(e){case 5120:case 5121:case 5122:case 5123:e=5126}for(var n in cr){var r=ie()(cr[n],3),i=r[0],a=r[1],o=r[2];if(i===e&&a===t)return{glType:n,name:o}}return null}var dr=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=fr(n),a={type:i.type,size:r*i.components};this._inferProperties(e,t,a);var o={location:e,name:t,accessor:new Ot(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=fr(n),a=i.type,o=i.components,s={location:e,name:t,accessor:new Ot({type:a,size:r*o})};this.varyingInfos.push(s),this.varyingInfosByName[s.name]=s}}]),e}();function vr(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 gr(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 gr(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 gr(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 pr(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var mr=["setVertexArray","setAttributes","setBuffers","unsetBuffers","use","getUniformCount","getUniformInfo","getUniformLocation","getUniformValue","getVarying","getFragDataLocation","getAttachedShaders","getAttributeCount","getAttributeLocation","getAttributeInfo"],yr=function(e,t){tt()(r,e);var n=pr(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",mr),t._isCached=!1,t.initialize(i),Object.seal($e()(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 sr(this.gl,{id:"".concat(e.id,"-vs"),source:n}):n,this.fs="string"==typeof r?new ur(this.gl,{id:"".concat(e.id,"-fs"),source:r}):r,ot(this.vs instanceof sr),ot(this.fs instanceof ur),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 dr(this),this.setProps(e)}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isCached?this:Je()(at()(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(ut(this.gl,i)," verts=").concat(a," ")+"instances=".concat(g," indexType=").concat(ut(this.gl,d)," ")+"isInstanced=".concat(m," isIndexed=").concat(f," ")+"Framebuffer=".concat(w);B.log(n,O)()}return ot(_),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=lr(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&&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 Pn&&(i=i.texture),i instanceof Xt)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)&&Yn(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=vr(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 sr({handle:i});break;case 35632:n.fs=new ur({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=lt(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=Xn(n.name).name,i=e.getUniformLocation(this.handle,r);if(this._uniformSetters[r]=Wn(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,"]")]=Wn(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}(mt,Symbol.toStringTag);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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var br=function(e,t){tt()(r,e);var n=_r(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($e()(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,ht(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 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)}}],[{key:"isSupported",value:function(e){return D(e)}}]),r}(mt,Symbol.toStringTag);function Ar(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 xr(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 xr(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 xr(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 Er(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Tr=function(e,t){tt()(r,e);var n=Er(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($e()(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=wn(e,Fn.TIMER_QUERY),a=r||i,o=Ar(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:ot(!1)}}}catch(e){o.e(e)}finally{o.f()}return a}}]),r}(mt,Symbol.toStringTag);var kr=Object(v.a)()&&"undefined"!=typeof document,wr=0,Or=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?Ye.get("animation-loop-".concat(wr++)):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 ot("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=Tr.isSupported(e.gl,["timers"])?new Tr(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=un()(ln.a.mark((function e(){return ln.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=kr?new Promise((function(e,t){kr&&"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 Pn(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 Sr(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var Lr={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 Ir(e){var t=Pr(e);return"object"===t?e?"type"in e?Object.assign({},e,Lr[e.type]):"value"in e?(t=Pr(e.value),Object.assign({type:t},e,Lr[t])):{type:"object",value:e}:{type:"object",value:null}:Object.assign({type:t,value:e},Lr[t])}function Pr(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":i()(e)}var Rr=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),Sr("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=Ir(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:Sr(!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&&Sr(i.validate(e[r],i),"".concat(this.name,": invalid ").concat(r)),t[r]=e[r]):t[r]=i.value}return t}}]),e}();function Fr(e){if(!e.normalized&&(e.normalized=!0,e.uniforms&&!e.getUniforms)){var t=new Rr(e);e.getUniforms=t.getUniforms.bind(t)}return e}function Cr(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 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=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 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 Mr(e){return Nr(function e(t,n){return t.map((function(t){return t instanceof Rr||(Sr("string"!=typeof t,"Shader module use by name is deprecated. Import shader module '".concat(t,"' and use it directly.")),Sr(t.name,"shader module has no name"),(t=new Rr(t)).dependencies=e(t.dependencies)),t}))}(e))}function Nr(e){var t={},n={};return Dr({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 Dr(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=Cr(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=Cr(t);try{for(c.s();!(u=c.n()).done;){var l=u.value;l.dependencies&&Dr({modules:l.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}}catch(e){c.e(e)}finally{c.f()}}function jr(){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 Ur={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]},Gr={};Object.keys(Ur).forEach((function(e){Gr[e]=e}));var Vr={};function zr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Ur[t];if(Sr(r,t),!jr(n))return!0;if(t in Vr)return Vr[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),Vr[t]=u,u}function Hr(e,t){var n=Ur[t];Sr(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 Sr(!1===i||!0===i),i}function Wr(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return Hr(e,t)}))}var Xr,qr=(Xr={},u()(Xr,"vs","#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n"),u()(Xr,"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"),Xr),Kr=/void\s+main\s*\([^)]*\)\s*\{\n?/,Yr=/}\n?[^{}]*$/,Qr=[];function $r(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})),Qr.length=r.length;for(var a=0,o=r.length;a<o;++a)Qr[a]=r[a].injection;var s="".concat(Qr.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(Kr,(function(e){return e+s})));break;case"vs:#main-end":i&&(e=e.replace(Yr,(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(Kr,(function(e){return e+s})));break;case"fs:#main-end":i||(e=e.replace(Yr,(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 Zr(e){var t={};return Sr(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 Jr(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 ei(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 ei(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 ei(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 ti(e){return new RegExp("\\b".concat(e,"[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)"),"g")}var ni,ri=[[/^(#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("]],ii=[].concat(ri,[[ti("attribute"),"in $1"],[ti("varying"),"out $1"]]),ai=[].concat(ri,[[ti("varying"),"in $1"]]),oi=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],si=[].concat(oi,[[ti("in"),"attribute $1"],[ti("out"),"varying $1"]]),ui=[].concat(oi,[[ti("in"),"varying $1"]]),ci=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,li=/void\s+main\s*\([^)]*\)\s*\{\n?/;function fi(e,t,n){switch(t){case 300:return n?hi(e,ii):function(e){var t=(e=hi(e,ai)).match(ci);if(t){var n=t[1];e=e.replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),n)}else{e=e.replace(li,(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?hi(e,si):function(e){var t=(e=hi(e,ui)).match(ci);if(t){var n=t[1];e=e.replace(ci,"").replace(new RegExp("\\b".concat(n,"\\b"),"g"),"gl_FragColor")}return e}(e);default:throw new Error("unknown GLSL version ".concat(t))}}function hi(e,t){var n,r=Jr(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 di(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 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=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 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}var gi="\n\n".concat("__LUMA_INJECT_DECLARATIONS__","\n\n"),pi=(ni={},u()(ni,"vs","vertex"),u()(ni,"fs","fragment"),ni);function mi(e,t){var n=t.vs,r=t.fs,i=Mr(t.modules||[]);return{gl:e,vs:yi(e,Object.assign({},t,{source:n,type:"vs",modules:i})),fs:yi(e,Object.assign({},t,{source:r,type:"fs",modules:i})),getUniforms:_i(i)}}function yi(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;Sr("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(pi[r],"\n\n"):""}({id:n,source:r,type:i}),"\n").concat(function(e){var t=e.type;return"\n#define SHADER_TYPE_".concat(pi[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 Wr(e,Gr.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"),Wr(e,Gr.GLSL_DERIVATIVES)&&zr(e,Gr.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"),Wr(e,Gr.GLSL_FRAG_DATA)&&zr(e,Gr.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"),Wr(e,Gr.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=di(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=$r(E+=gi,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=di(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=fi(E=$r(E+=A,i,O),d?100:_,m)}function _i(e){return function(t){var n,r={},i=di(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 bi(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 Ai(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 Ai(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 Ai(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 xi=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=bi(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=bi(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=mi(this.gl,{vs:i,fs:o,modules:m,inject:l,defines:u,hookFunctions:this._hookFunctions,transpileToGLSL100:p});this._programCache[P]=new yr(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}(),Ei=null;function Ti(e,t){var n;return new e((n=e.BYTES_PER_ELEMENT*t,(!Ei||Ei.byteLength<n)&&(Ei=new ArrayBuffer(n)),Ei),0,t)}var ki=n(20),wi=globalThis;function Oi(e){if(!e&&!Object(v.a)())return"Node";if(Object(ki.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":wi.chrome?"Chrome":wi.safari?"Safari":wi.mozInnerScreenX?"Firefox":"Unknown"}function Si(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Li="elements must be GL.ELEMENT_ARRAY_BUFFER",Ii=function(e,t){tt()(r,e);var n=Si(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($e()(t)),t}return h()(r,[{key:t,get:function(){return"VertexArrayObject"}},{key:"delete",value:function(){return Je()(at()(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 ot(!t||34963===t.target,Li),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?(ot(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 Bt(this.gl,r),a=(a=a||this.buffer.reallocate(r))||!this._compareConstantArrayValues(n,this.bufferValue)){var o=Ti(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 ot(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"===Oi())}},{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:ot(!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:ot(!1)}}},{key:"_setConstantIntArray",value:function(e,t,n){switch(ot(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:ot(!1)}}},{key:"_setConstantUintArray",value:function(e,t,n){switch(ot(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:ot(!1)}}}]),r}(mt,Symbol.toStringTag),Pi=/^(.+)__LOCATION_([0-9]+)$/,Ri=["setBuffers","setGeneric","clearBindings","setLocations","setGenericValues","setDivisor","enable","disable"],Fi=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 Ii(t),dt(this,"VertexArray","v6.0",Ri),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,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=Ot.resolve(c.accessor,l,n,r),h=f.size,d=f.type;return ot(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=Pi.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(Ii.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){Ii.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 B.deprecated("setElements","setElementBuffer")(),this.setElementBuffer(e,t)}}]),e}();function Ci(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+=Bi(e[s],t);var u=e.length>r?"...":"]";return"".concat(o).concat(u)}function Bi(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 Ci(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 Mi(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(ut(o,f),")")}else s=!0,p="".concat(v," bytes");return g={},u()(g,r,"".concat(c).concat(Bi(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(Bi(l,{size:h,isInteger:s})," (constant)")),u()(i,"Format ","".concat(h,"x").concat(f," (constant)")),i}function Ni(e,t){var n=hr(t.type,t.size);return n?"".concat(e," (").concat(n.name,")"):e}function Di(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 ji(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 ji(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 ji(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 Ui(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;ot(r);var s,c=r._uniformSetters,l={},f=Object.keys(c).sort(),h=0,d=Di(f);try{for(d.s();!(s=d.n()).done;){var v=s.value;v.match(".*_.*")||v.match(".*Matrix")||Gi({table:l,header:n,uniforms:i,uniformName:v,undefinedOnly:o})&&h++}}catch(e){d.e(e)}finally{d.f()}var g,p=Di(f);try{for(p.s();!(g=p.n()).done;){var m=g.value;m.match(".*Matrix")&&Gi({table:l,header:n,uniforms:i,uniformName:m,undefinedOnly:o})&&h++}}catch(e){p.e(e)}finally{p.f()}var y,_=Di(f);try{for(_.s();!(y=_.n()).done;){var b=y.value;l[b]||Gi({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,Bi(T)))}return{table:l,count:h,unusedTable:x,unusedCount:A}}function Gi(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?Bi(s):"N/A"),u()(t,"Uniform Type",c?s:"NOT PROVIDED"),t),!0)}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 zi(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 zi(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 zi(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 Hi(e){var t=e.accessor,n=hr(t.type,t.size);return n?"".concat(n.name," ").concat(e.name):e.name}function Wi(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 Xi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wi(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var qi={POSITION:"positions",NORMAL:"normals",COLOR_0:"colors",TEXCOORD_0:"texCoords",TEXCOORD_1:"texCoords1",TEXCOORD_2:"texCoords2"};function Ki(e,t){var n=(t||{}).attributeMap,r=void 0===n?qi:n;return r&&r[e]||e}function Yi(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}ot(Number.isFinite(t.size),"attribute ".concat(e," needs size"))}var Qi=function(){},$i={},Zi=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?lt("model"):r;ot(N(t)),this.id=i,this.gl=t,this.id=n.id||lt("Model"),this.lastLogTime=0,this.animated=!1,this.initialize(n)}return h()(e,[{key:"initialize",value:function(e){this.props={},this.programManager=e.programManager||xi.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={},ot(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 ot(Number.isFinite(e)),this.vertexCount=e,this}},{key:"setInstanceCount",value:function(e){return ot(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=Ki(a,n);if("indices"===a)i=o;else if(o.constant)r[s]=o.value;else{var u=o.value,c=Xi({},o);delete c.value,r[s]=[new Bt(e,u),c],Yi(a,c)}}if(i){var l=i.value||i;ot(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(ht(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 rn(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?Qi:S,I=O.onAfterRender,P=void 0===I?Qi:I;L(),this.program.setUniforms(this.uniforms);var R=this.program.draw(Object.assign($i,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}ot(e instanceof yr,"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 Fi(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&&ot(e,"Model.draw(): animated uniforms but no animationProps")}},{key:"_setFeedbackBuffers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(ht(e))return this;var t=this.program.gl;return this.transformFeedback=this.transformFeedback||new br(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=Mi(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(Ni(s.name,c))),i[u]=Mi(t,a[o],c,r)}}return i}({vertexArray:t,header:"".concat(this.id," attributes"),attributes:this._attributes}),a=Ui({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=Ui({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=Vi(e.attributeInfos);try{for(i.s();!(t=i.n()).done;){var a=t.value;if(a){var o=Hi(a);n["in ".concat(o)]=u()({},r,JSON.stringify(a.accessor))}}}catch(e){i.e(e)}finally{i.f()}var s,c=Vi(e.varyingInfos);try{for(c.s();!(s=c.n()).done;){var l=s.value;if(l){var f=Hi(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}(),Ji="void main() {gl_FragColor = vec4(0);}",ea="out vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}",ta="#version 300 es\n".concat(ea);function na(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 ra(){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?ta:n>300?"#version ".concat(n,"\n").concat(ea):Ji;var o=aa(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 ia(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:return Sr(!1),null}}function aa(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 Sr(!1),null}}function oa(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 sa(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 sa(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 sa(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 ua=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=oa(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&&ot(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 br(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],ot(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 ca(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 la,fa={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 ha(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 na(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 Sr(!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=Zr([c,h]),Object.assign(s,u.samplerTextureMap),a--}}r&&!o&&(o=function(e,t){var n=na(e,["varying","out"]);if(!n)return null;return n.name===t?n.type:null}(e,r))})),r){ot(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=Zr([c,{"vs:#decl":d,"vs:#main-start":v}])}u=f.join("\n")}return{vs:u,targetTextureType:o,inject:c,samplerTextureMap:s}}function da(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 va=(la={},u()(la,10241,9728),u()(la,10240,9728),u()(la,10242,33071),u()(la,10243,33071),la),ga=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=da({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=mn(r);if(!n)return i;for(var a=i.constructor,o=ia(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 $t)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 Pn(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(va)}},{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=pn(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=ha({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=Zr([e.inject||{},u]);this.targetTextureType=s,this.samplerTextureMap=c;var f=e._fs||ra({version:ca(a),input:this.targetTextureVarying,inputType:s,output:"transform_output"}),h=this.hasSourceTextures||this.targetTextureVarying?[fa].concat(e.modules||[]):e.modules;return{vs:a,fs:f,modules:h,uniforms:o,inject:l}}}]),e}();function pa(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 ma(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 ma(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 ma(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 ya=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=pa([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()}ot(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=pa(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=pa(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 Zi(t,Object.assign({},e,{fs:e.fs||ra({version:ca(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=pa([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(!ht(e.feedbackBuffers)||!ht(e.feedbackMap)||e.varyings&&e.varyings.length>0)return!0;return!1})(t)&&(this.bufferTransform=new ua(e,t)),function(e){if(!ht(e._sourceTextures)||e._targetTexture||e._targetTextureVarying)return!0;return!1}(t)&&(this.textureTransform=new ga(e,t)),ot(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=pa([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 _a(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 ba(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 ba(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 ba(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 Aa=1,xa=1,Ea=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=Aa++,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=_a(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=_a(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=_a(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=xa++;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 Ta(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 ka={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},wa=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?lt("geometry"):n,i=t.drawMode,a=void 0===i?ka.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?Ta(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ta(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,ot(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?(ot(!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 ot(Number.isFinite(n)),n}}],[{key:"DRAW_MODE",get:function(){return ka}}]),e}();function Oa(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Sa=[-1,-1,1,-1,-1,1,1,1],La=function(e){tt()(n,e);var t=Oa(n);function n(e,r){var i;l()(this,n);var a=Sa.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 wa({drawMode:5,vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(Sa)},aTexCoord:{size:2,value:new Float32Array(a)},aCoordinate:{size:2,value:new Float32Array(a)}}})}))).setVertexCount(4),i}return h()(n)}(Zi);function Ia(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 Pa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ia(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ia(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ra(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Fa={x:[2,0,1],y:[0,1,2],z:[1,2,0]},Ca=function(e){tt()(n,e);var t=Ra(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?lt("truncated-code-geometry"):r,a=Ba(e),o=a.indices,s=a.attributes;return t.call(this,Pa(Pa({},e),{},{id:i,indices:o,attributes:Pa(Pa({},s),e.attributes)}))}return h()(n)}(wa);function Ba(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=Fa[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 Ma(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 Na(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ma(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ma(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Da(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var ja=function(e){tt()(n,e);var t=Da(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?lt("cone-geometry"):r,a=e.radius,o=void 0===a?1:a,s=e.cap,u=void 0===s||s;return t.call(this,Na(Na({},e),{},{id:i,topRadius:0,topCap:Boolean(u),bottomCap:Boolean(u),bottomRadius:o}))}return h()(n)}(Ca);function Ua(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 Ga(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ua(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ua(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Va(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var za=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]),Ha=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]),Wa=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]),Xa=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]),qa={POSITION:{size:3,value:new Float32Array(Ha)},NORMAL:{size:3,value:new Float32Array(Wa)},TEXCOORD_0:{size:2,value:new Float32Array(Xa)}},Ka=function(e){tt()(n,e);var t=Va(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?lt("cube-geometry"):r;return t.call(this,Ga(Ga({},e),{},{id:i,indices:{size:1,value:new Uint16Array(za)},attributes:Ga(Ga({},qa),e.attributes)}))}return h()(n)}(wa);function Ya(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 Qa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ya(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ya(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function $a(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Za=function(e){tt()(n,e);var t=$a(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?lt("cylinder-geometry"):r,a=e.radius,o=void 0===a?1:a;return t.call(this,Qa(Qa({},e),{},{id:i,bottomRadius:o,topRadius:o}))}return h()(n)}(Ca);function Ja(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}Math.PI,Math.PI;var eo={};function to(e){return Math.round(e/eo.EPSILON)*eo.EPSILON}function no(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.precision,r=void 0===n?eo.precision||4:n;return e=to(e),"".concat(parseFloat(e.toPrecision(r)))}function ro(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function io(e,t,n){var r=eo.EPSILON;n&&(eo.EPSILON=n);try{if(e===t)return!0;if(ro(e)&&ro(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!io(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)<=eo.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{eo.EPSILON=r}}function ao(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}eo.EPSILON=1e-12,eo.debug=!1,eo.precision=4,eo.printTypes=!1,eo.printDegrees=!1,eo.printRowMajor=!0;var oo=function(e){tt()(n,e);var t=ao(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return Ja(!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:ro(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(eo)}},{key:"formatString",value:function(e){for(var t="",n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+no(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(!io(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(eo.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 so(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 uo(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function co(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(eo.debug&&!so(e,t))throw new Error("math.gl: ".concat(n," some fields set to invalid numbers'"));return e}var lo={};function fo(e,t){lo[e]||(lo[e]=!0,console.warn("".concat(e," has been removed in version ").concat(t,", see upgrade guide for more information")))}function ho(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var vo=function(e){tt()(n,e);var t=ho(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return Ja(!1),0}},{key:"copy",value:function(e){return Ja(!1),this}},{key:"x",get:function(){return this[0]},set:function(e){this[0]=uo(e)}},{key:"y",get:function(){return this[1]},set:function(e){this[1]=uo(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 uo(t)}},{key:"dot",value:function(e){for(var t=0,n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return uo(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 Ja(e>=0&&e<this.ELEMENTS,"index is out of range"),uo(this[e])}},{key:"setComponent",value:function(e,t){return Ja(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}(oo),go=1e-6,po="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function mo(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 yo,_o;yo=new po(3),po!=Float32Array&&(yo[0]=0,yo[1]=0,yo[2]=0),_o=yo;function bo(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 Ao(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var xo=[0,0,0],Eo={},To=function(e){tt()(n,e);var t=Ao(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&&ro(r)?e.copy(r):(eo.debug&&(uo(r),uo(i),uo(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 eo.debug&&(uo(e.x),uo(e.y),uo(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]=uo(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?xo: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?xo: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?xo:n,t),this.check()}},{key:"transform",value:function(e){return this.transformAsPoint(e)}},{key:"transformAsPoint",value:function(e){return mo(this,this,e),this.check()}},{key:"transformAsVector",value:function(e){return bo(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 Eo.ZERO=Eo.ZERO||Object.freeze(new n(0,0,0,0))}}]),n}(vo);function ko(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 wo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ko(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ko(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var So=[-1,0,0,0,1,0,0,0,-1,0,0,1,0,-1,0,1,0,0],Lo=[3,4,5,3,5,1,3,1,0,3,0,4,4,0,2,4,2,5,2,0,1,5,2,1],Io=function(e){tt()(n,e);var t=Oo(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?lt("ico-sphere-geometry"):r,a=Po(e),o=a.indices,s=a.attributes;return t.call(this,wo(wo({},e),{},{id:i,indices:o,attributes:wo(wo({},s),e.attributes)}))}return h()(n)}(wa);function Po(e){var t=e.iterations,n=void 0===t?0:t,r=Math.PI,i=2*r,a=[].concat(So),o=[].concat(Lo);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 To([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 Ro(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 Fo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ro(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ro(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Co(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Bo=function(e){tt()(n,e);var t=Co(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?lt("plane-geometry"):r,a=Mo(e),o=a.indices,s=a.attributes;return t.call(this,Fo(Fo({},e),{},{id:i,indices:o,attributes:Fo(Fo({},s),e.attributes)}))}return h()(n)}(wa);function Mo(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 No(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 Do(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?No(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):No(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function jo(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Uo=function(e){tt()(n,e);var t=jo(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?lt("sphere-geometry"):r,a=Go(e),o=a.indices,s=a.attributes;return t.call(this,Do(Do({},e),{},{id:i,indices:o,attributes:Do(Do({},s),e.attributes)}))}return h()(n)}(wa);function Go(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 Vo={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 zo(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 Ho(e){return e-Math.fround(e)}function Wo(e){for(var t=new Float32Array(32),n=0;n<4;++n)for(var r=0;r<4;++r){var i=4*n+r;zo(e[4*r+n],t,2*i)}return t}var Xo={ONE:1};var qo={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 Xo},fp64ify:zo,fp64LowPart:Ho,fp64ifyMatrix4:Wo}],fp64ify:zo,fp64LowPart:Ho,fp64ifyMatrix4:Wo};function Ko(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Yo=function(e){tt()(n,e);var t=Ko(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return Ja(!1),0}},{key:"RANK",get:function(){return Ja(!1),0}},{key:"toString",value:function(){var e="[";if(eo.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]=uo(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}(oo);function Qo(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 $o(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 Zo(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 Jo(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)<go&&Math.abs(g-A)<go&&Math.abs(p-x)<go?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 po(2);return po!=Float32Array&&(e[0]=0,e[1]=0),e}()}();!function(){var e=function(){var e=new po(4);return po!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();function es(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var ts=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ns=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),rs=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}),is={},as=function(e){tt()(n,e);var t=es(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 rs}},{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(ts)}},{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 Jo(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 Zo(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 Qo(this,e,this),this.check()}},{key:"multiplyRight",value:function(e){return Qo(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<go||(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)?$o(this,this,e):$o(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?(co(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=mo(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return co(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=bo(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return co(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 fo("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}},{key:"transformVector",value:function(e,t){return fo("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}},{key:"transformDirection",value:function(e,t){return fo("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}],[{key:"IDENTITY",get:function(){return is.IDENTITY=is.IDENTITY||Object.freeze(new n(ts)),is.IDENTITY}},{key:"ZERO",get:function(){return is.ZERO=is.ZERO||Object.freeze(new n(ns)),is.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}(Yo),os=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],ss={modelMatrix:os,viewMatrix:os,projectionMatrix:os,cameraPositionWorld:[0,0,0]};var us="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",cs={name:"project",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ss,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 as(e.projectionMatrix).multiplyRight(e.viewMatrix)),t},vs:"".concat(us,"\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(us)},ls={lightDirection:new Float32Array([1,1,2])};var fs={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]:ls,t={};return e.lightDirection&&(t.dirlight_uLightDirection=e.lightDirection),t},dependencies:[cs]},hs={pickingSelectedColor:null,pickingHighlightColor:new Uint8Array([0,255,255,255]),pickingActive:!1,pickingAttribute:!1};var ds={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]:hs,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}},vs="#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 gs(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 ps(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 ps(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 ps(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 ms={lightSources:{}};function ys(){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 _s(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?ys(t):[0,0,0],r.forEach((function(e,t){o["lighting_uPointLight[".concat(t,"].color")]=ys(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")]=ys(e),o["lighting_uDirectionalLight[".concat(t,"].direction")]=e.direction})),o.lighting_uDirectionalLightCount=a.length,o}var bs={name:"lights",vs:vs,fs:vs,getUniforms:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ms;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({},_s({ambientLight:r,pointLights:i,directionalLights:a}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){var s,u={pointLights:[],directionalLights:[]},c=gs(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}},As="\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",xs={};function Es(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 Ts(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xs;if(!("material"in e))return{};var t=e.material;return t?Es(t):{lighting_uEnabled:!1}}var ks={name:"gouraud-lighting",dependencies:[bs],vs:As,defines:{LIGHTING_VERTEX:1},getUniforms:Ts},ws={name:"phong-lighting",dependencies:[bs],fs:As,defines:{LIGHTING_FRAGMENT:1},getUniforms:Ts},Os={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:[bs]}}])}));
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 Ye})),n.d(t,"FEATURES",(function(){return Fn})),n.d(t,"hasFeature",(function(){return kn})),n.d(t,"hasFeatures",(function(){return wn})),n.d(t,"Buffer",(function(){return Bt})),n.d(t,"Program",(function(){return yr})),n.d(t,"Framebuffer",(function(){return Pn})),n.d(t,"Renderbuffer",(function(){return nn})),n.d(t,"Texture2D",(function(){return $t})),n.d(t,"TextureCube",(function(){return dn})),n.d(t,"VertexShader",(function(){return sr})),n.d(t,"FragmentShader",(function(){return ur})),n.d(t,"clear",(function(){return rn})),n.d(t,"readPixelsToArray",(function(){return mn})),n.d(t,"readPixelsToBuffer",(function(){return yn})),n.d(t,"cloneTextureFrom",(function(){return pn})),n.d(t,"copyToTexture",(function(){return bn})),n.d(t,"Texture3D",(function(){return gn})),n.d(t,"TransformFeedback",(function(){return br})),n.d(t,"AnimationLoop",(function(){return Or})),n.d(t,"Model",(function(){return Zi})),n.d(t,"Transform",(function(){return ya})),n.d(t,"ProgramManager",(function(){return xi})),n.d(t,"Timeline",(function(){return Ea})),n.d(t,"Geometry",(function(){return wa})),n.d(t,"ClipSpace",(function(){return La})),n.d(t,"ConeGeometry",(function(){return ja})),n.d(t,"CubeGeometry",(function(){return Ka})),n.d(t,"CylinderGeometry",(function(){return Za})),n.d(t,"IcoSphereGeometry",(function(){return Io})),n.d(t,"PlaneGeometry",(function(){return Bo})),n.d(t,"SphereGeometry",(function(){return Uo})),n.d(t,"TruncatedConeGeometry",(function(){return Ca})),n.d(t,"normalizeShaderModule",(function(){return Fr})),n.d(t,"fp32",(function(){return Vo})),n.d(t,"fp64",(function(){return qo})),n.d(t,"project",(function(){return cs})),n.d(t,"dirlight",(function(){return fs})),n.d(t,"picking",(function(){return ds})),n.d(t,"gouraudLighting",(function(){return ks})),n.d(t,"phongLighting",(function(){return ws})),n.d(t,"pbr",(function(){return Os})),n.d(t,"log",(function(){return B})),n.d(t,"assert",(function(){return ot})),n.d(t,"uid",(function(){return lt}));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.20"),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.20");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,r="clientWidth"in n?n.clientWidth:e.canvas.clientWidth;return r?e.drawingBufferWidth/r: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=new(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}());if(globalThis.luma&&"8.5.20"!==globalThis.luma.VERSION)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat("8.5.20"));globalThis.luma||(Object(v.a)()&&B.log(1,"luma.gl ".concat("8.5.20"," - ").concat("set luma.log.level=1 (or higher) to trace rendering"))(),globalThis.luma=globalThis.luma||{VERSION:"8.5.20",version:"8.5.20",log:B,stats:Ye,globals:{modules:{},nodeIO:{}}});globalThis.luma;var Qe=n(8),$e=n.n(Qe),Ze=n(13),Je=n.n(Ze),et=n(4),tt=n.n(et),nt=n(5),rt=n.n(nt),it=n(3),at=n.n(it);function ot(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}function st(e,t){if("string"!=typeof t)return t;var n=Number(t);if(!isNaN(n))return n;var r=e[t=t.replace(/^.*\./,"")];return ot(void 0!==r,"Accessing undefined constant GL.".concat(t)),r}function ut(e,t){for(var n in t=Number(t),e)if(e[n]===t)return"GL.".concat(n);return String(t)}var ct={};function lt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";ct[e]=ct[e]||1;var t=ct[e]++;return"".concat(e,"-").concat(t)}function ft(e){return ot("number"==typeof e,"Input must be a number"),e&&0==(e&e-1)}function ht(e){var t=!0;for(var n in e){t=!1;break}return t}function dt(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 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 gt(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 gt(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 gt(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 pt="Resource subclass must define virtual methods",mt=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||lt(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._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]:{};ot(e=st(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=vt(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?ut(this.gl,c):c;o[h]=this.getParameter(c,t),r&&"GLenum"===l.type&&(o[h]=ut(this.gl,o[h]))}}}catch(e){u.e(e)}finally{u.f()}return o}},{key:"setParameter",value:function(e,t){ot(e=st(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=st(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 dt(this,e,t,n)}},{key:"initialize",value:function(e){}},{key:"_createHandle",value:function(){throw new Error(pt)}},{key:"_deleteHandle",value:function(){throw new Error(pt)}},{key:"_bindHandle",value:function(e){throw new Error(pt)}},{key:"_getOptsFromHandle",value:function(){throw new Error(pt)}},{key:"_getParameter",value:function(e,t){throw new Error(pt)}},{key:"_setParameter",value:function(e,t){throw new Error(pt)}},{key:"_context",value:function(){return this.gl.luma=this.gl.luma||{},this.gl.luma}},{key:"_addStats",value:function(){var e=this[Symbol.toStringTag],t=Ye.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];Ye.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._trackAllocatedMemoryForContext(e,t),this._trackAllocatedMemoryForContext(e,t,this.gl.canvas&&this.gl.canvas.id),this.byteLength=e}},{key:"_trackAllocatedMemoryForContext",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]:"",r=Ye.get("Memory Usage".concat(n));r.get("GPU Memory").addCount(e),r.get("".concat(t," Memory")).addCount(e)}},{key:"_trackDeallocatedMemory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];this._trackDeallocatedMemoryForContext(e),this._trackDeallocatedMemoryForContext(e,this.gl.canvas&&this.gl.canvas.id),this.byteLength=0}},{key:"_trackDeallocatedMemoryForContext",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]:"",n=Ye.get("Memory Usage".concat(t));n.get("GPU Memory").subtractCount(this.byteLength),n.get("".concat(e," Memory")).subtractCount(this.byteLength)}}]),t}(Symbol.toStringTag),yt=n(21),_t=n.n(yt);function bt(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 At(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 xt(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 Et(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 Tt(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 kt={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},wt={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},Ot=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=Tt("Accessor",e,wt)).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 At(e.type||5126).BYTES_PER_ELEMENT}},{key:"getBytesPerVertex",value:function(e){return ot(e.size),At(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 _t()(e,[kt].concat(n))}}]),e}();function St(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Lt,It,Pt,Rt={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"},Ft={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:Rt},Ct={removedProps:Rt},Bt=function(e,t){tt()(r,e);var n=St(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($e()(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/Ot.getBytesPerElement(e))}},{key:"getVertexCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/Ot.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=Tt("Buffer",e,Ft),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=Tt("Buffer",e,Ct))&&this.setAccessor(e.accessor),this}},{key:"setAccessor",value:function(e){return delete(e=Object.assign({},e)).buffer,this.accessor=new Ot(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;ot(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=At(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 ot((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):(ot(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;ot(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=bt(e);return ot(i),this.setAccessor(new Ot(this.accessor,{type:i})),this}},{key:"_setByteLength",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.usage;ot(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/At(this.accessor.type||5126,{clamped:!1}).BYTES_PER_ELEMENT;return this.getElementCount()-t}},{key:"_inferType",value:function(e){this.accessor.type||this.setAccessor(new Ot(this.accessor,{type:bt(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 Ot(this.accessor,e),this}}]),r}(mt,Symbol.toStringTag),Mt=(Lt={},u()(Lt,6407,{dataFormat:6407,types:[5121,33635]}),u()(Lt,6408,{dataFormat:6408,types:[5121,32819,32820]}),u()(Lt,6406,{dataFormat:6406,types:[5121]}),u()(Lt,6409,{dataFormat:6409,types:[5121]}),u()(Lt,6410,{dataFormat:6410,types:[5121]}),u()(Lt,33326,{dataFormat:6403,types:[5126],gl2:!0}),u()(Lt,33328,{dataFormat:33319,types:[5126],gl2:!0}),u()(Lt,34837,{dataFormat:6407,types:[5126],gl2:!0}),u()(Lt,34836,{dataFormat:6408,types:[5126],gl2:!0}),Lt),Nt=(It={},u()(It,6403,1),u()(It,36244,1),u()(It,33319,2),u()(It,33320,2),u()(It,6407,3),u()(It,36248,3),u()(It,6408,4),u()(It,36249,4),u()(It,6402,1),u()(It,34041,1),u()(It,6406,1),u()(It,6409,1),u()(It,6410,2),It),Dt=(Pt={},u()(Pt,5126,4),u()(Pt,5125,4),u()(Pt,5124,4),u()(Pt,5123,2),u()(Pt,5122,2),u()(Pt,5131,2),u()(Pt,5120,1),u()(Pt,5121,1),Pt);function jt(e,t){var n=Mt[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 Ut(e,t){var n=Mt[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 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 Vt(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 Vt(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 Vt(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 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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Ht=[9729,9728],Wt=globalThis.WebGLBuffer||function(){},Xt=function(e,t){tt()(r,e);var n=zt(r);function r(e,t){var i;l()(this,r);var a=t.id,o=void 0===a?lt("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=Gt(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:ot(!1,"Unknown image data type")}})),"compressed"===L)this._trackAllocatedMemory(R,"Texture");else if(p&&p.byteLength)this._trackAllocatedMemory(p.byteLength,"Texture");else{var F=Nt[this.dataFormat]||4,C=Dt[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,ot(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),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 Wt){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 Bt?{data:t.handle,dataType:"buffer"}:t instanceof Wt?{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=Mt[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 ot(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"),ot(void 0===t||r.width===t,"Deduced texture width does not match supplied width"),ot(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:ot(!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)&&(!ft(this.width)||!ft(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===Ht.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&&jt(e,n))&&(!r||Ut(e,n))),i}}]),r}(mt,Symbol.toStringTag),qt="";function Kt(e,t){return ot("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 Yt(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Qt,$t=function(e,t){tt()(r,e);var n=Yt(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:Kt(i.data)})),(t=n.call(this,e,Object.assign({},i,{target:3553}))).initialize(i),Object.seal($e()(t)),t}return h()(r,[{key:t,get:function(){return"Texture2D"}}],[{key:"isSupported",value:function(e,t){return Xt.isSupported(e,t)}}]),r}(Xt,Symbol.toStringTag),Zt="EXT_color_buffer_float",Jt=(Qt={},u()(Qt,33189,{bpp:2}),u()(Qt,33190,{gl2:!0,bpp:3}),u()(Qt,36012,{gl2:!0,bpp:4}),u()(Qt,36168,{bpp:1}),u()(Qt,34041,{bpp:4}),u()(Qt,35056,{gl2:!0,bpp:4}),u()(Qt,36013,{gl2:!0,bpp:5}),u()(Qt,32854,{bpp:2}),u()(Qt,36194,{bpp:2}),u()(Qt,32855,{bpp:2}),u()(Qt,33321,{gl2:!0,bpp:1}),u()(Qt,33330,{gl2:!0,bpp:1}),u()(Qt,33329,{gl2:!0,bpp:1}),u()(Qt,33332,{gl2:!0,bpp:2}),u()(Qt,33331,{gl2:!0,bpp:2}),u()(Qt,33334,{gl2:!0,bpp:4}),u()(Qt,33333,{gl2:!0,bpp:4}),u()(Qt,33323,{gl2:!0,bpp:2}),u()(Qt,33336,{gl2:!0,bpp:2}),u()(Qt,33335,{gl2:!0,bpp:2}),u()(Qt,33338,{gl2:!0,bpp:4}),u()(Qt,33337,{gl2:!0,bpp:4}),u()(Qt,33340,{gl2:!0,bpp:8}),u()(Qt,33339,{gl2:!0,bpp:8}),u()(Qt,32849,{gl2:!0,bpp:3}),u()(Qt,32856,{gl2:!0,bpp:4}),u()(Qt,32857,{gl2:!0,bpp:4}),u()(Qt,36220,{gl2:!0,bpp:4}),u()(Qt,36238,{gl2:!0,bpp:4}),u()(Qt,36975,{gl2:!0,bpp:4}),u()(Qt,36214,{gl2:!0,bpp:8}),u()(Qt,36232,{gl2:!0,bpp:8}),u()(Qt,36226,{gl2:!0,bpp:16}),u()(Qt,36208,{gl2:!0,bpp:16}),u()(Qt,33325,{gl2:Zt,bpp:2}),u()(Qt,33327,{gl2:Zt,bpp:4}),u()(Qt,34842,{gl2:Zt,bpp:8}),u()(Qt,33326,{gl2:Zt,bpp:4}),u()(Qt,33328,{gl2:Zt,bpp:8}),u()(Qt,34836,{gl2:Zt,bpp:16}),u()(Qt,35898,{gl2:Zt,bpp:4}),Qt);function en(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}function tn(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 nn=function(e,t){tt()(r,e);var n=en(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($e()(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 ot(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)*Jt[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||tn(e,n,Jt)}},{key:"getSamplesForFormat",value:function(e,t){var n=t.format;return e.getInternalformatParameter(36161,n,32937)}}]),r}(mt,Symbol.toStringTag);function rn(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)),ot(0!==f,"clear: bad arguments"),Le(e,l,(function(){e.clear(f)}))}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.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:ot(!1,"clear: bad arguments")}}))}function on(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 ot(!1),0}}var sn=n(22),un=n.n(sn),cn=n(14),ln=n.n(cn);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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var hn=[34069,34070,34071,34072,34073,34074],dn=function(e,t){tt()(i,e);var n,r=fn(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($e()(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=un()(ln.a.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,h,d,v,g=this;return ln.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(hn.map((function(e){var t=d[e];return Promise.all(Array.isArray(t)?t:[t])})));case 5:v=e.sent,this.bind(),hn.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}(Xt,Symbol.toStringTag);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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}dn.FACES=hn;var gn=function(e,t){tt()(r,e);var n=vn(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($e()(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 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=Nt[this.dataFormat]||4,A=Dt[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}(Xt,Symbol.toStringTag);function pn(e,t){ot(e instanceof $t||e instanceof dn||e instanceof gn);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 mn(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=An(e),p=g.framebuffer,m=g.deleteFramebuffer;ot(p);var y=p.gl,_=p.handle,b=p.attachments;h=h||p.width,d=d||p.height,36064===c&&null===_&&(c=1028),ot(b[c]),f=xn(f,v=v||b[c].type,s,h,d),v=v||bt(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 yn(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=An(e),p=g.framebuffer,m=g.deleteFramebuffer;ot(p),h=h||p.width,d=d||p.height;var y=U(p.gl);if(v=v||(c?c.type:5121),!c){var _=on(s),b=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return ot(!1),0}}(v);c=new Bt(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 _n(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=mn(e,{sourceAttachment:r}),s=e.width,u=e.height;u>a;){var c=Et({data:o,width:s,height:u});o=c.data,s=c.width,u=c.height}xt({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 bn(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=An(e),m=p.framebuffer,y=p.deleteFramebuffer;ot(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);ot(t);var E=null;if(t instanceof Xt&&(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 An(e){return e instanceof Pn?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:(t=e,r=t.gl,i=t.width,a=t.height,o=t.id,new Pn(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 xn(e,t,n,r,i){return e||new(At(t=t||5121,{clamped:!1}))(r*i*on(n))}function En(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 Tn(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 Tn(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 Tn(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 kn(e,t){return wn(e,t)}function wn(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return On(e,t)}))}function On(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];ot(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=En(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:ot(!1);return n}(e,t)),e.luma.caps[t]||B.log(2,"Feature: ".concat(t," not supported"))(),e.luma.caps[t]}function Sn(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 Ln(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 Ln(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 Ln(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 In(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Pn=function(e,t){tt()(r,e);var n=In(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($e()(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(ot(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=Sn(this.ownResources);try{for(t.s();!(e=t.n()).done;){e.value.delete()}}catch(e){t.e(e)}finally{t.f()}return Je()(at()(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 ot(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){ot(void 0!==c,"Misspelled framebuffer binding point?");var l=Number(c),f=s[l],h=f;if(h)if(h instanceof nn)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(Pn.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)&&rn(this.gl,{color:n,depth:r,stencil:i}),o.forEach((function(t,n){an(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=ut(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=Sn(r);try{for(a.s();!(e=a.n()).done;){var o=e.value,s=n?ut(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?ut(this.gl,o):o;n[s]=this.getAttachmentParameters(o,e)}return n}},{key:"show",value:function(){return"undefined"!=typeof window&&window.open(_n(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=_n(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 $t(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 nn(this.gl,{id:"".concat(this.id,"-depth-stencil"),format:35056,width:r,height:111}),this.ownResources.push(o[33306])):t?((o=o||{})[36096]=new nn(this.gl,{id:"".concat(this.id,"-depth"),format:33189,width:r,height:i}),this.ownResources.push(o[36096])):n&&ot(!1),o}},{key:"_unattach",value:function(e){var t=this.attachments[e];t&&(t instanceof nn?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:ot(!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):ot(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):ot(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]=On(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}(mt,Symbol.toStringTag);var Rn;Pn.ATTACHMENT_PARAMETERS=[36049,36048,33296,33298,33299,33300,33301,33302,33303];var Fn={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 Cn,Bn=(Rn={},u()(Rn,Fn.WEBGL2,[!1,!0]),u()(Rn,Fn.VERTEX_ARRAY_OBJECT,["OES_vertex_array_object",!0]),u()(Rn,Fn.TIMER_QUERY,["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"]),u()(Rn,Fn.INSTANCED_RENDERING,["ANGLE_instanced_arrays",!0]),u()(Rn,Fn.MULTIPLE_RENDER_TARGETS,["WEBGL_draw_buffers",!0]),u()(Rn,Fn.ELEMENT_INDEX_UINT32,["OES_element_index_uint",!0]),u()(Rn,Fn.BLEND_EQUATION_MINMAX,["EXT_blend_minmax",!0]),u()(Rn,Fn.FLOAT_BLEND,["EXT_float_blend"]),u()(Rn,Fn.COLOR_ENCODING_SRGB,["EXT_sRGB",!0]),u()(Rn,Fn.TEXTURE_DEPTH,["WEBGL_depth_texture",!0]),u()(Rn,Fn.TEXTURE_FLOAT,["OES_texture_float",!0]),u()(Rn,Fn.TEXTURE_HALF_FLOAT,["OES_texture_half_float",!0]),u()(Rn,Fn.TEXTURE_FILTER_LINEAR_FLOAT,["OES_texture_float_linear"]),u()(Rn,Fn.TEXTURE_FILTER_LINEAR_HALF_FLOAT,["OES_texture_half_float_linear"]),u()(Rn,Fn.TEXTURE_FILTER_ANISOTROPIC,["EXT_texture_filter_anisotropic"]),u()(Rn,Fn.COLOR_ATTACHMENT_RGBA32F,[function(e){var t=new $t(e,{format:6408,type:5126,dataFormat:6408}),n=new Pn(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()(Rn,Fn.COLOR_ATTACHMENT_FLOAT,[!1,"EXT_color_buffer_float"]),u()(Rn,Fn.COLOR_ATTACHMENT_HALF_FLOAT,["EXT_color_buffer_half_float"]),u()(Rn,Fn.GLSL_FRAG_DATA,["WEBGL_draw_buffers",!0]),u()(Rn,Fn.GLSL_FRAG_DEPTH,["EXT_frag_depth",!0]),u()(Rn,Fn.GLSL_DERIVATIVES,["OES_standard_derivatives",!0]),u()(Rn,Fn.GLSL_TEXTURE_LOD,["EXT_shader_texture_lod",!0]),Rn),Mn=(Cn={},u()(Cn,5126,$n.bind(null,"uniform1fv",Vn,1,Zn)),u()(Cn,35664,$n.bind(null,"uniform2fv",Vn,2,Zn)),u()(Cn,35665,$n.bind(null,"uniform3fv",Vn,3,Zn)),u()(Cn,35666,$n.bind(null,"uniform4fv",Vn,4,Zn)),u()(Cn,5124,$n.bind(null,"uniform1iv",zn,1,Zn)),u()(Cn,35667,$n.bind(null,"uniform2iv",zn,2,Zn)),u()(Cn,35668,$n.bind(null,"uniform3iv",zn,3,Zn)),u()(Cn,35669,$n.bind(null,"uniform4iv",zn,4,Zn)),u()(Cn,35670,$n.bind(null,"uniform1iv",zn,1,Zn)),u()(Cn,35671,$n.bind(null,"uniform2iv",zn,2,Zn)),u()(Cn,35672,$n.bind(null,"uniform3iv",zn,3,Zn)),u()(Cn,35673,$n.bind(null,"uniform4iv",zn,4,Zn)),u()(Cn,35674,$n.bind(null,"uniformMatrix2fv",Vn,4,Jn)),u()(Cn,35675,$n.bind(null,"uniformMatrix3fv",Vn,9,Jn)),u()(Cn,35676,$n.bind(null,"uniformMatrix4fv",Vn,16,Jn)),u()(Cn,35678,Qn),u()(Cn,35680,Qn),u()(Cn,5125,$n.bind(null,"uniform1uiv",Hn,1,Zn)),u()(Cn,36294,$n.bind(null,"uniform2uiv",Hn,2,Zn)),u()(Cn,36295,$n.bind(null,"uniform3uiv",Hn,3,Zn)),u()(Cn,36296,$n.bind(null,"uniform4uiv",Hn,4,Zn)),u()(Cn,35685,$n.bind(null,"uniformMatrix2x3fv",Vn,6,Jn)),u()(Cn,35686,$n.bind(null,"uniformMatrix2x4fv",Vn,8,Jn)),u()(Cn,35687,$n.bind(null,"uniformMatrix3x2fv",Vn,6,Jn)),u()(Cn,35688,$n.bind(null,"uniformMatrix3x4fv",Vn,12,Jn)),u()(Cn,35689,$n.bind(null,"uniformMatrix4x2fv",Vn,8,Jn)),u()(Cn,35690,$n.bind(null,"uniformMatrix4x3fv",Vn,12,Jn)),u()(Cn,35678,Qn),u()(Cn,35680,Qn),u()(Cn,35679,Qn),u()(Cn,35682,Qn),u()(Cn,36289,Qn),u()(Cn,36292,Qn),u()(Cn,36293,Qn),u()(Cn,36298,Qn),u()(Cn,36299,Qn),u()(Cn,36300,Qn),u()(Cn,36303,Qn),u()(Cn,36306,Qn),u()(Cn,36307,Qn),u()(Cn,36308,Qn),u()(Cn,36311,Qn),Cn),Nn={},Dn={},jn={},Un=[0];function Gn(e,t,n,r){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Un[0]=e,e=Un);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 Vn(e,t){return Gn(e,t,Float32Array,Nn)}function zn(e,t){return Gn(e,t,Int32Array,Dn)}function Hn(e,t){return Gn(e,t,Uint32Array,jn)}function Wn(e,t,n){var r=Mn[n.type];if(!r)throw new Error("Unknown GLSL uniform type ".concat(n.type));return r().bind(null,e,t)}function Xn(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]))&&!Kn(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 Kn(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 Xt||(e instanceof nn||e instanceof Pn&&Boolean(e.texture))))}function Yn(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 Qn(){var e=null;return function(t,n,r){var i=e!==r;return i&&(t.uniform1i(n,r),e=r),i}}function $n(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{ot(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 Zn(e,t,n,r){e[t](n,r)}function Jn(e,t,n,r){e[t](n,!1,r)}function er(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 tr(e,t,n,r){for(var i=e.split(/\r?\n/),a={},o={},s=r||er(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 rr(a,i-o)+n+e}))}(t);return{shaderName:u,errors:nr(a,v),warnings:nr(o,v)}}function nr(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+=rr("^^^ ".concat(s,": ").concat(c,"\n\n"),u)}}return n}function rr(e,t){for(var n="",r=0;r<t;++r)n+=" ";return"".concat(n).concat(e)}function ir(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var ar,or=function(e,t){tt()(r,e);var n=ir(r);function r(e,t){var i;l()(this,r),j(e),ot("string"==typeof t.source,"Shader: GLSL source code must be a JavaScript string");var a=er(t.source,null)||t.id||lt("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=er(t,null);n&&(this.id=lt(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 er(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=tr(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 ot(!1),"unknown"}}}]),r}(mt,Symbol.toStringTag),sr=function(e,t){tt()(r,e);var n=ir(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}(or,Symbol.toStringTag),ur=function(e,t){tt()(r,e);var n=ir(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}(or,Symbol.toStringTag),cr=(ar={},u()(ar,5126,[5126,1,"float"]),u()(ar,35664,[5126,2,"vec2"]),u()(ar,35665,[5126,3,"vec3"]),u()(ar,35666,[5126,4,"vec4"]),u()(ar,5124,[5124,1,"int"]),u()(ar,35667,[5124,2,"ivec2"]),u()(ar,35668,[5124,3,"ivec3"]),u()(ar,35669,[5124,4,"ivec4"]),u()(ar,5125,[5125,1,"uint"]),u()(ar,36294,[5125,2,"uvec2"]),u()(ar,36295,[5125,3,"uvec3"]),u()(ar,36296,[5125,4,"uvec4"]),u()(ar,35670,[5126,1,"bool"]),u()(ar,35671,[5126,2,"bvec2"]),u()(ar,35672,[5126,3,"bvec3"]),u()(ar,35673,[5126,4,"bvec4"]),u()(ar,35674,[5126,8,"mat2"]),u()(ar,35685,[5126,8,"mat2x3"]),u()(ar,35686,[5126,8,"mat2x4"]),u()(ar,35675,[5126,12,"mat3"]),u()(ar,35687,[5126,12,"mat3x2"]),u()(ar,35688,[5126,12,"mat3x4"]),u()(ar,35676,[5126,16,"mat4"]),u()(ar,35689,[5126,16,"mat4x2"]),u()(ar,35690,[5126,16,"mat4x3"]),ar);function lr(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 ot(!1),0}}function fr(e){var t=cr[e];if(!t)return null;var n=ie()(t,2);return{type:n[0],components:n[1]}}function hr(e,t){switch(e){case 5120:case 5121:case 5122:case 5123:e=5126}for(var n in cr){var r=ie()(cr[n],3),i=r[0],a=r[1],o=r[2];if(i===e&&a===t)return{glType:n,name:o}}return null}var dr=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=fr(n),a={type:i.type,size:r*i.components};this._inferProperties(e,t,a);var o={location:e,name:t,accessor:new Ot(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=fr(n),a=i.type,o=i.components,s={location:e,name:t,accessor:new Ot({type:a,size:r*o})};this.varyingInfos.push(s),this.varyingInfosByName[s.name]=s}}]),e}();function vr(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 gr(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 gr(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 gr(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 pr(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var mr=["setVertexArray","setAttributes","setBuffers","unsetBuffers","use","getUniformCount","getUniformInfo","getUniformLocation","getUniformValue","getVarying","getFragDataLocation","getAttachedShaders","getAttributeCount","getAttributeLocation","getAttributeInfo"],yr=function(e,t){tt()(r,e);var n=pr(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",mr),t._isCached=!1,t.initialize(i),Object.seal($e()(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 sr(this.gl,{id:"".concat(e.id,"-vs"),source:n}):n,this.fs="string"==typeof r?new ur(this.gl,{id:"".concat(e.id,"-fs"),source:r}):r,ot(this.vs instanceof sr),ot(this.fs instanceof ur),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 dr(this),this.setProps(e)}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isCached?this:Je()(at()(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(ut(this.gl,i)," verts=").concat(a," ")+"instances=".concat(g," indexType=").concat(ut(this.gl,d)," ")+"isInstanced=".concat(m," isIndexed=").concat(f," ")+"Framebuffer=".concat(w);B.log(n,O)()}return ot(_),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=lr(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&&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 Pn&&(i=i.texture),i instanceof Xt)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)&&Yn(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=vr(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 sr({handle:i});break;case 35632:n.fs=new ur({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=lt(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=Xn(n.name).name,i=e.getUniformLocation(this.handle,r);if(this._uniformSetters[r]=Wn(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,"]")]=Wn(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}(mt,Symbol.toStringTag);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 Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var br=function(e,t){tt()(r,e);var n=_r(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($e()(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,ht(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 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)}}],[{key:"isSupported",value:function(e){return D(e)}}]),r}(mt,Symbol.toStringTag);function Ar(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 xr(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 xr(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 xr(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 Er(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Tr=function(e,t){tt()(r,e);var n=Er(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($e()(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=wn(e,Fn.TIMER_QUERY),a=r||i,o=Ar(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:ot(!1)}}}catch(e){o.e(e)}finally{o.f()}return a}}]),r}(mt,Symbol.toStringTag);var kr=Object(v.a)()&&"undefined"!=typeof document,wr=0,Or=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?Ye.get("animation-loop-".concat(wr++)):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 ot("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=Tr.isSupported(e.gl,["timers"])?new Tr(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=un()(ln.a.mark((function e(){return ln.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=kr?new Promise((function(e,t){kr&&"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 Pn(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 Sr(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var Lr={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 Ir(e){var t=Pr(e);return"object"===t?e?"type"in e?Object.assign({},e,Lr[e.type]):"value"in e?(t=Pr(e.value),Object.assign({type:t},e,Lr[t])):{type:"object",value:e}:{type:"object",value:null}:Object.assign({type:t,value:e},Lr[t])}function Pr(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":i()(e)}var Rr=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),Sr("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=Ir(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:Sr(!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&&Sr(i.validate(e[r],i),"".concat(this.name,": invalid ").concat(r)),t[r]=e[r]):t[r]=i.value}return t}}]),e}();function Fr(e){if(!e.normalized&&(e.normalized=!0,e.uniforms&&!e.getUniforms)){var t=new Rr(e);e.getUniforms=t.getUniforms.bind(t)}return e}function Cr(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 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=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 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 Mr(e){return Nr(function e(t,n){return t.map((function(t){return t instanceof Rr||(Sr("string"!=typeof t,"Shader module use by name is deprecated. Import shader module '".concat(t,"' and use it directly.")),Sr(t.name,"shader module has no name"),(t=new Rr(t)).dependencies=e(t.dependencies)),t}))}(e))}function Nr(e){var t={},n={};return Dr({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 Dr(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=Cr(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=Cr(t);try{for(c.s();!(u=c.n()).done;){var l=u.value;l.dependencies&&Dr({modules:l.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}}catch(e){c.e(e)}finally{c.f()}}function jr(){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 Ur={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]},Gr={};Object.keys(Ur).forEach((function(e){Gr[e]=e}));var Vr={};function zr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Ur[t];if(Sr(r,t),!jr(n))return!0;if(t in Vr)return Vr[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),Vr[t]=u,u}function Hr(e,t){var n=Ur[t];Sr(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 Sr(!1===i||!0===i),i}function Wr(e,t){return(t=Array.isArray(t)?t:[t]).every((function(t){return Hr(e,t)}))}var Xr,qr=(Xr={},u()(Xr,"vs","#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n"),u()(Xr,"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"),Xr),Kr=/void\s+main\s*\([^)]*\)\s*\{\n?/,Yr=/}\n?[^{}]*$/,Qr=[];function $r(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})),Qr.length=r.length;for(var a=0,o=r.length;a<o;++a)Qr[a]=r[a].injection;var s="".concat(Qr.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(Kr,(function(e){return e+s})));break;case"vs:#main-end":i&&(e=e.replace(Yr,(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(Kr,(function(e){return e+s})));break;case"fs:#main-end":i||(e=e.replace(Yr,(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 Zr(e){var t={};return Sr(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 Jr(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 ei(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 ei(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 ei(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 ti(e){return new RegExp("\\b".concat(e,"[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)"),"g")}var ni,ri=[[/^(#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("]],ii=[].concat(ri,[[ti("attribute"),"in $1"],[ti("varying"),"out $1"]]),ai=[].concat(ri,[[ti("varying"),"in $1"]]),oi=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],si=[].concat(oi,[[ti("in"),"attribute $1"],[ti("out"),"varying $1"]]),ui=[].concat(oi,[[ti("in"),"varying $1"]]),ci=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,li=/void\s+main\s*\([^)]*\)\s*\{\n?/;function fi(e,t,n){switch(t){case 300:return n?hi(e,ii):function(e){var t=(e=hi(e,ai)).match(ci);if(t){var n=t[1];e=e.replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),n)}else{e=e.replace(li,(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?hi(e,si):function(e){var t=(e=hi(e,ui)).match(ci);if(t){var n=t[1];e=e.replace(ci,"").replace(new RegExp("\\b".concat(n,"\\b"),"g"),"gl_FragColor")}return e}(e);default:throw new Error("unknown GLSL version ".concat(t))}}function hi(e,t){var n,r=Jr(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 di(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 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=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 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}var gi="\n\n".concat("__LUMA_INJECT_DECLARATIONS__","\n\n"),pi=(ni={},u()(ni,"vs","vertex"),u()(ni,"fs","fragment"),ni);function mi(e,t){var n=t.vs,r=t.fs,i=Mr(t.modules||[]);return{gl:e,vs:yi(e,Object.assign({},t,{source:n,type:"vs",modules:i})),fs:yi(e,Object.assign({},t,{source:r,type:"fs",modules:i})),getUniforms:_i(i)}}function yi(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;Sr("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(pi[r],"\n\n"):""}({id:n,source:r,type:i}),"\n").concat(function(e){var t=e.type;return"\n#define SHADER_TYPE_".concat(pi[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 Wr(e,Gr.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"),Wr(e,Gr.GLSL_DERIVATIVES)&&zr(e,Gr.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"),Wr(e,Gr.GLSL_FRAG_DATA)&&zr(e,Gr.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"),Wr(e,Gr.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=di(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=$r(E+=gi,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=di(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=fi(E=$r(E+=A,i,O),d?100:_,m)}function _i(e){return function(t){var n,r={},i=di(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 bi(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 Ai(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 Ai(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 Ai(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 xi=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=bi(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=bi(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=mi(this.gl,{vs:i,fs:o,modules:m,inject:l,defines:u,hookFunctions:this._hookFunctions,transpileToGLSL100:p});this._programCache[P]=new yr(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}(),Ei=null;function Ti(e,t){var n;return new e((n=e.BYTES_PER_ELEMENT*t,(!Ei||Ei.byteLength<n)&&(Ei=new ArrayBuffer(n)),Ei),0,t)}var ki=n(20),wi=globalThis;function Oi(e){if(!e&&!Object(v.a)())return"Node";if(Object(ki.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":wi.chrome?"Chrome":wi.safari?"Safari":wi.mozInnerScreenX?"Firefox":"Unknown"}function Si(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Li="elements must be GL.ELEMENT_ARRAY_BUFFER",Ii=function(e,t){tt()(r,e);var n=Si(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($e()(t)),t}return h()(r,[{key:t,get:function(){return"VertexArrayObject"}},{key:"delete",value:function(){return Je()(at()(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 ot(!t||34963===t.target,Li),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?(ot(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 Bt(this.gl,r),a=(a=a||this.buffer.reallocate(r))||!this._compareConstantArrayValues(n,this.bufferValue)){var o=Ti(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 ot(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"===Oi())}},{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:ot(!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:ot(!1)}}},{key:"_setConstantIntArray",value:function(e,t,n){switch(ot(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:ot(!1)}}},{key:"_setConstantUintArray",value:function(e,t,n){switch(ot(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:ot(!1)}}}]),r}(mt,Symbol.toStringTag),Pi=/^(.+)__LOCATION_([0-9]+)$/,Ri=["setBuffers","setGeneric","clearBindings","setLocations","setGenericValues","setDivisor","enable","disable"],Fi=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 Ii(t),dt(this,"VertexArray","v6.0",Ri),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,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=Ot.resolve(c.accessor,l,n,r),h=f.size,d=f.type;return ot(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=Pi.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(Ii.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){Ii.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 B.deprecated("setElements","setElementBuffer")(),this.setElementBuffer(e,t)}}]),e}();function Ci(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+=Bi(e[s],t);var u=e.length>r?"...":"]";return"".concat(o).concat(u)}function Bi(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 Ci(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 Mi(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(ut(o,f),")")}else s=!0,p="".concat(v," bytes");return g={},u()(g,r,"".concat(c).concat(Bi(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(Bi(l,{size:h,isInteger:s})," (constant)")),u()(i,"Format ","".concat(h,"x").concat(f," (constant)")),i}function Ni(e,t){var n=hr(t.type,t.size);return n?"".concat(e," (").concat(n.name,")"):e}function Di(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 ji(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 ji(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 ji(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 Ui(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;ot(r);var s,c=r._uniformSetters,l={},f=Object.keys(c).sort(),h=0,d=Di(f);try{for(d.s();!(s=d.n()).done;){var v=s.value;v.match(".*_.*")||v.match(".*Matrix")||Gi({table:l,header:n,uniforms:i,uniformName:v,undefinedOnly:o})&&h++}}catch(e){d.e(e)}finally{d.f()}var g,p=Di(f);try{for(p.s();!(g=p.n()).done;){var m=g.value;m.match(".*Matrix")&&Gi({table:l,header:n,uniforms:i,uniformName:m,undefinedOnly:o})&&h++}}catch(e){p.e(e)}finally{p.f()}var y,_=Di(f);try{for(_.s();!(y=_.n()).done;){var b=y.value;l[b]||Gi({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,Bi(T)))}return{table:l,count:h,unusedTable:x,unusedCount:A}}function Gi(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?Bi(s):"N/A"),u()(t,"Uniform Type",c?s:"NOT PROVIDED"),t),!0)}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 zi(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 zi(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 zi(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 Hi(e){var t=e.accessor,n=hr(t.type,t.size);return n?"".concat(n.name," ").concat(e.name):e.name}function Wi(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 Xi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wi(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var qi={POSITION:"positions",NORMAL:"normals",COLOR_0:"colors",TEXCOORD_0:"texCoords",TEXCOORD_1:"texCoords1",TEXCOORD_2:"texCoords2"};function Ki(e,t){var n=(t||{}).attributeMap,r=void 0===n?qi:n;return r&&r[e]||e}function Yi(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}ot(Number.isFinite(t.size),"attribute ".concat(e," needs size"))}var Qi=function(){},$i={},Zi=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?lt("model"):r;ot(N(t)),this.id=i,this.gl=t,this.id=n.id||lt("Model"),this.lastLogTime=0,this.animated=!1,this.initialize(n)}return h()(e,[{key:"initialize",value:function(e){this.props={},this.programManager=e.programManager||xi.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={},ot(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 ot(Number.isFinite(e)),this.vertexCount=e,this}},{key:"setInstanceCount",value:function(e){return ot(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=Ki(a,n);if("indices"===a)i=o;else if(o.constant)r[s]=o.value;else{var u=o.value,c=Xi({},o);delete c.value,r[s]=[new Bt(e,u),c],Yi(a,c)}}if(i){var l=i.value||i;ot(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(ht(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 rn(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?Qi:S,I=O.onAfterRender,P=void 0===I?Qi:I;L(),this.program.setUniforms(this.uniforms);var R=this.program.draw(Object.assign($i,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}ot(e instanceof yr,"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 Fi(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&&ot(e,"Model.draw(): animated uniforms but no animationProps")}},{key:"_setFeedbackBuffers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(ht(e))return this;var t=this.program.gl;return this.transformFeedback=this.transformFeedback||new br(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=Mi(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(Ni(s.name,c))),i[u]=Mi(t,a[o],c,r)}}return i}({vertexArray:t,header:"".concat(this.id," attributes"),attributes:this._attributes}),a=Ui({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=Ui({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=Vi(e.attributeInfos);try{for(i.s();!(t=i.n()).done;){var a=t.value;if(a){var o=Hi(a);n["in ".concat(o)]=u()({},r,JSON.stringify(a.accessor))}}}catch(e){i.e(e)}finally{i.f()}var s,c=Vi(e.varyingInfos);try{for(c.s();!(s=c.n()).done;){var l=s.value;if(l){var f=Hi(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}(),Ji="void main() {gl_FragColor = vec4(0);}",ea="out vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}",ta="#version 300 es\n".concat(ea);function na(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 ra(){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?ta:n>300?"#version ".concat(n,"\n").concat(ea):Ji;var o=aa(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 ia(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:return Sr(!1),null}}function aa(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 Sr(!1),null}}function oa(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 sa(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 sa(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 sa(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 ua=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=oa(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&&ot(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 br(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],ot(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 ca(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 la,fa={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 ha(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 na(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 Sr(!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=Zr([c,h]),Object.assign(s,u.samplerTextureMap),a--}}r&&!o&&(o=function(e,t){var n=na(e,["varying","out"]);if(!n)return null;return n.name===t?n.type:null}(e,r))})),r){ot(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=Zr([c,{"vs:#decl":d,"vs:#main-start":v}])}u=f.join("\n")}return{vs:u,targetTextureType:o,inject:c,samplerTextureMap:s}}function da(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 va=(la={},u()(la,10241,9728),u()(la,10240,9728),u()(la,10242,33071),u()(la,10243,33071),la),ga=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=da({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=mn(r);if(!n)return i;for(var a=i.constructor,o=ia(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 $t)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 Pn(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(va)}},{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=pn(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=ha({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=Zr([e.inject||{},u]);this.targetTextureType=s,this.samplerTextureMap=c;var f=e._fs||ra({version:ca(a),input:this.targetTextureVarying,inputType:s,output:"transform_output"}),h=this.hasSourceTextures||this.targetTextureVarying?[fa].concat(e.modules||[]):e.modules;return{vs:a,fs:f,modules:h,uniforms:o,inject:l}}}]),e}();function pa(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 ma(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 ma(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 ma(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 ya=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=pa([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()}ot(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=pa(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=pa(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 Zi(t,Object.assign({},e,{fs:e.fs||ra({version:ca(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=pa([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(!ht(e.feedbackBuffers)||!ht(e.feedbackMap)||e.varyings&&e.varyings.length>0)return!0;return!1})(t)&&(this.bufferTransform=new ua(e,t)),function(e){if(!ht(e._sourceTextures)||e._targetTexture||e._targetTextureVarying)return!0;return!1}(t)&&(this.textureTransform=new ga(e,t)),ot(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=pa([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 _a(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 ba(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 ba(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 ba(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 Aa=1,xa=1,Ea=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=Aa++,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=_a(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=_a(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=_a(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=xa++;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 Ta(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 ka={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},wa=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?lt("geometry"):n,i=t.drawMode,a=void 0===i?ka.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?Ta(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ta(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,ot(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?(ot(!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 ot(Number.isFinite(n)),n}}],[{key:"DRAW_MODE",get:function(){return ka}}]),e}();function Oa(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Sa=[-1,-1,1,-1,-1,1,1,1],La=function(e){tt()(n,e);var t=Oa(n);function n(e,r){var i;l()(this,n);var a=Sa.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 wa({drawMode:5,vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(Sa)},aTexCoord:{size:2,value:new Float32Array(a)},aCoordinate:{size:2,value:new Float32Array(a)}}})}))).setVertexCount(4),i}return h()(n)}(Zi);function Ia(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 Pa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ia(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ia(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ra(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Fa={x:[2,0,1],y:[0,1,2],z:[1,2,0]},Ca=function(e){tt()(n,e);var t=Ra(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?lt("truncated-code-geometry"):r,a=Ba(e),o=a.indices,s=a.attributes;return t.call(this,Pa(Pa({},e),{},{id:i,indices:o,attributes:Pa(Pa({},s),e.attributes)}))}return h()(n)}(wa);function Ba(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=Fa[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 Ma(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 Na(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ma(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ma(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Da(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var ja=function(e){tt()(n,e);var t=Da(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?lt("cone-geometry"):r,a=e.radius,o=void 0===a?1:a,s=e.cap,u=void 0===s||s;return t.call(this,Na(Na({},e),{},{id:i,topRadius:0,topCap:Boolean(u),bottomCap:Boolean(u),bottomRadius:o}))}return h()(n)}(Ca);function Ua(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 Ga(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ua(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ua(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Va(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var za=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]),Ha=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]),Wa=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]),Xa=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]),qa={POSITION:{size:3,value:new Float32Array(Ha)},NORMAL:{size:3,value:new Float32Array(Wa)},TEXCOORD_0:{size:2,value:new Float32Array(Xa)}},Ka=function(e){tt()(n,e);var t=Va(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?lt("cube-geometry"):r;return t.call(this,Ga(Ga({},e),{},{id:i,indices:{size:1,value:new Uint16Array(za)},attributes:Ga(Ga({},qa),e.attributes)}))}return h()(n)}(wa);function Ya(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 Qa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ya(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ya(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function $a(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Za=function(e){tt()(n,e);var t=$a(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?lt("cylinder-geometry"):r,a=e.radius,o=void 0===a?1:a;return t.call(this,Qa(Qa({},e),{},{id:i,bottomRadius:o,topRadius:o}))}return h()(n)}(Ca);function Ja(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}Math.PI,Math.PI;var eo={};function to(e){return Math.round(e/eo.EPSILON)*eo.EPSILON}function no(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.precision,r=void 0===n?eo.precision||4:n;return e=to(e),"".concat(parseFloat(e.toPrecision(r)))}function ro(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function io(e,t,n){var r=eo.EPSILON;n&&(eo.EPSILON=n);try{if(e===t)return!0;if(ro(e)&&ro(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!io(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)<=eo.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{eo.EPSILON=r}}function ao(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}eo.EPSILON=1e-12,eo.debug=!1,eo.precision=4,eo.printTypes=!1,eo.printDegrees=!1,eo.printRowMajor=!0;var oo=function(e){tt()(n,e);var t=ao(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return Ja(!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:ro(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(eo)}},{key:"formatString",value:function(e){for(var t="",n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+no(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(!io(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(eo.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 so(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 uo(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function co(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(eo.debug&&!so(e,t))throw new Error("math.gl: ".concat(n," some fields set to invalid numbers'"));return e}var lo={};function fo(e,t){lo[e]||(lo[e]=!0,console.warn("".concat(e," has been removed in version ").concat(t,", see upgrade guide for more information")))}function ho(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var vo=function(e){tt()(n,e);var t=ho(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return Ja(!1),0}},{key:"copy",value:function(e){return Ja(!1),this}},{key:"x",get:function(){return this[0]},set:function(e){this[0]=uo(e)}},{key:"y",get:function(){return this[1]},set:function(e){this[1]=uo(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 uo(t)}},{key:"dot",value:function(e){for(var t=0,n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return uo(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 Ja(e>=0&&e<this.ELEMENTS,"index is out of range"),uo(this[e])}},{key:"setComponent",value:function(e,t){return Ja(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}(oo),go=1e-6,po="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function mo(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 yo,_o;yo=new po(3),po!=Float32Array&&(yo[0]=0,yo[1]=0,yo[2]=0),_o=yo;function bo(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 Ao(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var xo=[0,0,0],Eo={},To=function(e){tt()(n,e);var t=Ao(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&&ro(r)?e.copy(r):(eo.debug&&(uo(r),uo(i),uo(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 eo.debug&&(uo(e.x),uo(e.y),uo(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]=uo(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?xo: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?xo: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?xo:n,t),this.check()}},{key:"transform",value:function(e){return this.transformAsPoint(e)}},{key:"transformAsPoint",value:function(e){return mo(this,this,e),this.check()}},{key:"transformAsVector",value:function(e){return bo(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 Eo.ZERO=Eo.ZERO||Object.freeze(new n(0,0,0,0))}}]),n}(vo);function ko(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 wo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ko(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ko(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var So=[-1,0,0,0,1,0,0,0,-1,0,0,1,0,-1,0,1,0,0],Lo=[3,4,5,3,5,1,3,1,0,3,0,4,4,0,2,4,2,5,2,0,1,5,2,1],Io=function(e){tt()(n,e);var t=Oo(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?lt("ico-sphere-geometry"):r,a=Po(e),o=a.indices,s=a.attributes;return t.call(this,wo(wo({},e),{},{id:i,indices:o,attributes:wo(wo({},s),e.attributes)}))}return h()(n)}(wa);function Po(e){var t=e.iterations,n=void 0===t?0:t,r=Math.PI,i=2*r,a=[].concat(So),o=[].concat(Lo);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 To([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 Ro(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 Fo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ro(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ro(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Co(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Bo=function(e){tt()(n,e);var t=Co(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?lt("plane-geometry"):r,a=Mo(e),o=a.indices,s=a.attributes;return t.call(this,Fo(Fo({},e),{},{id:i,indices:o,attributes:Fo(Fo({},s),e.attributes)}))}return h()(n)}(wa);function Mo(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 No(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 Do(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?No(Object(n),!0).forEach((function(t){u()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):No(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function jo(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Uo=function(e){tt()(n,e);var t=jo(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?lt("sphere-geometry"):r,a=Go(e),o=a.indices,s=a.attributes;return t.call(this,Do(Do({},e),{},{id:i,indices:o,attributes:Do(Do({},s),e.attributes)}))}return h()(n)}(wa);function Go(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 Vo={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 zo(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 Ho(e){return e-Math.fround(e)}function Wo(e){for(var t=new Float32Array(32),n=0;n<4;++n)for(var r=0;r<4;++r){var i=4*n+r;zo(e[4*r+n],t,2*i)}return t}var Xo={ONE:1};var qo={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 Xo},fp64ify:zo,fp64LowPart:Ho,fp64ifyMatrix4:Wo}],fp64ify:zo,fp64LowPart:Ho,fp64ifyMatrix4:Wo};function Ko(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var Yo=function(e){tt()(n,e);var t=Ko(n);function n(){return l()(this,n),t.apply(this,arguments)}return h()(n,[{key:"ELEMENTS",get:function(){return Ja(!1),0}},{key:"RANK",get:function(){return Ja(!1),0}},{key:"toString",value:function(){var e="[";if(eo.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]=uo(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}(oo);function Qo(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 $o(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 Zo(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 Jo(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)<go&&Math.abs(g-A)<go&&Math.abs(p-x)<go?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 po(2);return po!=Float32Array&&(e[0]=0,e[1]=0),e}()}();!function(){var e=function(){var e=new po(4);return po!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();function es(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=at()(e);if(t){var i=at()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return rt()(this,n)}}var ts=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ns=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),rs=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}),is={},as=function(e){tt()(n,e);var t=es(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 rs}},{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(ts)}},{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 Jo(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 Zo(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 Qo(this,e,this),this.check()}},{key:"multiplyRight",value:function(e){return Qo(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<go||(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)?$o(this,this,e):$o(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?(co(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=mo(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return co(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=bo(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return co(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 fo("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}},{key:"transformVector",value:function(e,t){return fo("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}},{key:"transformDirection",value:function(e,t){return fo("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}],[{key:"IDENTITY",get:function(){return is.IDENTITY=is.IDENTITY||Object.freeze(new n(ts)),is.IDENTITY}},{key:"ZERO",get:function(){return is.ZERO=is.ZERO||Object.freeze(new n(ns)),is.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}(Yo),os=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],ss={modelMatrix:os,viewMatrix:os,projectionMatrix:os,cameraPositionWorld:[0,0,0]};var us="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",cs={name:"project",getUniforms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ss,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 as(e.projectionMatrix).multiplyRight(e.viewMatrix)),t},vs:"".concat(us,"\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(us)},ls={lightDirection:new Float32Array([1,1,2])};var fs={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]:ls,t={};return e.lightDirection&&(t.dirlight_uLightDirection=e.lightDirection),t},dependencies:[cs]},hs={pickingSelectedColor:null,pickingHighlightColor:new Uint8Array([0,255,255,255]),pickingActive:!1,pickingAttribute:!1};var ds={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]:hs,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}},vs="#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 gs(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 ps(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 ps(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 ps(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 ms={lightSources:{}};function ys(){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 _s(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?ys(t):[0,0,0],r.forEach((function(e,t){o["lighting_uPointLight[".concat(t,"].color")]=ys(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")]=ys(e),o["lighting_uDirectionalLight[".concat(t,"].direction")]=e.direction})),o.lighting_uDirectionalLightCount=a.length,o}var bs={name:"lights",vs:vs,fs:vs,getUniforms:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ms;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({},_s({ambientLight:r,pointLights:i,directionalLights:a}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){var s,u={pointLights:[],directionalLights:[]},c=gs(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}},As="\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",xs={};function Es(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 Ts(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xs;if(!("material"in e))return{};var t=e.material;return t?Es(t):{lighting_uEnabled:!1}}var ks={name:"gouraud-lighting",dependencies:[bs],vs:As,defines:{LIGHTING_VERTEX:1},getUniforms:Ts},ws={name:"phong-lighting",dependencies:[bs],fs:As,defines:{LIGHTING_FRAGMENT:1},getUniforms:Ts},Os={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:[bs]}}])}));