Files
webgl_play/build/bundle.js
2020-06-23 23:53:03 +02:00

1 line
28 KiB
JavaScript

!function(e){var t=window.webpackHotUpdate;window.webpackHotUpdate=function(e,r){!function(e,t){if(!O[e]||!w[e])return;for(var r in w[e]=!1,t)Object.prototype.hasOwnProperty.call(t,r)&&(d[r]=t[r]);0==--m&&0===g&&S()}(e,r),t&&t(e,r)};var r,n=!0,o="f2c88108809235be8897",i={},a=[],u=[];function c(e){var t=j[e];if(!t)return R;var n=function(n){return t.hot.active?(j[n]?-1===j[n].parents.indexOf(e)&&j[n].parents.push(e):(a=[e],r=n),-1===t.children.indexOf(n)&&t.children.push(n)):(console.warn("[HMR] unexpected require("+n+") from disposed module "+e),a=[]),R(n)},o=function(e){return{configurable:!0,enumerable:!0,get:function(){return R[e]},set:function(t){R[e]=t}}};for(var i in R)Object.prototype.hasOwnProperty.call(R,i)&&"e"!==i&&"t"!==i&&Object.defineProperty(n,i,o(i));return n.e=function(e){return"ready"===f&&p("prepare"),g++,R.e(e).then(t,(function(e){throw t(),e}));function t(){g--,"prepare"===f&&(b[e]||P(e),0===g&&0===m&&S())}},n.t=function(e,t){return 1&t&&(e=n(e)),R.t(e,-2&t)},n}function l(t){var n={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_selfInvalidated:!1,_disposeHandlers:[],_main:r!==t,active:!0,accept:function(e,t){if(void 0===e)n._selfAccepted=!0;else if("function"==typeof e)n._selfAccepted=e;else if("object"==typeof e)for(var r=0;r<e.length;r++)n._acceptedDependencies[e[r]]=t||function(){};else n._acceptedDependencies[e]=t||function(){}},decline:function(e){if(void 0===e)n._selfDeclined=!0;else if("object"==typeof e)for(var t=0;t<e.length;t++)n._declinedDependencies[e[t]]=!0;else n._declinedDependencies[e]=!0},dispose:function(e){n._disposeHandlers.push(e)},addDisposeHandler:function(e){n._disposeHandlers.push(e)},removeDisposeHandler:function(e){var t=n._disposeHandlers.indexOf(e);t>=0&&n._disposeHandlers.splice(t,1)},invalidate:function(){switch(this._selfInvalidated=!0,f){case"idle":(d={})[t]=e[t],p("ready");break;case"ready":x(t);break;case"prepare":case"check":case"dispose":case"apply":(v=v||[]).push(t)}},check:k,apply:E,status:function(e){if(!e)return f;s.push(e)},addStatusHandler:function(e){s.push(e)},removeStatusHandler:function(e){var t=s.indexOf(e);t>=0&&s.splice(t,1)},data:i[t]};return r=void 0,n}var s=[],f="idle";function p(e){f=e;for(var t=0;t<s.length;t++)s[t].call(null,e)}var h,d,y,v,m=0,g=0,b={},w={},O={};function _(e){return+e+""===e?+e:e}function k(e){if("idle"!==f)throw new Error("check() is only allowed in idle status");return n=e,p("check"),(t=1e4,t=t||1e4,new Promise((function(e,r){if("undefined"==typeof XMLHttpRequest)return r(new Error("No browser support"));try{var n=new XMLHttpRequest,i=R.p+""+o+".hot-update.json";n.open("GET",i,!0),n.timeout=t,n.send(null)}catch(e){return r(e)}n.onreadystatechange=function(){if(4===n.readyState)if(0===n.status)r(new Error("Manifest request to "+i+" timed out."));else if(404===n.status)e();else if(200!==n.status&&304!==n.status)r(new Error("Manifest request to "+i+" failed."));else{try{var t=JSON.parse(n.responseText)}catch(e){return void r(e)}e(t)}}}))).then((function(e){if(!e)return p(A()?"ready":"idle"),null;w={},b={},O=e.c,y=e.h,p("prepare");var t=new Promise((function(e,t){h={resolve:e,reject:t}}));d={};return P(0),"prepare"===f&&0===g&&0===m&&S(),t}));var t}function P(e){O[e]?(w[e]=!0,m++,function(e){var t=document.createElement("script");t.charset="utf-8",t.src=R.p+""+e+"."+o+".hot-update.js",document.head.appendChild(t)}(e)):b[e]=!0}function S(){p("ready");var e=h;if(h=null,e)if(n)Promise.resolve().then((function(){return E(n)})).then((function(t){e.resolve(t)}),(function(t){e.reject(t)}));else{var t=[];for(var r in d)Object.prototype.hasOwnProperty.call(d,r)&&t.push(_(r));e.resolve(t)}}function E(t){if("ready"!==f)throw new Error("apply() is only allowed in ready status");return function t(n){var u,c,l,s,f;function h(e){for(var t=[e],r={},n=t.map((function(e){return{chain:[e],id:e}}));n.length>0;){var o=n.pop(),i=o.id,a=o.chain;if((s=j[i])&&(!s.hot._selfAccepted||s.hot._selfInvalidated)){if(s.hot._selfDeclined)return{type:"self-declined",chain:a,moduleId:i};if(s.hot._main)return{type:"unaccepted",chain:a,moduleId:i};for(var u=0;u<s.parents.length;u++){var c=s.parents[u],l=j[c];if(l){if(l.hot._declinedDependencies[i])return{type:"declined",chain:a.concat([c]),moduleId:i,parentId:c};-1===t.indexOf(c)&&(l.hot._acceptedDependencies[i]?(r[c]||(r[c]=[]),m(r[c],[i])):(delete r[c],t.push(c),n.push({chain:a.concat([c]),id:c})))}}}}return{type:"accepted",moduleId:e,outdatedModules:t,outdatedDependencies:r}}function m(e,t){for(var r=0;r<t.length;r++){var n=t[r];-1===e.indexOf(n)&&e.push(n)}}A();var g={},b=[],w={},k=function(){console.warn("[HMR] unexpected require("+S.moduleId+") to disposed module")};for(var P in d)if(Object.prototype.hasOwnProperty.call(d,P)){var S;f=_(P),S=d[P]?h(f):{type:"disposed",moduleId:P};var E=!1,x=!1,T=!1,M="";switch(S.chain&&(M="\nUpdate propagation: "+S.chain.join(" -> ")),S.type){case"self-declined":n.onDeclined&&n.onDeclined(S),n.ignoreDeclined||(E=new Error("Aborted because of self decline: "+S.moduleId+M));break;case"declined":n.onDeclined&&n.onDeclined(S),n.ignoreDeclined||(E=new Error("Aborted because of declined dependency: "+S.moduleId+" in "+S.parentId+M));break;case"unaccepted":n.onUnaccepted&&n.onUnaccepted(S),n.ignoreUnaccepted||(E=new Error("Aborted because "+f+" is not accepted"+M));break;case"accepted":n.onAccepted&&n.onAccepted(S),x=!0;break;case"disposed":n.onDisposed&&n.onDisposed(S),T=!0;break;default:throw new Error("Unexception type "+S.type)}if(E)return p("abort"),Promise.reject(E);if(x)for(f in w[f]=d[f],m(b,S.outdatedModules),S.outdatedDependencies)Object.prototype.hasOwnProperty.call(S.outdatedDependencies,f)&&(g[f]||(g[f]=[]),m(g[f],S.outdatedDependencies[f]));T&&(m(b,[S.moduleId]),w[f]=k)}var I,D=[];for(c=0;c<b.length;c++)f=b[c],j[f]&&j[f].hot._selfAccepted&&w[f]!==k&&!j[f].hot._selfInvalidated&&D.push({module:f,parents:j[f].parents.slice(),errorHandler:j[f].hot._selfAccepted});p("dispose"),Object.keys(O).forEach((function(e){!1===O[e]&&function(e){delete installedChunks[e]}(e)}));var C,L,F=b.slice();for(;F.length>0;)if(f=F.pop(),s=j[f]){var B={},U=s.hot._disposeHandlers;for(l=0;l<U.length;l++)(u=U[l])(B);for(i[f]=B,s.hot.active=!1,delete j[f],delete g[f],l=0;l<s.children.length;l++){var H=j[s.children[l]];H&&((I=H.parents.indexOf(f))>=0&&H.parents.splice(I,1))}}for(f in g)if(Object.prototype.hasOwnProperty.call(g,f)&&(s=j[f]))for(L=g[f],l=0;l<L.length;l++)C=L[l],(I=s.children.indexOf(C))>=0&&s.children.splice(I,1);p("apply"),void 0!==y&&(o=y,y=void 0);for(f in d=void 0,w)Object.prototype.hasOwnProperty.call(w,f)&&(e[f]=w[f]);var V=null;for(f in g)if(Object.prototype.hasOwnProperty.call(g,f)&&(s=j[f])){L=g[f];var q=[];for(c=0;c<L.length;c++)if(C=L[c],u=s.hot._acceptedDependencies[C]){if(-1!==q.indexOf(u))continue;q.push(u)}for(c=0;c<q.length;c++){u=q[c];try{u(L)}catch(e){n.onErrored&&n.onErrored({type:"accept-errored",moduleId:f,dependencyId:L[c],error:e}),n.ignoreErrored||V||(V=e)}}}for(c=0;c<D.length;c++){var G=D[c];f=G.module,a=G.parents,r=f;try{R(f)}catch(e){if("function"==typeof G.errorHandler)try{G.errorHandler(e)}catch(t){n.onErrored&&n.onErrored({type:"self-accept-error-handler-errored",moduleId:f,error:t,originalError:e}),n.ignoreErrored||V||(V=t),V||(V=e)}else n.onErrored&&n.onErrored({type:"self-accept-errored",moduleId:f,error:e}),n.ignoreErrored||V||(V=e)}}if(V)return p("fail"),Promise.reject(V);if(v)return t(n).then((function(e){return b.forEach((function(t){e.indexOf(t)<0&&e.push(t)})),e}));return p("idle"),new Promise((function(e){e(b)}))}(t=t||{})}function A(){if(v)return d||(d={}),v.forEach(x),v=void 0,!0}function x(t){Object.prototype.hasOwnProperty.call(d,t)||(d[t]=e[t])}var j={};function R(t){if(j[t])return j[t].exports;var r=j[t]={i:t,l:!1,exports:{},hot:l(t),parents:(u=a,a=[],u),children:[]};return e[t].call(r.exports,r,r.exports,c(t)),r.l=!0,r.exports}R.m=e,R.c=j,R.d=function(e,t,r){R.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},R.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},R.t=function(e,t){if(1&t&&(e=R(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(R.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)R.d(r,n,function(t){return e[t]}.bind(null,n));return r},R.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return R.d(t,"a",t),t},R.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},R.p="/",R.h=function(){return o},c(0)(R.s=0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";r.r(t);function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var a=function(){function e(){n(this,e),i(this,"matrix",void 0);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];if(16!==r[0].length)throw new VectorSizeError(16,r[0].length);r[0]instanceof Float32Array||(r[0]=new Float32Array(r[0])),this.matrix=r[0]}var t,r,a;return t=e,a=[{key:"Identity",value:function(){return new e((t=4,r=Array(t*t).fill(0),new Float32Array(r.map((function(e,t){return t%5==0?1:0})))));var t,r}}],(r=[{key:"times",value:function(t){var r=new e(Array(16)),n=this.matrix,o=t.matrix,i=r.matrix;return i[0]=n[0]*o[0]+n[1]*o[4]+n[2]*o[8]+n[3]*o[12],i[1]=n[0]*o[1]+n[1]*o[5]+n[2]*o[9]+n[3]*o[13],i[2]=n[0]*o[2]+n[1]*o[6]+n[2]*o[10]+n[3]*o[14],i[3]=n[0]*o[3]+n[1]*o[7]+n[2]*o[11]+n[3]*o[15],i[4]=n[4]*o[0]+n[5]*o[4]+n[6]*o[8]+n[7]*o[12],i[5]=n[4]*o[1]+n[5]*o[5]+n[6]*o[9]+n[7]*o[13],i[6]=n[4]*o[2]+n[5]*o[6]+n[6]*o[10]+n[7]*o[14],i[7]=n[4]*o[3]+n[5]*o[7]+n[6]*o[11]+n[7]*o[15],i[8]=n[8]*o[0]+n[9]*o[4]+n[10]*o[8]+n[11]*o[12],i[9]=n[8]*o[1]+n[9]*o[5]+n[10]*o[9]+n[11]*o[13],i[10]=n[8]*o[2]+n[9]*o[6]+n[10]*o[10]+n[11]*o[14],i[11]=n[8]*o[3]+n[9]*o[7]+n[10]*o[11]+n[11]*o[15],i[12]=n[12]*o[0]+n[13]*o[4]+n[14]*o[8]+n[15]*o[12],i[13]=n[12]*o[1]+n[13]*o[5]+n[14]*o[9]+n[15]*o[13],i[14]=n[12]*o[2]+n[13]*o[6]+n[14]*o[10]+n[15]*o[14],i[15]=n[12]*o[3]+n[13]*o[7]+n[14]*o[11]+n[15]*o[15],r}},{key:"buffer",value:function(){return this.matrix.slice()}},{key:"set",value:function(e,t,r){this.matrix[4*e+t]=r}},{key:"setRel",value:function(e,t,r){this.matrix[4*e+t]+=r}}])&&o(t.prototype,r),a&&o(t,a),e}();function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=function(){function e(){u(this,e),l(this,"trs",a.Identity());for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r[0]&&(r[0]instanceof e?this.trs=new a(r[0].buffer()):this.trs=r[0].times(r[1]).times(r[2]).times(r[3]).times(r[4]))}var t,r,n;return t=e,(r=[{key:"toMatrix4",value:function(){return this.trs}},{key:"buffer",value:function(){return this.trs.buffer()}},{key:"translateBy",value:function(e,t,r){return this.trs=this.trs.times(new a([1,0,0,0,0,1,0,0,0,0,1,0,e,t,r,1])),this}},{key:"rotateBy",value:function(e,t,r){var n=Math.sin(e),o=Math.cos(e),i=Math.sin(t),u=Math.cos(t),c=Math.sin(r),l=Math.cos(r);return this.trs=this.trs.times(new a([1,0,0,0,0,o,n,0,0,-n,o,0,0,0,0,1])).times(new a([u,0,-i,0,0,1,0,0,i,0,u,0,0,0,0,1])).times(new a([l,c,0,0,-c,l,0,0,0,0,1,0,0,0,0,1])),this}},{key:"scaleBy",value:function(e,t,r){return this.trs=this.trs.times(new a([e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1])),this}}])&&c(t.prototype,r),n&&c(t,n),e}();function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}(e)||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 h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=g(e);if(t){var o=g(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return m(this,r)}}function m(e,t){return!t||"object"!==f(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var b=function(e){!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&&y(e,t)}(i,e);var t,r,n,o=v(i);function i(e,t){var r;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),"number"==typeof e)r=o.call(this,e,t,0);else{if(2!==e.length)throw new VectorSizeError(2,e.length);r=o.call(this,[].concat(p(e),[0]))}return m(r)}return t=i,n=[{key:"Zeros",value:function(){return new i(0,0)}}],(r=[{key:"xOrd",value:function(){return this.rep[0]}},{key:"yOrd",value:function(){return this.rep[1]}},{key:"setX",value:function(e){this.rep[0]=e}},{key:"setY",value:function(e){this.rep[1]=e}},{key:"vec",value:function(){return new Float32Array(p(this.rep))}}])&&d(t.prototype,r),n&&d(t,n),i}((function e(t,r,n){var o,i,a;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a=void 0,(i="rep")in(o=this)?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,"number"==typeof t){if("number"!=typeof r||"number"!=typeof n)throw new TypeError("Incorrect constructor call for Point3D");this.rep=new Float32Array(3),this.rep[0]=t,this.rep[1]=r,this.rep[2]=n}else this.rep=new Float32Array(t[2])}));function w(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return O(e,t)}(e)||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 O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function P(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var S=function(){function e(){_(this,e),P(this,"geometryRep",void 0),P(this,"color",void 0),P(this,"trsMatrix",void 0);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];if(r[0]instanceof Float32Array){var o,i;if(6!==r[0].length&&8!==r[0].length)throw new VectorSizeError("6 or 9",r[0].length);6===r[0].length?this.geometryRep=new Float32Array([].concat(w(r[0].slice(0,2)),[0],w(r[0].slice(2,4)),[0],w(r[0].slice(4,6)),[0])):this.geometryRep=r[0],this.trsMatrix=null!==(o=r[1])&&void 0!==o?o:new s,this.color=null!==(i=r[2])&&void 0!==i?i:new BasicColor(0,0,0,1)}else{var a,u;this.geometryRep=new Float32Array([].concat(w(r[0].vec()),w(r[1].vec()),w(r[2].vec()))),this.trsMatrix=null!==(a=r[3])&&void 0!==a?a:new s,this.color=null!==(u=r[4])&&void 0!==u?u:new BasicColor(0,0,0,1)}}var t,r,n;return t=e,(r=[{key:"colorVec",value:function(){return this.color.vec()}},{key:"setColor",value:function(e){this.color=e}},{key:"getColor",value:function(){return this.color}},{key:"getTrsMatrix",value:function(){return this.trsMatrix}},{key:"mapPointTo",value:function(e,t){e instanceof b?(this.geometryRep[t]=e.xOrd(),this.geometryRep[t+1]=e.yOrd()):(this.geometryRep[t]=e[0],this.geometryRep[t+1]=e[1])}},{key:"updatePoints",value:function(e,t,r){e&&this.mapPointTo(e,0),t&&this.mapPointTo(t,3),r&&this.mapPointTo(r,6)}},{key:"updatePointsFromVec",value:function(e){if(6!==e.length)throw new VectorSizeError(6,e.length);this.geometryRep=e}},{key:"pointBuffer",value:function(){return this.geometryRep}},{key:"translateBy",value:function(e,t,r){return this.trsMatrix.translateBy(e,t,r),this}},{key:"rotateBy",value:function(e,t,r){return this.trsMatrix.rotateBy(e,t,r),this}},{key:"scaleBy",value:function(e,t,r){return this.trsMatrix.scaleBy(e,t,r),this}}])&&k(t.prototype,r),n&&k(t,n),e}();function E(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var A=function(){function e(t,r,n,o){var i,a,u;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u=void 0,(a="rep")in(i=this)?Object.defineProperty(i,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):i[a]=u,this.rep=new Float32Array([t,r,n,null!=o?o:1])}var t,r,n;return t=e,n=[{key:"fromVec",value:function(t){if(4===t.length)return new e(t[0],t[1],t[2],t[3]);if(3===t.length)return new e(t[0],t[1],t[2]);throw new VectorSizeError("3 to 4",t.length)}}],(r=[{key:"red",value:function(){return this.rep[0]}},{key:"green",value:function(){return this.rep[1]}},{key:"blue",value:function(){return this.rep[2]}},{key:"alpha",value:function(){return this.rep[3]}},{key:"setRed",value:function(e){this.rep[0]=e}},{key:"setGreen",value:function(e){this.rep[1]=e}},{key:"setBlue",value:function(e){this.rep[2]=e}},{key:"setAlpha",value:function(e){this.rep[3]=e}},{key:"vec",value:function(){return this.rep}}])&&E(t.prototype,r),n&&E(t,n),e}();function x(e){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function j(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function R(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&&L(e,t)}function T(e){var t=C();return function(){var r,n=F(e);if(t){var o=F(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return M(this,r)}}function M(e,t){return!t||"object"!==x(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function I(e){var t="function"==typeof Map?new Map:void 0;return(I=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return D(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),L(n,e)})(e)}function D(e,t,r){return(D=C()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&L(o,r.prototype),o}).apply(null,arguments)}function C(){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 L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var B,U=function(e){R(r,e);var t=T(r);function r(e){var n;return j(this,r),(n=t.call(this,e)).name="ShaderCompilationError",n}return r}(I(Error)),H=function(e){R(r,e);var t=T(r);function r(e){var n;return j(this,r),(n=t.call(this,e)).name="ProgramLinkingError",n}return r}(I(Error));Error;function V(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return q(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}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 i,a=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function G(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function N(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e[e.ERROR=0]="ERROR",e[e.QUIT=1]="QUIT",e[e.CONTINUE=2]="CONTINUE",e[e.WEBGL_ERROR=3]="WEBGL_ERROR"}(B||(B={}));var z=function(){function e(t,r){var n,o,i,u,c,l;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),N(this,"gl",void 0),N(this,"stage",void 0),N(this,"perspMat",void 0),N(this,"currentProgram",void 0),N(this,"positionAttributeLocation",0),N(this,"u_colorLoc",0),N(this,"u_trsMatrixLoc",0),N(this,"maxTris",1e3),N(this,"tris",[]),N(this,"sinceLastTri",0),N(this,"onShutdownCallback",(function(){})),this.gl=t,this.stage=r,this.currentProgram=this.createDefaultProgram(),this.perspMat=(n=90,o=this.stage.width/this.stage.height,i=1,u=2e3,c=Math.tan(.5*Math.PI-.5*n),new a([c/o,0,0,0,0,c,0,0,0,0,(i+u)*(l=1/(i-u)),-1,0,0,i*u*l*2,0])),this.setupGl()}var t,r,n;return t=e,(r=[{key:"setupGl",value:function(){this.gl.enable(this.gl.DEPTH_TEST),this.gl.enable(this.gl.CULL_FACE)}},{key:"onShutdown",value:function(e){this.onShutdownCallback=e}},{key:"shutdown",value:function(e){this.onShutdownCallback(e)}},{key:"createDefaultProgram",value:function(){var e=this.createProgram(this.createShaderFromString(this.gl.VERTEX_SHADER,"attribute vec4 a_position;\n\nuniform mat4 u_trsMatrix;\n\nvarying float v_depth;\n\n\nvoid main() {\n vec4 pos = u_trsMatrix * a_position;\n v_depth = pos.z;\n gl_Position = pos;\n}"),this.createShaderFromString(this.gl.FRAGMENT_SHADER,"precision mediump float;\n\nuniform vec4 u_color;\n\nvarying float v_depth;\n\nvoid main() {\n gl_FragColor = vec4(exp(v_depth), exp(v_depth), exp(v_depth), 1.0);\n}"));return this.positionAttributeLocation=this.gl.getAttribLocation(e,"a_position"),this.u_colorLoc=this.gl.getUniformLocation(e,"u_color"),this.u_trsMatrixLoc=this.gl.getUniformLocation(e,"u_trsMatrix"),e}},{key:"createProgram",value:function(e,t){var r=this.gl.createProgram();if(this.gl.attachShader(r,e),this.gl.attachShader(r,t),this.gl.linkProgram(r),this.gl.getProgramParameter(r,this.gl.LINK_STATUS))return r;var n=this.gl.getProgramInfoLog(r);throw this.gl.deleteProgram(r),new H(null!=n?n:"")}},{key:"createShaderFromString",value:function(e,t){var r=this.gl.createShader(e);if(this.gl.shaderSource(r,t),this.gl.compileShader(r),this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS))return r;var n,o=null===(n=this.gl.getShaderInfoLog(r))||void 0===n?void 0:n.toString();throw this.gl.deleteShader(r),new U(null!=o?o:"")}},{key:"renderTriangle",value:function(e){this.gl.bufferData(this.gl.ARRAY_BUFFER,e.pointBuffer(),this.gl.STATIC_DRAW),this.gl.uniform4fv(this.u_colorLoc,e.colorVec()),this.gl.uniformMatrix4fv(this.u_trsMatrixLoc,!1,e.getTrsMatrix().buffer()),this.gl.drawArrays(this.gl.TRIANGLES,0,3)}},{key:"initViewport",value:function(){this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}},{key:"useDefaultProgram",value:function(){this.gl.useProgram(this.currentProgram);var e=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e),this.gl.enableVertexAttribArray(this.positionAttributeLocation),this.gl.vertexAttribPointer(this.positionAttributeLocation,3,this.gl.FLOAT,!1,0,0)}},{key:"createRandomTriangle",value:function(){return new S(this.rand2DClipspacePoint(),this.rand2DClipspacePoint(),this.rand2DClipspacePoint(),this.randTrsMat(),this.randBasicColor())}},{key:"randTrsMat",value:function(){return(new s).translateBy(this.randClipspaceInt()/2,this.randClipspaceInt()/2,this.randClipspaceInt()/2).rotateBy(this.randAngle(),this.randAngle(),this.randAngle())}},{key:"rand2DClipspacePoint",value:function(){return new b(this.randClipspaceInt()/2,this.randClipspaceInt()/2)}},{key:"randBasicColor",value:function(){return new A(Math.random(),Math.random(),Math.random())}},{key:"randAngle",value:function(){return Math.random()*Math.PI/10}},{key:"randClipspaceInt",value:function(){return 2*Math.random()-1}},{key:"animateRandomTrisPopin",value:function(e){this.maxTris>=this.tris.length&&(this.sinceLastTri+=e,this.sinceLastTri>100&&(this.tris.push(this.createRandomTriangle()),this.sinceLastTri=0));var t,r=V(this.tris);try{for(r.s();!(t=r.n()).done;){var n=t.value;this.renderTriangle(n)}}catch(e){r.e(e)}finally{r.f()}}},{key:"animate",value:function(e){var t=this,r=Date.now(),n=r-e;this.animateRandomTrisPopin(n),window.requestAnimationFrame((function(){return t.animate(r)}))}},{key:"run",value:function(){var e=this;this.initViewport(),this.useDefaultProgram(),window.requestAnimationFrame((function(){return e.animate(Date.now())}))}}])&&G(t.prototype,r),n&&G(t,n),e}();function W(e,t){var r=document.createElement("div");r.id=e.id,r.innerText=t,e.replaceWith(r)}window.onload=function(){var e=function(e,t){var r=document.querySelector("#root"),n=document.createElement("canvas");return n.id="main-stage",n.width=e,n.height=t,r.appendChild(n),n}(1024,720),t=e.getContext("webgl");if(t){var r=new z(t,e);r.onShutdown((function(t){return function(e,t){t===B.QUIT?W(e,"We're done here."):t===B.ERROR&&W(e,"Something unexpected happened and forced the program to shut down.")}(e,t)})),r.run()}else W(e,"Unable to initialize WebGL. Your browser or machine may not support it.")}}]);