!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.toxi=t()}}(function(){return function t(e,i,n){function s(o,a){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[o]={exports:{}};e[o][0].call(u.exports,function(t){var i=e[o][1][t];return s(i?i:t)},u,u.exports,t,e,i,n)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;os;s++)i=a[s],e.vertices[s]=new THREE.Vector3(i.x,i.y,i.z),h[i.id]=s;if(t.faces)for(o=t.faces.length,s=0;o>s;s++)r=t.faces[s],e.faces[s]=new THREE.Face3(h[r.a.id],h[r.b.id],h[r.c.id],new THREE.Vector3(r.normal.x,r.normal.y,r.normal.z));return e.computeCentroids(),e.computeVertexNormals(),e},s.createMesh=function(t,e){void 0===e&&(e=new THREE.MeshBasicMaterial);var i=s.createMeshGeometry(t);return new THREE.Mesh(i,e)},s.createParticle=function(t,e){var i=new THREE.Particle(e);return i.position.x=t.x,i.position.y=t.y,i.position.z=t.z,i},s.prototype={addLine:function(t,e){void 0===e&&(e=new THREE.LineBasicMaterial);var i=s.createLineGeometry(t),n=new THREE.Line(i,e);return this.scene.add(n),n},addMesh:function(t,e){var i;1==arguments.length?(i=t.geometry,e=t.materials):i=t;var n=this.createMesh(i,e);return this.scene.add(n),n},addParticles:function(t,e){void 0===e&&(e=new THREE.ParticleBasicMaterial),t=n.Array(t)?t:[t];for(var i,s=new THREE.Geometry,r=0,o=t.length;o>r;r++)i=t[r],s.vertices[r]=new THREE.Vector3(i.x,i.y,i.z);var a=new THREE.ParticleSystem(s,e);return this.scene.add(a),s},createMeshGeometry:function(t){return s.createMeshGeometry(t)},createMesh:function(t,e){return s.createMesh(t,e)}},e.exports=s},{"../internals/is":106}],3:[function(t,e,i){i.accessCriteria=t("./color/accessCriteria"),i.AccessCriteria=i.accessCriteria,i.AlphaAccessor=t("./color/AlphaAccessor"),i.CMYKAccessor=t("./color/CMYKAccessor"),i.CMYKDDistanceProxy=t("./color/CMYKDistanceProxy"),i.ColorGradient=t("./color/ColorGradient"),i.ColorList=t("./color/ColorList"),i.ColorRange=t("./color/ColorRange"),i.ColorTheme=t("./color/ColorTheme"),i.createListUsingStrategy=t("./color/createListUsingStrategy"),i.HistEntry=t("./color/HistEntry"),i.Histogram=t("./color/Histogram"),i.HSVAccessor=t("./color/HSVAccessor"),i.HSVDistanceProxy=t("./color/HSVDistanceProxy"),i.Hue=t("./color/Hue"),i.LuminanceAccessor=t("./color/LuminanceAccessor"),i.namedColor=t("./color/namedColor"),i.NamedColor=i.namedColor,i.ProximityComparator=t("./color/ProximityComparator"),i.RGBAccessor=t("./color/RGBAccessor"),i.RGBDistanceProxy=t("./color/RGBDistanceProxy"),i.TColor=t("./color/TColor"),i.theory=t("./color/theory"),i.ToneMap=t("./color/ToneMap")},{"./color/AlphaAccessor":4,"./color/CMYKAccessor":5,"./color/CMYKDistanceProxy":6,"./color/ColorGradient":7,"./color/ColorList":8,"./color/ColorRange":9,"./color/ColorTheme":10,"./color/HSVAccessor":11,"./color/HSVDistanceProxy":12,"./color/HistEntry":13,"./color/Histogram":14,"./color/Hue":15,"./color/LuminanceAccessor":16,"./color/ProximityComparator":17,"./color/RGBAccessor":18,"./color/RGBDistanceProxy":19,"./color/TColor":20,"./color/ToneMap":21,"./color/accessCriteria":22,"./color/createListUsingStrategy":24,"./color/namedColor":26,"./color/theory":27}],4:[function(t,e,i){e.exports=t("./accessors").AlphaAccessor},{"./accessors":23}],5:[function(t,e,i){e.exports=t("./accessors").CMYKAccessor},{"./accessors":23}],6:[function(t,e,i){e.exports=t("./distanceProxies").CMYKDistanceProxy},{"./distanceProxies":25}],7:[function(t,e,i){var n=t("../internals").filter,s=t("../internals").numberComparator,r=t("../math/mathUtils"),o=t("../math/LinearInterpolation"),a=t("./ColorList"),h=function(t,e){this.pos=t,this.color=e};h.prototype={compareTo:function(t){return 0===s(t.pos,this.pos)?0:this.posl;l++)this.gradient[l].pos=o.pos});var d=0;if(l=0,f=p.length,o!==p[f-1])if(h=p[l],g){var m=o.pos-t;d=r.abs(m)>0?1/m:1}else h.pos-o.pos>0&&(d=1/(h.pos-o.pos));for(;u>t;){if(c=g?1-(o.pos-t)*d:(t-o.pos)*d,c>1&&(o=h,g=!1,l++,l1)return p.call(this,arguments);this.colors=[];var e=0;if(n.Array(t)&&t.length)if("number"==typeof t[0])for(e=0,l=t.length;eu;u++){var l=r[u];l.getComponentValue(t)e;e++)if(this.colors[e].equals(t))return!0;return!1},each:function(t){return s(this.colors,t),this},get:function(t){return 0>t&&(t+=this.colors.length),this.colors[t]},getAverage:function(){var t=0,e=0,i=0,n=0;this.each(function(s){t+=s.rgb[0],e+=s.rgb[1],i+=s.rgb[2],n+=s.alpha()});var s=this.colors.length;return s>0?a.newRGBA(t/s,e/s,i/s,n/s):void 0},getBlended:function(t){for(var e=[],i=this.colors.length,n=0;i>n;n++){var s=n>0?n-1:e.length-1,r=this.colors[s];e.push(this.colors[n].getBlended(r,t))}return new p(e)},getDarkest:function(){var t,e=Number.MAX_VALUE;return this.each(function(i){var n=i.luminance();e>n&&(t=i,e=n)}),t},getLightest:function(){var t,e=Number.MIN_VALUE;return this.each(function(i){var n=i.luminance();n>e&&(t=i,e=n)}),t},getRandom:function(){var t=Math.floor(o.random(this.colors.length));return this.colors[t]},getReverse:function(){return new p(this.colors).reverse()},invert:function(){return this.each(function(t){t.invert()}),this},iterator:function(){return new r(this.colors)},reverse:function(){return this.colors.reverse(),this},rotateRYB:function(t,e){var i;return i=t!==Math.floor(t)||e?o.degrees(t):t,this.each(function(t){t.rotateRYB(i)}),this},size:function(){return this.colors.length},sort:function(){return this.sortByCriteria(f.HUE,!1)},sortByComparator:function(t,e){return"function"==typeof t&&"undefined"==typeof t.compare&&(t={compare:t}),this.colors.sort(t.compare),e&&this.colors.reverse(),this},sortByCriteria:function(t,e){return this.sortByComparator(t,e)},sortByDistance:function(t,e){if(1===arguments.length&&(e=arguments[0],t=new h),0===this.colors.length)return this;var i=this.getDarkest(),n=this.colors.slice(0),s=[];n.splice(n.indexOf(i),1),s.push(i);for(var r=0;n.length>1;){for(var o=n[0],a=s[r],c=t.distanceBetween(o,a),u=n.length-1;u>=0;u--){var l=n[u],f=t.distanceBetween(l,a);c>f&&(o=l,c=f)}n.splice(n.indexOf(o),1),s.push(o),r++}return s.push(n[0]),e&&s.reverse(),this.colors=s,this},sortByProximityTo:function(t,e,i){return 2==arguments.length&&(t=arguments[0],e=new c,i=arguments[1]),this.sortByComparator(new u(t,e),i)},toARGBArray:function(){var t=[];return this.each(function(e){t.push(e.toARGB())}),t}},p.createFromARGBArray=function(t,e,i,n){if(n=n||100,e=o.min(e,t.length),!i&&e==t.length)return new p(t);var s,r=[],h=a.BLACK.copy(),c=0,u=!0,l=0;for(c=0;e>c;c++)if(i){u=!0,l=0;do s=o.random(t.length),h.setARGB(t[s]),u=!(r.indexOf(h)>=0);while(!u&&++ll))break;r.push(h.copy())}else s=o.random(t.length),r.push(a.newARGB(t[s]));return new p(r)},p.createUsingStrategy=function(){throw new Error("Not allowed, use toxi/color/createListUsingStrategy instead")},e.exports=p},{"../internals/Iterator":99,"../internals/each":102,"../internals/is":106,"../math/mathUtils":125,"./HSVDistanceProxy":12,"./ProximityComparator":17,"./RGBDistanceProxy":19,"./TColor":20,"./accessCriteria":22}],9:[function(t,e,i){var n,s,r,o,a=t("./TColor"),h=t("./ColorList"),c=t("../util/datatypes/FloatRange"),u=t("../internals/is"),l=t("../internals/each"),f=t("../math/mathUtils"),p=1;r=function(t,e){t.push.apply(t,e)},s=function(t){return function(e,i){return this[t.toLowerCase()+"Constraint"].push(u.FloatRange(e)?e:new c(e,i)),this}},o=function(t){return t[Math.floor(Math.random()*t.length)]},n=function(t,e,i,n,s,r,o){var a,h=this;if(0===arguments.length)return this;u.ColorList(t)&&(a=t,t=a.get(0)),u.Hue(t)&&(t=new c(t.getHue(),t.getHue())),u.TColor(t)&&(t=new c(t.hue(),t.hue())),this.hueConstraint=[u.FloatRange(t)?t:new c(0,1)],this.saturationConstraint=[u.FloatRange(e)?e:new c(0,1)],this.brightnessConstraint=[u.FloatRange(i)?i:new c(0,1)],this.alphaConstraint=[u.FloatRange(n)?n:new c(1,1)],this.black=u.FloatRange(s)?s:new c(0,1),this.white=u.FloatRange(r)?r:new c(0,1),a&&(this.hueConstraint=[],a.each(function(t){h.add(t)}));for(var l=arguments.length-1;l>=0;l--)if("string"==typeof arguments[l]){this.name=arguments[l];break}this.name||(this.name="untitled"+p++)},n.prototype={constructor:n,add:function(t){return u.ColorRange(t)?(r(this.hueConstraint,t.hueConstraint),r(this.saturationConstraint,t.saturationConstraint),r(this.brightnessConstraint,t.brightnessConstraint),r(this.alphaConstraint,t.alphaConstraint),this.black.min=Math.min(this.black.min,t.black.min),this.black.max=Math.max(this.black.max,t.black.max),this.white.min=Math.min(this.white.min,t.white.min),this.white.max=Math.max(this.white.max,t.white.max)):(this.hueConstraint.push(new c(t.hue(),t.hue())),this.saturationConstraint.push(new c(t.saturation(),t.saturation())),this.brightnessConstraint.push(new c(t.brightness(),t.brightness())),this.alphaConstraint.push(new c(t.alpha(),t.alpha()))),this},addAlphaRange:s("alpha"),addBrightnessRange:s("brightness"),addHue:function(t){return this.hueConstraint.push(new c(t.getHue(),t.getHue())),this},addHueRange:s("hue"),addSaturationRange:s("saturation"),contains:function(t){var e=this.isValueInConstraint(t.hue(),this.hueConstraint);return e&=this.isValueInConstraint(t.saturation(),this.saturationConstraint),e&=this.isValueInConstraint(t.brightness(),this.brightnessConstraint),e&=this.isValueInConstraint(t.alpha(),this.alphaConstraint),e||!1},copy:function(t,e){e="number"==typeof e?e:0;var i=new n;if(i.name=this.name,t){var s=t.hue()+e*f.normalizedRandom();i.hueConstraint=[new c(s,s)],i.alphaConstraint=[new c(t.alpha(),t.alpha())]}else i.hueConstraint=[].concat(this.hueConstraint),i.alphaConstraint=[].concat(this.alphaConstraint);return i.saturationConstraint=[].concat(this.saturationConstraint),i.brightnessConstraint=[].concat(this.brightnessConstraint),i.black=this.black.copy(),i.white=this.white.copy(),i},getColor:function(t,e){if(u.Hue(t))return a.newHSVA(t.getHue(),o(this.saturationConstraint).pickRandom(),o(this.brightnessConstraint).pickRandom(),o(this.alphaConstraint).pickRandom());var i,n,s,r,h=t;if(h){if(h.isBlack())return a.newHSVA(h.hue(),0,this.black.pickRandom(),h.alpha());if(h.isWhite())return a.newHSVA(h.hue(),0,this.white.pickRandom(),h.alpha());if(h.isGrey())return a.newHSVA(h.hue(),0,f.flipCoin()?this.black.pickRandom():this.white.pickRandom(),h.alpha());i=h.hue()+e*f.normalizedRandom(),r=h.alpha()}else i=o(this.hueConstraint).pickRandom(),r=o(this.alphaConstraint).pickRandom();return n=o(this.saturationConstraint).pickRandom(),s=o(this.brightnessConstraint).pickRandom(),a.newHSVA(i,n,s,r)},getColors:function(t,e,i){arguments.length<3&&(i=n.DEFAULT_VARIANCE),1===arguments.length&&(e=t,t=void 0);for(var s=new h,r=0;e>r;r++)s.add(this.getColor(t,i));return s},getGrayscale:function(t,e){return this.getColor(a.newGray(t),e)},getName:function(){return this.name},getSum:function(t){return this.copy().add(t)},isValueInConstraint:function(t,e){var i=!1;return l(e,function(e){i|=e.isValueInRange(t)}),i}},n.DEFAULT_VARIANCE=.035,function(t,e){n.PRESETS={},l({light:[e,new t(.3,.7),new t(.9,1),e,new t(.15,.3),e],dark:[e,new t(.7,1),new t(.15,.4),e,e,new t(.5,.75)],bright:[e,new t(.8,1),new t(.8,1)],weak:[e,new t(.15,.3),new t(.7,1),e,new t(.2,.2),e],neutral:[e,new t(.25,.35),new t(.3,.7),e,new t(.15,.15),new t(.9,1)],fresh:[e,new t(.4,.8),new t(.8,1),e,new t(.05,.3),new t(.8,1)],soft:[e,new t(.2,.3),new t(.6,.9),e,new t(.05,.15),new t(.6,.9)],hard:[e,new t(.9,1),new t(.4,1)],warm:[e,new t(.6,.9),new t(.4,.9),e,new t(.2,.2),new t(.8,1)],cool:[e,new t(.05,.2),new t(.9,1),e,e,new t(.95,1)],intense:[e,new t(.9,1),new t(.2,.35)]},function(t,e){t.push(e);var i=e.toUpperCase();n[i]=new n,n.apply(n[i],t),n.PRESETS[i]=n[i]}),n.INTENSE.addBrightnessRange(new t(.8,1))}(c,void 0),n.getPresetForName=function(t){return n.PRESETS[t.toUpperCase()]},e.exports=n},{"../internals/each":102,"../internals/is":106,"../math/mathUtils":125,"../util/datatypes/FloatRange":165,"./ColorList":8,"./TColor":20}],10:[function(t,e,i){var n,s,r=t("../internals/each"),o=(t("../math/mathUtils"),t("./ColorRange")),a=t("./namedColor"),h=t("./ColorList");s=function(t,e,i){this.range=t,this.color=e,this.weight=i},s.prototype.getColor=function(){return this.range.getColor(this.color,o.DEFAULT_VARIANCE)},n=function(t){this.name=t,this.parts=[],this._weightedSum=0},n.prototype={constructor:n,addRange:function(t,e,i){var n,h,c=this;return 3===arguments.length?(this.parts.push(new s(t,e,i)),this._weightedSum+=i):(r(t.split(" "),function(t){o.getPresetForName(t)?n=o.getPresetForName(t):a.getForName(t)&&(h=a.getForName(t))}),n&&c.addRange(n,h,e)),this},getColor:function(){for(var t,e,i=Math.random(),n=0,s=this.parts.length;s>n;n++){if(t=this.parts[n],e=t.weight/this._weightedSum,e>=i)return t.getColor();i-=e}return null},getColors:function(t){for(var e=new h,i=0;t>i;i++)e.add(this.getColor());return e},getName:function(){return this.name}},e.exports=n},{"../internals/each":102,"../math/mathUtils":125,"./ColorList":8,"./ColorRange":9,"./namedColor":26}],11:[function(t,e,i){e.exports=t("./accessors").HSVAccessor},{"./accessors":23}],12:[function(t,e,i){e.exports=t("./distanceProxies").HSVDistanceProxy},{"./distanceProxies":25}],13:[function(t,e,i){var n=function(t){this.col=t,this.freq=1};n.prototype={constructor:n,compareTo:function(t){return parseInt(t.freq-this.freq,10)},getColor:function(){return this.col},getFrequency:function(){return this.freq}},e.exports=n},{}],14:[function(t,e,i){var n=t("../internals").each,s=t("../internals").Iterator,r=t("./HistEntry"),o=t("./ColorList"),a=function(t){this.palette=t};a.prototype={constructor:a,compute:function(t,e){var i=this;this.entries=[];var s=1;return this.palette.each(function(n){var o,a,h=0,c=i.entries.length;for(h=0;c>h;h++)if(a=i.entries[h],a.col.distanceToRGB(n)s&&(s=o.freq)):i.entries.push(new r(n))}),this.entries.sort(),s=1/this.palette.size(),n(this.entries,function(t){t.freq*=s}),this.entries},getEntries:function(){return this.entries},getPalette:function(){return this.palette},iterator:function(){return new s(this.entries)},setPalette:function(t){this.palette=t}},a.newFromARGBArray=function(t,e,i,n){var s=new a(o.createFromARGBArray(t,e,!1));return s.compute(i,n),s},e.exports=a},{"../internals":98,"./ColorList":8,"./HistEntry":13}],15:[function(t,e,i){var n,s=t("../internals/LinkedMap"),r=t("../internals/each"),o=new s,a=[];n=function(t,e,i){this._isPrimary=i===!0,this.name=t,this.hue=e,o.put(t,this),this._isPrimary&&a.push(this)},n.prototype={constructor:n,getHue:function(){return this.hue},getName:function(){return this.name},isPrimary:function(){return this._isPrimary},toString:function(){return"Hue: ID:"+this.name+" @ "+parseInt(360*this.hue,10)+" degrees"}},n.PRESETS={},r([["red",!0],["orange",!0],["yellow",!0],["lime"],["green",!0],["teal"],["cyan"],["azure"],["blue",!0],["indigo"],["purple",!0],["pink",!0]],function(t,e){var i=t[0],s=i.toUpperCase(),r=t[1];n[s]=new n(i,30*e/360,r),n.PRESETS[s]=n[s]}),n.PRIMARY_VARIANCE=.01,n.getClosest=function(t,e){t%=1,e=e===!0;var i,n=Number.MAX_VALUE,s=e?a:o.getArray();return r(s,function(e){var s=Math.min(Math.abs(e.getHue()-t),Math.abs(1+e.getHue()-t));n>s&&(n=s,i=e)}),i},n.getForName=function(t){return o.get(t)},n.isPrimary=function(t,e){e="number"==typeof e?e:n.PRIMARY_VARIANCE;for(var i=!1,s=0,r=a.length;r>s;s++){var o=a[s];if(Math.abs(t-o.getHue())i?-1:i>n?1:0},e.exports=n},{}],18:[function(t,e,i){e.exports=t("./accessors").RGBAccessor},{"./accessors":23}],19:[function(t,e,i){e.exports=t("./distanceProxies").RGBDistanceProxy},{"./distanceProxies":25}],20:[function(t,e,i){var n=t("../internals/numberComparator"),s=t("../internals/is"),r=t("../math/mathUtils"),o=t("../geom/vectors"),a=o.Vec2D,h=o.Vec3D,c=t("./Hue"),u=function(t){return 0>t&&(t=4294967295+t+1),t.toString(16)},l=function(t){if(this.rgb=[],this.hsv=[],this.cmyk=[],this._alpha=1,void 0!==t){var e=t.toCMYKAArray();this.cmyk=e.splice(0,4),this.hsv=t.toHSVAArray().splice(0,3),this.rgb=t.toRGBAArray().splice(0,3),this._alpha=t._alpha}};l.prototype={add:function(t){return this.copy().addSelf(t)},addSelf:function(t){return this.rgb[0]=r.min(this.rgb[0]+t.rgb[0],1),this.rgb[1]=r.min(this.rgb[1]+t.rgb[1],1),this.rgb[2]=r.min(this.rgb[2]+t.rgb[2],1),this.setRGB(this.rgb)},adjustConstrast:function(t){return this.hsv[2]<.5?this.darken(t):this.lighten(t)},adjustHSV:function(t,e,i){return this.setHSV([this.hsv[0]+t,this.hsv[1]+e,this.hsv[2]+i])},adjustRGB:function(t,e,i){return this.setRGB([this.rgb[0]+t,this.rgb[1]+e,this.rgb[2]+i])},alpha:function(){return this._alpha},analog:function(t,e){var i=r.degrees(t);return this.rotateRYB(i*r.normalizedRandom()),this.hsv[1]+=e*r.normalizedRandom(),this.hsv[2]+=e*r.normalizedRandom(),this.setHSV(this.hsv)},black:function(){return this.cmyk[3]},blend:function(t,e){void 0===e&&(e=.5);var i=t.toRGBAArray();return this.rgb[0]+=(i[0]-this.rgb[0])*e,this.rgb[1]+=(i[1]-this.rgb[1])*e,this.rgb[2]+=(i[2]-this.rgb[2])*e,this._alpha+=(t._alpha-this._alpha)*e,this.setRGB(this.rgb)},blue:function(){return this.rgb[2]},brightness:function(){return this.hsv[2]},complement:function(){return this.rotateRYB(180)},copy:function(){return new l(this)},cyan:function(){return this.cmyk[0]},darken:function(t){return this.hsv[2]=r.clip(this.hsv[2]-t,0,1),this.setHSV(this.hsv)},desaturate:function(t){return this.hsv[1]=r.clip(this.hsv[1]-t,0,1),this.setHSV(this.hsv)},differenceTo:function(t){return l.newRGB(Math.abs(this.rgb[0]-t.rgb[0]),Math.abs(this.rgb[1]-t.rgb[1]),Math.abs(this.rgb[2]-t.rgb[2]))},distanceToCMYK:function(t){var e=t.toCMYKAArray(),i=this.cmyk[0]-e[0],n=this.cmyk[1]-e[1],s=this.cmyk[2]-e[2],r=this.cmyk[3]-e[3];return Math.sqrt(i*i+n*n+s*s+r*r)},distanceToHSV:function(t){var e=this.hsv[0]*r.TWO_PI,i=t.hue()*r.TWO_PI,n=new h(r.cos(e)*this.hsv[1],r.sin(e)*this.hsv[1],this.hsv[2]),s=new h(r.cos(i)*t.saturation(),r.sin(i)*t.saturation(),t.brightness());return n.distanceTo(s)},distanceToRGB:function(t){var e=t.toRGBAArray(),i=this.rgb[0]-e[0],n=this.rgb[1]-e[1],s=this.rgb[2]-e[2];return Math.sqrt(i*i+n*n+s*s)},equals:function(t){if(s.TColor(t)){var e=t,i=e.rgb[0]-this.rgb[0],n=e.rgb[1]-this.rgb[1],r=e.rgb[2]-this.rgb[2],o=e.alpha()-this._alpha,a=Math.sqrt(i*i+n*n+r*r+o*o);return a=l.WHITE_POINT&&this.rgb[0]===this.rgb[1]&&this.rgb[0]===this.rgb[2]},lighten:function(t){return this.hsv[2]=r.clip(this.hsv[2]+t,0,1),this.setHSV(this.hsv)},luminance:function(){return.299*this.rgb[0]+.587*this.rgb[1]+.114*this.rgb[2]},magenta:function(){return this.cmyk[1]},red:function(){return this.rgb[0]},rotateRYB:function(t){var e,i,n=(parseInt(r.degrees(t),10),360*this.hsv[0]),s=0;t%=360;var o=0;for(s=0;s>16&255)*l.INV8BIT,(t>>8&255)*l.INV8BIT,(255&t)*l.INV8BIT),this._alpha=(t>>>24)*l.INV8BIT,this},setBlack:function(t){return this.cmyk[3]=t,this.setCMYK(this.cmyk)},setBlue:function(t){return this.rgb[2]=t,this.setRGB(this.rgb)},setBrightness:function(t){return this.hsv[2]=r.clip(t,0,1),this.setHSV(this.hsv)},setCMYK:function(t,e,i,n){return s.Array(t)&&(e=t[1],i=t[2],n=t[3],t=t[0]),this.cmyk[0]=t,this.cmyk[1]=e,this.cmyk[2]=i,this.cmyk[3]=n,this.rgb=l.cmykToRGB(this.cmyk[0],this.cmyk[1],this.cmyk[2],this.cmyk[3]),this.hsv=l.rgbToHSV(this.rgb[0],this.rgb[1],this.rgb[2]),this},setComponent:function(t,e){return t.setComponentValueFor(this,e),this},setCyan:function(t){return this.cmyk[0]=t,this.setCMYK(this.cmyk)},setGreen:function(t){return this.rgb[1]=t,this.setRGB(this.rgb)},setHSV:function(t,e,i){s.Array(t)&&(e=t[1],i=t[2],t=t[0]);var n=[t,e,i];return this.hsv[0]=n[0]%1,this.hsv[0]<0&&this.hsv[0]++,this.hsv[1]=r.clip(n[1],0,1),this.hsv[2]=r.clip(n[2],0,1),this.rgb=l.hsvToRGB(this.hsv[0],this.hsv[1],this.hsv[2]),this.cmyk=l.rgbToCMYK(this.rgb[0],this.rgb[1],this.rgb[2]),this},setHue:function(t){return t%=1,0>t&&t++,this.hsv[0]=t,this.setHSV(this.hsv)},setMagenta:function(t){return this.cmyk[1]=t,this.setCMYK(this.cmyk)},setRed:function(t){return this.rgb[0]=t,this.setRGB(this.rgb)},setRGB:function(t,e,i){return s.Array(t)&&(e=t[1],i=t[2],t=t[0]),this.rgb[0]=r.clip(t,0,1),this.rgb[1]=r.clip(e,0,1),this.rgb[2]=r.clip(i,0,1),this.cmyk=l.rgbToCMYK(this.rgb[0],this.rgb[1],this.rgb[2]),this.hsv=l.rgbToHSV(this.rgb[0],this.rgb[1],this.rgb[2]),this},setSaturation:function(t){return this.hsv[1]=r.clip(t,0,1),this.setHSV(this.hsv)},setYellow:function(t){return this.cmyk[2]=t,this.setCMYK(this.cmyk)},sub:function(t){return this.copy().subSelf(t)},subSelf:function(t){return this.rgb[0]=r.max(this.rgb[0]-t.rgb[0],0),this.rgb[1]=r.max(this.rgb[1]-t.rgb[1],0),this.rgb[2]=r.max(this.rgb[2]-t.rgb[2],0),this.setRGB(this.rgb)},toARGB:function(){var t=parseInt(255*this.rgb[0],10),e=parseInt(255*this.rgb[1],10),i=parseInt(255*this.rgb[2],10),n=parseInt(255*this._alpha,10);return t<<16|e<<8|i|n<<24},toCMYKAArray:function(t){return void 0===t&&(t=[]),t[0]=this.cmyk[0],t[1]=this.cmyk[1],t[2]=this.cmyk[2],t[3]=this.cmyk[3],t[4]=this._alpha,t},toHex:function(){var t=u(this.toARGB());return t.length>6&&(t=t.substring(2)),t},toHexCSS:function(){return"#"+this.toHex()},toHSVAArray:function(t){return void 0===t&&(t=[]),t[0]=this.hsv[0],t[1]=this.hsv[1],t[2]=this.hsv[2],t[3]=this._alpha,t},toHSLCSS:function(){var t=this.hsv,e=Math.floor(360*t[0]),i=Math.floor(100*t[1]),n=Math.floor(100*t[2]);return"hsl("+e+","+i+"%,"+n+"%)"},toHSLACSS:function(){var t=this.hsv,e=Math.floor(360*t[0]),i=Math.floor(100*t[1]),n=Math.floor(100*t[2]);return"hsla("+e+","+i+"%,"+n+"%,"+this._alpha+")"},toInt:function(){return Number("0x"+this.toHex())},toRGBAArray:function(t,e){return t=t||[],e=e||0,t[e++]=this.rgb[0],t[e++]=this.rgb[1],t[e++]=this.rgb[2],t[e]=this._alpha,t},toRGBADecimalArray:function(t,e){return t=t||[],e=e||0,t[e++]=255*this.rgb[0],t[e++]=255*this.rgb[1],t[e++]=255*this.rgb[2],t[e]=255*this._alpha,t},toRGBCSS:function(t){var e=this.rgb,i=t?100:255,n=t?"%":"",s=Math.floor;return"rgb("+s(e[0]*i)+n+","+s(e[1]*i)+n+","+s(e[2]*i)+n+")"},toRGBACSS:function(t){var e=this.rgb,i=t?100:255,n=t?"%":"",s=Math.floor;return"rgba("+s(e[0]*i)+n+","+s(e[1]*i)+n+","+s(e[2]*i)+n+","+this._alpha+")"},toString:function(){return"TColor: rgb: "+this.rgb[0]+", "+this.rgb[1]+", "+this.rgb[2]+" hsv: "+this.hsv[0]+","+this.hsv[1]+","+this.hsv[2]+" cmyk: "+this.cmyk[0]+", "+this.cmyk[1]+","+this.cmyk[2]+","+this.cmyk[3]+" alpha: "+this._alpha},yellow:function(){return this.cmyk[2]}},l.INV60DEGREES=60/360,l.INV8BIT=1/255,l.EPS=.001,l.BLACK_POINT=.08,l.WHITE_POINT=1,l.GREY_THRESHOLD=.01,l.cmykToRGB=function(t,e,i,n,s){return void 0===s&&(s=[0,0,0]),s[0]=1-Math.min(1,t+n),s[1]=1-Math.min(1,e+n),s[2]=1-Math.min(1,i+n),s},l.hexToRGB=function(t,e){return void 0===e&&(e=[]),t="#"==t.charAt(0)?t.substring(1,7):t,e[0]=parseInt(t.substring(0,2),16)*l.INV8BIT,e[1]=parseInt(t.substring(2,4),16)*l.INV8BIT,e[2]=parseInt(t.substring(4,6),16)*l.INV8BIT,e},l.hsvToRGB=function(t,e,i,n){if(void 0===n&&(n=[]),0===e)n[0]=n[1]=n[2]=i;else{t/=l.INV60DEGREES;var s=parseInt(t,10),r=t-s,o=i*(1-e),a=i*(1-e*r),h=i*(1-e*(1-r));0===s?(n[0]=i,n[1]=h,n[2]=o):1==s?(n[0]=a,n[1]=i,n[2]=o):2==s?(n[0]=o,n[1]=i,n[2]=h):3==s?(n[0]=o,n[1]=a,n[2]=i):4==s?(n[0]=h,n[1]=o,n[2]=i):(n[0]=i,n[1]=o,n[2]=a)}return n},l.labToRGB=function(t,e,i,n){void 0===n&&(n=[]);var s=(t+16)/116,r=e/500+s,o=s-i/200,a=0;for(n[0]=r,n[1]=s,n[2]=o,a=0;3>a;a++){var h=Math.pow(n[a],3);h>.008856?n[a]=h:n[a]=(n[a]-16/116)/7.787}r=.95047*n[0],s=n[1],o=1.08883*n[2],n[0]=3.2406*r+-1.5372*s+o*-.4986,n[1]=r*-.9689+1.8758*s+.0415*o,n[2]=.0557*r+s*-.204+1.057*o;var c=1/2.4;for(a=0;3>a;a++)n[a]>.0031308?n[a]=1.055*Math.pow(n[a],c)-.055:n[a]=12.92*n[a];return n},l.newARGB=function(t){return l.newRGBA((t>>16&255)*l.INV8BIT,(t>>8&255)*l.INV8BIT,(255&t)*l.INV8BIT,(t>>>24)*l.INV8BIT)},l.newCMYK=function(t,e,i,n){return l.newCMYKA(t,e,i,n,1)},l.newCMYKA=function(t,e,i,n,s){var o=new l;return o.setCMYK([t,e,i,n]),o.setAlpha(r.clip(s,0,1)),o},l.newCSS=function(t){function e(e){var i=t.substr(0,t.length-1);return i.substr(e.length+1,i.length).split(",")}function i(t){var e=0,i=t.length;for(e=0;i>e;e++)t[e]=Number(t[e]);return t}for(;t.indexOf(" ")>-1;)t=t.replace(" ","");t=t.toLowerCase();var n={"#":function(){return l.newHex(t.substr(1,t.length))},rgba:function(){var t=i(e("rgba"));return l.newRGBA(t[0]/255,t[1]/255,t[2]/255,t[3])},rgb:function(){var t=i(e("rgb"));return l.newRGBA(t[0]/255,t[1]/255,t[2]/255,1)},hsla:function(t){return t=t||e("hsla"),t[0]=Number(t[0])/360,t[1]=Number(t[1].substr(0,t[1].length-1))/100,t[2]=Number(t[2].substr(0,t[2].length-1))/100,t[3]=Number(t[3]),l.newHSVA(t[0],t[1],t[2],t[3])},hsl:function(){var t=e("hsl");return t.push(1),n.hsla(t)}};if(void 0!==l.X11[t])return l.X11[t].copy();for(var s in n)if(t.indexOf(s)>-1)return n[s]()},l.newGray=function(t){return l.newGrayAlpha(t,1)},l.newGrayAlpha=function(t,e){var i=new l;return i.setRGB([t,t,t]),i.setAlpha(e),i},l.newHex=function(t){var e=new l;return e.setRGB(l.hexToRGB(t)),e.setAlpha(1),e},l.newHSV=function(t,e,i){return l.newHSVA(t,e,i,1)},l.newHSVA=function(t,e,i,n){var s=new l;return s.setHSV(t,e,i),s.setAlpha(r.clip(n,0,1)),s},l.newRandom=function(){return l.newRGBA(Math.random(),Math.random(),Math.random(),1)},l.newRGB=function(t,e,i){return l.newRGBA(t,e,i,1)},l.newRGBA=function(t,e,i,n){var s=new l;return s.setRGB(t,e,i),s.setAlpha(r.clip(n,0,1)),s},l.rgbToCMYK=function(t,e,i,n){return void 0===n&&(n=[]),n[0]=1-t,n[1]=1-e,n[2]=1-i,n[3]=r.min(n[0],n[1],n[2]),n[0]=r.clip(n[0]-n[3],0,1),n[1]=r.clip(n[1]-n[3],0,1),n[2]=r.clip(n[2]-n[3],0,1),n[3]=r.clip(n[3],0,1),n},l.rgbToHex=function(t,e,i){var n=u(255*r.clip(t,0,1))+u(255*r.clip(e,0,1))+u(255*r.clip(i,0,1));return n},l.rgbToHSV=function(t,e,i,s){void 0===s&&(s=[]);var o=0,a=0,h=r.max(t,e,i),c=h-r.min(t,e,i);return 0!==h&&(a=c/h),0!==a&&(o=0===n(t,h)?(e-i)/c:0===n(e,h)?2+(i-t)/c:4+(t-e)/c),o*=l.INV60DEGREES,0>o&&(o+=1),s[0]=o,s[1]=a,s[2]=h,s},l.RED=l.newRGB(1,0,0),l.RYB_WHEEL=[new a(0,0),new a(15,8),new a(30,17),new a(45,26),new a(60,34),new a(75,41),new a(90,48),new a(105,54),new a(120,60),new a(135,81),new a(150,103),new a(165,123),new a(180,138),new a(195,155),new a(210,171),new a(225,187),new a(240,204),new a(255,219),new a(270,234),new a(285,251),new a(300,267),new a(315,282),new a(330,298),new a(345,329),new a(360,0)],l.GREEN=l.newRGB(0,1,0),l.BLUE=l.newRGB(0,0,1),l.CYAN=l.newRGB(0,1,1),l.MAGENTA=l.newRGB(1,0,1),l.YELLOW=l.newRGB(1,1,0),l.BLACK=l.newRGB(0,0,0),l.WHITE=l.newRGB(1,1,1),l.X11={},function(){var t,e,i={indianred:[205,92,92],lightcoral:[240,128,128],salmon:[250,128,114],darksalmon:[233,150,122],lightsalmon:[255,160,122],red:[255,0,0],crimson:[220,20,60],fireBrick:[178,34,34],darkred:[139,0,0], pink:[255,192,203],lightpink:[255,182,193],hotpink:[255,105,180],deeppink:[255,20,147],mediumvioletred:[199,21,133],palevioletred:[219,112,147],coral:[255,127,80],tomato:[255,99,71],orangered:[255,69,0],darkorange:[255,140,0],orange:[255,165,0],gold:[255,215,0],yellow:[255,255,0],lightyellow:[255,255,224],lemonchiffon:[255,250,205],lightgoldenrodyellow:[250,250,210],papayawhip:[255,239,213],moccasin:[255,228,181],peachpuff:[255,218,185],palegoldenrod:[238,232,170],khaki:[240,230,140],darkkhaki:[189,183,107],lavender:[230,230,250],thistle:[216,191,216],plum:[221,160,221],violet:[238,130,238],orchid:[218,112,214],fuchsia:[255,0,255],Magenta:[255,0,255],mediumorchid:[186,85,211],mediumpurple:[147,112,219],blueviolet:[138,43,226],darkviolet:[148,0,211],darkorchid:[153,50,204],darkmagenta:[139,0,139],purple:[128,0,128],indigo:[75,0,130],darkslateblue:[72,61,139],slateblue:[106,90,205],mediumslateblue:[123,104,238],greenyellow:[173,255,47],chartreuse:[127,255,0],lawngreen:[124,252,0],lime:[0,255,0],limegreen:[50,205,50],palegreen:[152,251,152],lightgreen:[144,238,144],mediumspringgreen:[0,250,154],springgreen:[0,255,127],mediumseagreen:[60,179,113],seagreen:[46,139,87],forestgreen:[34,139,34],green:[0,128,0],darkgreen:[0,100,0],yellowgreen:[154,205,50],olivedrab:[107,142,35],olive:[128,128,0],darkolivegreen:[85,107,47],mediumaquamarine:[102,205,170],darkseagreen:[143,188,143],lightseagreen:[32,178,170],darkcyan:[0,139,139],teal:[0,128,128],aqua:[0,255,255],cyan:[0,255,255],lightcyan:[224,255,255],paleturquoise:[175,238,238],aquamarine:[127,255,212],turquoise:[64,224,208],mediumturquoise:[72,209,204],darkturquoise:[0,206,209],cadetblue:[95,158,160],steelblue:[70,130,180],lightsteelblue:[176,196,222],powderblue:[176,224,230],lightblue:[173,216,230],skyblue:[135,206,235],lightskyblue:[135,206,250],deepskyblue:[0,191,255],dodgerblue:[30,144,255],cornflowerblue:[100,149,237],royalblue:[65,105,225],blue:[0,0,255],mediumblue:[0,0,205],darkblue:[0,0,139],navy:[0,0,128],midnightblue:[25,25,112],cornsilk:[255,248,220],blanchedalmond:[255,235,205],bisque:[255,228,196],navajowhite:[255,222,173],wheat:[245,222,179],burlywood:[222,184,135],tan:[210,180,140],rosybrown:[188,143,143],sandybrown:[244,164,96],goldenrod:[218,165,32],darkgoldenrod:[184,134,11],Peru:[205,133,63],chocolate:[210,105,30],saddlebrown:[139,69,19],sienna:[160,82,45],brown:[165,42,42],maroon:[128,0,0],white:[255,255,255],snow:[255,250,250],honeydew:[240,255,240],mintcream:[245,255,250],azure:[240,255,255],aliceblue:[240,248,255],ghostwhite:[248,248,255],whitesmoke:[245,245,245],seashell:[255,245,238],beige:[245,245,220],oldlace:[253,245,230],floralwhite:[255,250,240],ivory:[255,255,240],antiquewhite:[250,235,215],linen:[250,240,230],lavenderblush:[255,240,245],mistyrose:[255,228,225],gainsboro:[220,220,220],lightgray:[211,211,211],silver:[192,192,192],darkgray:[169,169,169],gray:[128,128,128],dimgray:[105,105,105],lightslategray:[119,136,153],slategray:[112,128,144],darkslategray:[47,79,79],black:[0,0,0],bark:[64,48,33]};for(t in i)i.hasOwnProperty(t)&&(e=i[t],l.X11[t]=l.newRGB(e[0]/255,e[1]/255,e[2]/255),t.indexOf("gray")>=0&&(l.X11[t.replace("gray","grey")]=l.X11[t]));l.X11.transparent=l.newRGBA(0,0,0,0)}(),e.exports=l},{"../geom/vectors":96,"../internals/is":106,"../internals/numberComparator":109,"../math/mathUtils":125,"./Hue":15}],21:[function(t,e,i){var n,s=t("../internals/is"),r=t("../math/ScaleMap"),o=t("./ColorList"),a=t("./ColorGradient");n=function(t,e,i,n,h){var c=arguments.length;if(c>3)if(4===c)i=new o(i,n);else{var u=i;i=new a,i.addColorAt(0,u),i.addColorAt(h-1,n),i=i.calcGradient(0,h)}s.ColorGradient(i)&&(i=i.calcGradient()),this.map=new r(t,e,0,i.size()-1),this.colors=i},n.prototype={constructor:n,getARGBToneFor:function(t){return this.getToneFor(t).toARGB()},getToneFor:function(t){var e;return e=this.colors.size()>2?Math.floor(this.map.getClippedValueFor(t)+.5):t>=this.map.getInputMedian()?1:0,this.colors.get(e)},getToneMappedArray:function(t,e,i){if("number"!=typeof i)i=0;else if(0>i)throw new Error("offset into target pixel array is negative");e=e||new Array(t.length);for(var n=0,s=t.length;s>n;n++)e[i++]=this.getToneFor(t[n]).toARGB();return e},setMapFunction:function(t){this.map.setMapFunction(t)}},e.exports=n},{"../internals/is":106,"../math/ScaleMap":120,"./ColorGradient":7,"./ColorList":8}],22:[function(t,e,i){var n=t("./HSVAccessor"),s=t("./RGBAccessor"),r=t("./CMYKAccessor"),o=t("./AlphaAccessor"),a=t("./LuminanceAccessor");i.HUE=new n(0),i.SATURATION=new n(1),i.BRIGHTNESS=new n(2),i.RED=new s(0),i.GREEN=new s(1),i.BLUE=new s(2),i.CYAN=new r(0),i.MAGENTA=new r(1),i.YELLOW=new r(2),i.BLACK=new r(3),i.ALPHA=new o,i.LUMINANCE=new a},{"./AlphaAccessor":4,"./CMYKAccessor":5,"./HSVAccessor":11,"./LuminanceAccessor":16,"./RGBAccessor":18}],23:[function(t,e,i){function n(t,e){var n=t+"Accessor",o=t.toLowerCase();i[n]=function(t){this.component=t,this.compare=r(this.compare,this)},i[n].prototype.compare=function(t,e){var i=t[o][this.component],n=e[o][this.component];return s(i,n)},i[n].prototype.getComponentValueFor=function(t){return t[o][this.component]},i[n].prototype.setComponentValueFor=function(t,i){t["set"+e[this.component]](i)}}var s=t("../internals").numberComparator,r=t("../internals").bind;n("RGB",["Red","Green","Blue"]),n("HSV",["Hue","Saturation","Brightness"]),n("CMYK",["Cyan","Magenta","Yellow","Black"]);var o=function(){};o.prototype.compare=function(t,e){return s(t.luminance(),e.luminance())},o.prototype.getComponentValueFor=function(t){return t.luminance()},o.prototype.setComponentValueFor=function(){};var a=function(){};a.prototype.compare=function(t,e){return s(t.alpha(),e.alpha())},a.prototype.getComponentValueFor=function(t){return t.alpha()},a.prototype.setComponentValueFor=function(t,e){t.setAlpha(e)},i.LuminanceAccessor=o,i.AlphaAccessor=a},{"../internals":98}],24:[function(t,e,i){var n=t("./theory/colorTheoryRegistry");e.exports=function(t,e){"string"==typeof t&&(t=n.getStrategyForName(t));var i;return void 0!==t&&(i=t.createListFromColor(e)),i}},{"./theory/colorTheoryRegistry":38}],25:[function(t,e,i){function n(t){var e=t+"DistanceProxy";i[e]=function(){},i[e].prototype.distanceBetween=function(e,i){return e["distanceTo"+t](i)}}n("HSV"),n("RGB"),n("CMYK")},{}],26:[function(t,e,i){var n=t("./TColor"),s=t("../internals"),r=s.each,o=[],a={};r(n.X11,function(t,e){var n=e.toUpperCase();o.push(n),a[n]=t,a[e]=t,i[n]=t}),i.getForName=function(t){return a[t]||a[t.toLowerCase()]},i.getNames=function(){return o.slice(0)}},{"../internals":98,"./TColor":20}],27:[function(t,e,i){i.AnalagousStrategy=t("./theory/AnalagousStrategy"),i.colorTheoryRegistry=t("./theory/colorTheoryRegistry"),i.ColorTheoryRegistry=i.colorTheoryRegistry,i.ComplementaryStrategy=t("./theory/ComplementaryStrategy"),i.CompoundTheoryStrategy=t("./theory/CompoundTheoryStrategy"),i.LeftSplitComplementaryStrategy=t("./theory/LeftSplitComplementaryStrategy"),i.MonochromeTheoryStrategy=t("./theory/MonochromeTheoryStrategy"),i.RightSplitComplementaryStrategy=t("./theory/RightSplitComplementaryStrategy"),i.SingleComplementStrategy=t("./theory/SingleComplementStrategy"),i.SplitComplementaryStrategy=t("./theory/SplitComplementaryStrategy"),i.TetradTheoryStrategy=t("./theory/TetradTheoryStrategy"),i.TriadTheoryStrategy=t("./theory/TriadTheoryStrategy"),i.strategies=t("./theory/strategies")},{"./theory/AnalagousStrategy":28,"./theory/ComplementaryStrategy":29,"./theory/CompoundTheoryStrategy":30,"./theory/LeftSplitComplementaryStrategy":31,"./theory/MonochromeTheoryStrategy":32,"./theory/RightSplitComplementaryStrategy":33,"./theory/SingleComplementStrategy":34,"./theory/SplitComplementaryStrategy":35,"./theory/TetradTheoryStrategy":36,"./theory/TriadTheoryStrategy":37,"./theory/colorTheoryRegistry":38,"./theory/strategies":39}],28:[function(t,e,i){var n=t("./strategies"),s=t("../../geom/vectors"),r=t("../../math/mathUtils"),o=t("../../internals"),a=t("../ColorList"),h=o.each,c=s.Vec2D,u=[new c(1,2.2),new c(2,1),new c(-1,-.5),new c(-2,1)];e.exports=n.create("Analagous",function(t,e){this.contrast="number"==typeof e?e:.25,this.theta=r.radians("number"==typeof t?t:10)},{createListFromColor:function(t){var e=this;this.contrast=r.clipNormalized(this.contrast);var i=new a(t);return h(u,function(n){var s=t.getRotatedRYB(e.theta*n.x),r=.44-.1*n.y;t.brightness()-e.contras*n.ye?t.setBrightness(.1+.25*i):t.setBrightness(1-.25*i),t};e.exports=n.create("Complementary",{createListFromColor:function(t){var e,i=new s(t);return i.add(r(t.copy(),.4)),e=t.copy(),e.lighten(.3),e.setSaturation(.1+.3*e.saturation()),i.add(e),i.add(r(t.getComplement(),.3)),i.add(t.getComplement()),e=t.getComplement(),e.lighten(.3),e.setSaturation(.1+.25*e.saturation()),i.add(e),i}})},{"../ColorList":8,"./strategies":39}],30:[function(t,e,i){var n=t("./strategies"),s=t("../ColorList"),r=n.wrap;e.exports=n.create("Compound",function(t){this._isFlipped=t===!0},{createListFromColor:function(t){var e,i=new s(t),n=this._isFlipped?-1:1;return e=t.getRotatedRYB(30*n),e.setBrightness(r(e.brightness(),.25,.6,.25)),i.add(e),e=t.getRotatedRYB(30*n),e.setSaturation(r(e.saturation(),.4,.1,.4)),e.setBrightness(r(e.brightness(),.4,.2,.4)),i.add(e),e=t.getRotatedRYB(160*n),e.setSaturation(r(e.saturation(),.25,.1,.25)),e.setBrightness(Math.max(.2,e.brightness())),i.add(e),e=t.getRotatedRYB(150*n),e.setSaturation(r(e.saturation(),.1,.8,.1)),e.setBrightness(r(e.brightness(),.3,.6,.3)),i.add(e),i},isFlipped:function(){return this._isFlipped},setFlipped:function(t){this._isFlipped=t},toString:function(){return"Compound"+(this.isFlipped()?"_flipped":"")}})},{"../ColorList":8,"./strategies":39}],31:[function(t,e,i){var n,s=t("./strategies"),r=(t("../ColorList"),t("./ComplementaryStrategy"));e.exports=s.create("LeftSplitComplementary",{createListFromColor:function(t){n=n||new r;for(var e,i=t.getComplement().rotateRYB(-30).lighten(.1),s=n.createListFromColor(t),o=3;6>o;o++)e=s.get(o),e.setHue(i.hue());return s}})},{"../ColorList":8,"./ComplementaryStrategy":29,"./strategies":39}],32:[function(t,e,i){var n=t("./strategies"),s=t("../ColorList"),r=n.wrap;e.exports=n.create("Monochrome",{createListFromColor:function(t){var e=new s(t),i=t.copy();return i.setBrightness(r(i.brightness(),.5,.2,.3)),i.setSaturation(r(i.saturation(),.3,.1,.3)),e.add(i),i=t.copy(),i.setBrightness(r(i.brightness(),.2,.2,.6)),e.add(i),i=t.copy(),i.setBrightness(Math.max(.2,i.brightness()+.2*(1-i.brightness()))),i.setSaturation(r(i.saturation(),.3,.1,.3)),e.add(i),i=t.copy(),i.setBrightness(r(i.brightness(),.5,.2,.3)),e.add(i),e}})},{"../ColorList":8,"./strategies":39}],33:[function(t,e,i){var n,s=t("./strategies"),r=(t("../ColorList"),t("./ComplementaryStrategy"));e.exports=s.create("RightSplitComplementary",{createListFromColor:function(t){n=n||new r;for(var e,i=t.getComplement().rotateRYB(30).lighten(.1),s=n.createListFromColor(t),o=3;6>o;o++)e=s.get(o),e.setHue(i.hue());return s}})},{"../ColorList":8,"./ComplementaryStrategy":29,"./strategies":39}],34:[function(t,e,i){var n=t("./strategies"),s=t("../ColorList"),r=function(){return"complement"};e.exports=n.create("SingleComplement",{createListFromColor:function(t){var e=new s(t);return e.add(t.getComplement()),e},getName:r,toString:r})},{"../ColorList":8,"./strategies":39}],35:[function(t,e,i){var n=t("./strategies"),s=t("../ColorList");e.exports=n.create("SplitComplementary",{createListFromColor:function(t){var e=new s(t);return e.add(t.getRotatedRYB(150).lighten(.1)),e.add(t.getRotatedRYB(210).lighten(.1)),e}})},{"../ColorList":8,"./strategies":39}],36:[function(t,e,i){var n=t("./strategies"),s=t("../ColorList"),r=function(){return"tetrad"},o=function(t){return t[t.brightness()<.5?"lighten":"darken"](.2)};e.exports=n.create("TetradTheory",function(t){this.theta="number"==typeof t?t:90},{createListFromColor:function(t){var e=new s(t);return e.add(o(t.getRotatedRYB(this.theta))),e.add(o(t.getRotatedRYB(2*this.theta))),e.add(t.getRotatedRYB(3*this.theta).lighten(.1)),e},getName:r,toString:r})},{"../ColorList":8,"./strategies":39}],37:[function(t,e,i){var n=t("./strategies"),s=t("../ColorList"),r=function(){return"triad"};e.exports=n.create("TriadTheory",{createListFromColor:function(t){var e=new s(t);return e.add(t.getRotatedRYB(120).lighten(.1)),e.add(t.getRotatedRYB(-120).lighten(.1)),e},getName:r,toString:toString})},{"../ColorList":8,"./strategies":39}],38:[function(t,e,i){var n=t("../../internals"),s=n.each,r=n.keys,o=n.values,a={},h={SINGLE_COMPLEMENT:t("./SingleComplementStrategy"),COMPLEMENTARY:t("./ComplementaryStrategy"),SPLIT_COMPLEMENTARY:t("./SplitComplementaryStrategy"),LEFT_SPLIT_COMPLEMENTARY:t("./LeftSplitComplementaryStrategy"),RIGHT_SPLIT_COMPLEMENTARY:t("./RightSplitComplementaryStrategy"),ANALAGOUS:t("./AnalagousStrategy"),MONOCHROME:t("./MonochromeTheoryStrategy"),TRIAD:t("./TriadTheoryStrategy"),TETRAD:t("./TetradTheoryStrategy"),COMPOUND:t("./CompoundTheoryStrategy")};i.getRegisteredNames=function(){return r(a)},i.getRegisteredStrategies=function(){return o(a)},i.getStrategyForName=function(t){return a[t]},i.registerImplementation=function(t){a[t.getName()]=t},s(h,function(t,e){i[e]=new h[e],i.registerImplementation(i[e])})},{"../../internals":98,"./AnalagousStrategy":28,"./ComplementaryStrategy":29,"./CompoundTheoryStrategy":30,"./LeftSplitComplementaryStrategy":31,"./MonochromeTheoryStrategy":32,"./RightSplitComplementaryStrategy":33,"./SingleComplementStrategy":34,"./SplitComplementaryStrategy":35,"./TetradTheoryStrategy":36,"./TriadTheoryStrategy":37}],39:[function(t,e,i){var n=t("../../internals/has"),s=t("../../internals/is"),n=n.all,r=s.TColor;i.create=function(t,e,i){2===arguments.length&&(i=e,e=function(){});var n=t.charAt(0).toLowerCase()+t.slice(1,t.length);e.prototype.constructor=e,e.prototype.getName=function(){return n},e.prototype.toString=e.prototype.getName;for(var s in i)e.prototype[s]=i[s];return function(t){e.prototype.createListFromColor=function(e){if(!r(e))throw new Error("src color was not a valid TColor");return t.call(this,e)}}(e.prototype.createListFromColor),e},i.wrap=function(t,e,i,n){return i>t-e?t+n:t-e}},{"../../internals/has":105,"../../internals/is":106}],40:[function(t,e,i){e.exports=t("./index")},{"./index":97}],41:[function(t,e,i){i.AABB=t("./geom/AABB"),i.mesh=t("./geom/mesh"),i.BernsteinPolynomial=t("./geom/BernsteinPolynomial"),i.Circle=t("./geom/Circle"),i.CircleIntersector=t("./geom/CircleIntersector"),i.Cone=t("./geom/Cone"),i.ConvexPolygonClipper=t("./geom/ConvexPolygonClipper"),i.Ellipse=t("./geom/Ellipse"),i.IsectData2D=t("./geom/IsectData2D"),i.IsectData3D=t("./geom/IsectData3D"),i.Line2D=t("./geom/Line2D"),i.Line3D=t("./geom/Line3D"),i.LineStrip3D=t("./geom/LineStrip3D"),i.Matrix4x4=t("./geom/Matrix4x4"),i.Plane=t("./geom/Plane"),i.Polygon2D=t("./geom/Polygon2D"),i.Quaternion=t("./geom/Quaternion"),i.Ray2D=t("./geom/Ray2D"),i.Ray3D=t("./geom/Ray3D"),i.Ray3DIntersector=t("./geom/Ray3DIntersector"),i.Rect=t("./geom/Rect"),i.Sphere=t("./geom/Sphere"),i.Spline2D=t("./geom/Spline2D"),i.Spline3D=t("./geom/Spline3D"),i.SutherlandHodgemanClipper=t("./geom/SutherlandHodgemanClipper"),i.Triangle2D=t("./geom/Triangle2D"),i.Triangle3D=t("./geom/Triangle3D"),i.Vec2D=t("./geom/Vec2D"),i.Vec3D=t("./geom/Vec3D"),i.XAxisCylinder=t("./geom/XAxisCylinder"),i.YAxisCylinder=t("./geom/YAxisCylinder"),i.ZAxisCylinder=t("./geom/ZAxisCylinder")},{"./geom/AABB":42,"./geom/BernsteinPolynomial":44,"./geom/Circle":45,"./geom/CircleIntersector":46,"./geom/Cone":47,"./geom/ConvexPolygonClipper":48,"./geom/Ellipse":49,"./geom/IsectData2D":50,"./geom/IsectData3D":51,"./geom/Line2D":52,"./geom/Line3D":53,"./geom/LineStrip3D":54,"./geom/Matrix4x4":55,"./geom/Plane":56,"./geom/Polygon2D":57,"./geom/Quaternion":58,"./geom/Ray2D":59,"./geom/Ray3D":60,"./geom/Ray3DIntersector":61,"./geom/Rect":62,"./geom/Sphere":63,"./geom/Spline2D":64,"./geom/Spline3D":65,"./geom/SutherlandHodgemanClipper":66,"./geom/Triangle2D":67,"./geom/Triangle3D":68,"./geom/Vec2D":70,"./geom/Vec3D":71,"./geom/XAxisCylinder":72,"./geom/YAxisCylinder":73,"./geom/ZAxisCylinder":74,"./geom/mesh":75}],42:[function(t,e,i){var n=t("../internals"),s=t("./Vec3D"),r=t("./Vec2D"),o=t("../math/mathUtils"),a=function(t,e){void 0===t?(s.call(this),this.setExtent(new s)):"number"==typeof t?(s.call(this,new s),this.setExtent(t)):n.has.XYZ(t)&&(s.call(this,t),void 0===e&&n.is.AABB(t)?this.setExtent(t.getExtent()):"number"==typeof e?this.setExtent(new s(e,e,e)):this.setExtent(e))};n.extend(a,s),a.fromMinMax=function(t,e){var i=s.min(t,e),n=s.max(t,e);return new a(i.interpolateTo(n,.5),n.sub(i).scaleSelf(.5))},a.prototype.containsPoint=function(t){return t.isInAABB(this)},a.prototype.copy=function(){return new a(this)},a.prototype.getExtent=function(){return this.extent.copy()},a.prototype.getMax=function(){return this.max.copy()},a.prototype.getMin=function(){return this.min.copy()},a.prototype.getNormalForPoint=function(t){t=t.sub(this);var e=this.extent.sub(t.getAbs()),i=t.getSignum(),n=s.X_AXIS.scale(i.x),r=e.x;return e.yl||u>c)return null;u>h&&(h=u),c>l&&(c=l),a=o?this.max:this.min;var f=(a.z-t.z)*n.z;a=o?this.min:this.max;var p=(a.z-t.z)*n.z;return h>p||f>c?null:(f>h&&(h=f),c>p&&(c=p),i>h&&c>e?t.getPointAtDistance(h):void 0)},a.prototype.intersectsSphere=function(t,e){1==arguments.length&&(e=t.radius);var i,n=0;return t.xthis.max.x&&(i=t.x-this.max.x,n+=i*i),t.ythis.max.y&&(i=t.y-this.max.y,n+=i*i),t.zthis.max.z&&(i=t.z-this.max.z,n+=i*i),e*e>=n},a.prototype.intersectsTriangle=function(t){var e,i,n,s,r,a,h,c;if(e=t.a.sub(this),i=t.b.sub(this),n=t.c.sub(this),r=i.sub(e),a=n.sub(i),h=e.sub(n),c=r.getAbs(),this.testAxis(r.z,-r.y,c.z,c.y,e.y,e.z,n.y,n.z,this.extent.y,this.extent.z))return!1;if(this.testAxis(-r.z,r.x,c.z,c.x,e.x,e.z,n.x,n.z,this.extent.x,this.extent.z))return!1;if(this.testAxis(r.y,-r.x,c.y,c.x,i.x,i.y,n.x,n.y,this.extent.x,this.extent.y))return!1;if(c=a.getAbs(),this.testAxis(a.z,-a.y,c.z,c.y,e.y,e.z,n.y,n.z,this.extent.y,this.extent.z))return!1;if(this.testAxis(-a.z,a.x,c.z,c.x,e.x,e.z,n.x,n.z,this.extent.x,this.extent.z))return!1;if(this.testAxis(a.y,-a.x,c.y,c.x,e.x,e.y,i.x,i.y,this.extent.x,this.extent.y))return!1;if(c=h.getAbs(),this.testAxis(h.z,-h.y,c.z,c.y,e.y,e.z,i.y,i.z,this.extent.y,this.extent.z))return!1;if(this.testAxis(-h.z,h.x,c.z,c.x,e.x,e.z,i.x,i.z,this.extent.x,this.extent.z))return!1;if(this.testAxis(h.y,-h.x,c.y,c.x,i.x,i.y,n.x,n.y,this.extent.x,this.extent.y))return!1;if(o.min(e.x,i.x,n.x)>this.extent.x||o.max(e.x,i.x,n.x)<-this.extent.x)return!1;if(o.min(e.y,i.y,n.y)>this.extent.y||o.max(e.y,i.y,n.y)<-this.extent.y)return!1;if(o.min(e.z,i.z,n.z)>this.extent.z||o.max(e.z,i.z,n.z)<-this.extent.z)return!1;s=r.cross(a);var u=-s.dot(e);return this.planeBoxOverlap(s,u,this.extent)?!0:!1},a.prototype.planeBoxOverlap=function(t,e,i){var n=new s,r=new s;return t.x>0?(n.x=-i.x,r.x=i.x):(n.x=i.x,r.x=-i.x),t.y>0?(n.y=-i.y,r.y=i.y):(n.y=i.y,r.y=-i.y),t.z>0?(n.z=-i.z,r.z=i.z):(n.z=i.z,r.z=-i.z),t.dot(n)+e>0?!1:t.dot(r)+e>=0?!0:!1},a.prototype.set=function(t,e,i){return n.is.AABB(t)?(this.extent.set(t.extent),s.set.apply(this,[t])):(n.has.XYZ(t)&&(e=t.y,i=t.z,t=t.a),this.x=t,this.y=e,this.z=i,this.updateBounds(),this)},a.prototype.setExtent=function(t){return this.extent=t.copy(),this.updateBounds()},a.prototype.testAxis=function(t,e,i,n,s,r,o,a,h,c){var u,l,f=t*s+e*r,p=t*o+e*a;p>f?(u=f,l=p):(u=p,l=f);var g=i*h+n*c;return u>g||-g>l},a.prototype.toMesh=function(e){if(void 0===e){var i=t("./mesh/meshCommon").TriangleMesh;e=new i("aabb",8,12)}var n=this.min,o=this.max,a=new s(n.x,n.y,o.z),h=new s(o.x,n.y,o.z),c=new s(o.x,n.y,n.z),u=new s(n.x,o.y,n.z),l=new s(n.x,o.y,o.z),f=new s(o.x,o.y,n.z),p=new r(0,0),g=new r(1,0),d=new r(1,1),m=new r(0,1);return e.addFace(n,a,l,m,d,g),e.addFace(n,l,u,m,g,p),e.addFace(a,h,o,m,d,g),e.addFace(a,o,l,m,g,p),e.addFace(h,c,f,m,d,g),e.addFace(h,f,o,m,g,p),e.addFace(c,n,u,m,d,g),e.addFace(c,u,f,m,g,p),e.addFace(u,l,f,p,m,g),e.addFace(l,o,f,m,d,g),e.addFace(n,c,a,m,d,p),e.addFace(a,c,h,p,d,g),e},a.prototype.toString=function(){return" pos: "+s.prototype.toString.call(this)+" ext: "+this.extent.toString()},a.prototype.updateBounds=function(){return void 0!==this.extent&&(this.min=this.sub(this.extent),this.max=this.add(this.extent)),this},e.exports=a},{"../internals":98,"../math/mathUtils":125,"./Vec2D":70,"./Vec3D":71,"./mesh/meshCommon":92}],43:[function(t,e,i){var n=t("./Cone"),s=function(t,e,i){this.pos=void 0===t?void 0:t.copy(),this.setRadius(e),this.setLength(i)};s.prototype={containsPoint:function(t){throw Error("AxisAlignedCylinder.containsPoint(): not implmented")},getLength:function(){return this.length},getMajorAxis:function(){throw Error("AxisAlignedCylinder.getMajorAxis(): not implemented")},getPosition:function(){return this.pos.copy()},getRadius:function(){return this.radius},setLength:function(t){this.length=t},setPosition:function(t){this.pos.set(t)},setRadius:function(t){this.radius=t,this.radiusSquared=t*t},toMesh:function(t,e,i){var s={mesh:void 0,steps:12,thetaOffset:0};if(1==arguments.length&&"object"==typeof arguments[0])for(var r in arguments[0])s[r]=arguments[0][r];else 2==arguments.length&&(s.steps=arguments[0],s.thetaOffset=arguments[1]);var o=new n(this.pos,this.getMajorAxis().getVector(),this.radius,this.radius,this.length);return o.toMesh(s.mesh,s.steps,s.thetaOffset,!0,!0)}},e.exports=s},{"./Cone":47}],44:[function(t,e,i){var n=function(t){this.resolution=t;for(var e=[],i=[],n=[],s=[],r=0,o=1/(t-1),a=0;t>a;a++){var h=1-r,c=h*h,u=r*r;e[a]=h*c,i[a]=3*r*c,n[a]=3*u*h,s[a]=r*u,r+=o}this.b0=e,this.b1=i,this.b2=n,this.b3=s};e.exports=n},{}],45:[function(t,e,i){e.exports=t("./Ellipse").Circle},{"./Ellipse":49}],46:[function(t,e,i){var n=function(t){this.circle=t,this.isec=void 0};n.prototype={getIntersectionData:function(){return this.isec},intersectsRay:function(t){this.isec.clear();var e=circle.sub(t),i=e.magSquared(),n=e.dot(t.getDirection()),s=circle.getRadius(),r=s*s-(i-n*n);return r>=0&&(this.isec.isIntersection=!0,this.isec.dist=n-Math.sqrt(r),this.isec.pos=t.getPointAtDistance(isec.dist),this.isec.normal=this.isec.pos.sub(this.circle).normalize()),this.isec.isIntersection}},e.exports=n},{}],47:[function(t,e,i){function n(t){throw Error("Missing parameter: "+t)}var s=t("../internals").extend,r=t("./Vec3D"),o=t("./mesh/TriangleMesh"),a=function(t,e,i,s,o){function a(t,e,i,n,s){r.apply(h,[t]),h.dir=e.getNormalized(),h.radiusNorth=i,h.radiusSouth=n,h.length=s}var h=this;"object"==typeof t&&1===arguments.length?a(t.pos||t.position||new r,t.dir||t.direction||n("direction"),t.rNorth||t.radiusNorth||n("radiusNorth"),t.rSouth||t.radiusSouth||n("radiusSouth"),t.len||t.length||n("length")):a(t,e,i,s,o)};s(a,r),a.prototype.toMesh=function(t){var e={mesh:void 0,steps:NaN,thetaOffset:0,topClosed:!0,bottomClosed:!0};if(1==arguments.length)if("object"==typeof arguments[0]){var i=arguments[0];e.mesh=i.mesh,e.steps=i.steps||i.resolution||i.res,e.thetaOffset=i.thetaOffset||e.thetaOffset,e.topClosed=i.topClosed||e.topClosed,e.bottomClosed=i.bottomClosed||e.bottomClosed}else e.steps=arguments[0];else 2==arguments.length?(e.steps=arguments[0],e.thetaOffset=arguments[1]):5==arguments.length&&(e.mesh=arguments[0],e.steps=arguments[1],e.thetaOffset=arguments[2],e.topClosed=arguments[3],e.bottomClosed=arguments[4]);var n=this.add(.01,.01,.01),s=n.cross(this.dir.getNormalized()).normalize(),r=this.dir.scale(.5*this.length),a=this.sub(r),h=this.add(r),c=[],u=[],l=2*Math.PI/e.steps,f=0,p=1;for(f=0;f0&&e[0]!==e[e.length-1]&&e.push(e[0]),n=h,h=e,e=n}return new s(h).removeDuplicates(.001)},getBounds:function(){return this.bounds},_getClippedPosOnEdge:function(t,e,i){return t.intersectLine(new n(e,i)).getPos()},_isKnownVertex:function(t,e){for(var i=0,n=t.length;n>i;i++)if(t[i].equalsWitTolerance(e,.001))return!0;return!1},setBounds:function(t){this.bounds=t,this.boundsCentroid=this.bounds.getCentroid()}},e.exports=r},{"./Line2D":52,"./Polygon2D":57}],49:[function(t,e,i){var n,s,r=t("../internals/extend"),o=t("../internals/has"),a=t("../internals/is"),h=t("../math/mathUtils"),c=t("./Vec2D");n=function(t,e,i,n){this.radius=new c,0===arguments.length?(c.apply(this,[0,0]),this.setRadii(1,1)):o.XY(t)?(c.apply(this,[t.x,t.y]),o.XY(e)?this.setRadii(e.x,e.y):this.setRadii(e,i)):void 0===n?void 0===i?(c.call(this,0,0),this.setRadii(t,e)):(c.call(this,t,e),this.setRadii(i,i)):(c.call(this,t,e),this.setRadii(i,n))},r(n,c),n.prototype.containsPoint=function(t){if(h.abs(t.x-this.x)>this.radius.x||h.abs(t.y-this.y)>this.radius.y)return!1;var e=this.getFoci();return t.distanceTo(e[0])+t.distanceTo(e[1])<2*h.max(this.radius.x,this.radius.y)},n.prototype.getArea=function(){return h.PI*this.radius.x*this.radius.y},n.prototype.getCircumference=function(){return Math.sqrt(.5*this.radius.magSquared())*h.TWO_PI},n.prototype.getFoci=function(){return this.radius.x>this.radius.y?[this.sub(this.focus,0),this.add(this.focus,0)]:[this.sub(0,this.focus),this.add(0,this.focus)]},n.prototype.getRadii=function(){return this.radius.copy()},n.prototype.setRadii=function(t,e){return o.XY(t)&&(e=t.y,t=t.x),this.radius.set(t,e),this.radius.x>this.radius.y?this.focus=Math.sqrt(this.radius.x*this.radius.x-this.radius.y*this.radius.y):this.focus=Math.sqrt(this.radius.y*this.radius.y-this.radius.x*this.radius.x),this},n.prototype.toPolygon2D=function(e){for(var i=t("./Polygon2D"),n=new i,s=h.TWO_PI/e,r=0;e>r;r++){var o=c.fromTheta(r*s).scaleSelf(this.radius).addSelf(this);n.add(o)}return n},i=e.exports=n,s=function(t,e,i){1==arguments.length?a.Circle(t)?n.apply(this,[t,t.radius.x]):n.apply(this,[0,0,t]):2==arguments.length?n.apply(this,[t,e]):n.apply(this,[t,e,i,i])},r(s,n),s.from2Points=function(t,e){var i=t.interpolateTo(e,.5),n=i.distanceTo(t);return new s(i,n)},s.from3Points=function(t,e,i){var n,r,o,a=e.sub(t),u=i.sub(e);if(h.abs(a.x)<=1e-7&&h.abs(u.y)<=1e-7)r=new c(e.x+i.x,t.y+e.y).scaleSelf(.5),o=r.distanceTo(t),n=new s(r,o);else{var l=a.y/a.x,f=u.y/u.x;if(h.abs(l-f)>1e-7&&0!==l){var p=(l*f*(t.y-i.y)+f*(t.x+e.x)-l*(e.x+i.x))/(2*(f-l)),g=-(p-(t.x+e.x)/2)/l+(t.y+e.y)/2;r=new c(p,g),o=r.distanceTo(t),n=new s(r,o)}}return n},s.newBoundingCircle=function(t){for(var e=new c,i=0,n=0,r=t.length;r>n;n++)e.addSelf(t[n]);for(e.scaleSelf(1/t.length),n=0;r>n;n++){var o=e.distanceToSquared(t[n]);o>i&&(i=o)}return new s(e,Math.sqrt(i))},s.prototype.containsPoint=function(t){return this.distanceToSquared(t)<=this.radius.x*this.radius.x},s.prototype.getCircumference=function(){return h.TWO_PI*this.radius.x},s.prototype.getRadius=function(){return this.radius.x},s.prototype.getTangentPoints=function(t){var e=this.interpolateTo(t,.5);return this.intersectsCircle(new s(e,e.distanceTo(t)))},s.prototype.intersectsCircle=function(t){var e,i=t.sub(this),n=i.magnitude(),s=this.radius.x,r=t.radius.x;if(s+r>=n&&n>=Math.abs(s-r)){var o=(s*s-r*r+n*n)/(2*n);n=1/n;var a=this.add(i.scale(o*n)),h=Math.sqrt(s*s-o*o);i.perpendicular().scaleSelf(h*n);var c=a.add(i),u=a.sub(i);e=[c,u]}return e},s.prototype.setRadius=function(t){return this.setRadii(t,t),this},i.Circle=s},{"../internals/extend":103,"../internals/has":105,"../internals/is":106,"../math/mathUtils":125,"./Polygon2D":57,"./Vec2D":70}],50:[function(t,e,i){var n=t("./Vec2D"),s=function(t){void 0!==t?(this.isIntersection=t.isIntersection,this.dist=t.dist,this.pos=t.pos.copy(),this.dir=t.dir.copy(),this.normal=t.normal.copy()):this.clear()};s.prototype={clear:function(){this.isIntersection=!1,this.dist=0,this.pos=new n,this.dir=new n,this.normal=new n},toString:function(){var t="isec: "+this.isIntersection;return this.isIntersection&&(t+=" at:"+this.pos+" dist:"+this.dist+" normal:"+this.normal),t}},e.exports=s},{"./Vec2D":70}],51:[function(t,e,i){var n=t("./Vec3D"),s=function(t){void 0!==t?(this.isIntersection=t.isIntersection,this.dist=t.dist,this.pos=t.pos.copy(),this.dir=t.dir.copy(),this.normal=t.normal.copy()):this.clear()};s.prototype={clear:function(){this.isIntersection=!1,this.dist=0,this.pos=new n,this.dir=new n,this.normal=new n},toString:function(){var t="isec: "+this.isIntersection;return this.isIntersection&&(t+=" at:"+this.pos+" dist:"+this.dist+" normal:"+this.normal),t}},e.exports=s},{"./Vec3D":71}],52:[function(t,e,i){var n=(t("./Ray2D"),t("../internals")),s=t("../math/mathUtils"),r=function(t,e){this.a=t,this.b=e};r.prototype={constructor:r,classifyPoint:function(t){var e=this.b.sub(this.a).perpendicular(),i=t.sub(this.a).dot(e);return s.sign(i)},closestPointTo:function(t){var e=this.b.sub(this.a),i=t.sub(this.a).dot(e)/e.magSquared();return 0>i?this.a.copy():i>1?this.b.copy():this.a.add(e.scaleSelf(i))},copy:function(){return new r(this.a.copy(),this.b.copy())},distanceToPoint:function(t){return this.closestPointTo(t).distanceTo(t)},distanceToPointSquared:function(t){return this.closestPointTo(t).distanceToSquared(t)},equals:function(t){if(this==t)return!0;if(!n.is.Line2D(t))return!1;var e=t;return(this.a.equals(e.a)||this.a.equals(e.b))&&(this.b.equals(e.b)||this.b.equals(e.a))},getDirection:function(){return this.b.sub(this.a).normalize()},getHeading:function(){return this.b.sub(this.a).heading()},getLength:function(){return this.a.distanceTo(this.b)},getLengthSquared:function(){return this.a.distanceToSquared(this.b)},getMidPoint:function(){return this.a.add(this.b).scaleSelf(.5)},getNormal:function(){return this.b.sub(this.a).perpendicular()},getTheta:function(){return this.a.angleBetween(this.b,!0)},hasEndPoint:function(t){return this.a.equals(t)||this.b.equals(t)},intersectLine:function(t){var e,i=r.LineIntersection.Type,n=(t.b.y-t.a.y)*(this.b.x-this.a.x)-(t.b.x-t.a.x)*(this.b.y-this.a.y),s=(t.b.x-t.a.x)*(this.a.y-t.a.y)-(t.b.y-t.a.y)*(this.a.x-t.a.x),o=(this.b.x-this.a.x)*(this.a.y-t.a.y)-(this.b.y-this.a.y)*(this.a.x-t.a.x); if(0!==n){var a=s/n,h=o/n,c=this.a.interpolateTo(this.b,a);e=a>=0&&1>=a&&h>=0&&1>=h?new r.LineIntersection(i.INTERSECTING,c,a,h):new r.LineIntersection(i.NON_INTERSECTING,c,a,h)}else e=0===s&&0===o?0===this.distanceToPoint(t.a)?new r.LineIntersection(i.COINCIDENT,void 0):new r.LineIntersection(i.COINCIDENT_NO_INTERSECT,void 0):new r.LineIntersection(i.PARALLEL,void 0);return e},offsetAndGrowBy:function(t,e,i){var n=this.getMidPoint(),s=this.getDirection(),r=s.getPerpendicular();return void 0!==i&&n.sub(i).dot(r)<0&&r.invert(),r.normalizeTo(t),this.a.addSelf(r),this.b.addSelf(r),s.scaleSelf(e),this.a.subSelf(s),this.b.addSelf(s),this},scale:function(t){var e=.5*(1-t),i=this.a.interpolateTo(this.b,e);return this.b.interpolateToSelf(this.a,e),this.a.set(i),this},set:function(t,e){return this.a=t,this.b=e,this},splitIntoSegments:function(t,e,i){return r.splitIntoSegments(this.a,this.b,e,t,i)},toRay2D:function(){var e=t("./Ray2D");return new e(this.a.copy(),this.b.sub(this.a).normalize())}},r.splitIntoSegments=function(t,e,i,n,s){void 0===n&&(n=[]),s&&n.push(t.copy());var r=t.distanceTo(e);if(r>i)for(var o=t.copy(),a=e.sub(t).limit(i);r>i;)o.addSelf(a),n.push(o.copy()),r-=i;return n.push(e.copy()),n},r.LineIntersection=function(t,e,i,n){this.type=t,this.pos=e,this.coeff=[i,n]},r.LineIntersection.prototype={getPos:function(){return this.pos?this.pos.copy():void 0},getCoefficients:function(){return this.coeff},getType:function(){return this.type},toString:function(){return"type: "+this.type+" pos: "+this.pos}},r.LineIntersection.Type={COINCIDENT:0,COINCIDENT_NO_INTERSECT:4,PARALLEL:1,NON_INTERSECTING:2,INTERSECTING:3},e.exports=r},{"../internals":98,"../math/mathUtils":125,"./Ray2D":59}],53:[function(t,e,i){var n=t("../math/mathUtils"),s=t("./Ray3D"),r=function(t,e){this.a=t,this.b=e};r.prototype={constructor:r,closestLineTo:function(t){var e=t.a.sub(t.b);if(e.isZeroVector())return new r.LineIntersection(r.LineIntersection.Type.NON_INTERSECTING);var i=this.b.sub(this.a);if(i.isZeroVector())return new r.LineIntersection(r.LineIntersection.Type.NON_INTERSECTING);var s=this.a.sub(t.a),o=s.x*e.x+s.y*e.y+s.z*e.z,a=e.x*i.x+e.y*i.y+e.z*i.z,h=s.x*i.x+s.y*i.y+s.z*i.z,c=e.x*e.x+e.y*e.y+e.z*e.z,u=i.x*i.x+i.y*i.y+i.z*i.z,l=u*c-a*a;if(Math.abs(l)i?this.a.copy():i>1?this.b.copy():this.a.add(e.scaleSelf(i))},copy:function(){return new r(this.a.copy(),this.b.copy())},equals:function(t){return this==t?!0:typeof t!=r?!1:(this.a.equals(t.a)||this.a.equals(l.b))&&(this.b.equals(l.b)||this.b.equals(l.a))},getDirection:function(){return this.b.sub(this.a).normalize()},getLength:function(){return this.a.distanceTo(this.b)},getLengthSquared:function(){return this.a.distanceToSquared(this.b)},getMidPoint:function(){return this.a.add(this.b).scaleSelf(.5)},getNormal:function(){return this.b.cross(this.a)},hasEndPoint:function(t){return this.a.equals(t)||this.b.equals(t)},offsetAndGrowBy:function(t,e,i){var n=this.getMidPoint(),s=this.getDirection(),r=this.a.cross(s).normalize();return void 0!==i&&n.sub(i).dot(r)<0&&r.invert(),r.normalizeTo(t),this.a.addSelf(r),this.b.addSelf(r),s.scaleSelf(e),this.a.subSelf(s),this.b.addSelf(s),this},set:function(t,e){return this.a=t,this.b=e,this},splitIntoSegments:function(t,e,i){return r.splitIntoSegments(this.a,this.b,e,t,i)},toRay3D:function(){return new s(this.a.copy(),this.getDirection())},toString:function(){return this.a.toString()+" -> "+this.b.toString()}},r.splitIntoSegments=function(t,e,i,n,s){void 0===n&&(n=[]),s&&n.push(t.copy());var r=t.distanceTo(e);if(r>i)for(var o=t.copy(),a=e.sub(t).limit(i);r>i;)o.addSelf(a),n.push(o.copy()),r-=i;return n.push(e.copy()),n},r.LineIntersection=function(t,e,i,n){this.type=t,void 0===i&&(i=0),void 0===n&&(n=0),this.line=e,this.coeff=[i,n]},r.LineIntersection.prototype={getCoefficient:function(){return this.coeff},getLength:function(){return void 0!==this.line?this.line.getLength():void 0},getLine:function(){return void 0!==this.line?this.line.copy():void 0},getType:function(){return this.type},isIntersectionInside:function(){return this.type==r.LineIntersection.Type.INTERSECTING&&this.coeff[0]>=0&&this.coeff[0]<=1&&this.coeff[1]>=0&&this.coeff[1]<=1},toString:function(){return"type: "+this.type+" line: "+this.line}},r.LineIntersection.Type={NON_INTERSECTING:0,INTERSECTING:1},e.exports=r},{"../math/mathUtils":125,"./Ray3D":60}],54:[function(t,e,i){var n=t("./vectors").Vec3D,s=t("./Line3D"),r=t("../internals/has").XYZ,o=t("../internals/Iterator"),a=function(t){this.vertices=t||[]};a.prototype={constructor:a,add:function(t,e,i){return r(t)?this.vertices.push(new n(t)):this.vertices.push(new n(t,e,i)),this},get:function(t){return 0>t&&(t+=this.vertices.length),this.vertices[t]},getDecimatedVertices:function(t,e){e!==!1&&(e=!0);var i=[];if(this.vertices.length<3){if(2!==this.vertices.length)return;new s(this.vertices[0],this.vertices[1]).splitIntoSegments(i,t,!0),e||i.pop()}var n,r,o,a,h,c,u=this.getEstimatedArcLength(),l=t/u,f=0;for(r=0;1>r;r+=l){for(n=r*u;n>=this.arcLenIndex[f];)f++;o=this.get(f-1),a=this.get(f),h=(n-this.arcLenIndex[f-1])/(this.arcLenIndex[f]-this.arcLenIndex[f-1]),c=o.interpolateTo(a,h),i.push(c)}return e&&i.push(this.get(-1).copy()),i},getEstimatedArcLength:function(){(void 0===this.arcLenIndex||this.arcLenIndex.length!==this.vertices.length)&&(this.arcLenIndex=[0]);for(var t,e,i=0,n=1,s=this.vertices.length;s>n;n++)t=this.vertices[n-1],e=this.vertices[n],i+=t.distanceTo(e),this.arcLenIndex[n]=i;return i},getSegments:function(){for(var t=1,e=this.vertices.length,i=[];e>t;t++)i.push(new s(this.get(t-1),this.get(t)));return i},getVertices:function(){return vertices},iterator:function(){return new o(this.vertices)},setVertices:function(t){this.vertices=t}},e.exports=a},{"../internals/Iterator":99,"../internals/has":105,"./Line3D":53,"./vectors":96}],55:[function(t,e,i){var n=t("../math/mathUtils"),s=t("../internals"),r=t("./Vec3D"),o=function(t,e,i,n,r,o,a,h,c,u,l,f,p,g,d,m){this.temp=[],this.matrix=[];var y=this;if(0===arguments.length)this.matrix[0]=[1,0,0,0],this.matrix[1]=[0,1,0,0],this.matrix[2]=[0,0,1,0],this.matrix[3]=[0,0,0,1];else if("number"==typeof t){var x=[t,e,i,n],v=[r,o,a,h],b=[c,u,l,f],w=[p,g,d,m];this.matrix=[x,v,b,w]}else if(s.is.Array(t)){var S=t;if(9!=S.length&&16!=S.length)throw new Error("Matrix4x4: Array length must == 9 or 16");16==S.length?(this.matrix=[],this.matrix[0]=S.slice(0,4),this.matrix[1]=S.slice(4,8),this.matrix[2]=S.slice(8,12),this.matrix[3]=S.slice(12)):(this.matrix[0]=S.slice(0,3),this.matrix[0][3]=NaN,this.matrix[1]=S.slice(3,6),this.matrix[1][3]=NaN,this.matrix[2]=S.slice(6,9),this.matrix[2][3]=NaN,this.matrix[3]=[NaN,NaN,NaN,NaN])}else if(s.is.Matrix4x4(t)){var C,A,T=t,M=0,z=0;if(16==T.matrix.length)for(M=0;4>M;M++)this.matrix[M]=[T.matrix[M][0],T.matrix[M][1],T.matrix[M][2],T.matrix[M][3]];else if(4==T.matrix.length)for(C=T.matrix.length,M=0;C>M;M++)for(A=T.matrix[M].length,y.matrix[M]=[],z=0;A>z;z++)y.matrix[M][z]=T.matrix[M][z]}else console.error("Matrix4x4: incorrect parameters used to construct new instance")};o.prototype={add:function(t){var e=new o(this);return e.addSelf(t)},addSelf:function(t){for(var e=0;4>e;e++){var i=this.matrix[e],n=t.matrix[e];i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],i[3]+=n[3]}return this},applyTo:function(t){return this.applyToSelf(new r(t))},applyToSelf:function(t){for(var e=0;4>e;e++){var i=this.matrix[e];this.temp[e]=t.x*i[0]+t.y*i[1]+t.z*i[2]+i[3]}return t.set(this.temp[0],this.temp[1],this.temp[2]).scaleSelf(1/this.temp[3]),t},copy:function(){return new o(this)},getInverted:function(){return new o(this).invert()},getRotatedAroundAxis:function(t,e){return new o(this).rotateAroundAxis(t,e)},getRotatedX:function(t){return new o(this).rotateX(t)},getRotatedY:function(t){return new o(this).rotateY(t)},getRotatedZ:function(t){return new o(this).rotateZ(t)},getTransposed:function(){return new o(this).transpose()},identity:function(){var t=this.matrix[0];return t[1]=t[2]=t[3]=0,t=this.matrix[1],t[0]=t[2]=t[3]=0,t=this.matrix[2],t[0]=t[1]=t[3]=0,t=this.matrix[3],t[0]=t[1]=t[2]=0,this.matrix[0][0]=1,this.matrix[1][1]=1,this.matrix[2][2]=1,this.matrix[3][3]=1,this},invert:function(){var t=[],e=[],i=[],n=this.toArray(),s=0;for(s=0;4>s;s++){var r=s<<2;e[s]=n[r],e[s+4]=n[r+1],e[s+8]=n[r+2],e[s+12]=n[r+3]}t[0]=e[10]*e[15],t[1]=e[11]*e[14],t[2]=e[9]*e[15],t[3]=e[11]*e[13],t[4]=e[9]*e[14],t[5]=e[10]*e[13],t[6]=e[8]*e[15],t[7]=e[11]*e[12],t[8]=e[8]*e[14],t[9]=e[10]*e[12],t[10]=e[8]*e[13],t[11]=e[9]*e[12];var o=e[0],a=e[1],h=e[2],c=e[3],u=e[4],l=e[5],f=e[6],p=e[7];i[0]=t[0]*l+t[3]*f+t[4]*p,i[0]-=t[1]*l+t[2]*f+t[5]*p,i[1]=t[1]*u+t[6]*f+t[9]*p,i[1]-=t[0]*u+t[7]*f+t[8]*p,i[2]=t[2]*u+t[7]*l+t[10]*p,i[2]-=t[3]*u+t[6]*l+t[11]*p,i[3]=t[5]*u+t[8]*l+t[11]*f,i[3]-=t[4]*u+t[9]*l+t[10]*f,i[4]=t[1]*a+t[2]*h+t[5]*c,i[4]-=t[0]*a+t[3]*h+t[4]*c,i[5]=t[0]*o+t[7]*h+t[8]*c,i[5]-=t[1]*o+t[6]*h+t[9]*c,i[6]=t[3]*o+t[6]*a+t[11]*c,i[6]-=t[2]*o+t[7]*a+t[10]*c,i[7]=t[4]*o+t[9]*a+t[10]*h,i[7]-=t[5]*o+t[8]*a+t[11]*h,t[0]=h*p,t[1]=c*f,t[2]=a*p,t[3]=c*l,t[4]=a*f,t[5]=h*l,t[6]=o*p,t[7]=c*u,t[8]=o*f,t[9]=h*u,t[10]=o*l,t[11]=a*u,o=e[8],a=e[9],h=e[10],c=e[11],u=e[12],l=e[13],f=e[14],p=e[15],i[8]=t[0]*l+t[3]*f+t[4]*p,i[8]-=t[1]*l+t[2]*f+t[5]*p,i[9]=t[1]*u+t[6]*f+t[9]*p,i[9]-=t[0]*u+t[7]*f+t[8]*p,i[10]=t[2]*u+t[7]*l+t[10]*p,i[10]-=t[3]*u+t[6]*l+t[11]*p,i[11]=t[5]*u+t[8]*l+t[11]*f,i[11]-=t[4]*u+t[9]*l+t[10]*f,i[12]=t[2]*h+t[5]*c+t[1]*a,i[12]-=t[4]*c+t[0]*a+t[3]*h,i[13]=t[8]*c+t[0]*o+t[7]*h,i[13]-=t[6]*h+t[9]*c+t[1]*o,i[14]=t[6]*a+t[11]*c+t[3]*o,i[14]-=t[10]*c+t[2]*o+t[7]*a,i[15]=t[10]*h+t[4]*o+t[9]*a,i[15]-=t[8]*a+t[11]*h+t[5]*o;var g=1/(e[0]*i[0]+e[1]*i[1]+e[2]*i[2]+e[3]*i[3]);for(s=0,k=0;4>s;s++)for(var d=this.matrix[s],m=0;4>m;m++)d[m]=i[k++]*g;return this},multiply:function(t){return"number"==typeof t?new o(this).multiply(t):new o(this).multiplySelf(t)},multiplySelf:function(t){var e,i=0;if("number"==typeof t){for(i=0;4>i;i++)e=this.matrix[i],e[0]*=t,e[1]*=t,e[2]*=t,e[3]*=t;return this}var n=t.matrix[0],s=t.matrix[1],r=t.matrix[2],o=t.matrix[3];for(i=0;4>i;i++){e=this.matrix[i];for(var a=0;4>a;a++)this.temp[a]=e[0]*n[a]+e[1]*s[a]+e[2]*r[a]+e[3]*o[a];e[0]=this.temp[0],e[1]=this.temp[1],e[2]=this.temp[2],e[3]=this.temp[3]}return this},rotateAroundAxis:function(t,e){var i,n,s,r,o,h,c,u;return i=t.x,n=t.y,s=t.z,r=Math.sin(e),o=Math.cos(e),h=1-o,c=h*i,u=h*n,a.set(c*i+o,c*n+r*s,c*s-r*n,0,c*n-r*s,u*n+o,u*s+r*i,0,c*s+r*n,u*s-r*i,h*s*s+o,0,0,0,0,1),this.multiplySelf(a)},rotateX:function(t){return a.identity(),a.matrix[1][1]=a.matrix[2][2]=Math.cos(t),a.matrix[2][1]=Math.sin(t),a.matrix[1][2]=-a.matrix[2][1],this.multiplySelf(a)},rotateY:function(t){return a.identity(),a.matrix[0][0]=a.matrix[2][2]=Math.cos(t),a.matrix[0][2]=Math.sin(t),a.matrix[2][0]=-a.matrix[0][2],this.multiplySelf(a)},rotateZ:function(t){return a.identity(),a.matrix[0][0]=a.matrix[1][1]=Math.cos(t),a.matrix[1][0]=Math.sin(t),a.matrix[0][1]=-a.matrix[1][0],this.multiplySelf(a)},scale:function(t,e,i){return new o(this).scaleSelf(t,e,i)},scaleSelf:function(t,e,i){return s.has.XYZ(t)?(e=t.y,i=t.z,t=t.x):(void 0===e||void 0===i)&&(e=t,i=t),a.identity(),a.matrix[0][0]=t,a.matrix[1][1]=e,a.matrix[2][2]=i,this.multiplySelf(a)},set:function(t,e,i,n,s,r,o,a,h,c,u,l,f,p,g,d){var m;if("number"==typeof t)m=this.matrix[0],m[0]=t,m[1]=e,m[2]=i,m[3]=n,m=this.matrix[1],m[0]=s,m[1]=r,m[2]=o,m[3]=a,m=this.matrix[2],m[0]=h,m[1]=c,m[2]=u,m[3]=l,m=this.matrix[3],m[0]=f,m[1]=p,m[2]=g,m[3]=d;else for(var y=0;4>y;y++){m=this.matrix[y];var x=m.matrix[y];m[0]=x[0],m[1]=x[1],m[2]=x[2],m[3]=x[3]}return this},setFrustrum:function(t,e,i,n,s,r){var o=e-t,a=i-n,h=r-s;return this.set(2*s/o,0,(t+e)/o,0,0,2*s/a,(i+n)/a,0,0,0,-(s+r)/h,-2*s*r/h,0,0,-1,0)},setOrtho:function(t,e,i,n,s,r){var o=[2/(e-t),0,0,(t+e)/(e-t),0,2/(i-n),0,(i+n)/(i-n),0,0,-2/(r-s),(r+s)/(r-s),0,0,0,1];return this.set.apply(this,o)},setPerspective:function(t,e,i,s){var r=i*Math.tan(.5*n.radians(t)),o=e*r;return this.setFrustrum(-o,o,r,-r,i,s)},setPosition:function(t,e,i){return this.matrix[0][3]=t,this.matrix[1][3]=e,this.matrix[2][3]=i,this},setScale:function(t,e,i){return this.matrix[0][0]=t,this.matrix[1][1]=e,this.matrix[2][2]=i,this},sub:function(t){return new o(this).subSelf(t)},subSelf:function(t){for(var e=0;4>e;e++){var i=this.matrix[e],n=t.matrix[e];i[0]-=n[0],i[1]-=n[1],i[2]-=n[2],i[3]-=n[3]}return this},toArray:function(t){void 0===t&&(t=[]);for(var e=0,i=0;4>e;e++)for(var n=this.matrix[e],s=0;4>s;s++)t[i++]=n[s];return t},toFloatArray:function(t){return new Float32Array(this.toArray(t))},toString:function(){return"| "+this.matrix[0][0]+" "+this.matrix[0][1]+" "+this.matrix[0][2]+" "+this.matrix[0][3]+" |\n| "+this.matrix[1][0]+" "+this.matrix[1][1]+" "+this.matrix[1][2]+" "+this.matrix[1][3]+" |\n| "+this.matrix[2][0]+" "+this.matrix[2][1]+" "+this.matrix[2][2]+" "+this.matrix[2][3]+" |\n| "+this.matrix[3][0]+" "+this.matrix[3][1]+" "+this.matrix[3][2]+" "+this.matrix[3][3]+" |"},toTransposedFloatArray:function(t){void 0===t&&(t=[]);for(var e=0,i=0;4>e;e++)for(var n=0;4>n;n++)t[i++]=this.matrix[n][e];return t},translate:function(t,e,i){return new o(this).translateSelf(t,e,i)},translateSelf:function(t,e,i){return s.has.XYZ(t)&&(e=t.y,i=t.z,t=t.x),a.identity(),a.setPosition(t,e,i),this.multiplySelf(a)},transpose:function(){return this.set(this.matrix[0][0],this.matrix[1][0],this.matrix[2][0],this.matrix[3][0],this.matrix[0][1],this.matrix[1][1],this.matrix[2][1],this.matrix[3][1],this.matrix[0][2],this.matrix[1][2],this.matrix[2][2],this.matrix[3][2],this.matrix[0][3],this.matrix[1][3],this.matrix[2][3],this.matrix[3][3])}};var a=new o;e.exports=o},{"../internals":98,"../math/mathUtils":125,"./Vec3D":71}],56:[function(t,e,i){var n=t("../internals").extend,s=t("../math/mathUtils"),r=t("./Ray3D"),o=t("./vectors"),a=o.Vec3D,h=(o.Vec2D,t("./mesh/TriangleMesh")),c=function(t,e){var i,n;0===arguments.length?(i=new a,n=a.Y_AXIS.copy()):1==arguments.length?(i=arguments[0].computeCentroid(),n=arguments[0].computeNormal()):(i=arguments[0],n=arguments[1].getNormalized()),a.apply(this,[i]),this.normal=n};n(c,a),c.Classifier={FRONT:"front",BACK:"back",ON_PLANE:"on plane"},c.XY=new c(new a,a.Z_AXIS),c.XZ=new c(new a,a.Y_AXIS),c.YZ=new c(new a,a.X_AXIS),c.prototype.classifyPoint=function(t,e){var i=this.sub(t).normalize().dot(this.normal);return-e>i?c.Classifier.FRONT:i>e?c.Classifier.BACK:c.Classifier.ON_PLANE},c.prototype.containsPoint=function(t){return this.classifyPoint(t,s.EPS)==c.Classifier.ON_PLANE},c.prototype.getDistanceToPoint=function(t){var e=this.normal.dot(t.sub(this)),i=this.normal.magSquared(),n=t.add(this.normal.scale(e/i));return n.distanceTo(t)},c.prototype.getIntersectionWithRay=function(t){var e,i=this.normal.dot(t.getDirection());return i>s.EPS?(e=this.normal.dot(this.sub(t))/i,t.getPointAtDistance(e)):void 0},c.prototype.getProjectedPoint=function(t){var e,i;return e=this.normal.dot(this.sub(t))<0?this.normal.getInverted():this.normal,i=new r(t,e).getPointAtDistance(this.getDistanceToPoint(t))},c.prototype.intersectRayDistance=function(t){var e=this.normal.dot(this),i=this.normal.dot(t)+e,n=this.normal.dot(t.dir);return s.abs(n)1)for(t=0,e=arguments.length;e>t;t++)this.add(arguments[t].copy());else if(1==arguments.length){var i=arguments[0];if(h.Array(i))for(t=0,e=i.length;e>t;t++)this.add(i[t].copy())}};c.prototype={constructor:c,add:function(t){if(h.Array(t))for(var e=0,i=t.length;i>e;e++)this.vertices.indexOf(t[e])<0&&this.vertices.push(t[e]);else this.vertices.indexOf(t)<0&&this.vertices.push(t)},center:function(t){for(var e=this.getCentroid(),i=void 0!==t?t.sub(e):e.invert(),n=0,s=this.vertices.length;s>n;n++)this.vertices[n].addSelf(i);return this},containsPoint:function(t){var e=this.vertices.length,i=0,n=e-1,s=!1,r=t.x,o=t.y;for(i=0;e>i;i++){var a=this.vertices[i],h=this.vertices[n];(a.y=o||h.y=o)&&a.x+(o-a.y)/(h.y-a.y)*(h.x-a.x)e;e++)if(!this.containsPoint(t.vertices[e]))return!1;return!0},copy:function(){return new c(this.vertices)},flipVertexOrder:function(){return this.vertices.reverse(),this},get:function(t){return 0>t&&(t+=this.vertices.length),this.vertices[t]},getApothem:function(){return this.vertices[0].interpolateTo(this.vertices[1],.5).distanceTo(this.getCentroid())},getArea:function(){for(var t=0,e=this.vertices.length,i=0;e>i;i++){var n=this.vertices[i],s=this.vertices[(i+1)%e];t+=n.x*s.y,t-=n.y*s.x}return t*=.5},getBoundingCircle:function(){var e=t("./Circle");return e.newBoundingCircle(this.vertices)},getBounds:function(){var e=t("./Rect");return e.getBoundingRect(this.vertices)},getCentroid:function(){for(var t=new s,e=this.vertices.length,i=0;e>i;i++){var n=this.vertices[i],r=this.vertices[(i+1)%e],o=n.x*r.y-r.x*n.y;t.x+=(n.x+r.x)*o,t.y+=(n.y+r.y)*o}return t.scale(1/(6*this.getArea()))},getCircumference:function(){for(var t=0,e=0,i=this.vertices.length;i>e;e++)t+=this.vertices[e].distanceTo(this.vertices[(e+1)%i]);return t},getClosestPointTo:function(t){for(var e,i,n,s=Number.MAX_VALUE,r=this.getEdges(),o=0,a=r.length;a>o;o++)i=r[o].closestPointTo(t),n=i.distanceToSquared(t),s>n&&(e=i,s=n);return e},getClosestVertexTo:function(t){for(var e,i,n=Number.MAX_VALUE,s=0,r=this.vertices.length;r>s;s++)i=this.vertices[s].distanceToSquared(t),n>i&&(e=this.vertices[s],n=i);return e},getEdges:function(){for(var t=this.vertices.length,e=[],i=0;t>i;i++)e[i]=new r(this.vertices[i],this.vertices[(i+1)%t]);return e},getNumPoints:function(){return this.getNumVertices()},getNumVertices:function(){return this.vertices.length},getRandomPoint:function(){for(var t,e=this.getEdges(),i=e.length,s=e[n.random(i)];void 0===t||t.equals(s);)t=e[n.random(i)];var r=s.a.interpolateTo(s.b,Math.random());return r.interpolateToSelf(t.a.interpolateTo(t.b,Math.random()),Math.random())},increaseVertexCount:function(t){for(var e,i,n=this.vertices.length,s=0,r=0,o=0;t>n;){for(s=0,r=0,o=0;n>o;o++)e=this.vertices[o].distanceToSquared(this.vertices[(o+1)%n]),e>r&&(s=o,r=e);i=this.vertices[s].add(this.vertices[(s+1)%n]).scaleSelf(.5),this.vertices.splice(s+1,0,i),n++}return this},intersectsPolygon:function(t){if(this.containsPolygon(t))return!0;for(var e=this.getEdges(),i=t.getEdges(),n=0,s=e.length;s>n;n++)for(var o=0,a=i.length,h=e[n];a>o;o++)if(h.intersectLine(i[o]).getType()==r.LineIntersection.Type.INTERSECTING)return!0;return!1},isClockwise:function(){return this.getArea()>0},isConvex:function(){for(var t,e,i,n,s,r=!1,o=this.vertices.length,a=0;o>a;a++)if(t=0===a?o-1:a-1,e=a===o-1?0:a+1,i=this.vertices[a].sub(this.vertices[t]),n=this.vertices[e].sub(this.vertices[a]),s=i.cross(n)>0,0===a)r=!0;else if(r!=s)return!1;return!0},_offsetCorner:function(t,e,i,o,a,h,c,u){var l,f,p,g,d,m,y,x,v=i,b=o,w=i,S=o;if(l=i-t,f=o-e,p=Math.sqrt(l*l+f*f),g=a-i,d=h-o,m=Math.sqrt(g*g+d*d),!(p1){for(var n,s,r=e[0].x,o=e[0].y,a=e[i].x,h=e[i].y,c=r,u=o,l=0;i>l;l++)n=a,s=h,a=c,h=u,c=e[l+1].x,u=e[l+1].y,this._offsetCorner(n,s,a,h,c,u,t,e[l]);this._offsetCorner(a,h,c,u,r,o,t,e[i])}return this},reduceVertices:function(t){t*=t;var e,i=this.vertices,n=[],s=i[0],r=i.length-1;n.push(s);for(var o=0;r>o;o++)e=i[o],s.distanceToSquared(e)>=t&&(n.push(e),s=e);return i[0].distanceToSquared(i[r])>=t&&n.push(i[r]),this.vertices=n,this},removeDuplicates:function(t){for(var e,i,n,s=t?"equalsWithTolerance":"equals",r=0,o=this.vertices.length;o>r;r++)e=this.vertices[r],e[s](i,t)?(this.vertices.splice(r,1),r--,o--):i=e;return o=this.vertices.length,o>0&&(n=this.vertices[o-1],n[s](this.vertices[0],t)&&this.vertices.splice(o-1,1)),this},rotate:function(t){for(var e=0,i=this.vertices.length;i>e;e++)this.vertices[e].rotate(t);return this},scale:function(t,e){if(1==arguments.length){var i=arguments[0];a.XY(i)?(t=i.x,e=i.y):(t=i,e=i)}else{if(2!=arguments.length)throw"Invalid argument(s) passed.";t=arguments[0],e=arguments[1]}for(var n=0,s=this.vertices.length;s>n;n++)this.vertices[n].scaleSelf(t,e);return this},scaleSize:function(t,e){var i;if(1===arguments.length){var n=arguments[0];a.XY(n)?(t=n.x,e=n.y):(t=n,e=n)}else{if(2!==arguments.length)throw new Error("Invalid argument(s) passed.");t=arguments[0],e=arguments[1]}i=this.getCentroid();for(var s=0,r=this.vertices.length;r>s;s++){var o=this.vertices[s];o.subSelf(i).scaleSelf(t,e).addSelf(i)}return this},smooth:function(t,e){for(var i=this.getCentroid(),n=this.vertices.length,s=[],r=0,o=n-1,a=1;n>r;r++){var h=this.vertices[r],c=this.vertices[o].sub(h).addSelf(this.vertices[a].sub(h)).addSelf(h.sub(i).scaleSelf(e));s.push(h.add(c.scaleSelf(t))),o++,o==n&&(o=0),a++,a==n&&(a=0)}return this.vertices=s,this},toMesh:function(t,e,i){t=t||new o;var n=this.vertices.length;e=e||this.getCentroid();var r=e.to3DXY();r.z=i;for(var a,h,c,u,l=this.getBounds(),f=new s(1/l.width,1/l.height),p=e.sub(l.getTopLeft()).scaleSelf(f),g=1;n>=g;g++)a=this.vertices[g%n],h=this.vertices[g-1],c=a.sub(l.getTopLeft()).scaleSelf(f),u=h.sub(l.getTopLeft()).scaleSelf(f),t.addFace(r,a.to3DXY(),h.to3DXY(),p,c,u);return t},toPolygon2D:function(){return this},toString:function(){for(var t="",e=0;ei;i++)this.vertices[i].addSelf(t,e);return this}},c.fromBaseEdge=function(t,e,i){for(var s,r=-(n.PI-n.PI*(i-2)/i),o=e.sub(t),a=e,h=new c(t,e),u=0;i-1>u;u++)s=a.add(o.getRotated(r*u)),h.add(s),a=s;return h},c.fromEdgeLength=function(e,i){var n=t("./Circle");return new n(c.getRadiusForEdgeLength(e,i)).toPolygon2D(i)},c.getRadiusForEdgeLength=function(t,e){return t/(2*n.sin(n.PI/e))},e.exports=c},{"../internals/has":105,"../internals/is":106,"../math/mathUtils":125,"./Circle":45,"./Line2D":52,"./Rect":62,"./Vec2D":70,"./mesh/TriangleMesh":87}],58:[function(t,e,i){var n=t("../math/mathUtils"),s=t("./Matrix4x4"),r=function(t,e,i,n){4==arguments.length?(this.w=t,this.x=e,this.y=i,this.z=n):2==arguments.length?(this.x=e.x,this.y=e.y,this.z=e.z,this.w=t):1==arguments.length&&(this.w=q.w,this.x=q.x,this.y=q.y,this.z=q.z)};r.prototype={add:function(t){return new r(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},addSelf:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},copy:function(){return new r(this.w,this.x,this.y,this.z)},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},getConjugate:function(){var t=new r;return t.x=-this.x,t.y=-this.y,t.z=-this.z,t.w=w,t},identity:function(){return this.w=1,this.x=0,this.y=0,this.z=0,this},interpolateTo:function(t,e,i){return 3==arguments.length?this.copy().interpolateTo(t,i.interpolate(0,1,e)):this.copy().interpolateToSelf(t,e)},interpolateToSelf:function(t,e,i){3==arguments.length&&(e=i.interpolate(0,1,e));var s,r,o=n.clip(this.dot(t),-1,1);if(1-o>=n.EPS){var a=Math.acos(o),h=1/Math.sin(a);s=Math.sin(a*(1-e))*h,r=Math.sin(a*e)*h}else s=1-e,r=e;return 0>o?(this.w=s*this.w-r*t.w,this.x=s*this.x-r*t.x,this.y=s*this.y-r*t.y,this.z=s*this.z-r*t.z):(this.w=s*w+r*t.w,this.x=s*x+r*t.x,this.y=s*y+r*t.y,this.z=s*z+r*t.z),this},magnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},multiply:function(t){var e=new r;return e.w=this.w*t.w-x*t.x-y*t.y-z*t.z,e.x=this.w*t.x+x*t.w+y*t.z-z*t.y,e.y=this.w*t.y+y*t.w+z*t.x-x*t.z,e.z=this.w*t.z+z*t.w+x*t.y-y*t.x,e},normalize:function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return t>n.EPS&&(t=1/t,this.x*=t,this.y*=t,this.z*=t,this.w*=t),this},scale:function(t){return new r(this.x*t,this.y*t,this.z*t,this.w*t)},scaleSelf:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},set:function(t,e,i,n){return 4==arguments.length?(this.w=t,this.x=e,this.y=i,this.z=n):2==arguments.length?(this.w=t,this.x=v.x,this.y=v.y,this.z=v.z):(this.w=q.w,this.x=q.x,this.y=q.y,this.z=q.z),this},sub:function(t){return new r(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},subSelf:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},toArray:function(){return[this.w,this.x,this.y,this.z]},toAxisAngle:function(){var t=[],e=Math.sqrt(1-this.w*this.w);return e=e0)e=Math.sqrt(n+1),i[3]=.5*e,e=.5/e,i[0]=t.matrix[1][2]-t.matrix[2][1]*e,i[1]=t.matrix[2][0]-t.matrix[0][2]*e,i[2]=t.matrix[0][1]-t.matrix[1][0]*e;else{var s=[1,2,0],o=0,a=0,h=0;t.matrix[1][1]>t.matrix[0][0]&&(o=1),t.matrix[2][2]>t.matrix[o][o]&&(o=2),a=s[o],h=s[a],e=Math.sqrt(t.matrix[o][o]-(t.matrix[a][a]+t.matrix[h][h])+1),i[o]=.5*e,e=.5/e,i[3]=(t.matrix[a][h]-t.matrix[h][a])*e,i[a]=(t.matrix[o][a]+t.matrix[a][o])*e,i[h]=(t.matrix[o][h]+t.matrix[h][o])*e}return new r(i[3],i[0],i[1],i[2])},r.getAlignmentQuat=function(t,e){var i=t.getNormalized(),n=e.cross(i),s=n.magnitude()+1e-4,r=Math.atan2(s,e.dot(i));return this.createFromAxisAngle(n,r)},e.exports=r},{"../math/mathUtils":125,"./Matrix4x4":55}],59:[function(t,e,i){var n=t("../internals").extend,s=t("./Vec2D"),r=(t("./Line2D"),function(t,e,i){3==arguments.length?(s.apply(this,[t,e]),this.dir=i.getNormalized()):2==arguments.length?(s.apply(this,[t]),this.dir=e.getNormalized()):0===arguments.length&&(s.apply(this),this.dir=s.Y_AXIS.copy())});n(r,s),r.prototype.getDirection=function(){return this.dir.copy()},r.prototype.getDistanceToPoint=function(t){var e=t.sub(this);return e.distanceTo(this.dir.scale(e.dot(this.dir)))},r.prototype.getPointAtDistance=function(t){return this.add(this.dir.scale(t))},r.prototype.setDirection=function(t){return this.dir.set(t).normalize(),this},r.prototype.toLine2DWithPointAtDistance=function(e){var i=t("./Line2D");return new i(this,this.getPointAtDistance(e))},r.prototype.toString=function(){return"origin: "+s.prototype.toString.apply(this)+" dir: "+this.dir},e.exports=r},{"../internals":98,"./Line2D":52,"./Vec2D":70}],60:[function(t,e,i){var n=t("../internals").extend,s=t("./Vec3D"),r=t("./Line3D"),o=function(t,e,i,n){var r,o;4==arguments.length?(r=new s(t,e,i),o=n):2==arguments.length?(r=t,o=e):(r=new s,o=s.Y_AXIS.copy()),s.apply(this,[r]),this.dir=o};n(o,s),o.prototype.getDirection=function(){return this.dir.copy()},o.prototype.getDistanceToPoint=function(t){var e=t.sub(this);return e.distanceTo(this.dir.scale(e.dot(this.dir)))},o.prototype.getPointAtDistance=function(t){return this.add(this.dir.scale(t))},o.prototype.setDirection=function(t){return this.dir.set(t).normalize(),this},o.prototype.toLine3DWithPointAtDistance=function(e){return new(r=t("./Line3D"))(this,this.getPointAtDistance(e))},o.prototype.toString=function(){return"origin: "+this.parent.toString.call(this)+" dir: "+this.dir},e.exports=o},{"../internals":98,"./Line3D":53,"./Vec3D":71}],61:[function(t,e,i){var n,s=t("./IsectData3D"),r=t("../math/mathUtils");n=function(t){this.ray=t,this.isec=new s},n.prototype={getIntersectionData:function(){return this.isec},intersectsRay:function(t){var e,i=this.ray.dir.cross(t.dir),n=this.ray.sub(t),s=r.abs(i.x),o=r.abs(i.y),a=r.abs(i.z);return e=a>s&&a>o?(n.x*t.dir.y-n.y*t.dir.x)/i.z:s>o?(n.y*t.dir.z-n.z*t.dir.y)/i.x:(n.z*t.dir.x-n.x*t.dir.z)/i.y,this.isec.isIntersection=e<=r.EPS&&!isFinite(e),this.isec.pos=this.ray.getPointAtDistance(-e),this.isec.isIntersection}},e.exports=n},{"../math/mathUtils":125,"./IsectData3D":51}],62:[function(t,e,i){var n=t("../internals"),s=t("../math/mathUtils"),r=t("./Vec2D"),o=t("./Line2D"),a=function(t,e,i,s){if(2===arguments.length){if(!n.has.XY(t))throw new Error("Rect received incorrect parameters");this.x=t.x,this.y=t.y,this.width=e.x-this.x,this.height=e.y-this.y}else if(4==arguments.length)this.x=t,this.y=e,this.width=i,this.height=s;else if(1===arguments.length){var r=arguments[0];n.has.XYWidthHeight(r)&&(this.x=r.x,this.y=r.y,this.width=r.width,this.height=r.height)}else if(arguments.length>0)throw new Error("Rect received incorrect parameters")};a.fromCenterExtent=function(t,e){return new a(t.sub(e),t.add(e))},a.getBoundingRect=function(t){for(var e=t[0],i=new a(e.x,e.y,0,0),n=1,s=t.length;s>n;n++)i.growToContainPoint(t[n]);return i},a.prototype={containsPoint:function(t){var e=t.x,i=t.y;return e=this.x+this.width?!1:i=this.y+this.height?!1:!0},copy:function(){return new a(this.x,this.y,this.width,this.height)},getArea:function(){return this.width*this.height},getAspect:function(){return this.width/this.height},getBottom:function(){return this.y+this.height},getBottomRight:function(){return new r(this.x+this.width,this.y+this.height)},getCentroid:function(){return new r(this.x+.5*this.width,this.y+.5*this.height)},getDimensions:function(){return new r(this.width,this.height)},getEdge:function(t){var e;switch(t){case 0:e=new o(new r(this.x,this.y),new r(this.x+this.width,this.y));break;case 1:e=new o(new r(this.x+this.width,this.y),new r(this.x+this.width,this.y+this.height));break;case 2:e=new o(new r(this.x,this.y+this.height),new r(this.x+this.width,this.y+this.height));break;case 3:e=new o(new r(this.x,this.y),new r(this.x,this.y+this.height));break;default:throw new Error("edge ID needs to be 0...3")}return e},getLeft:function(){return this.x},getRight:function(){return this.x+this.width},getTop:function(){return this.y},getTopLeft:function(){return new r(this.x,this.y)},growToContainPoint:function(t){return this.containsPoint(t)||(t.xthis.getRight()&&(this.width=t.x-this.x),t.ythis.getBottom()&&(this.height=t.y-this.y)),this},intersectsRay:function(t,e,i){var n=t.getDirection().reciprocal(),s=n.x<0,r=n.y<0,o=this.getTopLeft(),a=this.getBottomRight(),h=s?a:o,c=(h.x-t.x)*n.x; h=s?o:a;var u=(h.x-t.x)*n.x;h=r?a:o;var l=(h.y-t.y)*n.y;h=r?o:a;var f=(h.y-t.y)*n.y;return c>f||l>u?void 0:(l>c&&(c=l),u>f&&(u=f),i>c&&u>e?t.getPointAtDistance(c):void 0)},intersectsRect:function(t){return!(this.x>t.x+t.width||this.x+this.widtht.y+t.height||this.y+this.height=0&&(h=Math.sqrt(h),i=a+h,n=a-h,0>i&&0>n||(i>0&&n>0?i>n&&(s=i,i=n,n=s):n>0&&(s=i,i=n,n=s)),e=[i,n]),e},n.prototype.intersectSphereTriangle=function(t,e){e.set(t.closestPointOnSurface(this));var i=e.sub(this);return i.magSquared()<=this.radius*this.radius},n.prototype.tangentPlaneNormalAt=function(t){return this.sub(t).normalize()},n.prototype.toMesh=function(){var t={mesh:void 0,resolution:0};1===arguments.length?"object"==typeof arguments[0]?(t.mesh=arguments[0].mesh,t.resolution=arguments[0].res||arguments[0].resolution):t.resolution=arguments[0]:(t.mesh=arguments[0],t.resolution=arguments[1]);var e=new i.SurfaceMeshBuilder(new s(this));return e.createMesh(t.mesh,t.resolution,1)}}(),function(e){var i=t("../math/mathUtils"),n=t("./Vec3D"),r=t("../internals");s=function(t){void 0===t&&(this.sphere=new e(new n,1)),r.is.Sphere(t)?this.sphere=t:this.sphere=new e(new n,t),this.phiRange=i.PI,this.thetaRange=i.TWO_PI},s.prototype={computeVertexFor:function(t,e,n){e-=i.HALF_PI;var s=i.cos(e),r=i.cos(n),o=i.sin(e),a=i.sin(n),h=i.sign(s)*i.abs(s);return t.x=h*i.sign(r)*i.abs(r),t.y=i.sign(o)*i.abs(o),t.z=h*i.sign(a)*i.abs(a),t.scaleSelf(this.sphere.radius).addSelf(this.sphere)},getPhiRange:function(){return this.phiRange},getPhiResolutionLimit:function(t){return t},getThetaRange:function(){return this.thetaRange},getThetaResolutionLimit:function(t){return t},setMaxPhi:function(t){this.phiRange=i.min(t/2,i.PI)},setMaxTheta:function(t){this.thetaRange=i.min(t,i.TWO_PI)}}}(n),n.SphereFunction=s,e.exports=n},{"../internals":98,"../math/mathUtils":125,"./Vec3D":71,"./mesh/meshCommon":92}],64:[function(t,e,i){var n=t("./Vec2D"),s=t("../internals/is"),r=t("./BernsteinPolynomial"),o=function(t,e,i){1===arguments.length&&!s.Array(t)&&s.Object(t)&&(e=e||t.bernsteinPoly,i=i||t.tightness,t=t.points);var r,a=0;if(this.pointList=[],"number"!=typeof i&&(i=o.DEFAULT_TIGHTNESS),this.setTightness(i),this.bernstein=e,void 0!==t)for(a=0,r=t.length;r>a;a++)this.add(t[a].copy());for(this.coeffA=[],this.delta=[],this.bi=[],a=0;at&&(t=1),t++,(void 0===this.bernstein||this.bernstein.resolution!=t)&&(this.bernstein=new r(t));var e=this.bernstein;this.findCPoints();var i=new n,s=new n;t--;var o=(this.numP-1)*t+1;("undefined"==typeof this.vertices||this.vertices.length!=o)&&(this.vertices=Array.apply(null,Array(o)).map(function(){return new n}));for(var a=0,h=0;hl;l++){var f=c.x*e.b0[l]+i.x*e.b1[l]+s.x*e.b2[l]+u.x*e.b3[l],p=c.y*e.b0[l]+i.y*e.b1[l]+s.y*e.b2[l]+u.y*e.b3[l];this.vertices[a].x=f,this.vertices[a].y=p,a++}}return this.vertices[a].x=this.vertices[a-1].x,this.vertices[a].y=this.vertices[a-1].y,this.vertices},findCPoints:function(){this.bi[1]=-.25;var t,e,i,n;for(e=this.pointList[0],i=this.pointList[2],n=this.delta[0],this.coeffA[1].x=(i.x-e.x-n.x)*this.tightness,this.coeffA[1].y=(i.y-e.y-n.y)*this.tightness,t=2;t0;t--)this.delta[t].x=this.coeffA[t].x+this.delta[t+1].x*this.bi[t],this.delta[t].y=this.coeffA[t].y+this.delta[t+1].y*this.bi[t]},getDecimatedVertices:function(t,e){void 0===e&&(e=!0),(void 0===this.vertices||this.vertices.length<2)&&this.computeVertices(o.DEFAULT_RES);for(var i=this.getEstimatedArcLength(),n=[],s=t/i,r=0,a=0;1>a;a+=s){for(var h=a*i;h>=this.arcLenIndex[r];)r++;var c=this.vertices[r-1],u=this.vertices[r],l=(h-this.arcLenIndex[r-1])/(this.arcLenIndex[r]-this.arcLenIndex[r-1]),f=c.interpolateTo(u,l);n.push(f)}return e&&n.push(this.vertices[this.vertices.length-1]),n},getEstimatedArcLength:function(){var t,e=0;void 0===this.arcLenIndex||void 0!==this.arcLenIndex&&this.arcLenIndex.length!=this.vertices.length?(this.arcLenIndex=[0],t=this.vertices.length):t=this.arcLenIndex.length;for(var i=1;t>i;i++){var n=this.vertices[i-1],s=this.vertices[i];e+=n.distanceTo(s),this.arcLenIndex[i]=e}return e},getNumPoints:function(){return this.numP},getPointList:function(){return this.pointList},getTightness:function(){return this.tightness},setPointList:function(t){return this.pointList=t.slice(0),this},setTightness:function(t){return this.tightness=t,this.invTightness=1/this.tightness,this},updateCoefficients:function(){if(this.numP=this.pointList.length,void 0===this.points||void 0!==this.points&&this.points.length!=this.numP){this.coeffA=[],this.delta=[],this.bi=[];for(var t=0;ta;a++)this.add(t[a].copy());for(this.coeffA=[],this.delta=[],this.bi=[],a=0;at&&(t=1),t++,(void 0===this.bernstein||this.bernstein.resolution!=t)&&(this.bernstein=new r(t));var e=this.bernstein;this.vertices=[],this.findCPoints();var i=new n,s=new n;t--;for(var o=0;oc;c++){var u=a.x*e.b0[c]+i.x*e.b1[c]+s.x*e.b2[c]+h.x*e.b3[c],l=a.y*e.b0[c]+i.y*e.b1[c]+s.y*e.b2[c]+h.y*e.b3[c],f=a.z*e.b0[c]+i.z*e.b1[c]+s.z*e.b2[c]+h.z*e.b3[c];this.vertices.push(new n(u,l,f))}}return this.vertices.push(this.points[this.points.length-1].copy()),this.vertices},findCPoints:function(){this.bi[1]=-.25;var t,e,i,n;for(e=this.pointList[0],i=this.pointList[2],n=this.delta[0],this.coeffA[1].set((i.x-e.x-n.x)*this.tightness,(i.y-e.y-n.y)*this.tightness,(i.z-e.z-n.z)*this.tightness),t=2;t0;t--)this.delta[t].set(this.coeffA[t].x+this.delta[t+1].x*this.bi[t],this.coeffA[t].y+this.delta[t+1].y*this.bi[t],this.coeffA[t].z+this.delta[t+1].z*this.bi[t])},getDecimatedVertices:function(t,e){void 0===e&&(e=!0),(void 0===this.vertices||this.vertices.length<2)&&this.computeVertices(o.DEFAULT_RES);for(var i=this.getEstimatedArcLength(),n=[],s=t/i,r=0,a=0;1>a;a+=s){for(var h=a*i;h>=this.arcLenIndex[r];)r++;var c=this.vertices[r-1],u=this.vertices[r],l=(h-this.arcLenIndex[r-1])/(this.arcLenIndex[r]-this.arcLenIndex[r-1]),f=c.interpolateTo(u,l);n.push(f)}return e&&n.push(this.vertices[this.vertices.length-1]),n},getEstimatedArcLength:function(){var t,e=0;void 0===this.arcLenIndex||void 0!==this.arcLenIndex&&this.arcLenIndex.length!=this.vertices.length?(this.arcLenIndex=[0],t=this.vertices.length):t=this.arcLenIndex.length;for(var i=1;t>i;i++){var n=this.vertices[i-1],s=this.vertices[i];e+=n.distanceTo(s),this.arcLenIndex[i]=e}return e},getNumPoints:function(){return this.numP},getPointList:function(){return this.pointList},getTightness:function(){return this.tightness},setPointList:function(t){return this.pointList=t.slice(0),this},setTightness:function(t){return this.tightness=t,this.invTightness=1/this.tightness,this},updateCoefficients:function(){if(this.numP=this.pointList.length,void 0===this.points||void 0!==this.points&&this.points.length!=this.numP){this.coeffA=[],this.delta=[],this.bi=[];for(var t=0;t=t.y},1:function(t,e){return e.x=t.x}},h=function(t,e,i){return a[i](t,e)},c=function(t){this.bounds=t};c.prototype={constructor:c,clipPolygon:function(t){var e,i,s,r=t.vertices.slice(0),a=0,c=0,u=r.length-1;for(r.push(r[0]);4>a;a++){for(c=0,u=r.length-1,e=[];u>c;c++)i=r[c],s=r[c+1],h(this.bounds,i,a)?h(this.bounds,s,a)?e.push(s.copy()):e.push(o(this.bounds,a,i,s)):h(this.bounds,s,a)&&(e.push(o(this.bounds,a,i,s)),e.push(s.copy()));e.length>0&&e[0]!==e[e.length-1]&&e.push(e[0]),r=e}return new n(r).removeDuplicates(.001)},getBounds:function(){return this.bounds},isKnownVertex:function(t,e){for(var i=0,n=t.length;n>i;i++)if(t[i].equalsWithTolerance(e,1e-4))return!0;return!1},setBounds:function(t){this.bounds=t}},e.exports=c},{"./Polygon2D":57,"./vectors":96}],67:[function(t,e,i){var n=t("./Vec2D"),s=t("./Line2D"),r=t("./Rect"),o=t("./Circle"),a=t("./Polygon2D"),h=t("../math/mathUtils"),c=function(t,e,i){3===arguments.length&&(this.a=t.copy(),this.b=e.copy(),this.c=i.copy())};c.createEquilateralFrom=function(t,e){var i=t.interpolateTo(e,.5),n=t.sub(e),s=n.getPerpendicular();return i.addSelf(s.normalizeTo(n.magnitude()*h.SQRT3/2)),new c(t,e,i)},c.isClockwise=function(t,e,i){var n=(e.x-t.x)*(i.y-t.y)-(i.x-t.x)*(e.y-t.y);return 0>n},c.prototype={adjustTriangleSizeBy:function(t,e,i){1==arguments.length&&(e=t,i=t),this.computeCentroid();var n=new s(this.a.copy(),this.b.copy()).offsetAndGrowBy(t,1e5,this.centroid),r=new s(this.b.copy(),this.c.copy()).offsetAndGrowBy(e,1e5,this.centroid),o=new s(this.c.copy(),this.a.copy()).offsetAndGrowBy(i,1e5,this.centroid);return this.a=n.intersectLine(o).getPos(),this.b=n.intersectLine(r).getPos(),this.c=r.intersectLine(o).getPos(),this.computeCentroid(),this},computeCentroid:function(){return this.centroid=this.a.add(this.b).addSelf(this.c).scaleSelf(1/3),this.centroid},containsPoint:function(t){var e=t.sub(this.a).normalize(),i=t.sub(this.b).normalize(),n=t.sub(this.c).normalize(),s=Math.acos(e.dot(i));return s+=Math.acos(i.dot(n)),s+=Math.acos(n.dot(e)),h.abs(s-h.TWO_PI)<=.01},copy:function(){return new c(this.a.copy(),this.b.copy(),this.c.copy())},flipVertexOrder:function(){var t=this.a;return this.a=this.c,this.c=t,this},getArea:function(){return.5*this.b.sub(this.a).cross(this.c.sub(this.a))},getBounds:function(){return new r(n.min(n.min(this.a,this.b),this.c),n.max(n.max(this.a,this.b),this.c))},getCircumCircle:function(){var t=this.a.bisect(this.b).cross(this.b.bisect(this.c)),e=new n(t.x/t.z,t.y/t.z),i=this.a.distanceTo(this.b),s=this.b.distanceTo(this.c),r=this.c.distanceTo(this.a),a=i*s*r/Math.sqrt((i+s+r)*(-i+s+r)*(i-s+r)*(i+s-r));return new o(e,a)},getCircumference:function(){return this.a.distanceTo(this.b)+this.b.distanceTo(this.c)+this.c.distanceTo(this.a)},getClosestPointTo:function(t){var e=new s(this.a,this.b),i=e.closestPointTo(t),n=e.set(this.b,this.c).closestPointTo(t),r=e.set(this.c,this.a).closestPointTo(t),o=t.sub(i).magSquared(),a=t.sub(n).magSquared(),h=t.sub(r).magSquared(),c=o,u=i;return c>a&&(c=a,u=n),c>h&&(u=r),u},intersectsTriangle:function(t){if(this.containsPoint(t.a)||this.containsPoint(t.b)||this.containsPoint(t.c))return!0;if(t.containsPoint(this.a)||t.containsPoint(this.b)||t.containsPoint(this.c))return!0;for(var e=[new s(this.a,this.b),new s(this.b,this.c),new s(this.c,this.a)],i=[new s(t.a,t.b),new s(t.b,t.c),new s(t.c,t.a)],n=0,r=e.length;r>n;n++)for(var o=e[n],a=0,h=i.length;h>a;a++){var c=i[a],u=o.intersectLine(c).getType();if(u!=s.LineIntersection.Type.NON_INTERSECTING&&u!=s.LineIntersection.Type.PARALLEL)return!0}return!1},isClockwise:function(){return c.isClockwise(this.a,this.b,this.c)},set:function(t,e,i){this.a=t,this.b=e,this.c=i},toPolygon2D:function(){var t=new a;return t.add(this.a.copy()),t.add(this.b.copy()),t.add(this.c.copy()),t},toString:function(){return"Triangle2D: "+this.a+","+this.b+","+this.c}},e.exports=c},{"../math/mathUtils":125,"./Circle":45,"./Line2D":52,"./Polygon2D":57,"./Rect":62,"./Vec2D":70}],68:[function(t,e,i){var n=t("../math/mathUtils"),s=t("./Vec3D"),r=t("./Line3D"),o=t("./AABB"),h=function(t,e,i){this.a=t,this.b=e,this.c=i};h.createEquilateralFrom=function(t,e){var i=t.interpolateTo(e,.5),s=e.sub(t),r=t.cross(s.normalize());return i.addSelf(r.normalizeTo(s.magnitude()*n.SQRT3/2)),new h(t,e,i)},h.isClockwiseInXY=function(t,e,i){var n=(e.x-t.x)*(i.y-t.y)-(i.x-t.x)*(e.y-t.y);return 0>n},h.isClockwiseInXZ=function(t,e,i){var n=(e.x-t.x)*(i.z-t.z)-(i.x-t.x)*(e.z-t.z);return 0>n},h.isClockwiseInYZ=function(t,e,i){var n=(e.y-t.y)*(i.z-t.z)-(i.y-t.y)*(e.z-t.z);return 0>n},h.prototype={closestPointOnSurface:function(t){var e=this.b.sub(this.a),i=this.c.sub(this.a),n=this.c.sub(this.b),s=t.sub(this.a),r=t.sub(this.b),o=t.sub(this.c),h=a.sub(this.p),u=b.sub(this.p),l=c.sub(this.p),f=s.dot(e),p=s.dot(i);if(0>=f&&0>=p)return this.a;var g=r.dot(this.a.sub(this.b)),d=o.dot(this.a.sub(this.c)),m=r.dot(n),y=o.dot(this.b.sub(this.c));if(0>=g&&0>=m)return this.b;if(0>=d&&0>=y)return this.c;var x=e.cross(i),v=x.dot(h.crossSelf(u));if(0>=v&&f>=0&&g>=0)return this.a.add(e.scaleSelf(f/(f+g)));var w=x.dot(u.crossSelf(l));if(0>=w&&m>=0&&y>=0)return this.b.add(n.scaleSelf(m/(m+y)));var S=x.dot(l.crossSelf(h));if(0>=S&&p>=0&&d>=0)return this.a.add(i.scaleSelf(p/(p+d)));var C=w/(w+S+v),A=S/(w+S+v),T=1-C-A;return this.a.scale(C).addSelf(this.b.scale(A)).addSelf(this.c.scale(T))},computeCentroid:function(){return this.centroid=this.a.add(this.b).addSelf(this.c).scaleSelf(1/3),this.centroid},computeNormal:function(){return this.normal=this.a.sub(this.c).crossSelf(this.a.sub(this.b)).normalize(),this.normal},containsPoint:function(t){if(t.equals(this.a)||t.equals(this.b)||t.equals(this.c))return!0;var e=t.sub(this.a).normalize(),i=t.sub(this.b).normalize(),s=t.sub(this.c).normalize(),r=Math.acos(e.dot(i));return r+=Math.acos(i.dot(s)),r+=Math.acos(s.dot(e)),n.abs(r-n.TWO_PI)<=.005},flipVertexOrder:function(){this.a;return this.a=this.c,this.c=this.t,this},fromBarycentric:function(t){return new s(this.a.x*t.x+this.b.x*t.y+this.c.x*t.z,this.a.y*t.x+this.b.y*t.y+this.c.y*t.z,this.a.z*t.x+this.b.z*t.y+this.c.z*t.z)},getBoundingBox:function(){var t=s.min(s.min(this.a,this.b),this.c),e=s.max(s.max(this.a,this.b),this.c);return o.fromMinMax(t,e)},getClosestPointTo:function(t){var e=new r(this.a,this.b),i=e.closestPointTo(t),n=e.set(this.b,this.c).closestPointTo(t),s=e.set(this.c,this.a).closestPointTo(t),o=t.sub(i).magSquared(),a=t.sub(n).magSquared(),h=t.sub(s).magSquared(),c=o,u=i;return c>a&&(c=a,u=n),c>h&&(u=s),u},isClockwiseInXY:function(){return h.isClockwiseInXY(this.a,this.b,this.c)},isClockwiseInXZ:function(){return h.isClockwiseInXY(this.a,this.b,this.c)},isClockwiseInYZ:function(){return h.isClockwiseInXY(this.a,this.b,this.c)},set:function(t,e,i){this.a=t,this.b=e,this.c=i},toBarycentric:function(t){var e=b.sub(this.a).cross(this.c.sub(this.a)),i=e.getNormalized(),n=i.dot(e),r=i.dot(this.b.sub(t).cross(this.c.sub(t))),o=r/n,a=i.dot(this.c.sub(t).cross(this.a.sub(t))),h=a/n,c=1-o-h;return new s(o,h,c)},toString:function(){return"Triangle: "+this.a+","+this.b+","+this.c}},e.exports=h},{"../math/mathUtils":125,"./AABB":42,"./Line3D":53,"./Vec3D":71}],69:[function(t,e,i){var n=t("../math/mathUtils"),s=t("./Triangle3D"),r=(t("./Vec3D"),t("./IsectData3D")),o=function(t){this.triangle=t||new s,this.isectData=new r};o.prototype={getIntersectionData:function(){return this.isectData},getTriangle:function(){return this.triangle},intersectsRay:function(t){this.isectData.isIntersection=!1;var e=this.triangle.computeNormal(),i=e.dot(t.dir);if(0>i){var s=t.sub(this.triangle.a),r=-(e.x*s.x+e.y*s.y+e.z*s.z)/(e.x*t.dir.x+e.y*t.dir.y+e.z*t.dir.z);if(r>=n.EPS){var o=t.getPointAtDistance(r);this.triangle.containsPoint(o)&&(this.isectData.isIntersection=!0,this.isectData.pos=o,this.isectData.normal=e,this.isectData.dist=r,this.isectData.dir=this.isectData.pos.sub(t).normalize())}}return this.isectData.isIntersection},setTriangle:function(t){return this.triangle=t,this}},e.exports=o},{"../math/mathUtils":125,"./IsectData3D":51,"./Triangle3D":68,"./Vec3D":71}],70:[function(t,e,i){e.exports=t("./vectors").Vec2D},{"./vectors":96}],71:[function(t,e,i){e.exports=t("./vectors").Vec3D},{"./vectors":96}],72:[function(t,e,i){var n=t("../internals").extend,s=t("../math/mathUtils"),r=t("./Vec3D"),o=t("./AxisAlignedCylinder"),a=function(t,e,i){o.apply(this,[t,e,i])};n(a,o),a.prototype.containsPoint=function(t){if(s.abs(t.x-this.pos.x)<.5*this.length){var e=t.y-this.pos.y,i=t.z-this.pos.z;if(Math.abs(i*i+e*e)e;e++){this.points[e]=this.points[e]||[];for(var i=0;4>i;i++)this.points[e][i]=new n}}};o.prototype={computePointAt:function(t,e){return o.computePointAt(t,e,this.points)},set:function(t,e,i){return this.points[e][t].set(i),this},toMesh:function(t,e){var i,n;void 0===e?(i=new s,n=t):(i=t,n=e);for(var r=new Array(n+1),o=new Array(n+1),a=1/n,h=0;n>=h;h++){for(var c=0;n>=c;c++){var u=this.computePointAt(c*a,h*a,this.points);c>0&&h>0&&(i.addFace(u,r[c-1],o[c-1]),i.addFace(u,o[c-1],o[c])),r[c]=u}var l=o;o=r,r=l}return i}},o.computePointAt=function(t,e,i){var s=1-t,r=s*s*3*t,o=s*s*s,a=t*t,h=1-e,c=e*e*3,u=h*h*3,l=h*h*h,f=e*e*e,p=s*a*3,g=t*a,d=h*c,m=u*e,y=i[0],x=i[1],v=i[2],b=i[3],w=o*(y[0].x*l+y[1].x*m+y[2].x*d+y[3].x*f)+r*(x[0].x*l+x[1].x*m+x[2].x*d+x[3].x*f)+p*(v[0].x*l+v[1].x*m+v[2].x*d+v[3].x*f)+g*(b[0].x*l+b[1].x*m+b[2].x*d+b[3].x*f),S=o*(y[0].y*l+y[1].y*m+y[2].y*d+y[3].y*f)+r*(x[0].y*l+x[1].y*m+x[2].y*d+x[3].y*f)+p*(v[0].y*l+v[1].y*m+v[2].y*d+v[3].y*f)+g*(b[0].y*l+b[1].y*m+b[2].y*d+b[3].y*f),C=o*(y[0].z*l+y[1].z*m+y[2].z*d+y[3].z*f)+r*(x[0].z*l+x[1].z*m+x[2].z*d+x[3].z*f)+p*(v[0].z*l+v[1].z*m+v[2].z*d+v[3].z*f)+g*(b[0].z*l+b[1].z*m+b[2].z*d+b[3].z*f);return new n(w,S,C)},e.exports=o},{"../../internals/is":106,"../Vec3D":71,"./TriangleMesh":87}],77:[function(t,e,i){var n=t("../../internals").extend,s=t("./VertexSelector"),r=function(t,e){s.apply(this,[t]),this.box=e};n(r,s),r.prototype.selectVertices=function(){this.clearSelection();for(var t=this.mesh.getVertices(),e=t.length,i=0;e>i;i++){var n=t[i];this.box.containsPoint(n)&&this.selection.add(n)}return this},e.exports=r},{"../../internals":98,"./VertexSelector":89}],78:[function(t,e,i){var n=t("../../internals").extend,s=t("./VertexSelector"),r=function(t){s.call(this,t)};n(r,s),r.prototype.selectVertices=function(){return this.clearSelection(),this.selection=this.selection.concat(this.mesh.getVertices()),this},e.exports=r},{"../../internals":98,"./VertexSelector":89}],79:[function(t,e,i){var n,s;!function(){var e=t("../Triangle3D");n=function(t,e,i,n,s,r){this.a=t,this.b=e,this.c=i;var o=this.a.sub(this.c),a=this.a.sub(this.b),h=o.crossSelf(a);this.normal=h.normalize(),this.a.addFaceNormal(this.normal),this.b.addFaceNormal(this.normal),this.c.addFaceNormal(this.normal),void 0!==n&&(this.uvA=n,this.uvB=s,this.uvC=r)},n.prototype={computeNormal:function(){this.normal=this.a.sub(this.c).crossSelf(this.a.sub(this.b)).normalize()},flipVertexOrder:function(){var t=this.a;this.a=this.b,this.b=t,this.normal.invert()},getCentroid:function(){return this.a.add(this.b).addSelf(this.c).scale(1/3)},getClass:function(){return"Face"},getVertices:function(t){return void 0!==t?(t[0]=this.a,t[1]=this.b,t[2]=this.c):t=[this.a,this.b,this.c],t},toString:function(){return this.getClass()+" "+this.a+", "+this.b+", "+this.c},toTriangle:function(){return new e(this.a.copy(),this.b.copy(),this.c.copy())}}}(),function(){var e,i=t("../../internals");s=function(t,e,i,s,r,o){n.call(this,t,e,i,s,r,o),this.edges=[]},i.extend(s,n),e=s.prototype,e.addEdge=function(t){this.edges.push(t)},e.getEdges=function(){return this.edges},e.getVertices=function(t){return void 0!==t?(t[0]=this.a,t[1]=this.b,t[2]=this.c):t=[this.a,this.b,this.c],t}}(),n.WEFace=s,e.exports=n},{"../../internals":98,"../Triangle3D":68}],80:[function(t,e,i){var n=t("../../internals"),s=function(){this.buffer=[]};s.prototype.append=function(t){return this.buffer.push(t),this},s.prototype.toString=function(){return this.buffer.join("")};var r=function(){this.VERSION="0.3",this.__stringBuffer=new s,this.objStream=void 0,this.__filename="objwriter.obj",this._numVerticesWritten=0,this._numNormalsWritten=0};r.prototype={beginSave:function(t){"string"==typeof t||n.hasProperties(t,["write","end","writable"]&&t.writable)&&(this.objStream=t),this._handleBeginSave()},endSave:function(){if(void 0!==this.objStream)try{this.objStream.destroy()}catch(t){}},face:function(t,e,i){this.__stringBuffer.append("f "+t+" "+e+" "+i+"\n")},faceList:function(){this.__stringBuffer.append("s off \n")},faceWithNormals:function(t,e,i,n,s,r){this.__stringBuffer.append("f "+t+"//"+n+" "+e+"//"+s+" "+i+"//"+r+"\n")},getCurrNormalOffset:function(){return this._numNormalsWritten},getCurrVertexOffset:function(){return this._numVerticesWritten},getOutput:function(){return this.__stringBuffer.toString()},_handleBeginSave:function(){this.numVerticesWritten=0,this.numNormalsWrittern=0,this.__stringBuffer.append("# generated by OBJExport (js) v"+this.VERSION+"\n")},newObject:function(t){this.__stringBuffer.append("o "+t+"\n")},normal:function(t){this.__stringBuffer.append("vn "+t.x+" "+t.y+" "+t.z+"\n"),this._numNormalsWritten++},vertex:function(t){this.__stringBuffer.append("v "+t.x+" "+t.y+" "+t.z+"\n"),this._numVerticesWritten++}},e.exports=r},{"../../internals":98}],81:[function(t,e,i){var n=t("../../internals").extend,s=t("./VertexSelector"),r=function(t,e,i,n){s.apply(this,[t]),this.plane=e,this.classifier=i,this.tolerances=void 0===n?1e-4:n};n(r,s),r.prototype.selectVertices=function(){this.clearSelection();for(var t=this.mesh.getVertices(),e=t.length,i=0;e>i;i++){var n=t[i];this.plane.classifyPoint(n,this.tolerance)==this.classifier&&this.selection.add(n)}return this},e.exports=r},{"../../internals":98,"./VertexSelector":89}],82:[function(t,e,i){e.exports=t("../Sphere").SphereFunction},{"../Sphere":63}],83:[function(t,e,i){var n=t("../../math/mathUtils"),s=function(t){this.m=t};s.prototype={computeVertexFor:function(t,e,i){var s=0;s+=Math.pow(n.sin(this.m[0]*i),this.m[1]),s+=Math.pow(n.cos(this.m[2]*i),this.m[3]),s+=Math.pow(n.sin(this.m[4]*e),this.m[5]),s+=Math.pow(n.cos(this.m[6]*e),this.m[7]);var r=n.sin(i);return t.x=s*r*n.cos(e),t.y=s*n.cos(i),t.z=s*r*n.sin(e),t},getPhiRange:function(){return n.TWO_PI},getPhiResolutionLimit:function(t){return t},getThetaRange:function(){return n.PI},getThetaResolutionLimit:function(t){return t}},e.exports=s},{"../../math/mathUtils":125}],84:[function(t,e,i){var n=t("../../math/mathUtils"),s=(t("./TriangleMesh"),function(t,e){this.p1=t,this.p2=e});s.prototype={computeVertexFor:function(t,e,i){e-=n.HALF_PI;var s=n.cos(e),r=n.cos(i),o=n.sin(e),a=n.sin(i),h=n.sign(s)*Math.pow(n.abs(s),this.p1);return t.x=h*n.sign(r)*Math.pow(Math.abs(r),this.p2),t.y=n.sign(o)*Math.pow(Math.abs(o),this.p1),t.z=h*n.sign(a)*Math.pow(n.abs(a),this.p2),t},getPhiRange:function(){return n.TWO_PI},getPhiResolutionLimit:function(t){return t/2},getThetaRange:function(){return n.TWO_PI},getThetaResolutionLimit:function(t){return t}},e.exports=s},{"../../math/mathUtils":125,"./TriangleMesh":87}],85:[function(t,e,i){e.exports=t("./meshCommon").SurfaceMeshBuilder},{"./meshCommon":92}],86:[function(t,e,i){e.exports=t("./meshCommon").Terrain},{"./meshCommon":92}],87:[function(t,e,i){e.exports=t("./meshCommon").TriangleMesh},{"./meshCommon":92}],88:[function(t,e,i){var n,s;!function(){var e,i=t("../../internals").extend,s=t("../Vec3D");n=function(t,e){s.call(this,t),this.id=e,this.normal=new s},i(n,s),e=n.prototype,e.addFaceNormal=function(t){this.normal.addSelf(t)},e.clearNormal=function(){this.normal.clear()},e.computeNormal=function(){this.normal.normalize()},e.toString=function(){return this.id+": p: "+this.parent.toString.call(this)+" n:"+this.normal.toString()}}(),function(){var e,i=t("../../internals").extend;return s=function(t,e){n.call(this,t,e),this.edges=[]},i(s,n),e=s.prototype,e.addEdge=function(t){this.edges.push(t)},e.getNeighborInDirection=function(t,e){for(var i,n,s=1-e,r=this.getNeighbors(),o=0,a=r.length;a>o;o++)n=r[o].sub(this).normalize().dot(t),n>s&&(i=r[o],s=n);return i},e.getNeighbors=function(){for(var t=[],e=0,i=this.edges.length;i>e;e++)t.push(this.edges[e].getOtherEndFor(this));return t},e.removeEdge=function(t){this.edges.splice(this.edges.indexOf(t),1)},e.toString=function(){return this.id+" {"+this.x+","+this.y+","+this.z+"}"},s}(),n.WEVertex=s,e.exports=n},{"../../internals":98,"../Vec3D":71}],89:[function(t,e,i){var n=function(t){this.mesh=t,this.selection=[]};n.prototype={addSelection:function(t){return this.checkMeshIdentity(t.getMesh()),this.selection=this.selection.concat(t.getSelection()),this},checkMeshIdentity:function(t){if(t!=this.mesh)throw new Error("The given selector is not using the same mesh instance")},clearSelection:function(){return this.selection=[],this},getMesh:function(){return this.mesh},getSelection:function(){return this.selection},invertSelection:function(){for(var t=[],e=this.mesh.getVertices(),i=e.length,n=0;i>n;n++){var s=e[n];this.selection.indexOf(s)<0&&t.push(s)}return this.selection=t,this},selectSimilar:function(t){for(var e=t.length,i=0;e>i;i++){var n=t[i];this.selection.push(this.mesh.getClosestVertexToPoint(n))}return this},selectVertices:function(){return this},setMesh:function(t){this.mesh=t,this.clearSelection()},size:function(){return this.selection.length},subtractSelection:function(t){this.checkMeshIdentity(t.getMesh());var e,i=t.getSelection(),n=i.length;for(e=0;n>e;e++)this.selection.splice(this.selection.indexOf(i[e]),1);return this}},e.exports=n},{}],90:[function(t,e,i){e.exports=t("./meshCommon").WETriangleMesh},{"./meshCommon":92}],91:[function(t,e,i){var n,s,r=t("../../internals"),o=t("../Line3D");n=function(t,e,i,n){o.call(this,t,e),this.id=n,this.faces=[],this.addFace(i)},r.extend(n,o),s=n.prototype,s.addFace=function(t){return this.faces.push(t),this},s.getFaces=function(){return this.faces},s.getOtherEndFor=function(t){return this.a===t?this.b:this.b===t?this.a:void 0},s.remove=function(){for(var t=this,e=function(e){e.splice(e.indexOf(t),1)},i=0,n=this.faces.length;n>i;i++)e(this.faces[i].edges);e(this.a.edges),e(this.b.edges)},s.toString=function(){return"id: "+this.id+" "+o.prototype.toString.call(this)+" f: "+this.faces.length},e.exports=n},{"../../internals":98,"../Line3D":53}],92:[function(t,e,n){ function s(t){return"[ x: "+l(t.x)+", y: "+l(t.y)+", z: "+l(t.z)+"]"}function r(t){return t.a.id+"->"+t.b.id}var o,a,h,c,u=1e6,l=function(t){return Math.floor(t*u)/u};!function(){var e=t("../../internals"),n=t("../../math/mathUtils"),r=t("../Matrix4x4"),h=t("./Face"),c=t("../Vec3D"),u=t("../Triangle3D"),l=t("../TriangleIntersector"),p=t("../Quaternion"),g=t("./Vertex");o=function(t){return void 0===t&&(t="untitled"),this.init(t),this},o.__vertexKeyGenerator=s,o.DEFAULT_NUM_VERTICES=1e3,o.DEFAULT_NUM_FACES=3e3,o.DEFAULT_STRIDE=4,o.prototype={addFace:function(t,e,i,n,s,r,o){6==arguments.length&&(o=r,r=s,s=n,n=void 0);var a=this.__checkVertex(t),c=this.__checkVertex(e),u=this.__checkVertex(i);if(a.id===c.id||a.id===u.id||c.id===u.id);else{if(null!=n){var l=a.sub(u).crossSelf(a.sub(c));if(n.dot(l)<0){var f=a;a=c,c=f}}var p=new h(a,c,u,s,r,o);this.faces.push(p)}return this},addMesh:function(t){for(var e=t.getFaces().length,i=0;e>i;i++){var n=t.getFaces()[i];this.addFace(n.a,n.b,n.c)}return this},center:function(t){this.computeCentroid();for(var e=null!=t?t.sub(this.centroid):this.centroid.getInverted(),i=this.vertices.length,n=0;i>n;n++){var s=this.vertices[n];s.addSelf(e)}return this.getBoundingBox()},__checkVertex:function(t){var e=this.vertexMap.get(t);return e||(e=this._createVertex(t,this.uniqueVertexID++),this.vertexMap.put(e,e)),e},clear:function(){return this.vertexMap=new e.LinkedMap(s),this.vertices=this.vertexMap.getArray(),this.faces=[],this.bounds=void 0,this},computeCentroid:function(){this.centroid.clear();for(var t=this.vertices.length,e=0;t>e;e++)this.centroid.addSelf(this.vertices[e]);return this.centroid.scaleSelf(1/this.vertexMap.size()).copy()},computeFaceNormals:function(){for(var t=this.faces.length,e=0;t>e;e++)this.faces[e].computeNormal()},computeVertexNormals:function(){var t=this.vertices.length,e=0;for(e=0;t>e;e++)this.vertices[e].clearNormal();for(t=this.faces.length,e=0;t>e;e++){var i=this.faces[e];i.a.addFaceNormal(i.normal),i.b.addFaceNormal(i.normal),i.c.addFaceNormal(i.normal)}for(t=this.vertices.length,e=0;t>e;e++)this.vertices[e].computeNormal();return this},copy:function(){for(var t=new o(this.name+"-copy",this.vertexMap.size(),this.faces.length),e=this.faces.length,i=0;e>i;i++){var n=this.faces[i];t.addFace(n.a,n.b,n.c,n.normal,n.uvA,n.uvB,n.uvC)}return t},_createVertex:function(t,e){var i=new g(t,e);return i},faceOutwards:function(){this.computeCentroid();for(var t=this.faces.length,e=0;t>e;e++){var i=this.faces[e],n=i.getCentroid().sub(this.centroid),s=n.dot(i.normal);0>s&&i.flipVertexOrder()}return this},flipVertexOrder:function(){for(var t,e=this.faces.length,i=0;e>i;i++){var n=this.faces[i],s=n.a;n.a=n.b,n.b=s,n.uvA&&(t=n.uvA,n.uvA=n.uvB,n.uvB=t),n.normal.invert()}return this},flipYAxis:function(){return this.transform((new r).scaleSelf(1,-1,1)),this.flipVertexOrder(),this},getBoundingBox:function(){for(var e=t("../AABB"),i=this,n=c.MAX_VALUE.copy(),s=c.MIN_VALUE.copy(),r=i.vertices.length,o=0;r>o;o++){var a=i.vertices[o];n.minSelf(a),s.maxSelf(a)}return i.bounds=e.fromMinMax(n,s),i.bounds},getBoundingSphere:function(){var e=t("../Sphere"),i=0;this.computeCentroid();for(var s=this.vertices.length,r=0;s>r;r++){var o=this.vertices[r];i=n.max(i,o.distanceToSquared(this.centroid))}var a=new e(this.centroid,Math.sqrt(i));return a},getClosestVertexToPoint:function(t){for(var e,i=Number.MAX_VALUE,n=this.vertices.length,s=0;n>s;s++){var r=this.vertices[s],o=r.distanceToSquared(t);i>o&&(e=r,i=o)}return e},getFaceNormalsAsArray:function(t,e,i){if(0===arguments.length)t=void 0,e=0,i=o.DEFAULT_STRIDE;else if(1==arguments.length&&"object"==typeof arguments[0]){var s=arguments[0];t=s.normals,e=s.offset,i=s.stride}i=n.max(i,3),void 0===t&&(t=[]);for(var r=e,a=this.faces.length,h=0;a>h;h++){var c=this.faces[h];t[r]=c.normal.x,t[r+1]=c.normal.y,t[r+2]=c.normal.z,r+=i,t[r]=c.normal.x,t[r+1]=c.normal.y,t[r+2]=c.normal.z,r+=i,t[r]=c.normal.x,t[r+1]=c.normal.y,t[r+2]=c.normal.z,r+=i}return t},getFaces:function(){return this.faces},getFacesAsArray:function(t){t=t||[];for(var e=0,i=this.faces.length,n=0;i>n;n++){var s=this.faces[n];t[e++]=s.a.id,t[e++]=s.b.id,t[e++]=s.c.id}return t},getIntersectionData:function(){return this.intersector.getIntersectionData()},getMeshAsVertexArray:function(t,e,i){void 0===t&&(t=void 0),void 0===e&&(e=0),void 0===i&&(i=o.DEFAULT_STRIDE),i=n.max(i,3),void 0===t&&(t=[]);for(var s=0,r=this.faces.length,a=0;r>a;++a){var h=this.faces[a];t[s]=h.a.x,t[s+1]=h.a.y,t[s+2]=h.a.z,s+=i,t[s]=h.b.x,t[s+1]=h.b.y,t[s+2]=h.b.z,s+=i,t[s]=h.c.x,t[s+1]=h.c.y,t[s+2]=h.c.z,s+=i}return t},getNumFaces:function(){return this.faces.length},getNumVertices:function(){return this.vertexMap.size()},getRotatedAroundAxis:function(t,e){return this.copy().rotateAroundAxis(t,e)},getRotatedX:function(t){return this.copy().rotateX(t)},getRotatedY:function(t){return this.copy().rotateY(t)},getRotatedZ:function(t){return this.copy().rotateZ(t)},getScaled:function(t){return this.copy().scale(t)},getTranslated:function(t){return this.copy().translate(t)},getUniqueVerticesAsArray:function(t){t=t||[];for(var e=0,i=this.vertices.length,n=0;i>n;n++){var s=this.vertices[n];t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return t},getUniqueVertexNormalsAsArray:function(t){t=t||[];var e=0;for(i=0;in;n++){var s=this.vertices[n];s.equals(t)&&(e=n)}return e},getVertexForID:function(t){for(var e,i=this.vertices.length,n=0;i>n;n++){var s=this.vertices[n];if(s.id==t){e=s;break}}return e},getVertexNormalsAsArray:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=o.DEFAULT_STRIDE),i=n.max(i,3),void 0===t&&(t=[]);for(var s=e,r=this.faces.length,a=0;r>a;a++){var h=this.faces[a];t[s]=h.a.normal.x,t[s+1]=h.a.normal.y,t[s+2]=h.a.normal.z,s+=i,t[s]=h.b.normal.x,t[s+1]=h.b.normal.y,t[s+2]=h.b.normal.z,s+=i,t[s]=h.c.normal.x,t[s+1]=h.c.normal.y,t[s+2]=h.c.normal.z,s+=i}return t},getVertices:function(){return this.vertices},handleSaveAsSTL:function(t,e){throw new Error("TriangleMesh.handleSaveAsSTL() currently not implemented")},init:function(t){this.setName(t),this.matrix=new r,this.centroid=new c,this.vertexMap=new e.LinkedMap(s),this.vertices=this.vertexMap.getArray(),this.faces=[],this.uniqueVertexID=0,this.intersector=new l},intersectsRay:function(t){for(var e,i=this.intersector.getTriangle(),n=this.faces.length,s=0;n>s;s++)if(e=this.faces[s],i.a=e.a,i.b=e.b,i.c=e.c,this.intersector.intersectsRay(t))return!0;return!1},perforateFace:function(t,e){var i=t.getCentroid(),n=1-e,s=t.a.interpolateTo(i,n),r=t.b.interpolateTo(i,n),o=t.c.interpolateTo(i,n);return this.removeFace(t),this.addFace(t.a,r,s),this.addFace(t.a,t.b,r),this.addFace(t.b,o,r),this.addFace(t.b,t.c,o),this.addFace(t.c,s,o),this.addFace(t.c,t.a,s),new u(s,r,o)},pointTowards:function(t,e){return e=e||c.Z_AXIS,this.transform(p.getAlignmentQuat(t,e).toMatrix4x4(this.matrix),!0)},removeFace:function(t){for(var e=-1,i=this.faces.length,n=0;i>n;n++)if(this.faces[n]==t){e=n;break}e>-1&&this.faces.splice(e,1)},rotateAroundAxis:function(t,e){return this.transform(this.matrix.identity().rotateAroundAxis(t,e))},rotateX:function(t){return this.transform(this.matrix.identity().rotateX(t))},rotateY:function(t){return this.transform(this.matrix.identity().rotateY(t))},rotateZ:function(t){return this.transform(this.matrix.identity().rotateZ(t))},saveAsOBJ:function(t,e){void 0===e&&(e=!0);var i=t.getCurrVertexOffset()+1,n=t.getCurrNormalOffset()+1;t.newObject(this.name);var s,r=0,o=0,a=this.vertices.length,h=this.faces.length;for(r=0;a>r;r++)t.vertex(this.vertices[r]);if(e){for(r=0;a>r;r++)t.normal(this.vertices[r].normal);for(o=0;h>o;o++)s=this.faces[o],t.faceWithNormals(s.b.id+i,s.a.id+i,s.c.id+i,s.b.id+n,s.a.id+n,s.c.id+n)}else for(o=0;h>o;o++)s=this.faces[o],t.face(s.b.id+i,s.a.id+i,s.c.id+i)},saveAsSTL:function(t,e,i){throw new Error("TriangleMesh.saveAsSTL() currently not implemented")},scale:function(t){return this.transform(this.matrix.identity().scaleSelf(t))},setName:function(t){return this.name=t,this},toString:function(){return"TriangleMesh: "+this.name+" vertices: "+this.getNumVertices()+" faces: "+this.getNumFaces()},toWEMesh:function(){return new a(this.name).addMesh(this)},transform:function(t,e){void 0===e&&(e=!0);for(var i=this.vertices.length,n=0;i>n;n++){var s=this.vertices[n];s.set(t.applyTo(s))}return e&&this.computeFaceNormals(),this},translate:function(t,e,i){return 1==arguments.length&&(e=t.y,i=t.z,t=t.x),this.transform(this.matrix.identity().translateSelf(t,e,i))},updateVertex:function(t,e){var i=this.vertexMap.get(t);return void 0!==i&&(this.vertexMap.remove(i),i.set(e),this.vertexMap.put(e,i)),this}}}(),function(e){var i,n=t("../../internals"),o=t("../Line3D"),h=t("../Vec3D"),c=t("./Vertex").WEVertex,u=t("./Face").WEFace,l=t("./WingedEdge"),f=t("./subdiv/MidpointSubdivision");a=function(t){t=t||"untitled",e.call(this,t)},a.DEFAULT_NUM_FACES=e.DEFAULT_NUM_FACES,a.DEFAULT_NUM_VERTICES=e.DEFAULT_NUM_VERTICES,n.extend(a,e),i=a.prototype,i.addFace=function(t,e,i,n,s,r,o){6===arguments.length&&(o=r,r=s,s=n,n=void 0);var a,h,c,l=this.__checkVertex(t),f=this.__checkVertex(e),p=this.__checkVertex(i);return l.id===f.id||l.id===p.id||f.id===p.id?console.log("Ignoring invalid face: "+t+","+e+","+i):(void 0!==n&&null!==n&&(a=l.sub(p).crossSelf(l.sub(f)),n.dot(a)<0&&(h=l,l=f,f=h)),c=new u(l,f,p,s,r,o),this.faces.push(c),this.updateEdge(l,f,c),this.updateEdge(f,p,c),this.updateEdge(p,l,c)),this},i.center=function(t,i){e.prototype.center.call(this,t,i),this.rebuildIndex()},i.clear=function(){return e.prototype.clear.call(this),this.edgeMap=new n.LinkedMap(r),this.edges=this.edgeMap.getArray(),this},i.copy=function(){var t,e,i,n=new a(this.name+"-copy");for(e=this.faces.length,t=0;e>t;t++)i=this.faces[t],n.addFace(i.a,i.b,i.c,i.normal,i.uvA,i.uvB,i.uvC);return n},i._createVertex=function(t,e){var i=new c(t,e);return i},i.getNumEdges=function(){return this.edgeMap.size()},i.init=function(t){e.prototype.init.call(this,t),this.edgeMap=new n.LinkedMap(r),this.edges=this.edgeMap.getArray(),this.__edgeCheck=new o(new h,new h),this.__uniqueEdgeID=0},i.rebuildIndex=function(){var t=new n.LinkedMap(s),e=new n.LinkedMap(r),i=0,o=this.vertexMap.getArray();for(i=0;i-1&&this.faces.splice(e,1),e=0;var i;for(e=0;e1&&this.splitFace(n.faces[1],n,s),this.removeEdge(n)},i.splitFace=function(t,e,i){var n,s,r,o,a,h;for(s=0;3>s;s++)if(r=t.edges[s],!r.equals(e)){n=r.a.equals(e.a)||r.a.equals(e.b)?r.b:r.a;break}for(a=i.length,s=0;a>s;s++)h=i[s],0===s?this.addFace(n,e.a,h,t.normal):this.addFace(n,o,h,t.normal),s===a-1&&this.addFace(n,h,e.b,t.normal),o=h},i.subdivide=function(t,e){1===arguments.length&&(e=t,t=new f),this.subdivideEdges(this.edges.slice(0),t,e)},i.subdivideEdges=function(t,e,i){t.sort(e.getEdgeOrdering()),i*=i;var n=0,s=t.length;for(n=0;s>n;n++){var r=t[n];this.edges.indexOf(r)>-1&&r.getLengthSquared()>=i&&this.splitEdge(r,e)}},i.subdivideFaceEdges=function(t,e,i){var n,s,r,o,a,h,c=[];for(a=this.faces.length,n=0;a>n;n++)for(r=this.faces[n],h=r.edges.length,s=0;h>s;s++)o=r.edges[s],c.indexOf(o)<0&&c.push(o);this.subdividEdges(c,e,i)},i.toString=function(){return"WETriangleMesh: "+this.name+" vertices: "+this.getNumVertices()+" faces: "+this.getNumFaces()+" edges:"+this.getNumEdges()},i.transform=function(t,e){(void 0===e||null===e)&&(e=!0);for(var i=0,n=this.vertices.length;n>i;i++)t.applyToSelf(this.vertices[i]);return this.rebuildIndex(),e&&this.computeFaceNormals(),this},i.updateEdge=function(t,e,i){this.__edgeCheck.set(t,e);var n=this.edgeMap.get(this.__edgeCheck);n||(this.__edgeCheck.set(e,t),n=this.edgeMap.get(this.__edgeCheck)),void 0!==n?n.addFace(i):(n=new l(t,e,i,this.__uniqueEdgeID++),this.edgeMap.put(n,n),t.addEdge(n),e.addEdge(n)),i.addEdge(n)}}(o),function(e){var i=t("../../internals"),n=t("../../math/mathUtils"),s=t("../../math/Interpolation2D"),r=t("../Ray3D"),o=t("../TriangleIntersector"),a=t("../Triangle3D"),c=t("../IsectData3D"),u=t("../vectors").Vec2D,l=t("../vectors").Vec3D;h=function(t,e,n){this.width=t,this._depth=e,i.has.XY(n)||(n=new u(n,n)),this.setScale(n),this.elevation=[];var s=0,r=t*e;for(s=0;r>s;s++)this.elevation[s]=0;this.__elevationLength=this.width*this._depth,this.vertices=[];var o=new l(parseInt(this.width/2,10),0,parseInt(this._depth/2,10)),a=this.getScale().to3DXZ();s=0;for(var h=0;h=0&i=0&&ni||i>this.__elevationLength)throw new Error("the given terrain cell is invalid: "+t+";"+e);return i},getScale:function(){return this._scale},getVertexAtCell:function(t,e){return this.vertices[this._getIndex(t,e)]},getWidth:function(){return this.width},intersectAtPoint:function(t,e){var i=t/this._scale.x+.5*this.width,n=e/this._scale.y+.5*this._depth,s=new c;if(i>=0&&i=0&&ne;e++)this.vertices[e].y=this.elevation[e]=t[e];return this},setHeightAtCell:function(t,e,i){var n=this._getIndex(t,e);return this.elevation[n]=i,this.vertices[n].y=i,this},setScale:function(t){i.has.XY(t)||(t=new u(t,t)),this._scale=t},toMesh:function(){var t={mesh:void 0,minX:0,minZ:0,maxX:this.width,maxZ:this._depth},i=this.vertices,s=this.width,r=this._depth;if(1==arguments.length&&"object"==typeof arguments[0]){var o=arguments[0];t.mesh=o.mesh||new e("terrain"),t.minX=o.minX||t.minX,t.minZ=o.minZ||t.minZ,t.maxX=o.maxX||t.maxX,t.maxZ=o.maxZ||t.maxZ}else arguments.length>=5&&(t.mesh=arguments[0],t.minX=arguments[1],t.minZ=arguments[2],t.maxX=arguments[3],t.maxZ=arguments[4]);t.mesh=t.mesh||new e("terrain"),t.minX=n.clip(t.minX,0,s-1),t.maxX=n.clip(t.maxX,0,s),t.minZ=n.clip(t.minZ,0,r-1),t.maxZ=n.clip(t.maxZ,0,r),t.minX++,t.minZ++;for(var a=t.minZ,h=t.minX*s;a2&&(t.mesh=arguments[0],t.resolution=arguments[1],t.size=arguments[2],4==arguments.length&&(t.isClosed=arguments[3]));var r=t.mesh;(void 0===r||null===r)&&(r=new e);for(var o=new i,a=new i,h=new i,c=new i,u=new i,l=new i,f=this.func.getPhiResolutionLimit(t.resolution),p=this.func.getPhiRange(),g=this.func.getThetaResolutionLimit(t.resolution),d=this.func.getThetaRange(),m=1/f,y=1/g,x=1/t.resolution,v=new n,b=new n,w=new n,S=new n,C=0;f>C;C++)for(var A=C*p*x,T=(C+1)*p*x,M=0;g>=M;M++){var z=M*d*x,I=this.func;o=I.computeVertexFor(o,T,z).scaleSelf(t.size),w.set(M*y,1-(C+1)*m),a=I.computeVertexFor(a,A,z).scaleSelf(t.size),S.set(M*y,1-C*m),a.equalsWithTolerance(o,1e-4)&&a.set(o),M>0?(M==g&&t.isClosed&&(o.set(u),a.set(l)),r.addFace(h,c,o,v.copy(),b.copy(),w.copy()),r.addFace(c,a,o,b.copy(),S.copy(),w.copy())):(u.set(o),l.set(a)),h.set(o),c.set(a),v.set(w),b.set(S)}return r},getFunction:function(){return this.func},setFunction:function(t){this.func=t}}}(o),n.TriangleMesh=o,n.WETriangleMesh=a,n.Terrain=h,n.SurfaceMeshBuilder=c},{"../../internals":98,"../../math/Interpolation2D":118,"../../math/mathUtils":125,"../AABB":42,"../IsectData3D":51,"../Line3D":53,"../Matrix4x4":55,"../Quaternion":58,"../Ray3D":60,"../Sphere":63,"../Triangle3D":68,"../TriangleIntersector":69,"../Vec2D":70,"../Vec3D":71,"../vectors":96,"./Face":79,"./Vertex":88,"./WingedEdge":91,"./subdiv/MidpointSubdivision":94}],93:[function(t,e,i){var n=function(){};n.prototype.compare=function(t,e){return-parseInt(t.getLengthSquared()-e.getLengthSquared(),10)},e.exports=n},{}],94:[function(t,e,i){var n=t("../../../internals"),s=t("./SubdivisionStrategy"),r=function(){s.call(this)};n.extend(r,s),r.prototype.computeSplitPoints=function(t){var e=[];return e.push(t.getMidPoint()),e},e.exports=r},{"../../../internals":98,"./SubdivisionStrategy":95}],95:[function(t,e,i){var n,s,r=t("./EdgeLengthComparator");n=function(){this._order=n.DEFAULT_ORDERING},n.DEFAULT_ORDERING=new r,s=n.prototype,s.getEdgeOrdering=function(){return this._order.compare},s.setEdgeOrdering=function(t){this._order=t},e.exports=n},{"./EdgeLengthComparator":93}],96:[function(t,e,i){var n,s,r=t("../math/mathUtils"),o=t("../internals/has"),a=t("../internals/is"),h=o.XY,c=a.Rect;n=function(t,e){h(t)?(e=t.y,t=t.x):(t=t||0,e=e||0),this.x=t,this.y=e},n.Axis={X:{getVector:function(){return n.X_AXIS},toString:function(){return"Vec2D.Axis.X"}},Y:{getVector:function(){return n.Y_AXIS},toString:function(){return"Vec2D.Axis.Y"}}};var u=function(){var t={x:0,y:0};return function(e,i){return e&&"number"==typeof e.x&&"number"==typeof e.y?e:(void 0!==e&&void 0===i?i=e:void 0===e?e=0:void 0===i&&(i=0),t.x=e,t.y=i,t)}}();n.prototype={abs:function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this},add:function(t,e){var i=new n(t,e);return i.x+=this.x,i.y+=this.y,i},addSelf:function(t,e){var i=u(t,e);return this.x+=i.x,this.y+=i.y,this},angleBetween:function(t,e){if(void 0===e)return Math.acos(this.dot(t));var i=e?this.getNormalized().dot(t.getNormalized()):this.dot(t);return Math.acos(r.clipNormalized(i))},clear:function(){return this.x=this.y=0,this},compareTo:function(t){return this.x==t.x&&this.y==t.y?0:this.magSquared()-t.magSquared()},constrain:function(t,e){return h(t)&&h(e)?(this.x=r.clip(this.x,t.x,e.x),this.y=r.clip(this.y,t.y,e.y)):c(t)&&(this.x=r.clip(this.x,t.x,t.x+t.width),this.y=r.clip(this.y,t.y,t.y+t.height)),this},copy:function(){return new n(this)},cross:function(t){return this.x*t.y-this.y*t.x},distanceTo:function(t){if(void 0!==t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}return NaN},distanceToSquared:function(t){if(void 0!==t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i}return NaN},dot:function(t){return this.x*t.x+this.y*t.y},equals:function(t){return h(t)?this.x==t.x&&this.y==t.y:!1},equalsWithTolerance:function(t,e){return h(t)&&r.abs(this.x-t.x)t*t?this.getNormalizedTo(t):new n(this)},getNormalized:function(){return new n(this).normalize()},getNormalizedTo:function(t){return new n(this).normalizeTo(t)},getPerpendicular:function(){return new n(this).perpendicular()},getReciprocal:function(){return new n(this).reciprocal()},getReflected:function(t){return new n(this).reflect(t)},getRotated:function(t){return new n(this).rotate(t)},getSignum:function(){return new n(this).signum()},heading:function(){return Math.atan2(this.y,this.x)},interpolateTo:function(t,e,i){return void 0===i?new n(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e):new n(i.interpolate(this.x,t.x,e),i.interpolate(this.y,t.y,e))},interpolateToSelf:function(t,e,i){return void 0===i?(this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e):(this.x=i.interpolate(this.x,t.x,e),this.y=i.interpolate(this.y,t.y,e)),this},invert:function(){return this.x*=-1,this.y*=-1,this},isInCircle:function(t,e){var i=this.sub(t).magSquared();return e*e>=i},isInRectangle:function(t){return this.xt.x+t.width?!1:this.yt.y+t.height?!1:!0},isInTriangle:function(t,e,i){var n=this.sub(t).normalize(),s=this.sub(e).normalize(),o=this.sub(i).normalize(),a=Math.acos(n.dot(s));return a+=Math.acos(s.dot(o)),a+=Math.acos(o.dot(n)),Math.abs(a-r.TWO_PI)<=.005},isMajorAxis:function(t){var e=Math.abs(this.x),i=Math.abs(this.y),n=1-t;return e>n?t>i:i>n?t>e:!1},isZeroVector:function(){return Math.abs(this.x)t*t?this.normalize().scaleSelf(t):this},magnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},magSquared:function(){return this.x*this.x+this.y*this.y},max:function(t){return new n(r.max(this.x,t.x),r.max(this.y,t.y))},maxSelf:function(t){return this.x=r.max(this.x,t.x),this.y=r.max(this.y,t.y),this},min:function(t){return new n(r.min(this.x,t.x),r.min(this.y,t.y))},minSelf:function(t){return this.x=r.min(this.x,t.x),this.y=r.min(this.y,t.y),this},normalize:function(){var t=this.x*this.x+this.y*this.y;return t>0&&(t=1/Math.sqrt(t),this.x*=t,this.y*=t),this},normalizeTo:function(t){var e=Math.sqrt(this.x*this.x+this.y*this.y);return e>0&&(e=t/e,this.x*=e,this.y*=e),this},perpendicular:function(){var t=this.x;return this.x=-this.y,this.y=t,this},positiveHeading:function(){var t=Math.sqrt(this.x*this.x+this.y*this.y);return this.y>=0?Math.acos(this.x/t):Math.acos(-this.x/t)+r.PI},reciprocal:function(){return this.x=1/this.x,this.y=1/this.y,this},reflect:function(t){return this.set(t.scale(2*this.dot(t)).subSelf(this))},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),n=e*this.x-i*this.y;return this.y=i*this.x+e*this.y,this.x=n,this},roundToAxis:function(){return Math.abs(this.x)<.5?this.x=0:(this.x=this.x<0?-1:1,this.y=0),Math.abs(this.y)<.5?this.y=0:(this.y=this.y<0?-1:1,this.x=0),this},scale:function(t,e){var i=u(t,e);return new n(this.x*i.x,this.y*i.y)},scaleSelf:function(t,e){var i=u(t,e);return this.x*=i.x,this.y*=i.y,this},set:function(t,e){var i=u(t,e);return this.x=i.x,this.y=i.y,this},setComponent:function(t,e){return"number"==typeof t&&(t=0===t?n.Axis.X:n.Axis.Y),t===n.Axis.X?this.x=e:t===n.Axis.Y&&(this.y=e),this},signum:function(){return this.x=this.x<0?-1:0===this.x?0:1,this.y=this.y<0?-1:0===this.y?0:1,this},sub:function(t,e){var i=u(t,e);return new n(this.x-i.x,this.y-i.y)},subSelf:function(t,e){var i=u(t,e);return this.x-=i.x,this.y-=i.y,this},tangentNormalOfEllipse:function(t,e){var i=this.sub(t),s=e.x*e.x,r=e.y*e.y;return new n(i.x/s,i.y/r).normalize()},toArray:function(){return[this.x,this.y]},toCartesian:function(){var t=this.x*Math.cos(this.y);return this.y=this.x*Math.sin(this.y),this.x=t,this},toPolar:function(){var t=Math.sqrt(this.x*this.x+this.y*this.y);return this.y=Math.atan2(this.y,this.x),this.x=t,this},toString:function(){var t="{x:"+this.x+", y:"+this.y+"}";return t}},n.prototype.bisect=function(t){var e=this.sub(t),i=this.add(t),n=e.dot(i);return new s(e.x,e.y,-n/2)},n.prototype.to3DXY=function(){return new s(this.x,this.y,0)},n.prototype.to3DXZ=function(){return new s(this.x,0,this.y)},n.prototype.to3DYZ=function(){return new s(0,this.x,this.y)},n.X_AXIS=new n(1,0),n.Y_AXIS=new n(0,1),n.ZERO=new n,n.MIN_VALUE=new n(Number.MIN_VALUE,Number.MIN_VALUE),n.MAX_VALUE=new n(Number.MAX_VALUE,Number.MAX_VALUE),n.fromTheta=function(t){return new n(Math.cos(t),Math.sin(t))},n.max=function(t,e){return new n(r.max(t.x,e.x),r.max(t.y,e.y))},n.min=function(t,e){return new n(r.min(t.x,e.x),r.min(t.y,e.y))},n.randomVector=function(t){var e=new n(2*Math.random()-1,2*Math.random()-1);return e.normalize()},s=function(t,e,i){o.XYZ(t)?(this.x=t.x,this.y=t.y,this.z=t.z):void 0===t?(this.x=0,this.y=0,this.z=0):(this.x=t,this.y=e,this.z=i)},s.prototype={abs:function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this},add:function(t,e,i){return o.XYZ(t)?new s(this.x+t.x,this.y+t.y,this.z+t.z):new s(this.x+t,this.y+e,this.z+i)},addSelf:function(t,e,i){return void 0!==t&&void 0!==e&&void 0!==i?(this.x+=t,this.y+=e,this.z+=i):(this.x+=t.x,this.y+=t.y,this.z+=t.z),this},angleBetween:function(t,e){var i;return i=e?this.getNormalized().dot(t.getNormalized()):this.dot(t),Math.acos(i)},clear:function(){return this.x=this.y=this.z=0,this},compareTo:function(t){return this.x==t.x&&this.y==t.y&&this.z==t.z?0:this.magSquared()-t.magSqaured()},constrain:function(t,e){var i;return a.AABB(t)?(e=t.getMax(),i=t.getMin()):i=t,this.x=r.clip(this.x,i.x,e.x),this.y=r.clip(this.y,i.y,e.y),this.z=r.clip(this.z,i.z,e.z),this},copy:function(){return new s(this)},cross:function(t){return new s(this.y*t.z-t.y*this.z,this.z*t.x-t.z*this.x,this.x*t.y-t.x*this.y)},crossInto:function(t,e){var i=t.x,n=t.y,s=t.z;return e.x=this.y*s-n*this.z,e.y=this.z*i-s*this.x,e.z=this.x*n-i*this.y,e},crossSelf:function(t){var e=this.y*t.z-t.y*this.z,i=this.z*t.x-t.z*this.x;return this.z=this.x*t.y-t.x*this.y,this.y=i,this.x=e,this},distanceTo:function(t){if(void 0!==t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return Math.sqrt(e*e+i*i+n*n)}return NaN},distanceToSquared:function(t){if(void 0!==t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}return NaN},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},equals:function(t){return o.XYZ(t)?this.x==t.x&&this.y==t.y&&this.z==t.z:!1},equalsWithTolerance:function(t,e){return Math.abs(this.x-t.x)t*t?this.getNormalizedTo(t):new s(this)},getNormalized:function(){return new s(this).normalize()},getNormalizedTo:function(t){return new s(this).normalizeTo(t)},getReciprocal:function(){return this.copy().reciprocal()},getReflected:function(t){return this.copy().reflect(t)},getRotatedAroundAxis:function(t,e){return new s(this).rotateAroundAxis(t,e)},getRotatedX:function(t){return new s(this).rotateX(t)},getRotatedY:function(t){return new s(this).rotateY(t)},getRotatedZ:function(t){return new s(this).rotateZ(t)},getSignum:function(){return new s(this).signum()},headingXY:function(){return Math.atan2(this.y,this.x)},headingXZ:function(){return Math.atan2(this.z,this.x)},headingYZ:function(){return Math.atan2(this.y,this.z)},immutable:function(){return this},interpolateTo:function(t,e,i){return void 0===i?new s(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e,this.z+(t.z-this.z)*e):new s(i.interpolate(this.y,t.y,e),i.interpolate(this.y,t.y,e),i.interpolate(this.z,t.z,e))},interpolateToSelf:function(t,e,i){return void 0===i?(this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e):(this.x=i.interpolate(this.x,t.x,e),this.y=i.interpolate(this.y,t.y,e),this.z=i.interpolate(this.z,t.z,e)),this},invert:function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},isInAABB:function(t,e){if(e){var i=e.x;if(this.xt.x+i)return!1;if(i=e.y,this.yt.y+i)return!1;if(i=e.y,this.zt.z+i)return!1}else{var n=t.getMin(),s=t.getMax();if(this.xs.x)return!1;if(this.ys.y)return!1;if(this.zs.z)return!1}return!0},isMajorAxis:function(t){var e=r.abs(this.x),i=r.abs(this.y),n=r.abs(this.z),s=1-t;if(e>s){if(t>i)return t>n}else if(i>s){if(t>e)return t>n}else if(n>s&&t>e)return t>i;return!1},isZeroVector:function(){return Math.abs(this.x)t*t?this.normalize().scaleSelf(t):this},magnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},magSquared:function(){return this.x*this.x+this.y*this.y+this.z*this.z},maxSelf:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},minSelf:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},modSelf:function(t,e,i){return(void 0===e||void 0===i)&&(e=i=t),this.x%=t,this.y%=e,this.z%=i,this},normalize:function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return t>0&&(t=1/t,this.x*=t,this.y*=t,this.z*=t),this},normalizeTo:function(t){var e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return e>0&&(e=t/e,this.x*=e,this.y*=e,this.z*=e),this},reciprocal:function(){return this.x=1/this.x,this.y=1/this.y,this.z=1/this.z,this},reflect:function(t){return this.set(t.scale(2*this.dot(t)).subSelf(this))},rotateAroundAxis:function(t,e){var i=t.x,n=t.y,s=t.z,r=i*this.x,o=i*this.y,a=i*this.z,h=n*this.x,c=n*this.y,u=n*this.z,l=s*this.x,f=s*this.y,p=s*this.z,g=Math.sin(e),d=Math.cos(e),m=i*(r+c+p)+(this.x*(n*n+s*s)-i*(c+p))*d+(-f+u)*g,y=n*(r+c+p)+(this.y*(i*i+s*s)-n*(r+p))*d+(l-a)*g,x=s*(r+c+p)+(this.z*(i*i+n*n)-s*(r+c))*d+(-h+o)*g; return this.x=m,this.y=y,this.z=x,this},rotateX:function(t){var e=Math.cos(t),i=Math.sin(t),n=e*this.z-i*this.y;return this.y=i*this.z+e*this.y,this.z=n,this},rotateY:function(t){var e=Math.cos(t),i=Math.sin(t),n=e*this.x-i*this.z;return this.z=i*this.x+e*this.z,this.x=n,this},rotateZ:function(t){var e=Math.cos(t),i=Math.sin(t),n=e*this.x-i*this.y;return this.y=i*this.x+e*this.y,this.x=n,this},roundToAxis:function(){return Math.abs(this.x)<.5?this.x=0:(this.x=this.x<0?-1:1,this.y=this.z=0),Math.abs(this.y)<.5?this.y=0:(this.y=this.y<0?-1:1,this.x=this.z=0),Math.abs(this.z)<.5?this.z=0:(this.z=this.z<0?-1:1,this.x=this.y=0),this},scale:function(t,e,i){return o.XYZ(t)?new s(this.x*t.x,this.y*t.y,this.z*t.z):((void 0===e||void 0===i)&&(e=i=t),new s(this.x*t,this.y*e,this.z*i))},scaleSelf:function(t,e,i){return o.XYZ(t)?(this.x*=t.x,this.y*=t.y,this.z*=t.z,this):((void 0===e||void 0===i)&&(e=i=t),this.x*=t,this.y*=e,this.z*=i,this)},set:function(t,e,i){return o.XYZ(t)?(this.x=t.x,this.y=t.y,this.z=t.z,this):((void 0===e||void 0===i)&&(e=i=t),this.x=t,this.y=e,this.z=i,this)},setXY:function(t){return this.x=t.x,this.y=t.y,this},shuffle:function(t){for(var e,i=0;t>i;i++)switch(Math.floor(3*Math.random())){case 0:e=this.x,this.x=this.y,this.z=e;break;case 1:e=this.x,this.x=this.z,this.z=e;break;case 2:e=this.y,this.y=this.z,this.z=e}return this},signum:function(){return this.x=this.x<0?-1:0===this.x?0:1,this.y=this.y<0?-1:0===this.y?0:1,this.z=this.z<0?-1:0===this.z?0:1,this},sub:function(t,e,i){return o.XYZ(t)?new s(this.x-t.x,this.y-t.y,this.z-t.z):((void 0===e||void 0===i)&&(e=i=t),new s(this.x-t,this.y-e,this.z-i))},subSelf:function(t,e,i){return o.XYZ(t)?(this.x-=t.x,this.y-=t.y,this.z-=t.z,this):((void 0===e||void 0===i)&&(e=i=t),this.x-=t,this.y-=e,this.z-=i,this)},to2DXY:function(){return new n(this.x,this.y)},to2DXZ:function(){return new n(this.x,this.z)},to2DYZ:function(){return new n(this.y,this.z)},toArray:function(){return[this.x,this.y,this.z]},toArray4:function(t){var e=this.toArray();return e[3]=t,e},toCartesian:function(){var t=this.x*Math.cos(this.z),e=t*Math.cos(this.y),i=this.x*Math.sin(this.z),n=t*Math.sin(this.y);return this.x=e,this.y=i,this.z=n,this},toSpherical:function(){var t=Math.abs(this.x)<=r.EPS?r.EPS:this.x,e=this.z,i=Math.sqrt(t*t+this.y*this.y+e*e);return this.z=Math.asin(this.y/i),this.y=Math.atan(e/t)+(0>t?Math.PI:0),this.x=i,this},toString:function(){return"[ x: "+this.x+", y: "+this.y+", z: "+this.z+"]"}},s.MIN_VALUE=new s(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),s.MAX_VALUE=new s(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s.fromXYTheta=function(t){return new s(Math.cos(t),Math.sin(t),0)},s.fromXZTheta=function(t){return new s(Math.cos(t),0,Math.sin(t))},s.fromYZTheta=function(t){return new s(0,Math.cos(t),Math.sin(t))},s.max=function(t,e){return new s(Math.max(t.x,e.x),Math.max(t.y,e.y),Math.max(t.z,e.z))},s.min=function(t,e){return new s(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.min(t.z,e.z))},s.randomVector=function(){var t=new s(2*Math.random()-1,2*Math.random()-1,2*Math.random()-1);return t.normalize()},s.ZERO=new s(0,0,0),s.X_AXIS=new s(1,0,0),s.Y_AXIS=new s(0,1,0),s.Z_AXIS=new s(0,0,1),s.Axis={X:{getVector:function(){return s.X_AXIS},toString:function(){return"Vec3D.Axis.X"}},Y:{getVector:function(){return s.Y_AXIS},toString:function(){return"Vec3D.Axis.Y"}},Z:{getVector:function(){return s.Z_AXIS},toString:function(){return"Vec3D.Axis.Z"}}},i.Vec2D=n,i.Vec3D=s},{"../internals/has":105,"../internals/is":106,"../math/mathUtils":125}],97:[function(t,e,i){i.color=t("./color"),i.geom=t("./geom"),i.internals=t("./internals"),i.math=t("./math"),i.physics2d=t("./physics2d"),i.processing=t("./processing"),i.THREE=t("./THREE"),i.util=t("./util")},{"./THREE":1,"./color":3,"./geom":41,"./internals":98,"./math":112,"./physics2d":140,"./processing":160,"./util":162}],98:[function(t,e,i){i.is=t("./internals/is"),i.has=t("./internals/has"),i.extend=t("./internals/extend"),i.each=t("./internals/each"),i.bind=t("./internals/bind"),i.keys=t("./internals/keys"),i.values=t("./internals/values"),i.filter=t("./internals/filter"),i.mixin=t("./internals/mixin"),i.Iterator=t("./internals/Iterator"),i.LinkedMap=t("./internals/LinkedMap"),i.numberComparator=t("./internals/numberComparator"),i.removeItemFrom=t("./internals/removeItemFrom")},{"./internals/Iterator":99,"./internals/LinkedMap":100,"./internals/bind":101,"./internals/each":102,"./internals/extend":103,"./internals/filter":104,"./internals/has":105,"./internals/is":106,"./internals/keys":107,"./internals/mixin":108,"./internals/numberComparator":109,"./internals/removeItemFrom":110,"./internals/values":111}],99:[function(t,e,i){var n=t("./is"),s=function(t){this.__it=t.slice(0)};s.prototype={hasNext:function(){return this.__it.length>0},next:function(){return this.__it.shift()}};var r=function(t){this.__obj={},this.__keys=[];for(var e in t)this.__obj[e]=t[e],this.__keys.push(e);this.__it=new s(this.__keys)};r.prototype={hasNext:function(){return this.__it.hasNext()},next:function(){var t=this.__it.next();return this.__obj[t]}};var o=function(t){return n.array(t)?new s(t):new r(t)};e.exports=o},{"./is":106}],100:[function(t,e,i){var n=t("./each"),s=function(t){this.__list=[],this.__map={},"function"==typeof t&&(this.generateKey=t)};s.prototype={each:function(t){n(this.__map,t)},get:function(t){var e=this.__map[t];return void 0===e&&(t=this.generateKey(t),e=this.__map[t]),e},generateKey:function(t){return t.toString()},getArray:function(){return this.__list},has:function(t){var e=this,i=function(t){return void 0!==e.__map[t]};return i(t)?!0:this.__map[id]?!0:this.__map[this.generateKey(t)]},put:function(t,e){t=this.generateKey(t),this.__map[t]=e,this.__list.push(e)},remove:function(t){t=this.get(t);var e=this.generateKey(t);return delete this.__map[e],this.__list.splice(this.__list.indexOf(t),1)[0]},size:function(){return this.__list.length},values:function(){return this.__list.slice(0)}},e.exports=s},{"./each":102}],101:[function(t,e,i){var n={};e.exports=function(t,e){var i,s,r=Function.prototype,o=Array.prototype.slice;return t.bind===r.bind&&r.bind?r.bind.apply(t,o.call(arguments,1)):(i=o.call(arguments,2),s=function(){if(!(this instanceof s))return t.apply(e,i.concat(o.call(arguments)));n.prototype=t.prototype;var r=new n;n.prototype=null;var a=t.apply(r,i.concat(o.call(arguments)));return Object(a)===a?a:r})}},{}],102:[function(t,e,i){var n={};e.exports=function(t,e,i){if(null!=t)if(Array.prototype.forEach&&t.forEach===Array.prototype.forEach)t.forEach(e,i);else if(t.length===+t.length){for(var s=0,r=t.length;r>s;s++)if(s in t&&e.call(i,t[s],s,t)===n)return}else for(var o in t)if(hasOwnProperty.call(t,o)&&e.call(i,t[o],o,t)===n)return}},{}],103:[function(t,e,i){e.exports=function(t,e){if("function"!=typeof t)throw Error("childClass was not function, possible circular: ",t);if("function"!=typeof e)throw Error("superClass was not function, possible circular: ",e);t.prototype=Object.create(e.prototype),t.constructor=t,t.prototype.parent=e.prototype}},{}],104:[function(t,e,i){e.exports=function(t,e,n){var s=[];return null==t?s:Array.prototype.filter&&t.filter===Array.prototype.filter?t.filter(e,n):(i.each(t,function(t,i,r){e.call(n,t,i,r)&&(s[s.length]=t)}),s)}},{}],105:[function(t,e,i){var n=function(t,e){if(void 0===t||"object"!=typeof t)return!1;var i,n=0,s=e.length;for(n=0;s>n;n++)if(i=e[n],!(i in t))return!1;return!0};i.property=function(t,e){return hasOwnProperty.call(t,e)},i.all=n,i.typedArrays=function(){return"undefined"!=typeof Int32Array&&"undefined"!=typeof Float32Array&&"undefined"!=typeof Uint8Array},i.XY=function(t){return t&&"number"==typeof t.x&&"number"==typeof t.y},i.XYZ=function(t){return t&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.z},i.XYWidthHeight=function(t){return t&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.width&&"number"==typeof t.height}},{}],106:[function(t,e,i){var n=t("./has"),s=function(t){return function(e){return n.all(e,t)}};i.Array=Array.isArray||function(t){return"[object Array]"==t.toString()},i.Object=function(t){return"object"==typeof t},i.undef=function(t){return void 0===t},i.existy=function(t){return null!=t},i.String=function(t){return"string"==typeof t},i.Number=function(t){return"number"==typeof t},i.Function=function(t){return"function"==typeof t},i.AABB=s(["setExtent","getNormalForPoint"]),i.ColorGradient=s(["gradient","interpolator","maxDither","addColorAt","calcGradient"]),i.ColorList=s(["add","addAll","adjustBrightness","adjustSaturation"]),i.ColorRange=s(["add","addAlphaRange","addBrightnessRange","addHueRange"]),i.Circle=s(["getCircumference","getRadius","intersectsCircle"]),i.FloatRange=s(["min","max","adjustCurrentBy","getMedian"]),i.Hue=s(["getHue","isPrimary"]),i.Line2D=s(["closestPointTo","intersectLine","getLength"]),i.Matrix4x4=s(["identity","invert","setFrustrum"]),i.Rect=s(["x","y","width","height","getArea","getCentroid","getDimensions"]),i.Sphere=s(["x","y","z","radius","toMesh"]),i.ScaleMap=s(["mapFunction","setInputRange","setOutputRange","getMappedValueFor"]),i.TColor=s(["rgb","cmyk","hsv"]),i.ParticleBehavior=s(["applyBehavior","configure"]),i.VerletParticle2D=s(["x","y","weight"])},{"./has":105}],107:[function(t,e,i){e.exports=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var n in t)i.has(t,n)&&e.push(n);return e}},{}],108:[function(t,e,i){var n=t("./each");e.exports=function(t,e){return n(e,function(e,i){t[i]=e}),t}},{"./each":102}],109:[function(t,e,i){e.exports=function(t,e){return t==e?0:e>t?-1:t>e?1:void 0}},{}],110:[function(t,e,i){e.exports=function(t,e){var i=e.indexOf(t);return i>-1?e.splice(i,1):void 0}},{}],111:[function(t,e,i){var n=t("./has");e.exports=function(t){var e=[];for(var i in t)n.property(t,i)&&e.push(t[i]);return e}},{"./has":105}],112:[function(t,e,i){e.exports={BezierInterpolation:t("./math/BezierInterpolation"),CircularInterpolation:t("./math/CircularInterpolation"),CosineInterpolation:t("./math/CosineInterpolation"),DecimatedInterpolation:t("./math/DecimatedInterpolation"),ExponentialInterpolation:t("./math/ExponentialInterpolation"),Interpolation2D:t("./math/Interpolation2D"),LinearInterpolation:t("./math/LinearInterpolation"),mathUtils:t("./math/mathUtils"),MathUtils:t("./math/mathUtils"),ScaleMap:t("./math/ScaleMap"),SigmoidInterpolation:t("./math/SigmoidInterpolation"),SinCosLUT:t("./math/SinCosLUT"),ThresholdInterpolation:t("./math/ThresholdInterpolation"),ZoomLensInterpolation:t("./math/ZoomLensInterpolation")},e.exports.noise=t("./math/noise"),e.exports.waves=t("./math/waves")},{"./math/BezierInterpolation":113,"./math/CircularInterpolation":114,"./math/CosineInterpolation":115,"./math/DecimatedInterpolation":116,"./math/ExponentialInterpolation":117,"./math/Interpolation2D":118,"./math/LinearInterpolation":119,"./math/ScaleMap":120,"./math/SigmoidInterpolation":121,"./math/SinCosLUT":122,"./math/ThresholdInterpolation":123,"./math/ZoomLensInterpolation":124,"./math/mathUtils":125,"./math/noise":126,"./math/waves":129}],113:[function(t,e,i){var n=function(t,e){this.c1=t,this.c2=e};n.interpolate=function(t,e,i,n,s){var r=i*i,o=1-i,a=o*o;return t*a*o+3*(n*(e-t)+t)*i*a+3*(s*(e-t)+e)*r*o+e*r*i},n.prototype={interpolate:function(t,e,i){var n=i*i,s=1-i,r=s*s;return t*r*s+3*(this.c1*(e-t)+t)*i*r+3*(this.c2*(e-t)+e)*n*s+e*n*i},setCoefficients:function(t,e){this.c1=t,this.c2=e}},e.exports=n},{}],114:[function(t,e,i){var n=function(t){void 0===t&&(this.isFlipped=!1)};n.interpolate=function(t,e,i,n){return n?t-(e-t)*(Math.sqrt(1-i*i)-1):(i=1-i,t+(e-t)*Math.sqrt(1-i*i))},n.prototype.interpolate=function(t,e,i){return this.isFlipped?t-(e-t)*(Math.sqrt(1-i*i)-1):(i=1-i,t+(e-t)*Math.sqrt(1-i*i))},n.prototype.setFlipped=function(t){this.isFlipped=t},e.exports=n},{}],115:[function(t,e,i){var n=function(){};n.interpolate=function(t,e,i){return e+(t-e)*(.5+.5*Math.cos(i*Math.PI))},n.prototype.interpolate=n.interpolate,e.exports=n},{}],116:[function(t,e,i){var n=t("./LinearInterpolation"),s=function(t,e){if(void 0===t)throw new Error("steps was not passed to constructor");this.numSteps=t,this.strategy=e||new n};s.prototype={interpolate:function(t,e,i){var n=Math.floor(i*this.numSteps)/this.numSteps;return this.strategy.interpolate(t,e,n)}},e.exports=s},{"./LinearInterpolation":119}],117:[function(t,e,i){var n=function(t){this.exponent=void 0===t?2:t};n.interpolate=function(t,e,i,n){return t+(e-t)*Math.pow(i,n)},n.prototype.interpolate=function(t,e,i){return t+(e-t)*Math.pow(i,this.exponent)},e.exports=n},{}],118:[function(t,e,i){var n=t("../internals"),s={};s.bilinear=function(t,e,i,s,r,o,a,h,c,u){var l,f,p,g,d,m,y,x,v,b;n.has.XY(t)?(l=t.x,f=t.y,p=e.x,g=e.y,d=i.x,m=i.y,y=s,x=r,v=o,b=a):(l=t,f=e,p=i,g=s,d=r,m=o,y=a,x=h,v=c,b=u);var w=1/((d-p)*(m-g)),S=(l-p)*w,C=(d-l)*w,A=f-g,T=m-f;return y*C*T+x*S*T+v*C*A+b*S*A},e.exports=s},{"../internals":98}],119:[function(t,e,i){var n=function(){},s=function(t,e,i){return t+(e-t)*i};n.interpolate=s,n.prototype.interpolate=s,e.exports=n},{}],120:[function(t,e,i){var n=t("./mathUtils"),s=t("./LinearInterpolation"),r=function(t,e){this.min=t,this.max=e};r.prototype.toString=function(){return"{ min: "+this.min+", max: "+this.max+"}"};var o=function(t,e,i,n){if(1==arguments.length&&void 0!==arguments[0].input&&void 0!==arguments[0].output){var r=arguments[0];i=r.output.min,n=r.output.max,e=r.input.max,t=r.input.min}this.mapFunction=new s,this.setInputRange(t,e),this.setOutputRange(i,n)};o.prototype={getClippedValueFor:function(t){var e=n.clipNormalized((t-this._in.min)/this._interval);return this.mapFunction.interpolate(0,this.mapRange,e)+this._out.min},getInputMedian:function(){return.5*(this._in.min+this._in.max)},getInputRange:function(){return this._in},getMappedMedian:function(){return this.getMappedValueFor(.5)},getMappedValueFor:function(t){var e=(t-this._in.min)/this._interval;return this.mapFunction.interpolate(0,this.mapRange,e)+this._out.min},getOutputMedian:function(){return.5*(this._out.min+this._out.max)},getOutputRange:function(){return this._out},setInputRange:function(t,e){this._in=new r(t,e),this._interval=e-t},setMapFunction:function(t){this.mapFunction=t},setOutputRange:function(t,e){this._out=new r(t,e),this.mapRange=e-t},toString:function(){return"ScaleMap, inputRange: "+this._in.toString()+" outputRange: "+this._out.toString()}},e.exports=o},{"./LinearInterpolation":119,"./mathUtils":125}],121:[function(t,e,i){var n=function(t){void 0===t&&(t=2),this.setSharpness(t)},s=function(t,e,i,n){return i=(2*i-1)*n,i=1/(1+Math.exp(-i)),t+(e-t)*i};n.prototype={getSharpness:function(){return this.sharpness},interpolate:function(t,e,i){return s(t,e,i,this.sharpPremult)},setSharpness:function(t){this.sharpness=t,this.sharpPremult=5*t}},n.interpolate=s,e.exports=n},{}],122:[function(t,e,i){var n=t("./mathUtils"),s=function(t){t||(t=s.DEFAULT_PRECISION),this.precision=t,this.period=360/this.precision,this.quadrant=this.period>>2,this.deg2rad=Math.PI/180*this.precision,this.rad2deg=180/Math.PI/this.precision,this.sinLUT=[];for(var e=0;et;)t+=n.TWO_PI;return this.sinLUT[(t*this.rad2deg+this.quadrant)%this.period]},getPeriod:function(){return this.period},getPrecision:function(){return this.precision},getSinLUT:function(){return this.sinLUT},sin:function(t){for(;0>t;)t+=n.TWO_PI;return this.sinLUT[t*this.rad2deg%this.period]}},s.DEFAULT_PRECISION=.25,s.DEFAULT_INSTANCE=void 0,s.getDefaultInstance=function(){return void 0===s.DEFAULT_INSTANCE&&(s.DEFAULT_INSTANCE=new s),s.DEFAULT_INSTANCE},e.exports=s},{"./mathUtils":125}],123:[function(t,e,i){var n=function(t){this.threshold=t},s=function(t,e,i,n){return n>i?t:e};n.prototype={interpolate:function(t,e,i){return i0),this.rightImpl.setFlipped(this.lensStrength<0)};r.prototype={interpolate:function(t,e,i){var n=t+(e-t)*i;return n+=i0),this.rightImpl.setFlipped(this.lensStrength<0)}},e.exports=r},{"./CircularInterpolation":114,"./mathUtils":125}],125:[function(t,e,i){var n={};n.SQRT2=Math.sqrt(2),n.SQRT3=Math.sqrt(3),n.LOG2=Math.log(2),n.PI=3.141592653589793,n.INV_PI=1/n.PI,n.HALF_PI=n.PI/2,n.THIRD_PI=n.PI/3,n.QUARTER_PI=n.PI/4,n.TWO_PI=2*n.PI,n.THREE_HALVES_PI=n.TWO_PI-n.HALF_PI,n.PI_SQUARED=n.PI*n.PI,n.EPS=1.1920928955078125e-7,n.DEG2RAD=n.PI/180,n.RAD2DEG=180/n.PI,n.SHIFT23=1<<23,n.INV_SHIFT23=1/n.SHIFT23,n.SIN_A=-4/(n.PI*n.PI),n.SIN_B=4/n.PI,n.SIN_P=.225,n.abs=Math.abs,n.ceilPowerOf2=function(t){for(var e=1;t>e;)e<<=1;return e},n.clip=function(t,e,i){return e>t?e:t>i?i:t},n.clipNormalized=function(t){return 0>t?0:t>1?1:t},n.cos=Math.cos,n.degrees=function(t){return t*n.RAD2DEG},n.fastCos=function(t){return n.fastSin(t+(t>n.HALF_PI?-n.THREE_HALVES_PI:n.HALF_PI))},n.fastSin=function(t){return t=n.SIN_B*t+n.SIN_A*t*Math.abs(t),n.SIN_P*(t*Math.abs(t)-t)+t},n.flipCoin=function(t){return Math.random()<.5},n.floor=function(t){var e=~~t;return 0>t&&t!=e&&e--,e},n.floorPowerOf2=function(t){return~~Math.pow(2,parseInt(Math.log(t)/n.LOG2,10))},n.max=function(t,e,i){return void 0===i?Math.max(t,e):t>e?t>i?t:i:e>i?e:i},n.min=function(t,e,i){return void 0===i?Math.min(t,e):e>t?i>t?t:i:i>e?e:i},n.normalizedRandom=function(){return 2*Math.random()-1},n.radians=function(t){return t*n.DEG2RAD},n.random=function(t,e,i){return 1===arguments.length?Math.random()*arguments[0]:(2==arguments.length&&(i=e,e=t,t=Math.random),e||i?i?t()*(i-e)+e:(i=e,t()*i):Math.random())},n.reduceAngle=function(t){return t%=n.TWO_PI,Math.abs(t)>n.PI&&(t-=n.TWO_PI),Math.abs(t)>n.HALF_PI&&(t=n.PI-t),t},n.sign=function(t){return 0>t?-1:t>0?1:0},n.sin=function(t){return t=n.reduceAngle(t),Math.abs(t)<=n.QUARTER_PI?n.fastSin(t):n.fastCos(n.HALF_PI-t)},e.exports=n},{}],126:[function(t,e,i){e.exports={PerlinNoise:t("./noise/PerlinNoise"),simplexNoise:t("./noise/simplexNoise")}},{"./noise/PerlinNoise":127,"./noise/simplexNoise":128}],127:[function(t,e,i){var n=t("../SinCosLUT"),s=t("../../internals/has").typedArrays(),r={};r.pow=Math.pow,r.random=Math.random,function(t,e,i,n,s,r,o){function a(t){var e,n,s=this,r=t.length,o=0,a=s.i=s.j=s.m=0;for(s.S=[],s.c=[],r||(t=[r++]);i>o;)s.S[o]=o++;for(o=0;i>o;o++)e=s.S[o],a=u(a+e+t[o%r]),n=s.S[a],s.S[o]=n,s.S[a]=e;s.g=function(t){var e=s.S,n=u(s.i+1),r=e[n],o=u(s.j+r),a=e[o];e[n]=a,e[o]=r;for(var h=e[u(r+a)];--t;)n=u(n+1),r=e[n],o=u(o+r),a=e[o],e[n]=a,e[o]=r,h=h*i+e[u(r+a)];return s.i=n,s.j=o,h},s.g(i)}function h(t,e,i,n,s){if(i=[],s=typeof t,e&&"object"==s)for(n in t)if(n.indexOf("S")<5)try{i.push(h(t[n],e-1))}catch(r){}return i.length?i:t+("string"!=s?"\x00":"")}function c(t,e,i,n){for(t+="",i=0,n=0;nt;)t=(t+a)*i,e*=i,a=f.g(1);for(;t>=r;)t/=2,e/=2,a>>>=1;return(t+a)/e},u},o=e.pow(i,n),s=e.pow(2,s),r=2*s,c(e.random(),t)}([],r,256,6,52);var o=4,a=1<n;n++)this._perlin[n]=r.random()}this._perlin_cosTable=this._sinCosLUT.getSinLUT(),this._perlin_TWOPI=this._perlin_PI=this._sinCosLUT.getPeriod(),this._perlin_PI>>=1,0>t&&(t=-t),0>e&&(e=-e),0>i&&(i=-i);var p,g,d,m,y,x,v=t,b=e,w=i,S=t-v,C=e-b,A=i-w,T=0,M=.5;for(n=0;nM));n++)v<<=1,S*=2,b<<=1,C*=2,w<<=1,A*=2,S>=1&&(v++,S--),C>=1&&(b++,C--),A>=1&&(w++,A--);return T},noiseDetail:function(t,e){t>0&&(this._perlin_octaves=t),e&&e>0&&(this._perlin_amp_falloff=e)},noiseSeed:function(t){r.seedrandom(t)}},e.exports=p},{"../../internals/has":105,"../SinCosLUT":122}],128:[function(t,e,i){var n=t("../../internals/each"),s=t("../../internals/has"),r=Math.sqrt(3),o=Math.sqrt(5),a=.5*(r-1),h=(3-r)/6,c=2*h-1,u=1/3,l=1/6,f=(o-1)/4,p=(5-o)/20,g=2*p,d=3*p,m=4*p-1,y=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],x=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],v=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],b=function(){for(var t=s.typedArrays()?new Int32Array(512):[],e=0;512>e;e++)t[e]=v[255&e];return t}(),w=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]];if(s.typedArrays()){var S=function(t){var e=[];return n(t,function(t){e.push(new Int32Array(t))}),e};y=S(y),x=S(x),v=new Int32Array(v),w=S(w),this.testObjs={_grad3:y,_grad4:x,_p:v,_simplex:w}}var C=function(t,e,i,n,s){var r=t[0]*e+t[1]*i;return n&&(r+=t[2]*n,s&&(r+=t[3]*s)),r},A=function(t){return t>=0?Math.floor(t):Math.floor(t-1)},T={noise:function(t,e,i,n){var s=arguments.length,r=0,o=0,v=0,S=0,T=0,M=function(){switch(s){case 2:return(t+e)*a;case 3:return(t+e+i)*u;case 4:return(t+e+i+n)*f;default:throw new Error("Wrong arguments supplied to SimplexNoise.noise()")}}(),z=A(t+M),I=A(e+M),R=void 0!==i?A(i+M):void 0,P=void 0!==n?A(n+M):void 0,D=function(){switch(s){case 2:return(z+I)*h;case 3:return(z+I+R)*l;case 4:return(z+I+R+P)*p}}(),L=t-(z-D),_=e-(I-D),E=void 0!==i?i-(R-D):void 0,V=void 0!==n?n-(P-D):void 0;return 2==s?function(){var t,e,i,n,s,a,u,l,f,p,g,d,m;L>_?(t=1,e=0):(t=0,e=1),i=L-t+h,n=_-e+h,s=L+c,a=_+c,u=255&z,l=255&I,f=.5-L*L-_*_,f>0&&(f*=f,p=b[u+b[l]]%12,r=f*f*C(y[p],L,_));var x=.5-i*i-n*n;return x>0&&(x*=x,g=b[u+t+b[l+e]]%12,o=x*x*C(y[g],i,n)),m=.5-s*s-a*a,m>0&&(m*=m,d=b[u+1+b[l+1]]%12,v=m*m*C(y[d],s,a)),70*(r+o+v)}():3==s?function(){var t,e,i,n,s,a,h,c,f,p,g,d,m,x,w,A,T,M,P,D,V,N,B,F,k,q;return L>=_?_>=E?(t=1,e=0,i=0,n=1,s=1,a=0):L>=E?(t=1,e=0,i=0,n=1,s=0,a=1):(t=0,e=0,i=1,n=1,s=0,a=1):E>_?(t=0,e=0,i=1,n=0,s=1,a=1):E>L?(t=0,e=1,i=0,n=0,s=1,a=1):(t=0,e=1,i=0,n=1,s=1,a=0),h=L-t+l,c=_-e+l,f=E-i+l,p=L-n+u,g=_-s+u,d=E-a+u,m=L-.5,x=_-.5,w=E-.5,A=255&z,T=255&I,M=255&R,P=.6-L*L-_*_-E*E,P>0&&(P*=P,D=b[A+b[T+b[M]]]%12,r=P*P*C(y[D],L,_,E)),V=.6-h*h-c*c-f*f,V>0&&(V*=V,N=b[A+t+b[T+e+b[M+i]]]%12,o=V*V*C(y[N],h,c,f)),B=.6-p*p-g*g-d*d,B>0&&(B*=B,F=b[A+n+b[T+s+b[M+a]]]%12,v=B*B*C(y[F],p,g,d)),k=.6-m*m-x*x-w*w,k>0&&(k*=k,q=b[A+1+b[T+1+b[M+1]]]%12,S=k*k*C(y[q],m,x,w)),32*(r+o+v+S)}():function(){var t,e,i,n,s,a,h,c,u,l,f,y,A,M,D,N,B,F,k,q,O,U,H,G,W,Y,X,Z,j,K,Q,J,$,tt,et,it,nt,st,rt,ot,at,ht,ct=w[function(){var t=0;return L>_&&(t=32),L>E&&(t|=16),_>E&&(t|=8),L>V&&(t|=4),_>V&&(t|=2),E>V&&(t|=1),t}()];return t=ct[0]>=3?1:0,e=ct[1]>=3?1:0,i=ct[2]>=3?1:0,n=ct[3]>=3?1:0,s=ct[0]>=2?1:0,a=ct[1]>=2?1:0,h=ct[2]>=2?1:0,c=ct[3]>=2?1:0,u=ct[0]>=1?1:0,l=ct[1]>=1?1:0,f=ct[2]>=1?1:0,y=ct[3]>=1?1:0,A=L-t+p,M=_-e+p,D=E-i+p,N=V-n+p,B=L-s+g,F=_-a+g,k=E-h+g,q=V-c+g,O=L-u+d,U=_-l+d,H=E-f+d,G=V-y+d,W=L+m,Y=_+m,X=E+m,Z=V+m,j=255&z,K=255&I,Q=255&R,J=255&P,$=.6-L*L-_*_-E*E-V*V,$>0&&($*=$,tt=b[j+b[K+b[Q+b[J]]]]%32,r=$*$*C(x[tt],L,_,E,V)),et=.6-A*A-M*M-D*D-N*N,et>0&&(et*=et,it=b[j+t+b[K+e+b[Q+i+b[J+n]]]]%32,o=et*et*C(x[it],A,M,D,N)),nt=.6-B*B-F*F-k*k-q*q,nt>0&&(nt*=nt,st=b[j+s+b[K+a+b[Q+h+b[J+c]]]]%32,v=nt*nt*C(x[st],B,F,k,q)),rt=.6-O*O-U*U-H*H-G*G,rt>0&&(rt*=rt,ot=b[j+u+b[K+l+b[Q+f+b[J+y]]]]%32,S=rt*rt*C(x[ot],O,U,H,G)),at=.6-W*W-Y*Y-X*X-Z*Z,at>0&&(at*=at,ht=b[j+1+b[K+1+b[Q+1+b[J+1]]]]%32,T=at*at*C(x[ht],W,Y,X,Z)),27*(r+o+v+S+T)}()}};e.exports=T},{"../../internals/each":102,"../../internals/has":105}],129:[function(t,e,i){e.exports={AbstractWave:t("./waves/AbstractWave"),AMFMSineWave:t("./waves/AMFMSineWave"),ConstantWave:t("./waves/ConstantWave"),FMHarmonicSquareWave:t("./waves/FMHarmonicSquareWave"),FMSawtoothWave:t("./waves/FMSawtoothWave"),FMSineWave:t("./waves/FMSineWave"),FMSquareWave:t("./waves/FMSquareWave"),FMTriangleWave:t("./waves/FMTriangleWave"),SineWave:t("./waves/SineWave"),WaveState:t("./waves/WaveState")}},{"./waves/AMFMSineWave":130,"./waves/AbstractWave":131,"./waves/ConstantWave":132,"./waves/FMHarmonicSquareWave":133,"./waves/FMSawtoothWave":134,"./waves/FMSineWave":135,"./waves/FMSquareWave":136,"./waves/FMTriangleWave":137,"./waves/SineWave":138,"./waves/WaveState":139}],130:[function(t,e,i){var n=t("../../internals").extend,s=t("./AbstractWave"),r=function(t,e,i,n,r){"number"==typeof i?(s.call(this,t,e,1,i),this.amod=n,this.fmod=r):(s.call(this,t,e),this.amod=i,this.fmod=n)};n(r,s),r.prototype.getClass=function(){return"AMFMSineWave"},r.prototype.pop=function(){this.parent.pop.call(this),this.amod.pop(),this.fmod.pop()},r.prototype.push=function(){this.parent.push.call(this),this.amod.push(),this.fmod.push()},r.prototype.reset=function(){this.parent.reset.call(this),this.fmod.reset(),this.amod.reset()},r.prototype.update=function(){return this.amp=this.amod.update(),this.value=this.amp*Math.sin(this.phase)+this.offset,this.cyclePhase(this.frequency+this.fmod.update()),this.value},e.exports=r},{"../../internals":98,"./AbstractWave":131}],131:[function(t,e,i){var n=t("./WaveState"),s=function(t,e){return"number"==typeof t?t:e},r=function(t,e,i,n){"object"!=typeof arguments[0]||e||i||n||(n=t.offset,i="number"==typeof t.amp?t.amp:t.amplitude,e="number"==typeof t.freq?t.freq:t.frequency,t=t.phase),this.setPhase(s(t,0)),this.frequency=s(e,0),this.amp=s(i,1),this.offset=s(n,0)};r.prototype={cyclePhase:function(t){return void 0===t&&(t=0),this.phase=(this.phase+t)%r.TWO_PI,this.phase<0&&(this.phase+=r.TWO_PI),this.phase},getClass:function(){return"AbstractWave"},pop:function(){if(void 0===this.stateStack||void 0!==this.stateStack&&this.stateStack.length<=0)return console.log(this.toString()),void console.log("no wave states on stack");var t=this.stateStack.pop();this.phase=t.phase,this.frequency=t.frequency,this.amp=t.amp,this.offset=t.offset},push:function(){void 0===this.stateStack&&(this.stateStack=[]),this.stateStack.push(new n(this.phase,this.frequency,this.amp,this.offset))},reset:function(){this.phase=this.origPhase},setPhase:function(t){this.phase=t,this.cyclePhase(),this.origPhase=t},toString:function(){return this.getClass()+" phase:"+this.phase+" frequency: "+this.frequency+" amp: "+this.amp+" offset: "+this.offset},update:function(){console.log(this.getClass()+" this should be overridden")}},r.PI=3.141592653589793,r.TWO_PI=2*r.PI,r.hertzToRadians=function(t,e){return t/e*r.TWO_PI},r.radiansToHertz=function(t,e){return t/r.TWO_PI*e},e.exports=r},{"./WaveState":139}],132:[function(t,e,i){var n=t("../../internals").extend,s=t("./AbstractWave"),r=function(t){s.apply(this),this.value=t};n(r,s),r.prototype.getClass=function(){return"ConstantWave"},r.prototype.update=function(){return this.value},e.exports=r},{"../../internals":98,"./AbstractWave":131}],133:[function(t,e,i){var n=t("../../internals").extend,s=t("./AbstractWave"),r=function(t,e,i,n,r){this.maxHarmonics=3,"number"==typeof i?(void 0===r&&(r=new ConstantWave(0)),s.call(this,t,e,i,n),this.fmod=r):(s.call(this,t,e),this.fmod=i)};n(r,s),r.prototype.getClass=function(){return"FMHarmonicSquareWave"},r.prototype.pop=function(){this.parent.pop.call(this),this.fmod.pop()},r.prototype.push=function(){this.parent.push.call(this),this.fmod.push()},r.prototype.reset=function(){this.parent.reset.call(this),this.fmod.reset()},r.prototype.update=function(){this.value=0;for(var t=1;t<=this.maxHarmonics;t+=2)this.value+=1/t*Math.sin(t*this.phase);return this.value*=this.amp,this.value+=this.offset,this.cyclePhase(this.frequency+this.fmod.update()),this.value},e.exports=r},{"../../internals":98,"./AbstractWave":131}],134:[function(t,e,i){var n=t("../../internals").extend,s=t("./AbstractWave"),r=function(t,e,i,n,r){"number"==typeof i?(s.call(this,t,e,i,n),this.fmod=r):(s.call(this,t,e),this.fmod=i)};n(r,s),r.prototype.getClass=function(){return"FMSawtoothWave"},r.prototype.pop=function(){this.parent.pop.call(this),this.fmod.pop()},r.prototype.push=function(){this.parent.push.call(this),this.fmod.push()},r.prototype.reset=function(){this.parent.reset.call(this),this.fmod.reset()},r.prototype.update=function(){return this.value=(this.phase/s.TWO_PI*2-1)*this.amp+this.offset,this.cyclePhase(this.frequency+this.fmod.update()),this.value},e.exports=r},{"../../internals":98,"./AbstractWave":131}],135:[function(t,e,i){var n=t("../../internals").extend,s=t("./AbstractWave"),r=function(t,e,i,n,r){"number"==typeof i?(s.call(this,t,e,i,n),this.fmod=r):(s.call(this,t,e),this.fmod=i)};n(r,s),r.prototype.getClass=function(){return"FMSineWave"},r.prototype.pop=function(){this.parent.pop.call(this),this.fmod.pop()},r.prototype.push=function(){this.parent.push.call(this),this.fmod.push()},r.prototype.reset=function(){this.parent.reset.call(this),this.fmod.reset()},r.prototype.update=function(){return this.value=Math.sin(this.phase)*this.amp+this.offset,this.cyclePhase(this.frequency+this.fmod.update()),this.value},e.exports=r},{"../../internals":98,"./AbstractWave":131}],136:[function(t,e,i){var n=t("../../internals").extend,s=t("./AbstractWave"),r=t("./ConstantWave"),o=function(t,e,i,n,o){ "number"==typeof i?void 0===o?s.call(this,t,e,i,n,new r(0)):(s.call(this,t,e,i,n),this.fmod=o):(s.call(this,t,e),this.fmod=i)};n(o,s),o.prototype.getClass=function(){return"FMSquareWave"},o.prototype.pop=function(){this.parent.pop.call(this),this.fmod.pop()},o.prototype.push=function(){this.parent.push.call(this),this.fmod.push()},o.prototype.reset=function(){this.parent.reset.call(this),this.fmod.reset()},o.prototype.update=function(){return this.value=(this.phase/s.TWO_PI<.5?1:-1)*this.amp+this.offset,this.cyclePhase(this.frequency+this.fmod.update()),this.value},e.exports=o},{"../../internals":98,"./AbstractWave":131,"./ConstantWave":132}],137:[function(t,e,i){var n=t("../../internals").extend,s=t("../mathUtils"),r=t("./AbstractWave"),o=t("./ConstantWave"),a=function(t,e,i,n,s){"number"==typeof i?void 0!==s?(r.call(this,t,e,i,n),this.fmod=s):r.call(this,t,e,i,n,new o(0)):r.call(this,t,e,1,0)};n(a,r),a.prototype.getClass=function(){return"FMTriangleWave"},a.prototype.pop=function(){this.parent.pop.call(this),this.fmod.pop()},a.prototype.push=function(){this.parent.push.call(this),this.fmod.push()},a.prototype.reset=function(){this.parent.reset.call(this),this.fmod.reset()},a.prototype.update=function(){return this.value=2*this.amp*(Math.abs(r.PI-this.phase)*s.INV_PI-.5)+this.offset,this.cyclePhase(this.frequency+this.fmod.update()),this.value},e.exports=a},{"../../internals":98,"../mathUtils":125,"./AbstractWave":131,"./ConstantWave":132}],138:[function(t,e,i){var n=t("../../internals").extend,s=t("./AbstractWave"),r=function(t,e,i,n){s.call(this,t,e,i,n)};n(r,s),r.prototype.getClass=function(){return"SineWave"},r.prototype.update=function(){return this.value=Math.sin(this.phase)*this.amp+this.offset,this.cyclePhase(this.frequency),this.value},e.exports=r},{"../../internals":98,"./AbstractWave":131}],139:[function(t,e,i){var n=function(t,e,i,n){this.phase=t,this.frequency=e,this.amp=i,this.offset=n};e.exports=n},{}],140:[function(t,e,i){e.exports={ParticlePath2D:t("./physics2d/ParticlePath2D"),ParticleString2D:t("./physics2d/ParticleString2D"),PullBackString2D:t("./physics2d/PullBackString2D"),VerletConstrainedSpring2D:t("./physics2d/VerletConstrainedSpring2D"),VerletMinDistanceSpring2D:t("./physics2d/VerletMinDistanceSpring2D"),VerletParticle2D:t("./physics2d/VerletParticle2D"),VerletPhysics2D:t("./physics2d/VerletPhysics2D"),VerletSpring2D:t("./physics2d/VerletSpring2D")},e.exports.behaviors=t("./physics2d/behaviors"),e.exports.constraints=t("./physics2d/constraints")},{"./physics2d/ParticlePath2D":141,"./physics2d/ParticleString2D":142,"./physics2d/PullBackString2D":143,"./physics2d/VerletConstrainedSpring2D":144,"./physics2d/VerletMinDistanceSpring2D":145,"./physics2d/VerletParticle2D":146,"./physics2d/VerletPhysics2D":147,"./physics2d/VerletSpring2D":148,"./physics2d/behaviors":149,"./physics2d/constraints":153}],141:[function(t,e,i){var n=t("../internals"),s=t("../geom/Spline2D"),r=t("./VerletParticle2D"),o=function(t){s.call(this,t),this.particles=[]};n.extend(o,s),o.prototype.createParticles=function(t,e,i,n){this.particles=[],this.computeVertices(e);var s=0,o=this.getDecimatedVertices(i,!0);for(s=0;st;t++)this.physics.removeSpringElements(this.links[t]);this.particles=[],this.links=[]},createSpring:function(t,e,i,n){return new s(t,e,i,n)},getHead:function(){return this.particles[0]},getNumParticles:function(){return this.particles.length},getTail:function(){return this.particles[this.particles.length-1]}},e.exports=r},{"./VerletParticle2D":146,"./VerletSpring2D":148}],143:[function(t,e,i){var n=t("../internals"),s=t("./VerletSpring2D"),r=function(t,e,i){s.apply(this,[t,e,0,i]),t.lock(),this.setRestLength(.5)};n.extend(r,s),r.prototype.update=function(t){this.b.distanceToSquared(this.a)>this.restLengthSquared&&this.parent.update.call(this,t)},e.exports=r},{"../internals":98,"./VerletSpring2D":148}],144:[function(t,e,i){var n=t("../internals"),s=t("./VerletSpring2D"),r=function(t,e,i,n,r){s.call(this,t,e,i,n),this.limit=void 0===r?Number.MAX_VALUE:r};n.extend(r,s),r.update=function(t){var e=this.b.sub(this.a),i=e.magnitude()+s.EPS,n=(i-this.restLength)/(i*(this.a.invWeight+this.b.invWeight))*this.strength;this.a.isLocked||this.isALocked||(this.a.addSelf(e.scale(n*this.a.invWeight).limit(this.limit)),t&&this.a.applyConstraints()),this.b.isLocked||this.isBLocked||(this.b.subSelf(e.scale(n*this.b.invWeight).limit(this.limit)),t&&this.b.applyConstraints())},e.exports=r},{"../internals":98,"./VerletSpring2D":148}],145:[function(t,e,i){var n=t("../internals"),s=t("./VerletSpring2D"),r=function(t,e,i,n){s.call(this,t,e,i,n),this.setRestLength(i)};n.extend(r,s),r.prototype.update=function(t){this.b.distanceToSquared(this.a)t;t++)this.behaviors[t].applyBehavior(this)}},r.prototype.applyConstraints=function(){if(void 0!==this.constraints){var t=0,e=this.constraints.length;for(t=0;e>t;t++)this.constraints[t].applyConstraint(this)}},r.prototype.clearForce=function(){return this.force.clear(),this},r.prototype.clearVelocity=function(){return this.prev.set(this),this},r.prototype.getInvWeight=function(){return this.invWeight},r.prototype.getPreviousPosition=function(){return this.prev},r.prototype.getVelocity=function(){return this.sub(this.prev)},r.prototype.getWeight=function(){return this.weight},r.prototype.lock=function(){return this.isLocked=!0,this},r.prototype.removeAllBehaviors=function(){return this.behaviors=[],this},r.prototype.removeAllConstraints=function(){return this.constraints=[],this},r.prototype.removeBehavior=function(t){return n.removeItemFrom(t,this.behaviors)},r.prototype.removeConstraint=function(t){return n.removeItemFrom(t,this.constraints)},r.prototype.scaleVelocity=function(t){return this.prev.interpolateToSelf(this,1-t),this},r.prototype.setPreviousPosition=function(t){return this.prev.set(t),this},r.prototype.setWeight=function(t){this.weight=t,this.invWeight=0!==t?1/t:0},r.prototype.unlock=function(){return this.clearVelocity(),this.isLocked=!1,this},r.prototype.update=function(){this.isLocked||(this.applyBehaviors(),this.temp.set(this),this.addSelf(this.sub(this.prev).addSelf(this.force.scale(this.weight))),this.prev.set(this.temp),this.force.clear(),this.applyConstraints())},e.exports=r},{"../geom/Vec2D":70,"../internals":98}],147:[function(t,e,i){var n=t("../internals"),s=t("./behaviors/GravityBehavior"),r=t("../geom/Rect"),o=t("../geom/Vec2D"),a=0,h=function(t,e,i,r){var h,c={numIterations:50,drag:0,timeStep:1};1==arguments.length&&(arguments[0].gravity||arguments[0].numIterations||arguments[0].timeStep||arguments[0].drag)?(h=arguments[0],c.gravity=h.gravity,c.numIterations=h.numIterations||c.numIterations,c.drag=h.drag||c.drag,c.timeStep=h.timeStep||c.timeStep):1==arguments.length?c.gravity=t:4==arguments.length&&(c.gravity=t,c.numIterations=e,c.drag=i,c.timeStep=r),this.behaviors=[],this.particles=[],this.springs=[],this.numIterations=c.numIterations,this.timeStep=c.timeStep,this.setDrag(c.drag),c.gravity&&(n.has.XY(c.gravity)&&(c.gravity=new s(new o(c.gravity))),this.addBehavior(c.gravity)),this.id=a++};h.addConstraintToAll=function(t,e){for(var i=0;ie;e++)t=this.particles[e],void 0!==t.bounds&&t.constrain(t.bounds);if(void 0!==this.worldBounds)for(e=0;i>e;e++)t=this.particles[e],t.constrain(this.worldBounds)},getCurrentBounds:function(){for(var t,e=new o(Number.MAX_VALUE,Number.MAX_VALUE),i=new o(Number.MIN_VALUE,Number.MIN_VALUE),n=0,s=this.particles.length;s>n;n++)t=this.particles[n],e.minSelf(t),i.maxSelf(t);return new r(e,i)},getDrag:function(){return 1-this.drag},getNumIterations:function(){return this.numIterations},getSpring:function(t,e){for(var i=0,n=this.springs.length;n>i;i++){var s=this.springs[i];if(s.a===t&&s.b===e||s.a===e&&s.b===e)return s}},getTimeStep:function(){return this.timeStep},getWorldBounds:function(){return this.worldBounds},removeBehavior:function(t){return n.removeItemFrom(t,this.behaviors)},removeParticle:function(t){return n.removeItemFrom(t,this.particles)},removeSpring:function(t){return n.removeItemFrom(t,this.springs)},removeSpringElements:function(t){return void 0!==this.removeSpring(t)?this.removeParticle(t.a)&&this.removeParticle(t.b):!1},setDrag:function(t){this.drag=1-t},setNumIterations:function(t){this.numIterations=t},setTimeStep:function(t){this.timeStep=t;for(var e=0,i=this.behaviors.length;i>e;e++)this.behaviors[e].configure(t)},setWorldBounds:function(t){return this.worldBounds=t,this},update:function(){return this.updateParticles(),this.updateSprings(),this.constrainToBounds(),this},updateParticles:function(){for(var t,e,i=0,n=0,s=this.behaviors.length,r=this.particles.length;s>i;i++)for(t=this.behaviors[i],n=0;r>n;n++)t.applyBehavior(this.particles[n]);for(n=0;r>n;n++)e=this.particles[n],e.scaleVelocity(this.drag),e.update()},updateSprings:function(){for(var t=this.numIterations,e=this.springs.length,i=0;t>0;t--)for(i=0;e>i;i++)this.springs[i].update(1===t)}},e.exports=h},{"../geom/Rect":62,"../geom/Vec2D":70,"../internals":98,"./behaviors/GravityBehavior":152}],148:[function(t,e,i){var n=function(t,e,i,n){this.a=t,this.b=e,this.restLength=i,this.strength=n};n.EPS=1e-6,n.prototype={getRestLength:function(){return this.restLength},getStrength:function(){return this.strength},lockA:function(t){return this.isALocked=t,this},lockB:function(t){return this.isBLocked=t,this},setRestLength:function(t){return this.restLength=t,this.restLengthSquared=t*t,this},setStrength:function(t){return this.strength=t,this},update:function(t){var e=this.b.sub(this.a),i=e.magnitude()+n.EPS,s=(i-this.restLength)/(i*(this.a.invWeight+this.b.invWeight))*this.strength;this.a.isLocked||this.isALocked||(this.a.addSelf(e.scale(s*this.a.invWeight)),t&&this.a.applyConstraints()),this.b.isLocked||this.isBLocked||(this.b.addSelf(e.scale(-s*this.b.invWeight)),t&&this.b.applyConstraints())}},e.exports=n},{}],149:[function(t,e,i){var n=t("./behaviors/AttractionBehavior"),s=t("./behaviors/ConstantForceBehavior"),r=t("./behaviors/GravityBehavior");i.AttractionBehavior=n,i.ConstantForceBehavior=s,i.GravityBehavior=r},{"./behaviors/AttractionBehavior":150,"./behaviors/ConstantForceBehavior":151,"./behaviors/GravityBehavior":152}],150:[function(t,e,i){var n=function(t,e,i,n){if(arguments.length<3)throw new Error("Constructor received incorrect Parameters");this.jitter=n||0,this.attractor=t,this.strength=i,this.setRadius(e)};n.prototype={applyBehavior:function(t){var e=this.attractor.sub(t),i=e.magSquared();if(i1?(this.theta=e,this.rootPos=new n(t)):(this.rootPos=new n,this.theta=t)};s.prototype.applyConstraint=function(t){var e=t.sub(this.rootPos),i=Math.floor(e.heading()/this.theta)*this.theta;t.set(this.rootPos.add(n.fromTheta(i).scaleSelf(e.magnitude())))},e.exports=s},{"../../geom/Vec2D":70}],155:[function(t,e,i){var n=function(t,e){this.axis=t,this.constraint=e};n.prototype.applyConstraint=function(t){t.setComponent(this.axis,this.constraint)},e.exports=n},{}],156:[function(t,e,i){var n=t("../../geom/Circle"),s=function(t,e){1==arguments.length?this.circle=t:this.circle=new n(t,e)};s.prototype.applyConstraint=function(t){this.circle.containsPoint(t)&&t.set(this.circle.add(t.sub(this.circle).normalizeTo(this.circle.getRadius())))},e.exports=s},{"../../geom/Circle":45}],157:[function(t,e,i){var n=function(t,e){this.axis=t,this.threshold=e};n.prototype.applyConstraint=function(t){t.getComponent(this.axis)>this.threshold&&t.setComponent(this.axis,this.threshold)},e.exports=n},{}],158:[function(t,e,i){var n=function(t,e){this.axis=t,this.threshold=e};n.prototype.applyConstraint=function(t){t.getComponent(this.axis)1&&(this.rect=new o(t,e)),!this.rect)throw new Error("Received Incorrect arguments");this.intersectRay=new r(this.rect.getCentroid(),new n)};a.prototype={applyConstraint:function(t){this.rect.containsPoint(t)&&t.set(this.rect.intersectsRay(this.intersectRay.setDirection(this.intersectRay.sub(t)),0,Number.MAX_VALUE))},getBox:function(){return this.rect.copy()},setBox:function(t){this.rect=t.copy(),this.intersectRay.set(this.rect.getCentroid())}},e.exports=a},{"../../geom/Ray2D":59,"../../geom/Rect":62,"../../geom/Vec2D":70,"../../internals/has":105}],160:[function(t,e,i){e.exports={ToxiclibsSupport:t("./processing/ToxiclibsSupport")}},{"./processing/ToxiclibsSupport":161}],161:[function(t,e,i){var n=t("../geom/Matrix4x4"),s=t("../geom/Vec3D"),r=t("../geom/mesh/TriangleMesh"),o=function(t,e){if("undefined"==typeof Processing)throw new Error("Processing.js has not been loaded");this.sketch=t,this.app=t,void 0!==e?this.gfx=t:this.gfx=this.app,this._normalMap=(new n).translateSelf(128,128,128).scaleSelf(127)};o.prototype={box:function(t,e){var i=t.toMesh();void 0===e&&(e=!1),e&&i.computeVertexNormals(),this.mesh(i,e,0)},circle:function(t,e){this.gfx.ellipse(t.x,t.y,e,e)},cone:function(){var t=arguments[0],e=6,i=0,n=!0,s=!0,o=!1;5==arguments.length?(e=arguments[1],n=arguments[2],s=arguments[3],o=arguments[4]):3==arguments.length&&(e=arguments[1],o=arguments[2]);var a=t.toMesh({mesh:new r,steps:e,thetaOffset:i,topClosed:n,bottomClosed:s});o&&a.computeVertexNormals(),window.mesh=a,this.mesh(a,o,0)},cylinder:function(t,e,i){if(1==arguments.length)this.mesh(t.toMesh(),!1,0);else{var n=t.toMesh(e,0);void 0===i&&(i=!1),i&&n.computeVertexNormals(),this.mesh(n,i,0)}},ellipse:function(t,e){var i=t.getRadii();void 0===e&&(e=this.app.CENTER),e===this.app.CENTER?this.gfx.ellipse(t.x,t.y,2*i.x,2*i.y):e===this.app.RADIUS?this.gfx.ellipse(t.x,t.y,2*i.x,2*i.y):(e===this.app.CORNER||this.gfx.ellipseMode===this.app.CORNERS)&&this.gfx.ellipse(t.x-i.x,t.y-i.y,2*i.x,2*i.y)},getGraphics:function(){return this.gfx},line:function(){var t,e;if(1==arguments.length){var i=arguments[0];t=i.a,e=i.b}else t=arguments[0],e=arguments[1];void 0===t.z?this.gfx.line(t.x,t.y,e.x,e.y):this.gfx.line(t.x,t.y,t.z,e.x,e.y,e.z)},lineStrip2D:function(t){this.processVertices2D(t,this.app.POLYGON,!1)},lineStrip3D:function(t){this.processVertices3D(t,this.app.POLYGON,!1)},mesh:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=0),this.gfx.beginShape(this.app.TRIANGLES);var n=0,s=t.faces.length;if(e)for(n=0;s>n;n++){var r=t.faces[n];this.gfx.normal(r.a.normal.x,r.a.normal.y,r.a.normal.z),this.gfx.vertex(r.a.x,r.a.y,r.a.z),this.gfx.normal(r.b.normal.x,r.b.normal.y,r.b.normal.z),this.gfx.vertex(r.b.x,r.b.y,r.b.z),this.gfx.normal(r.c.normal.x,r.c.normal.y,r.c.normal.z),this.gfx.vertex(r.c.x,r.c.y,r.c.z)}else for(var n=0;s>n;n++){var r=t.faces[n];this.gfx.normal(r.normal.x,r.normal.y,r.normal.z),this.gfx.vertex(r.a.x,r.a.y,r.a.z),this.gfx.vertex(r.b.x,r.b.y,r.b.z),this.gfx.vertex(r.c.x,r.c.y,r.c.z)}if(this.gfx.endShape(),i>0){var o=0,a=this.gfx.stroke;if(a&&(o=this.gfx.strokeColor),s=t.vertices.length,e)for(n=0;s>n;n++){var h=t.vertices[n],c=h.add(h.normal.scale(i));p=h.normal.scale(127),this.gfx.stroke(p.x+128,p.y+128,p.z+128),this.gfx.line(h.x,h.y,h.z,c.x,c.y,c.z)}else{var u=1/3;for(s=t.faces.length,n=0;s>n;n++){var r=t.faces[n],l=r.a.add(r.b).addSelf(r.c).scaleSelf(u),f=l.add(r.normal.scale(i)),p=r.normal.scale(127);this.gfx.stroke(p.x+128,p.y+128,p.z+128),this.gfx.line(l.x,l.y,l.z,f.x,f.y,f.z)}}a?this.gfx.stroke(o):this.gfx.noStroke()}},meshNormalMapped:function(t,e,i){this.gfx.beginShape(this.app.TRIANGLES);var n=0,s=t.faces.length;if(e)for(n=0;s>n;n++){var r=t.faces[n],o=this._normalMap.applyTo(r.a.normal);this.gfx.fill(o.x,o.y,o.z),this.gfx.normal(r.a.normal.x,r.a.normal.y,r.a.normal.z),this.gfx.vertex(r.a.x,r.a.y,r.a.z),o=this._normalMap.applyTo(r.b.normal),this.gfx.fill(o.x,o.y,o.z),this.gfx.normal(r.b.normal.x,r.b.normal.y,r.b.normal.z),this.gfx.vertex(r.b.x,r.b.y,r.b.z),o=this._normalMap.applyTo(r.c.nromal),this.gfx.fil(o.x,o.y,o.z),this.gfx.normal(r.c.normal.x,r.c.normal.y,r.c.normal.z),this.gfx.vertex(r.c.x,r.c.y,r.c.z)}else for(n=0;s>n;n++){var r=t.faces[n];this.gfx.normal(r.normal.x,r.normal.y,r.normal.z),this.gfx.vertex(r.a.x,r.a.y,r.a.z),this.gfx.vertex(r.b.x,r.b.y,r.b.z),this.gfx.vertex(r.c.x,r.c.y,r.c.z)}if(this.gfx.endShape(),i>0)if(e)for(s=t.vertices.length,n=0;s>n;n++){var a=t.vertices[n],h=a.add(a.normal.scale(i)),o=a.normal.scale(127);this.gfx.stroke(o.x+128,o.y+128,o.z+128),this.gfx.line(a.x,a.y,a.z,h.x,h.y,h.z)}else for(s=t.faces.length,n=0;s>n;n++){var r=t.faces[n],c=r.getCentroid(),u=c.add(r.normal.scale(i)),o=r.normal.scale(127);this.gfx.stroke(o.x+128,o.y+128,o.z+128),this.gfx.line(c.x,c.y,c.z,u.x,u.y,u.z)}},origin:function(){var t=void 0,e=void 0;1==arguments.length?(e=arguments[0],t=s.ZERO):(t=arguments[0],e=arguments[1]),this.gfx.stroke(255,0,0),this.gfx.line(t.x,t.y,t.z,t.x+e,t.y,t.z),this.gfx.stroke(0,255,0),this.gfx.line(t.x,t.y,t.z,t.x,t.y+e,t.z),this.gfx.stroke(0,0,255),this.gfx.line(t.x,t.y,t.z,t.x,t.y,t.z+e)},plane:function(t,e){this.mesh(t.toMesh(e),!1,0)},point:function(t){void 0===t.z?this.gfx.point(t.x,t.y):this.gfx.point(t.x,t.y,t.z)},points2D:function(t){this.processVertices2D(t,this.app.POINTS,!1)},points3D:function(t){this.processVertices3D(t,this.app.POINTS,!1)},polygon2D:function(t){this.processVertices2D(t.vertices,this.app.POLYGON,!1)},processVertices2D:function(t,e,i){(void 0===t.hasNext||void 0===t.next)&&(t=new this.app.ObjectIterator(t)),this.gfx.beginShape(e);for(var n=void 0;t.hasNext()&&(n=t.next(),!0);)this.gfx.vertex(n.x,n.y);i?this.gfx.endShape(this.app.CLOSE):this.gfx.endShape()},processVertices3D:function(t,e,i){(void 0===t.hasNext||void 0===t.next)&&(t=new this.app.ObjectIterator(t)),this.gfx.beginShape(e);for(var n=void 0;t.hasNext()&&(n=t.next(),!0);)this.gfx.vertex(n.x,n.y,n.z);i?this.gfx.endShape(this.app.CLOSE):this.gfx.endShape()},ray:function(t,e){var i=t.getPointAtDistance(e);void 0===t.z?this.gfx.line(t.x,t.y,i.x,i.y):this.gfx.line(t.x,t.y,t.z,i.x,i.y,i.z)},rect:function(t,e){if(void 0===e&&(e=this.app.CORNER),e===this.app.CORNER)this.gfx.rect(t.x,t.y,t.width,t.height);else if(e===this.app.CORNERS)this.gfx.rect(t.x,t.y,t.x+t.width,t.y+t.height);else if(e===this.app.CENTER)this.gfx.rect(t.x+.5*t.widt,t.y+.5*t.height,t.width,t.height);else if(e===this.app.RADIUS){var i=.5*t.width,n=.5*t.height;this.gfx.rect(t.x+i,t.y+n,i,n)}},setGraphics:function(t){this.gfx=t},sphere:function(t,e,i){this.mesh(t.toMesh(e),i)},texturedMesh:function(t,e,i){this.gfx.beginShape(this.app.TRIANGLES),this.gfx.texture(e);var n=0,s=t.faces.length;if(i)for(n=0;s>n;n++){var r=t.faces[n];void 0!==r.uvA&&void 0!==r.uvB&&void 0!==r.uvC?(this.gfx.normal(r.a.normal.x,r.a.normal.y,r.a.normal.z),this.gfx.vertex(r.a.x,r.a.y,r.a.z,r.uvA.x,r.uvA.y),this.gfx.normal(r.b.normal.x,r.b.normal.y,r.b.normal.z),this.gfx.vertex(r.b.x,r.b.y,r.b.z,r.uvB.x,r.uvB.y),this.gfx.normal(r.c.normal.x,r.c.normal.y,r.c.normal.z),this.gfx.vertex(r.c.x,r.c.y,r.c.z,r.uvC.x,r.uvC.y)):(this.gfx.vertex(r.a.x,r.a.y,r.a.z),this.gfx.vertex(r.b.x,r.b.y,r.b.z),this.gfx.vertex(r.c.x,r.c.y,r.c.z))}else for(n=0;s>n;n++){var r=t.faces[n];this.gfx.normal(r.normal.x,r.normal.y,r.normal.z),void 0!==r.uvA&&void 0!==r.uvB&&void 0!==r.uvC?(this.gfx.vertex(r.a.x,r.a.y,r.a.z,r.uvA.x,r.uvA.y),this.gfx.vertex(r.b.x,r.b.y,r.b.z,r.uvB.x,r.uvB.y),this.gfx.vertex(r.c.x,r.c.y,r.c.z,r.uvC.x,r.uvC.y)):(this.gfx.vertex(r.a.x,r.a.y,r.a.z),this.gfx.vertex(r.b.x,r.b.y,r.b.z),this.gfx.vertex(r.c.x,r.c.y,r.c.z))}this.gfx.endShape()},triangle:function(t,e){var i=function(){return void 0!==t.a&&void 0!==t.b&&void 0!==t.c?void 0!==t.a.x:!1},n=function(){return i()?void 0!==t.a.z:!1};if((e||void 0===e)&&this.gfx.beginShape(this.app.TRIANGLES),n()){var s=t.computeNormal();this.gfx.normal(s.x,s.y,s.z),this.gfx.vertex(t.a.x,t.a.y,t.a.z),this.gfx.vertex(t.b.x,t.b.y,t.b.z),this.gfx.vertex(t.c.x,t.c.y,t.c.z)}else this.gfx.vertex(t.a.x,t.a.y),this.gfx.vertex(t.b.x,t.b.y),this.gfx.vertex(t.c.x,t.c.y);(e||void 0===e)&&this.gfx.endShape()},vertex:function(t){void 0===t.z?this.gfx.vertex(t.x,t.y):this.gfx.vertex(t.x,t.y,t.z)}},e.exports=o},{"../geom/Matrix4x4":55,"../geom/Vec3D":71,"../geom/mesh/TriangleMesh":87}],162:[function(t,e,i){i.datatypes=t("./util/datatypes")},{"./util/datatypes":163}],163:[function(t,e,i){e.exports={ArraySet:t("./datatypes/ArraySet"),FloatRange:t("./datatypes/FloatRange"),UndirectedGraph:t("./datatypes/UndirectedGraph")}},{"./datatypes/ArraySet":164,"./datatypes/FloatRange":165,"./datatypes/UndirectedGraph":166}],164:[function(t,e,i){var n=t("../../internals"),s=function(t){if(Array.apply(this),arguments.length>=1)for(var e=0,i=t.length;i>e;e++){var n=t[e];this.indexOf(n)<0&&this.push(n)}};n.extend(s,Array),n.mixin(s.prototype,{add:function(t){return this.contains(t)?!1:(this.push(t),!0)},addAll:function(t){for(var e=0,i=t.length;i>e;e++)this.push(t[e])},clear:function(){this.retainAll([])},clone:function(){return new s(this)},contains:function(t){return this.indexOf(t)>=0},containsAll:function(t){for(var e=0,i=t.length;i>e;e++){var n=t[e];if(!this.contains(n))return!1}return!0},containsAny:function(t){for(var e=0,i=t.length;i>e;e++)if(this.contains(t[e]))return!0;return!1},equals:function(t){return this===t},get:function(t){return this[t]},iterator:function(){return new n.Iterator(this)},isEmpty:function(){return this.length<1},remove:function(t){var e=this.indexOf(t);return e>=0?(this.splice(e,1),!0):!1},removeAll:function(){this.retainAll([])},retainAll:function(t){for(var e=!1,i=0;ie){var i=e;e=t,t=i}this.min=t,this.max=e,this.currValue=t};s.prototype={adjustCurrentBy:function(t){return this.setCurrent(this.currValue+t)},copy:function(){var t=new s(this.min,this.max);return t.currValue=this.currValue,t},getAt:function(t){return this.min+(this.max-this.min-n.EPS)*t},getCurrent:function(){return this.currValue},getMedian:function(){return.5*(this.min+this.max)},getRange:function(){return this.max-this.min},isValueInRange:function(t){return t>=this.min&&t<=this.max},pickRandom:function(){return this.currValue=n.random(this.min,this.max),this.currValue},setCurrent:function(t){return this.currValue=n.clip(t,this.min,this.max),this.currValue},toArray:function(t){for(var e=[],i=this.min;i "+this.max}},e.exports=s},{"../../math/mathUtils":125}],166:[function(t,e,i){var n=t("./ArraySet"),s=function(){this._nodeLinks={},this._nodeIDs=[]};s.prototype={add:function(t){void 0===this._nodeLinks[t]&&(this._nodeLinks[t]=new n,this._nodeIDs.push(t))},connect:function(t,e){if(void 0===this._nodeLinks[t])throw new Error("nodeA has not been added");if(void 0===this._nodeLinks[e])throw new Error("nodeB has not been added");this._nodeLinks[t].push(e),this._nodeLinks[e].push(t)},disconnect:function(t,e){if(void 0===this._nodeLinks[t])throw new Error("nodeA has not been added");if(void 0===this._nodeLinks[e])throw new Error("nodeB has not been added");this._nodeLinks[t].splice(this._nodeLinks[t].indexOf(e),1),this._nodeLinks[e].splice(this._nodeLinks[e].indexOf(t),1)},getConnectedNodesFor:function(t){if(void 0===this._nodeLinks[t])throw new Error("node has not been added");return this._nodeLinks[t]},getNodes:function(){return this._nodeIDs},remove:function(t){var e=this._nodeLinks[t];if(void 0!==e){for(var i=0,n=e.length;n>i;i++){var s=e[i],r=s.indexOf(t);s.splice(r,1)}delete this._nodeLinks[t];var i=this._nodeIDs.indexOf(t);this._nodeIDs.splice(t,1)}}},e.exports=s},{"./ArraySet":164}]},{},[40])(40)});