@voidrayco/voidgl
Version:
This is a WebGL foundation library that VoidRay uses in our visualizations.
1 lines • 139 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("three"),require("ramda"),require("react"),require("d3-color"),require("bowser")):"function"==typeof define&&define.amd?define(["three","ramda","react","d3-color","bowser"],e):"object"==typeof exports?exports.voidgl=e(require("three"),require("ramda"),require("react"),require("d3-color"),require("bowser")):t.voidgl=e(t.three,t.ramda,t.react,t["d3-color"],t.bowser)}(this,function(t,e,r,n,o){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=30)}([function(e,r){e.exports=t},function(t,e,r){"use strict";function n(t,e){O=t[0],T=t[1],z=t[2],R=t[3],E=t[4],L=t[5],U=t[6],D=t[7],k=t[8],j=t[9],N=t[10],J=e[0],K=e[1],tt=e[2],et=e[3],rt=e[4],nt=e[5],ot=e[6],it=e[7],st=e[8],at=e[9],ut=e[10]}function o(t,e){for(var r=ft;r<t;++r)W=r*J,e(r-ft,O,W)}function i(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,e(r-ft,O,W,T,X)}function s(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,e(r-ft,O,W,T,X,z,F)}function a(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,e(r-ft,O,W,T,X,z,F,R,V)}function u(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,Y=r*rt,e(r-ft,O,W,T,X,z,F,R,V,E,Y)}function f(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,Y=r*rt,q=r*nt,e(r-ft,O,W,T,X,z,F,R,V,E,Y,L,q)}function c(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,Y=r*rt,q=r*nt,H=r*ot,e(r-ft,O,W,T,X,z,F,R,V,E,Y,L,q,U,H)}function h(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,Y=r*rt,q=r*nt,H=r*ot,Z=r*it,e(r-ft,O,W,T,X,z,F,R,V,E,Y,L,q,U,H,D,Z)}function l(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,Y=r*rt,q=r*nt,H=r*ot,Z=r*it,G=r*st,e(r-ft,O,W,T,X,z,F,R,V,E,Y,L,q,U,H,D,Z,k,G)}function d(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,Y=r*rt,q=r*nt,H=r*ot,Z=r*it,G=r*st,Q=r*at,e(r-ft,O,W,T,X,z,F,R,V,E,Y,L,q,U,H,D,Z,k,G,j,Q)}function p(t,e){for(var r=ft;r<t;++r)W=r*J,X=r*K,F=r*tt,V=r*et,Y=r*rt,q=r*nt,H=r*ot,Z=r*it,G=r*st,Q=r*at,$=r*ut,e(r-ft,O,W,T,X,z,F,R,V,E,Y,L,q,U,H,D,Z,k,G,j,Q,N,$)}function m(t){M=t[0]||0,A=t[1]||0,B=t[2]||0,S=t[3]||0}function y(t,e){t[e]=M}function g(t,e){t[e]=M,t[++e]=A}function b(t,e){t[e]=M,t[++e]=A,t[++e]=B}function v(t,e){t[e]=M,t[++e]=A,t[++e]=B,t[++e]=S}function x(t){return!!Array.isArray(t)}Object.defineProperty(e,"__esModule",{value:!0});var w=r(0),_=r(10),C=r(5),I=r(5)("WebGLSurface:BufferUtil");!function(t){t[t.CW=0]="CW",t[t.CCW=1]="CCW",t[t.DEGENERATE=2]="DEGENERATE"}(e.TriangleOrientation||(e.TriangleOrientation={}));var P;!function(t){t[t.ONE=0]="ONE",t[t.TWO=1]="TWO",t[t.THREE=2]="THREE",t[t.FOUR=3]="FOUR"}(P=e.AttributeSize||(e.AttributeSize={}));!function(t){t[t.ONE=0]="ONE",t[t.TWO=1]="TWO",t[t.THREE=2]="THREE",t[t.FOUR=3]="FOUR"}(e.UniformAttributeSize||(e.UniformAttributeSize={}));var M=0,A=0,B=0,S=0,O=[],T=[],z=[],R=[],E=[],L=[],U=[],D=[],k=[],j=[],N=[],W=0,X=0,F=0,V=0,Y=0,q=0,H=0,Z=0,G=0,Q=0,$=0,J=0,K=0,tt=0,et=0,rt=0,nt=0,ot=0,it=0,st=0,at=0,ut=0,ft=0,ct=!1,ht=(pt={},pt[P.ONE]=y,pt[P.TWO]=g,pt[P.THREE]=b,pt[P.FOUR]=v,pt),lt={1:o,2:i,3:s,4:a,5:u,6:f,7:c,8:h,9:l,10:d,11:p},dt=function(){function t(){}return t.beginUpdates=function(){ct=!0,ft=0},t.dispose=function(t){t&&t.forEach(function(t){t.attributes=null,t.currentData=null,t.geometry.dispose(),t.geometry=null,t.system=null})},t.endUpdates=function(){var t=ft;return ct=!1,ft=0,t},t.examineBuffer=function(t,e,r){var n=C(r);if(n.enabled){var o=t.attributes,i=t.geometry,s=o.map(function(t){return i.attributes[t.name]}),a=s.map(function(t){return t.array}),u=[];if(t.system.drawMode===w.TrianglesDrawMode)for(var f=0,c=0,h=0,l=i.drawRange.start+i.drawRange.count;f<l;)!function(){for(var t={vertex_0:{},vertex_1:{},vertex_2:{}},e=0;e<3;++e)!function(e){o.forEach(function(r,n){c=r.size+1,h=f*c,t["vertex_"+e][r.name]=a[n].slice(h,h+c)}),f++}(e);u.push(t)}();else if(t.system.drawMode===w.TriangleStripDrawMode)for(var d=0,p=0,m=0,y=i.drawRange.start+i.drawRange.count;d<y;)!function(){for(var t={vertex_0:{},vertex_1:{},vertex_2:{}},e=0;e<3;++e)!function(e){o.forEach(function(r,n){p=r.size+1,m=d*p,t["vertex_"+e][r.name]=a[n].slice(m,m+p)}),d++}(e);d-=2,u.push(t)}();n(e||"vertices: %o uniforms: %o",{drawRange:i.drawRange,triangles:u},t.system.material.uniforms)}},t.flattenMultiBuffers=function(t){function e(t){return t[0]&&Array.isArray(t[0])}var r=[];return t.forEach(function(t){t.getBuffers().forEach(function(t){e(t)?t.forEach(function(t){return r=r.concat(t)}):r=r.concat(t)})}),r},t.updateMultiBuffer=function(t,e,r,n,o){if(!t)return!1;var i,s=!1;i=x(t)?t.reduce(function(t,e){return t.concat(e.getBuffers())},[]):t.getBuffers();var a=new Map;e.forEach(function(t){return a.set(t.bufferItems.currentData,t)});var u=[];if(o?u=[].concat(i):i.forEach(function(t){a.get(t)?a.delete(t):t.length>0&&u.push(t)}),u.length>=a.size)a.forEach(function(t){s=n(t,u.shift())||s}),u.forEach(function(t){var o=r();e.push(o),s=n(o,t)||s});else{var f=Array.from(a.values());u.forEach(function(t){var e=f.shift();s=n(e,t)||s}),f.forEach(function(t){t.bufferItems.geometry.setDrawRange(0,0)})}return s},t.makeBuffer=function(t,e){for(var r=e.length,n=new w.BufferGeometry,o=0,i=!1,s=0;s<r;++s){var a=e[s],u=a.size+1;o+=u;var f=a.name,c=a.injectBuffer,h=c||new Float32Array(u*t),l=ht[a.size],d=a.customFill,p=a.defaults;if("position"===f&&(i=!0),!c)if(d)for(var y=0;y<t;++y)d(h,y,y*u,p);else{m(p);for(var y=0;y<t;++y)l(h,y*u)}var g=new w.BufferAttribute(h,u);g.setDynamic(!0),n.addAttribute(f,g),I("Made Buffer Attribute:",f,u)}return i||console.warn("It is recommended you ALWAYS use the position attribute as one of your attributes","There are features of threejs that REQUIRES this to be in place (even if not explicitly","documented). You don't have to use for exact position information, rather fill it with something","you need. Failure to do so will have you see consequences that are EXTREMELY hard to find."),o>16&&console.warn("A Buffer has specified more attributes than available. The max is 16 and the buffer provided:",o),n},t.shareBuffer=function(t,e){for(var r=e.attributes,n=new w.BufferGeometry,o=0,i=t;o<i.length;o++){var s=i[o],a=r[s.name];a?n.addAttribute(s.name,a):console.warn("Could not find attribute",s,"in the buffer to be shared. Can not share buffers properly")}return n},t.makeUniformBuffer=function(t){var e=0,r=[],n=_.WebGLStat.MAX_VERTEX_INSTANCE_DATA,o={};t.forEach(function(t){e=Math.max(t.block,e),(o[t.block]=(o[t.block]||0)+(t.size+1))>4&&console.warn("There were too many uniform attribute usages of a single block:",t)});for(var i=0;i<n;++i)r.push(new w.Vector4(0,0,0,0));return{blocksPerInstance:e+1,buffer:r,maxInstances:Math.floor(n/e)}},t.updateBuffer=function(t,e,r,o,i,s){var a=e.attributes,u=e.geometry,f=0!==ft&&ct;if(void 0!==t&&t!==e.currentData||f||s){ct||(ft=0),e.currentData=t;var c=a.map(function(t){return u.attributes[t.name]});n(c.map(function(t){return t.array}),a.map(function(t){return(t.size+1)*r}));return(0,lt[a.length])(o+ft,i),c.forEach(function(t){t.updateRange&&(t.updateRange.offset=0,t.updateRange.count=r*(ft+o)*t.itemSize),t.needsUpdate=!0}),ft+=o,!0}return ft+=o,!1},t.updateUniformBuffer=function(t,e,r,n,o){var i=0!==ft&&ct;if(void 0!==t&&t!==e.currentData||i||o){ct||(ft=0);var s=e.system.material,a=s.uniforms,u=a.instanceData;if(e.currentData=t,!(u&&"v4v"===u.type||"bvec4"===u.type&&e.uniformBuffer))return console.warn("A uniform buffer update was specified on a material that lacks uniform buffer usage"),!1;for(var f=e.uniformAttributes,c=e.uniformBuffer.blocksPerInstance,h=e.uniformBuffer.buffer,l=e.uniformBuffer.maxInstances,d=ft,p=ft*c,m=0;m<r&&d<l;++m){d=ft+m,p=c*d;for(var y=[d],g=0,b=f;g<b.length;g++){var v=b[g];y.push(h[v.block+p])}n.apply(null,y)}return u.value=[].concat(h),ft+=r,!0}return ft+=r,!1},t.makeBufferItems=function(){return{attributes:[],currentData:[],geometry:null,system:null,uniformAttributes:[],uniformBuffer:null}},t}();e.BufferUtil=dt;var pt},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(1),o=function(){function t(){}return t.prototype.dispose=function(){this.bufferItems&&n.BufferUtil.dispose([this.bufferItems])},t.prototype.init=function(t,e){},t.prototype.update=function(t){return!1},t}();e.BaseBuffer=o},function(t,r){t.exports=e},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,r,n){this.height=0,this.width=0,this.x=0,this.y=0,4===arguments.length&&(this.x=t,this.width=e-t,this.y=r,this.height=r-n)}return Object.defineProperty(t.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y-this.height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mid",{get:function(){return{x:this.x+this.width/2,y:this.y-this.height/2}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),t.prototype.containsPoint=function(t){return!(t.x<this.x)&&(!(t.y>this.y)&&(!(t.x>this.right)&&!(t.y<this.bottom)))},t.prototype.copyBounds=function(t){this.height=t.height,this.width=t.width,this.x=t.x,this.y=t.y},t.prototype.encapsulate=function(t){t.x<this.x&&(this.width+=this.x-t.x,this.x=t.x),t.y>this.y&&(this.height+=t.y-this.y,this.y=t.y),t.right>this.right&&(this.width=t.right-this.x),t.bottom<this.bottom&&(this.height=this.y-t.bottom)},t.prototype.encapsulateBounds=function(e,r){if(r&&e.length&&this.copyBounds(e[0]),0!==e.length){var n=Number.MAX_VALUE,o=-Number.MAX_VALUE,i=Number.MAX_VALUE,s=-Number.MAX_VALUE;e.forEach(function(t){t.x<n&&(n=t.x),t.right>o&&(o=t.right),t.bottom<i&&(i=t.bottom),t.y>s&&(s=t.y)}),this.encapsulate(new t(n,o,s,i))}},t.prototype.encapsulatePoint=function(t){t.x<this.x&&(this.width+=this.x-t.x,this.x=t.x),t.y>this.y&&(this.height+=t.y-this.y,this.y=t.y),t.x>this.right&&(this.width=t.x-this.x),t.y<this.bottom&&(this.height=this.y-t.y)},t.prototype.encapsulatePoints=function(e){var r=Number.MAX_VALUE,n=-Number.MAX_VALUE,o=Number.MAX_VALUE,i=-Number.MAX_VALUE;void 0!==e[0]&&e[0].x?e.forEach(function(t){t.x<r?r=t.x:t.x>n&&(n=t.x),t.y<o?o=t.y:t.y>i&&(i=t.y)}):e.forEach(function(t){t[0]<r?r=t[0]:t[0]>n&&(n=t[0]),t[1]<o?o=t[1]:t[1]>i&&(i=t[1])}),this.encapsulate(new t(r,n,i,o))},t.prototype.fits=function(t){return this.width===t.width&&this.height===t.height?1:this.width>=t.width&&this.height>=t.height?2:0},t.prototype.hitBounds=function(t){return!(t.right<this.x)&&(!(t.x>this.right)&&(!(t.bottom>this.y)&&!(t.y<this.bottom)))},t.prototype.pointInside=function(t){return!(t.x<this.x)&&(!(t.y>this.y)&&(!(t.x>this.right)&&!(t.y<this.bottom)))},t.isBounds=function(t){return!!t&&(t instanceof this||t&&"containsPoint"in t&&"encapsulate"in t&&"hitTest"in t)},t.scaleBounds=function(e,r,n,o,i){var s=new t(0,0,0,0);s.copyBounds(e);var a=s.width*n;i&&a<i.width&&(a=i.width,n=a/s.width),o&&a>o.width&&(a=o.width,n=a/s.width);var u=s.height*n;return i&&u<i.height&&(u=i.height,n=u/s.height),o&&u>o.height&&(u=o.height,n=u/s.height),a=s.width*n,s.x-=r.x,s.y-=r.y,s.x*=n,s.y*=n,s.x+=r.x,s.y+=r.y,s.width=a,s.height=u,s},t.prototype.isInside=function(t){return t.x<=this.x&&t.right>=this.right&&t.y>=this.y&&t.bottom<=this.bottom},t.maxBounds=function(){return new t(Number.MIN_VALUE,Number.MAX_VALUE,Number.MIN_VALUE,Number.MAX_VALUE)},t}();e.Bounds=n},function(t,e,r){(function(n){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(t){var r=this.useColors;if(t[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+t[0]+(r?"%c ":" ")+"+"+e.humanize(this.diff),r){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(o++,"%c"===t&&(i=o))}),t.splice(i,0,n)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(t){}}function u(){var t;try{t=e.storage.debug}catch(t){}return!t&&void 0!==n&&"env"in n&&(t=n.env.DEBUG),t}e=t.exports=r(34),e.log=s,e.formatArgs=i,e.save=a,e.load=u,e.useColors=o,e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(u())}).call(e,r(33))},function(t,e,r){"use strict";function n(t,e){var r=t.x-e.x,n=t.y-e.y;return r*r+n*n}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(){}return t.add=function(t,e,r){return r?(r.x=t.x+e.x,r.y=t.y+e.y,r):{x:t.x+e.x,y:t.y+e.y}},t.getClosest=function(t,e){var r,o=Number.MAX_VALUE,i=null,s=function(e){(r=n(e,t))<o&&(o=r,i=e)};return e.forEach(s),i},t.getClosestIndex=function(t,e){var r,o=Number.MAX_VALUE,i=0,s=function(e,s){(r=n(e,t))<o&&(o=r,i=s)};return e.forEach(s),i},t.getDirection=function(t,e,r){void 0===r&&(r=!1);var n=e.x-t.x,o=e.y-t.y;if(r){var i=Math.sqrt(n*n+o*o);n/=i,o/=i}return{x:n,y:o}},t.getDistance=function(t,e,r){return void 0===r&&(r=!1),r?n(t,e):Math.sqrt(n(t,e))},t.getMidpoint=function(e,r){var n=t.getDirection(e,r);return{x:n.x/2+e.x,y:n.y/2+e.y}},t.make=function(t,e){return{x:t,y:e}},t.scale=function(t,e,r){return r?(r.x=t.x*e,r.y=t.y*e,r):{x:t.x*e,y:t.y*e}},t.zero=function(){return{x:0,y:0}},t}();e.Point=o},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=r(4),i=function(t){function e(e,r){var n=t.call(this,0,1,1,0)||this;return n.setPoints(e,r),n}return n(e,t),e.prototype.directionTo=function(t){var e={x:this.p1.x-t.x,y:this.p1.y-t.y};return this.perpendicular.x*e.x+this.perpendicular.y*e.y},e.prototype.distanceTo=function(t){var e={x:this.p1.x-t.x,y:this.p1.y-t.y};return Math.abs(this.perpendicular.x*e.x+this.perpendicular.y*e.y)},e.getClosest=function(t,e){var r,n=Number.MAX_VALUE,o=0;return t.forEach(function(t){(o=t.distanceTo(e))<n&&(r=t,n=o)}),r},e.prototype.setPoints=function(t,e){this.x=t.x-1,this.y=t.y-1,this.width=2,this.height=2,this.encapsulatePoint(e);var r=e.x-t.x,n=e.y-t.y;this.slope=n/r,this.p1=t,this.p2=e,this.magnitude=Math.sqrt(r*r+n*n),this.perpendicular={x:this.p2.y-this.p1.y,y:-(this.p2.x-this.p1.x)};var o=Math.sqrt(this.perpendicular.x*this.perpendicular.x+this.perpendicular.y*this.perpendicular.y);this.perpendicular.x/=o,this.perpendicular.y/=o},e}(o.Bounds);e.Line=i},function(t,e,r){"use strict";function n(t,e,r,n){var o=t*t,i=1-t,s=i*i;return{x:e.x*s+2*n.x*i*t+r.x*o,y:e.y*s+2*n.y*i*t+r.y*o}}function o(t,e,r,n,o){var i=t*t,s=i*t,a=1-t,u=a*a,f=u*a;return{x:e.x*f+3*n.x*u*t+3*o.x*a*i+r.x*s,y:e.y*f+3*n.y*u*t+3*o.y*a*i+r.y*s}}function i(t,e,r,n,o){var i=a.Point.getDirection(n,e),s=Math.atan2(i.y,i.x),f=a.Point.getDirection(n,r),c=Math.atan2(f.y,f.x);s<0&&(s+=2*Math.PI),c<0&&(c+=2*Math.PI);var h=c-s;h>Math.PI&&(h=s-c),h*=t;var l=a.Point.getDistance(e,n),d=a.Point.getDistance(r,n),p=(o||u.linear)(t,l,d-l,1);return{x:Math.cos(s+h)*p+n.x,y:Math.sin(s+h)*p+n.y}}Object.defineProperty(e,"__esModule",{value:!0});var s,a=r(6),u=r(11);!function(t){t[t.BEZIER2=0]="BEZIER2",t[t.BEZIER3=1]="BEZIER3",t[t.CIRCULAR=2]="CIRCULAR"}(s=e.InterpolationMethod||(e.InterpolationMethod={})),e.bezier2=n,e.bezier3=o,e.circular=i,e.pickInterpolation=(f={},f[s.BEZIER2]=n,f[s.BEZIER3]=o,f[s.CIRCULAR]=i,f);var f},function(t,e,r){"use strict";function n(t,e){return t.x>e.x?Math.atan((t.y-e.y)/(t.x-e.x)):t.x===e.x?t.y>e.y?Math.PI/2:-Math.PI/2:t.y>=e.y?Math.PI+Math.atan((t.y-e.y)/(t.x-e.x)):Math.atan((t.y-e.y)/(t.x-e.x))-Math.PI}var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=r(16),s=r(7),a=r(6),u=function(t){function e(e){var r=t.call(this,e)||this;return r.depth=0,r.lineWidth=1,r.cachesQuadSegments=e.cacheSegments,r.depth=e.depth||0,r.lineWidth=e.lineWidth||1,r.encapsulatePoints(r.getTriangleStrip()),r.startColor=e.startColor,r.endColor=e.endColor,r.marchingAnts=e.marchingAnts,r}return o(e,t),e.prototype.clone=function(){var t=new e({cacheSegments:this.cachesSegments,controlPoints:this.controlPoints,end:this.end,endColor:this.endColor,lineWidth:this.lineWidth,resolution:this.resolution,start:this.start,startColor:this.startColor,type:this.type});return t.d=this.d,t},e.prototype.distanceTo=function(e){return Math.max(0,t.prototype.distanceTo.call(this,e)-this.lineWidth/2)},e.prototype.getTriangleStrip=function(){if(this.cachesSegments&&this.cachedQuadSegments)return this.cachedQuadSegments;var t=[],e=[],r=this.getLineStrip(),n=this.lineWidth/2,o=new s.Line(a.Point.zero(),a.Point.zero()),i=a.Point.zero();if(r.length<2)return[];for(var u=0;u<r.length-1;u++){if(o.setPoints(r[u],r[u+1]),0===e.length)e.push(o.perpendicular);else{var f={x:e[u].x+o.perpendicular.x,y:e[u].y+o.perpendicular.y},c=Math.sqrt(f.x*f.x+f.y*f.y);f.x=f.x/c,f.y=f.y/c,e[u]=f}e.push(o.perpendicular)}for(var u=0;u<r.length-1;u++){var h=r[u],l=r[u+1];t.push(a.Point.add(a.Point.scale(e[u+1],-n,i),l)),t.push(a.Point.add(a.Point.scale(e[u+1],n,i),l)),t.push(a.Point.add(a.Point.scale(e[u],-n,i),h)),t.push(a.Point.add(a.Point.scale(e[u],n,i),h))}return t},e.prototype.setPoints=function(e,r,n){t.prototype.setPoints.call(this,e,r,n),this.cachedQuadSegments=[]},e.prototype.containsPoint=function(e){if(this.type===i.CurveType.CircularCW||this.type===i.CurveType.CircularCCW){var r=this.controlPoints[1],o=Math.pow(this.start.x-r.x,2)+Math.pow(this.start.y-r.y,2),s=Math.sqrt(o),a=Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2),u=this.lineWidth*this.lineWidth,f=n(e,r),c=n(this.start,r),h=n(this.end,r);return c>0&&h<0&&(f<0&&(f+=2*Math.PI),h+=2*Math.PI),a<=o+this.lineWidth*s+u/4&&a>=o-this.lineWidth*s+u/4&&f>=c&&f<=h}return this.type===i.CurveType.Bezier&&t.prototype.containsPoint.call(this,e)},e}(i.CurvedLine);e.CurvedLineShape=u},function(t,e,r){"use strict";function n(t,e){for(var r={attributeCount:0,attributes:new Array,uniformCount:0,uniforms:new Array},n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),o=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),i={35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT"},s={35664:1,35665:1,35666:1,35667:1,35668:1,35669:1,35670:1,35671:1,35672:1,35673:1,35674:1,35675:3,35676:4,35678:1,35680:1,5120:1,5121:1,5122:1,5123:1,5124:1,5125:1,5126:1},a=0;a<n;++a){var u=t.getActiveUniform(e,a);u.typeName=i[u.type],r.uniforms.push(u),r.uniformCount+=u.size,u.size=u.size*s[u.type]}for(var a=0;a<o;a++){var f=t.getActiveAttrib(e,a);f.typeName=i[f.type],r.attributes.push(f),r.attributeCount+=f.size}return r}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(){}return t.printCurrentProgramInfo=function(t,e){if(e.gl){var r=n(e.gl,e.gl.getParameter(e.gl.CURRENT_PROGRAM)),o=window.table;o&&o(r.uniforms)}else t("Attempted to printProgramInfo but the surface has not established its gl context yet")},t.MAX_VERTEX_UNIFORMS=0,t.MAX_FRAGMENT_UNIFORMS=0,t.MAX_ATTRIBUTES=0,t.WEBGL_SUPPORTED=!1,t.MAX_VERTEX_INSTANCE_DATA=96,t}();e.WebGLStat=o,function(){var t=function(){try{var t=document.createElement("canvas");return window.WebGLRenderingContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(t){return!1}}();t&&(o.WEBGL_SUPPORTED=!0,o.MAX_VERTEX_UNIFORMS=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),o.MAX_FRAGMENT_UNIFORMS=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),o.MAX_ATTRIBUTES=t.getParameter(t.MAX_VERTEX_ATTRIBS),o.MAX_VERTEX_INSTANCE_DATA=96)}()},function(t,e,r){"use strict";function n(t,e,r,n){return r*t/n+e}function o(t,e,r,n){return r*(t/=n)*t+e}function i(t,e,r,n){return-r*(t/=n)*(t-2)+e}function s(t,e,r,n){return(t/=n/2)<1?r/2*t*t+e:-r/2*(--t*(t-2)-1)+e}function a(t,e,r,n){return r*(t/=n)*t*t+e}function u(t,e,r,n){return r*((t=t/n-1)*t*t+1)+e}function f(t,e,r,n){return(t/=n/2)<1?r/2*t*t*t+e:r/2*((t-=2)*t*t+2)+e}function c(t,e,r,n){return r*(t/=n)*t*t*t+e}function h(t,e,r,n){return-r*((t=t/n-1)*t*t*t-1)+e}function l(t,e,r,n){return(t/=n/2)<1?r/2*t*t*t*t+e:-r/2*((t-=2)*t*t*t-2)+e}function d(t,e,r,n){return r*(t/=n)*t*t*t*t+e}function p(t,e,r,n){return r*((t=t/n-1)*t*t*t*t+1)+e}function m(t,e,r,n){return(t/=n/2)<1?r/2*t*t*t*t*t+e:r/2*((t-=2)*t*t*t*t+2)+e}function y(t,e,r,n){return-r*Math.cos(t/n*(Math.PI/2))+r+e}function g(t,e,r,n){return r*Math.sin(t/n*(Math.PI/2))+e}function b(t,e,r,n){return-r/2*(Math.cos(Math.PI*t/n)-1)+e}function v(t,e,r,n){return 0===t?e:r*Math.pow(2,10*(t/n-1))+e}function x(t,e,r,n){return t===n?e+r:r*(1-Math.pow(2,-10*t/n))+e}function w(t,e,r,n){return 0===t?e:t===n?e+r:(t/=n/2)<1?r/2*Math.pow(2,10*(t-1))+e:r/2*(2-Math.pow(2,-10*--t))+e}function _(t,e,r,n){return-r*(Math.sqrt(1-(t/=n)*t)-1)+e}function C(t,e,r,n){return r*Math.sqrt(1-(t=t/n-1)*t)+e}function I(t,e,r,n){return(t/=n/2)<1?-r/2*(Math.sqrt(1-t*t)-1)+e:r/2*(Math.sqrt(1-(t-=2)*t)+1)+e}function P(t,e,r,n){var o=1.70158,i=0,s=r;return 0===t?e:1==(t/=n)?e+r:(i||(i=.3*n),s<Math.abs(r)?(s=r,o=i/4):o=i/(2*Math.PI)*Math.asin(r/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/i)+e)}function M(t,e,r,n){var o=1.70158,i=0,s=r;return 0===t?e:1==(t/=n)?e+r:(i||(i=.3*n),s<Math.abs(r)?(s=r,o=i/4):o=i/(2*Math.PI)*Math.asin(r/s),s*Math.pow(2,-10*t)*Math.sin((t*n-o)*(2*Math.PI)/i)+r+e)}function A(t,e,r,n){var o=1.70158,i=0,s=r;return 0===t?e:2==(t/=n/2)?e+r:(i||(i=n*(.3*1.5)),s<Math.abs(r)?(s=r,o=i/4):o=i/(2*Math.PI)*Math.asin(r/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/i)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/i)*.5+r+e)}function B(t,e,r,n,o){return void 0===o&&(o=1.70158),r*(t/=n)*t*((o+1)*t-o)+e}function S(t,e,r,n,o){return void 0===o&&(o=1.70158),r*((t=t/n-1)*t*((o+1)*t+o)+1)+e}function O(t,e,r,n,o){return void 0===o&&(o=1.70158),(t/=n/2)<1?r/2*(t*t*((1+(o*=1.525))*t-o))+e:r/2*((t-=2)*t*((1+(o*=1.525))*t+o)+2)+e}function T(t,e,r,n){return r-z(n-t,0,r,n)+e}function z(t,e,r,n){return(t/=n)<1/2.75?r*(7.5625*t*t)+e:t<2/2.75?r*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?r*(7.5625*(t-=2.25/2.75)*t+.9375)+e:r*(7.5625*(t-=2.625/2.75)*t+.984375)+e}function R(t,e,r,n){return t<n/2?.5*T(2*t,0,r,n)+e:.5*z(2*t-n,0,r,n)+.5*r+e}Object.defineProperty(e,"__esModule",{value:!0}),e.linear=n,e.easeInQuad=o,e.easeOutQuad=i,e.easeInOutQuad=s,e.easeInCubic=a,e.easeOutCubic=u,e.easeInOutCubic=f,e.easeInQuart=c,e.easeOutQuart=h,e.easeInOutQuart=l,e.easeInQuint=d,e.easeOutQuint=p,e.easeInOutQuint=m,e.easeInSine=y,e.easeOutSine=g,e.easeInOutSine=b,e.easeInExpo=v,e.easeOutExpo=x,e.easeInOutExpo=w,e.easeInCirc=_,e.easeOutCirc=C,e.easeInOutCirc=I,e.easeInElastic=P,e.easeOutElastic=M,e.easeInOutElastic=A,e.easeInBack=B,e.easeOutBack=S,e.easeInOutBack=O,e.easeInBounce=T,e.easeOutBounce=z,e.easeInOutBounce=R},function(t,e,r){"use strict";function n(){var t=o.lastFrameTime/1e7;return Math.floor(1e7*(t-Math.floor(t)))}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(){}return t.lastFrameTime=Date.now(),t.nextFrameTime=Date.now(),t.framesPlayed=new Map,t}();e.FrameInfo=o,e.getAttributeCurrentTime=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){this.aspectRatio=1,this.imagePath=t,this.label=e,e&&(this.label.rasterizedLabel=this)}return t}();e.AtlasTexture=n},function(t,e){t.exports=r},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.base=t}return t}();e.ReferenceColor=n},function(t,e,r){"use strict";function n(t,e){var r,n=t.getLineStrip(),o=y.Point.getClosestIndex(e,n),i=Number.MAX_VALUE;return o>0&&(r=new m.Line(n[o],n[o-1]),i=r.distanceTo(e)),o<n.length-1&&(r=new m.Line(n[o],n[o+1]),i=Math.min(i,r.distanceTo(e))),i}function o(t,e){var r,n=t.getLineStrip(),o=y.Point.getClosestIndex(e,n),i=Number.MAX_VALUE;return o>0&&(r=new m.Line(n[o],n[o-1]),i=r.distanceTo(e)),o<n.length-1&&(r=new m.Line(n[o],n[o+1]),i=Math.min(i,r.distanceTo(e))),i}function i(t,e){return new m.Line(t.start,t.end).distanceTo(e)}function s(t){if(t.cachesSegments&&t.cachedSegments)return t.cachedSegments;for(var e=[],r=1/t.resolution,n=t.start,o=t.end,i=t.controlPoints[0],s=0,a=t.resolution;s<=a;++s)e.push(d.bezier2(r*s,n,o,i));return t.cachesSegments&&(t.cachedSegments=e),e}function a(t){if(t.cachesSegments&&t.cachedSegments)return t.cachedSegments;for(var e=[],r=1/t.resolution,n=t.start,o=t.end,i=t.controlPoints[0],s=t.controlPoints[1],a=0,u=t.resolution;a<=u;++a)e.push(d.bezier3(r*a,n,o,i,s));return t.cachesSegments&&(t.cachedSegments=e),e}function u(t){if(t.cachesSegments&&t.cachedSegments)return t.cachedSegments;g("CW");var e=new m.Line(t.start,t.end),r=y.Point.getDistance(t.start,t.controlPoints[0]),n=t.controlPoints[1];if(!n){var o=y.Point.getMidpoint(t.start,t.end),i=y.Point.getDistance(o,t.start);r<i&&(r=y.Point.getDistance(o,t.start));var s=e.perpendicular,a=Math.sqrt(r*r-i*i);n={x:s.x*a+o.x,y:s.y*a+o.y},t.controlPoints[1]=n}g(" center of circle is %o %o",n.x,n.y);var u=y.Point.getDirection(n,t.start),f=Math.atan2(u.y,u.x),c=y.Point.getDirection(n,t.end),h=Math.atan2(c.y,c.x);f<h&&(f+=2*Math.PI);var l=(f-h)/t.resolution;g("theta1 is %o, theta2 is %o",f,h);for(var d=[],p=0,b=t.resolution+1;p<b;++p)d.push({x:Math.cos(f-l*p)*r+n.x,y:Math.sin(f-l*p)*r+n.y});return t.cachesSegments&&(t.cachedSegments=d),g("Generated Circular Segments: %o dTheta: %o radius: %o",d,l,r),d}function f(t){if(t.cachesSegments&&t.cachedSegments)return t.cachedSegments;var e=new m.Line(t.start,t.end),r=y.Point.getDistance(t.start,t.controlPoints[0]),n=t.controlPoints[1];if(!n){var o=y.Point.getMidpoint(t.start,t.end),i=y.Point.getDistance(o,t.start);r<i&&(r=y.Point.getDistance(o,t.start));var s=e.perpendicular,a=Math.sqrt(r*r-i*i);n={x:-s.x*a+o.x,y:-s.y*a+o.y},t.controlPoints[1]=n}var u=y.Point.getDirection(n,t.start),f=Math.atan2(u.y,u.x),c=y.Point.getDirection(n,t.end),h=Math.atan2(c.y,c.x);h<f&&(h+=2*Math.PI);for(var l=(h-f)/t.resolution,d=[],p=0,g=t.resolution+1;p<g;++p)d.push({x:Math.cos(f+l*p)*r+n.x,y:Math.sin(f+l*p)*r+n.y});return t.cachedSegments&&(t.cachedSegments=d),d}function c(t){return[t.start,t.end]}var h=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var l,d=r(8),p=r(4),m=r(7),y=r(6),g=r(5)("bezier");!function(t){t[t.Bezier=0]="Bezier",t[t.CircularCCW=1]="CircularCCW",t[t.CircularCW=2]="CircularCW",t[t.Straight=3]="Straight"}(l=e.CurveType||(e.CurveType={}));var b=(w={},w[l.Bezier]=[null,s,a],w[l.CircularCW]=[null,u,u],w[l.CircularCCW]=[null,f,f],w[l.Straight]=[c],w),v=(_={},_[l.Bezier]=n,_[l.CircularCW]=o,_[l.CircularCCW]=o,_[l.Straight]=i,_),x=function(t){function e(e){var r=this,n=Number.MAX_VALUE,o=-Number.MAX_VALUE,i=Number.MAX_VALUE,s=-Number.MAX_VALUE;return r=t.call(this,n,o,s,i)||this,r.cachesSegments=e.cacheSegments||!1,r.type=e.type,r.resolution=e.resolution||20,r.setPoints(e.start,e.end,e.controlPoints),r.distanceMethod=v[e.type],r}return h(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return{controlPoints:this.controlPoints,end:this.end,start:this.start}},enumerable:!0,configurable:!0}),e.prototype.distanceTo=function(t){return this.distanceMethod(this,t)},e.getClosest=function(t,e){var r,n=Number.MAX_VALUE,o=0;return t.forEach(function(t){(o=t.distanceTo(e))<n&&(r=t,n=o)}),r},e.prototype.getLineStrip=function(){return this.segmentMethod(this)},e.prototype.setPoints=function(t,e,r){this.start=t,this.end=e,0===r.length&&g("start: %o, end:%o",t,e);var n=b[this.type];if(r){this.controlPoints=r;var o=r.length;if(o>n.length&&(o=n.length-1),this.segmentMethod=n[o],!this.segmentMethod)throw new Error("An Invalid number of control points was provided to a curved line. You must have at LEAST 1 control point. Or 0 for a straight line");this.type===l.Bezier?this.encapsulatePoints(r):this.type!==l.CircularCCW&&this.type!==l.CircularCW||this.encapsulatePoints(this.getLineStrip())}this.encapsulatePoint(t),this.encapsulatePoint(e),this.cachedSegments=null},e}(p.Bounds);e.CurvedLine=x;var w,_},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=r(4),i=0,s=function(t){function e(e){var r=t.call(this,0,0,0,0)||this;return r._id=++i,r._radius=0,r._centerX=0,r._centerY=0,r._centerX=e.centerX,r._centerY=e.centerY,r._radius=e.radius,r.updateBounds(),r}return n(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return{radius:this._radius,x:this._centerX,y:this._centerY}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){this._radius=t,this.updateBounds()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"centerX",{get:function(){return this._centerX},set:function(t){this._centerX=t,this.updateBounds()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"centerY",{get:function(){return this._centerY},set:function(t){this._centerY=t,this.updateBounds()},enumerable:!0,configurable:!0}),e.prototype.boundsInside=function(t){var e=this._radius*this._radius,r=t.x-this._centerX,n=t.y-this._centerY,o=n*n,i=r*r;return!(i+o>e)&&(r=t.right-this._centerX,!((i=r*r)+o>e)&&(n=t.bottom-this._centerY,o=n*n,!(i+o>e)&&(r=t.x-this._centerX,(i=r*r)+o<e)))},e.prototype.distanceTo=function(t,e){var r=this._centerX-t.x,n=this._centerY-t.y;return e?r*r+n*n:Math.sqrt(r*r+n*n)},e.getClosest=function(t,e){var r,n=Number.MAX_VALUE,o=0;return t.forEach(function(t){(o=t.distanceTo(e,!0))<n&&(r=t,n=o)}),r},e.prototype.hitCircle=function(t){var e=t._radius+this._radius;return e*=e,this.distanceTo({x:t._centerX,y:t._centerY},!0)<e},e.prototype.hitPoint=function(t){var e=this._radius*this._radius,r=t.x-this._centerX,n=t.y-this._centerY;return r*r+n*n<e},e.prototype.position=function(t,e,r){this._centerX=t,this._centerY=e,this._radius=r,this.updateBounds()},e.prototype.pointInside=function(t){var e=this._radius*this._radius,r=t.x-this._centerX,n=t.y-this._centerY;return r*r+n*n<e},e.prototype.updateBounds=function(){var t=this._radius;this.x=this._centerX-t,this.y=this._centerY-t,this.height=2*t,this.width=2*t},e.prototype.toString=function(){return"[Circle {x: "+this._centerX+", y: "+this._centerY+", r: "+this._radius+"}]"},e}(o.Bounds);e.Circle=s},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=r(7),i=function(t){function e(e){var r=t.call(this,e.p1,e.p2)||this;return r.allowScaling=e.allowScaling||!1,r.depth=e.depth||0,r.endColor=e.endColor,r.startColor=e.startColor,r.thickness=e.thickness||1,r}return n(e,t),e.prototype.clone=function(t){return Object.assign(new e(this),t)},e}(o.Line);e.LineShape=i},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=r(3),i=r(20),s=r(21),a=r(22),u=new a.Sprite(200,200,1,1),f=function(t){function e(e){void 0===e&&(e={});var r=t.call(this,{x:0,y:1},{width:1,height:1},0,s.AnchorPosition.TopLeft)||this;return r.depth=40,r.direction="inherit",r.font="serif",r.fontSize=10,r.fontWeight=400,r.maxWidth=void 0,r.maxLength=void 0,r.text="",r.truncatedText="",r.id="",r.textAlign="start",r.textBaseline="alphabetic",r.allowScaling=!0,r.rasterizationOffset={x:20,y:0},r.rasterizationPadding={width:0,height:0},Object.assign(r,e),r.setFontSize(e.fontSize||12),r}return n(e,t),Object.defineProperty(e.prototype,"baseLabel",{get:function(){return this._baseLabel},set:function(t){this._baseLabel=t,this.text=t.text,this.fontSize=t.fontSize,this.font=t.font,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rasterizedLabel",{get:function(){return this.baseLabel?this.baseLabel.rasterizedLabel:this._rasterizedLabel},set:function(t){this._rasterizedLabel=t},enumerable:!0,configurable:!0}),e.prototype.copyLabel=function(t){Object.assign(this,o.omit(["x","y","width","height"],t)),this.setText(t.text)},e.prototype.getBoundsWithAnchor=function(){var t=new i.Bounds(0,0,0,0);return t.copyBounds(this),t.encapsulatePoint(this.getAnchor(!0)),t},e.prototype.getText=function(){return this._baseLabel?this._baseLabel.getText():this.text},e.prototype.makeCSSFont=function(t){return this.fontWeight+" "+(t||this.fontSize)+"px "+this.font},e.prototype.position=function(t,e){this.x=t,this.y=e},e.prototype.setFontSize=function(t){var e=this.getText(),r=this.getSize(),n=r.width,o=r.height;if(this.baseLabel){var i=this.baseLabel.getSize(),s=t/this.baseLabel.fontSize;o=i.height*s,n=i.width*s}else{var a=u.context;a.font=this.makeCSSFont();var f=a.measureText(e);o=t+this.rasterizationPadding.height,n=f.width+this.rasterizationOffset.x+this.rasterizationPadding.width;var c=a.measureText("...").width,h=this.text,l=n;if(this.maxWidth&&n>this.maxWidth){var d=!1;for(l+=c;l>this.maxWidth;)h=h.substring(0,h.length-2),l=a.measureText(h).width+c+this.rasterizationOffset.x+this.rasterizationPadding.width,d=!0;this.maxLength&&h.length>this.maxLength&&(h=h.substring(0,this.maxLength),l=a.measureText(h).width+c+this.rasterizationOffset.x+this.rasterizationPadding.width),d&&(h+="..."),this.truncatedText=h,n=l}else this.maxLength&&h.length>this.maxLength?(h=h.substring(0,this.maxLength),h+="...",this.truncatedText=h,l=a.measureText(h).width+c+this.rasterizationOffset.x+this.rasterizationPadding.width,n=l):this.truncatedText=""}this.fontSize=t,this.setSize({width:n,height:o})},e.prototype.setText=function(t){this.text=t,this.setFontSize(this.fontSize)},e.prototype.update=function(){this.setFontSize(this.fontSize),t.prototype.update.call(this)},e}(s.RotateableQuad);e.Label=f},function(t,e,r){"use strict";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(4)),n(r(17)),n(r(16)),n(r(7)),n(r(6)),n(r(21))},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var o,i=r(0),s=r(4);!function(t){t[t.BottomLeft=0]="BottomLeft",t[t.BottomRight=1]="BottomRight",t[t.Custom=2]="Custom",t[t.Middle=3]="Middle",t[t.MiddleBottom=4]="MiddleBottom",t[t.MiddleLeft=5]="MiddleLeft",t[t.MiddleRight=6]="MiddleRight",t[t.MiddleTop=7]="MiddleTop",t[t.TopLeft=8]="TopLeft",t[t.TopRight=9]="TopRight"}(o=e.AnchorPosition||(e.AnchorPosition={}));var a=(f={},f[o.BottomLeft]=function(t){return new i.Vector4(0,0,0,1)},f[o.BottomRight]=function(t){return new i.Vector4(t.getSize().width,0,0,1)},f[o.Custom]=function(t){return new i.Vector4(0,-t.getSize().height,0,1)},f[o.Middle]=function(t){return new i.Vector4(t.getSize().width/2,-t.getSize().height/2,0,1)},f[o.MiddleBottom]=function(t){return new i.Vector4(t.getSize().width/2,0,0,1)},f[o.MiddleLeft]=function(t){return new i.Vector4(0,-t.getSize().height/2,0,1)},f[o.MiddleRight]=function(t){return new i.Vector4(t.getSize().width,-t.getSize().height/2,0,1)},f[o.MiddleTop]=function(t){return new i.Vector4(t.getSize().width/2,-t.getSize().height,0,1)},f[o.TopLeft]=function(t){return new i.Vector4(0,t.getSize().height,0,1)},f[o.TopRight]=function(t){return new i.Vector4(t.getSize().width,-t.getSize().height,0,1)},f),u=function(t){function e(e,r,n,i){void 0===i&&(i=o.Middle);var s=t.call(this,0,0,0,0)||this;return s.setSize(r),s.setAnchor(i),s.setLocation(e),s.setRotation(n),s}return n(e,t),e.prototype.calculateAnchor=function(t){this.anchor=a[t](this)},e.prototype.getSize=function(){return this.size},e.prototype.setAnchor=function(t,e){if(void 0===t&&(t=o.Middle),this.isDirty=!0,this.anchorType=t,e)return this.anchorType=o.Custom,void(this.anchor=new i.Vector4(e.x,e.y,0,1));this.calculateAnchor(t)},e.prototype.getAnchor=function(t){if(t){this.update();var e=this.anchor.clone();return e.y=-this.anchor.y,e.applyMatrix4(this.transform),e}return this.anchor},e.prototype.getAnchorType=function(){return this.anchorType},e.prototype.setLocation=function(t){this.isDirty=!0,this.location=t},e.prototype.getLocation=function(){return this.location},e.prototype.setRotation=function(t){this.isDirty=!0,this.rotation=t},e.prototype.getRotation=function(){return this.rotation},e.prototype.getDirection=function(){var t=this.rotation;return{x:Math.cos(t),y:Math.sin(t)}},e.prototype.setSize=function(t){this.isDirty=!0,this.size=t,this.base=[new i.Vector4(0,t.height,0,1),new i.Vector4(t.width,t.height,0,1),new i.Vector4(0,0,0,1),new i.Vector4(t.width,0,0,1)],this.anchorType&&this.anchorType!==o.Custom&&this.calculateAnchor(this.anchorType)},e.prototype.update=function(){if(this.isDirty){var t=(new i.Matrix4).makeTranslation(-this.anchor.x,this.anchor.y,0),e=(new i.Matrix4).makeRotationZ(this.rotation),r=(new i.Matrix4).makeTranslation(this.location.x,this.location.y,0);this.transform=(new i.Matrix4).multiply(r).multiply(e).multiply(t),this.TL=this.base[0].clone().applyMatrix4(this.transform),this.TR=this.base[1].clone().applyMatrix4(this.transform),this.BL=this.base[2].clone().applyMatrix4(this.transform),this.BR=this.base[3].clone().applyMatrix4(this.transform),this.x=this.TL.x,this.y=this.TL.y,this.width=1,this.height=1,this.encapsulatePoints([this.TR,this.BL,this.BR]),this.isDirty=!1}},e}(s.Bounds);e.RotateableQuad=u;var f},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,r,n){this.scaleX=1,this.scaleY=1;var o=document.createElement("canvas");o&&(this.scaleX=r||this.scaleX,this.scaleY=n||this.scaleY,o.width=t*this.scaleX,o.height=e*this.scaleY,this.context=o.getContext("2d"),this.canvas=o)}return t.prototype.getContentScale=function(){return{x:this.scaleX,y:this.scaleY}},t.prototype.getContentSize=function(){return{height:this.canvas.height,width:this.canvas.width}},t.prototype.getWidth=function(){return this.canvas.width/this.scaleX},t.prototype.getHeight=function(){return this.canvas.height/this.scaleY},t}();e.Sprite=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),o=function(){function t(t,e,r,o){void 0===o&&(o=1),this.opacity=1,this.pixelWidth=2,this.pixelHeight=2,t instanceof n.Color?(this.color=t.clone(),this.opacity=void 0===e?1:e):(this.color=new n.Color(t,e,r),this.opacity=o)}return t}();e.AtlasColor=o},function(t,e,r){"use strict";function n(t){return Boolean(t&&t.src)}function o(t){return Boolean(t&&t.substr)}function i(t){var e=t.label,r=e.getSize(),n=document.createElement("canvas"),o=n.getContext("2d");if(n.width=r.width,n.height=r.height,o){var i=e.fontSize,s=u.rgb(255*e.color.base.color.r,255*e.color.base.color.g,255*e.color.base.color.b,e.color.base.opacity);o.font=e.makeCSSFont(i),o.textAlign=e.textAlign,o.textBaseline=e.textBaseline,o.fillStyle=s.toString(),o.fillText(e.truncatedText||e.text,t.label.rasterizationOffset.x,t.label.rasterizationOffset.y)}return o}var s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}u((n=n.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){function r(t){return function(e){return n([t,e])}}function n(r){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(s=i[2&r[0]?"return":r[0]?"throw":"next"])&&!(s=s.call(i,r[1])).done)return s;switch(i=0,s&&(r=[0,s.value]),r[0]){case 0:case 1:s=r;break;case 4:return u.label++,{value:r[1],done:!1};case 5:u.label++,i=r[1],r=[0];continue;case 7:r=u.ops.pop(),u.trys.pop();continue;default:if(s=u.trys,!(s=s.length>0&&s[s.length-1])&&(6===r[0]||2===r[0])){u=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){u.label=r[1];break}if(6===r[0]&&u.label<s[1]){u.label=s[1],s=r;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(r);break}s[2]&&u.ops.pop(),u.trys.pop();continue}r=e.call(t,u)}catch(t){r=[6,t],i=0}finally{o=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}var o,i,s,a,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a};Object.defineProperty(e,"__esModule",{value:!0});var u=r(55),f=r(0),c=r(23),h=r(4),l=r(25),d=r(15),p=r(19),m=r(13),y=r(5)("webgl-surface:Atlas"),g=r(5)("webgl-surface:Labels"),b={atlasBL:{x:0,y:0},atlasBR:{x:0,y:0},atlasTL:{x:0,y:0},atlasTR:{x:0,y:0},label:new p.Label({text:" "}),pixelHeight:0,pixelWidth:0},v=!1,x=function(){function t(t,e){this.atlasImages={},this.atlasMap={},this.atlasTexture={},this.textureWidth=t,this.textureHeight=e}return t.prototype.createAtlas=function(t,e,r){return s(this,void 0,void 0,function(){var n,o,i,s,u,u,c,h;return a(this,function(a){switch(a.label){case 0:if(n=new l.PackNode(0,0,this.textureWidth,this.textureHeight),this.atlasMap[t]=n,this.atlasImages[t]=[],o=document.createElement("canvas").getContext("2d"),o.canvas.width=this.textureWidth,o.canvas.height=this.textureHeight,!e)return[3,4];i=0,s=e,a.label=1;case 1:return i<s.length?(u=s[i],[4,this.draw(u,t,o)]):[3,4];case 2:a.sent(),a.label=3;case 3:return i++,[3,1];case 4:return r?[4,this.drawColors(r,t,o)]:[3,6];case 5:u=a.sent(),u&&this.atlasImages[t].push(u),a.label=6;case 6:return c=new f.Texture(o.canvas),c.premultiplyAlpha=!0,c.generateMipmaps=!0,this.atlasTexture[t]=c,e&&(h=this.atlasImages[t]).push.apply(h,e),y("Atlas Created-> texture: %o mapping: %o images: %o",c,n,e),[2,c]}})})},t.prototype.destroyAtlas=function(t){if(this.atlasTexture[t]&&(this.atlasTexture[t].dispose(),this.atlasTexture[t]=null),this.atlasMap[t]&&(this.atlasMap[t].destroy(),this.atlasMap[t]=null),this.atlasImages[t]){var e={x:0,y:0};this.atlasImages[t].forEach(function(t){t.atlasReferenceID=null,t.pixelWidth=0,t.pixelHeight=0,t.atlasBL=e,t.atlasBR=e,t.atlasTL=e,t.atlasTR=e}),this.atlasImages[t]=null}},t.prototype.isValidImage=function(t){var e=!1;return t&&(t.imagePath||t.label&&t.label.text)&&t.pixelWidth&&t.pixelHeight&&(e=!0),e},t.prototype.setDefaultImage=function(t,e){return t=Object.assign(t,b,{atlasReferenceID:e})},t.prototype.draw=function(t,e,r){return s(this,void 0,void 0,function(){var n,o,i,s,u,f,c,l,d,p,m;return a(this,function(a){switch(a.label){case 0:return this.atlasMap[e]?v?[3,2]:[4,this.waitForValidCanvasRendering()]:(y("Can not load image, invalid Atlas Name: %o for atlasMaps: %o",e,this.atlasMap),[2,!1]);case 1:a.sent(),a.label=2;case 2:return[4,this.loadImage(t)];case 3:return n=a.sent(),t.atlasReferenceID=null,n&&this.isValidImage(t)?(y("Image loaded: %o",t.imagePath),o=new h.Bounds(0,t.pixelWidth,t.pixelHeight,0),i={first:t,second:o},i.second.width+=1,i.second.height+=1,s=this.atlasMap[e],u=s.insert(i),u?(y("Atlas location determined: %o",u),t.label&&g("Atlas location determined. PackNode: %o Dimensions: %o",u,i),u.nodeImage=t,f=u.nodeDimensions.x/this.textureWidth,c=u.nodeDimensions.y/this.textureHeight,l=u.nodeDimensions.width/this.textureWidth,d=u.nodeDimensions.height/this.textureHeight,p=1/this.textureWidth,m=new h.Bounds(f,f+l,1-c,1-(c+d)),t.atlasReferenceID=e,t.atlasBL={x:m.x,y:m.y-m.height},t.atlasBR={x:m.x+m.width-p,y:m.y-m.height},t.atlasTL={x:m.x,y:m.y},t.atlasTR={x:m.x+m.width-p,y:m.y},r.drawImage(n,u.nodeDimensions.x,u.nodeDimensions.y),[2,!0]):(console.error("Could not fit image into atlas "+t.imagePath),t=this.setDefaultImage(t,e),[2,!1])):(t.imagePath?console.error("Could not load image: "+t.imagePath):console.error("Could not load label: "+t.label.text),t=this.setDefaultImage(t,e),[2,!1])}})})},t.prototype.drawColors=function(t,e,r){return s(this,void 0,void 0,function(){var n,o,i,s,u,f,c,l,d,p,g,b,v,x,w,_,C,I,P,M,A,B,S,O,T,z,R,E,L,U,D,k;return a(this,function(a){if(y("Finding space for colors on the atlas: %o",t),n=2,o=2,i=(this.textureWidth-2)/n,s=Math.min(this.textureWidth,i*n),u=Math.ceil(t.length*n/s),f=Math.ceil(s/n),c=u*o,l={first:new m.AtlasTexture(null,null),second:new h.Bounds(0,s,c,0)},l.second.width+=1,l.second.height+=1,d=this.atlasMap[e],p=d.insert(l)){for(y("Atlas location determined for colors: %o",p),g=p.nodeImage=l.first,b=p.nodeDimensions.x/this.textureWidth,v=p.nodeDimensions.y/this.textureHeight,x=p.nodeDimensions.width/this.textureWidth,w=p.nodeDimensions.height/this.textureHeight,_=new h.Bounds(b,b+x,1-v,1-(v+w)),g.atlasReferenceID=e,g.atlasBL={x:_.x,y:_.y-_.height},g.atlasBR={x:_.x+_.width,y:_.y-_.height},g.atlasTL={x:_.x,y:_.y},g.atlasTR={x:_.x+_.width,y:_.y},C=p.nodeDimensions,I=C.x,P=C.y,M=n/this.textureWidth,A=-o/this.textureHeight,B=I/this.textureWidth+M/2,S=1-P/this.textureHeight+A/2,O=0,T=0,z=0,R=t;z<R.length;z++)E=R[z],E.atlasReferenceID=e,E.colorIndex=O+T*f,E.colorsPerRow=f,E.firstColor={x:B,y:S},E.nextColor={x:M,y:A},L=E.color,U=L.r,D=L.g,k=L.b,r.fillStyle="rgba("+Math.round(255*U)+", "+Math.round(255*D)+", "+Math.round(255*k)+", "+E.opacity+")",r.fillRect(O*n+I,T*o+P,n,o),++O===f&&(O=0,T++);return[2,g]}throw new Error("Could not fit colors into atlas")})})},t.prototype.getAtlasTexture=function(t){return this.atlasTexture[t]},t.prototype.waitForValidCanvasRendering=function(){return s(this,void 0,void 0,function(){var t=this;return a(this,function(e){return[2,new Promise(function(e,r){return s(t,void 0,void 0,function(){function t(t,e,r){var n=e*(4*r)+4*t;return[n,n+1,n+2,n+3]}var n,o,s,u,h,l,y,g,b,x,w,_,C,I,P,M,A,B;return a(this,function(a){switch(a.label){case 0:n=!1,o=setTimeout(function(){console.warn("Unable to establish a Canvas context that is able to render labels"),n=!0,r()},1e4),s=new c.AtlasColor(new f.Color(1,1,1),1),u=new d.ReferenceColor(s),h=new p.Label({color:u,font:"Calibri, Candara, Segoe, Segoe UI, Optima, Arial, sans-serif",fontSize:14,text:"abcdefghijklmnopqrstuvwxyz0123456789"}),l=new m.AtlasTexture(null,h),a.label=1;case 1:if(v||n)return[3,3];for(y=i(l),g=y.canvas,b=g.width,x=g.height,w=y.getImageData(0,0,b,x).data,_=void 0,C=void 0,I=void 0,P=void 0,M=void 0,A=0;A<b;++A)for(B=0;B<x;++B)if(_=t(A,B,b),C=w[_[0]],I=w[_[1]],P=w[_[2]],M=w[_[3]],255===C&&255===I&&255===P)return e(),clearTimeout(o),v=!0,[2];return[4,new Promise(function(t){return setTimeout(t,10)})];case 2:return a.sent(),[3,1];case 3:return[2]}})})})]})})},t.prototype.loadImage=function(t){if(t.imagePath){var e=t.imagePath;if(n(e))return t.pixelWidth=e.width,t.pixelHeight=e.height,t.aspectRatio=e.width/e.height,Promise.resolve(e);if(o(e))return new Promise(function(r,n){var o=new Image;o.onload=function(){t.pixelWidth=o.width,t.pixelHeight=o.height,t.aspectRatio=o.width/o.height,r(o)},o.onerror=function(){r(null)},o.src=e})}else if(t.label)return new Promise(function(e,r){var n=t.label,o=n.getSize(),i=document.createElement("canvas"),s=i.getContext("2d");if(i.width=o.width,i.height=o.height,y("label X %o",t.label.rasterizationOffset.x),s){var a=n.fontSize,f=u.rgb(255*n.color.base.color.r,2