/*! * dolly - A JavaScript library for objects to follow other objects in 3D space * @version v0.0.3 * @link https://github.com/povdocs/dolly * @license MIT */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):"object"==typeof exports?exports.Dolly=e():t.Dolly=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){function e(){return a.apply(this,t)}return"number"==typeof t?new a(t,t,t):Array.isArray(t)?(e.prototype=a.prototype,new e):t instanceof a?a.clone(t):t&&"object"==typeof t?new a(t.x||0,t.y||0,t.z||0):new a}function o(t,e){var n,r,o=t.vec,i=e.vec;for(n=0;3>n;n++)r=i[n],r&&(o[n]=o[n]/r)}function i(t){var e=t||{};this.lastUpdate=-1,this.id=f++,this.name=e.name||"prop"+this.id,this.position=r(e.position),this.minBounds=r(void 0===e.minBounds?-(1/0):e.minBounds),this.maxBounds=r(void 0===e.maxBounds?1/0:e.maxBounds),this.lag="number"!=typeof e.lag||isNaN(e.lag)?0:e.lag,this.maxSpeed="number"!=typeof e.maxSpeed||isNaN(e.maxSpeed)?1/0:e.maxSpeed,this.goal=new a,this.attractorGoal=new a,this.velocity=new a,this.lastPosition=a.clone(this.position),this.targets=[],this.attractors=[],u(this)}function s(){var t=-1,e=[],n=!1,r=this;this.update=function(o){return n?void 0:(n=!0,t++,e.forEach(function(e){e.update(o,t)}),n=!1,r)},this.prop=function(t){var n=new i(t);return e.push(n),n},this.active=function(t){var n;for(n=0;n=e||void 0===e||(this.lastUpdate=e,this.lastPosition.copyVector(this.position),this.emit("updatestart",this.position),!this.targets.length&&!this.attractors.length)?void 0:(this.attractorGoal.zero(),this.attractors.forEach(function(o){var s,a=0,c=o.attraction;o.prop.update(t,e),o.subject.update(t,e),s=o.prop.position.distance(o.subject.position),si?(this.targets.forEach(function(r){var o;r.prop.update(t,e),r.offsetPosition.copyVector(r.prop.position).add(r.offset),h.copyVector(r.offsetPosition).subtract(n.position),r.offsetPosition.copyVector(n.position),o=h.length(),o>r.radius&&(h.normalize().scale(o-r.radius),r.offsetPosition.add(h)),r.offsetPosition.multiply(r.weight),n.goal.add(r.offsetPosition),l.add(r.weight)}),l.length()&&o(this.goal,l),i&&this.goal.lerp(this.attractorGoal,i)):this.goal.copyVector(this.attractorGoal),this.velocity.copyVector(this.goal).subtract(this.position),this.lag&&this.velocity.scale(Math.pow(t,this.lag)),this.maxSpeed&&this.maxSpeed<1/0&&this.maxSpeed(t||1e-5)},t.exports=s},function(t,e,n){"use strict";function r(t,e,n){var r=this;this.vec=o.fromValues(t||0,e||0,n||0),Object.defineProperties(this,{x:{writeable:!0,enumerable:!0,get:function(){return r.vec[0]},set:function(t){return r.vec[0]=t}},y:{writeable:!0,enumerable:!0,get:function(){return r.vec[1]},set:function(t){return r.vec[1]=t}},z:{writeable:!0,enumerable:!0,get:function(){return r.vec[2]},set:function(t){return r.vec[2]=t}}})}var o=n(2);r.prototype.toString=function(){return o.str(this.vec)},r.prototype.clone=function(t){return new r(t.x,t.y,t.z)},r.prototype.copy=function(t){return t instanceof r?o.copy(this.vec,t.vec):"object"==typeof t&&t&&this.set(t.x||0,t.y||0,t.z||0),this},r.prototype.copyVector=function(t){return o.copy(this.vec,t.vec),this},r.prototype.zero=function(){return o.set(this.vec,0,0,0),this},r.prototype.set=function(t,e,n){return o.set(this.vec,t,e,n),this},r.prototype.negate=function(){return o.negate(this.vec,this.vec),this},r.prototype.normalize=function(){return o.normalize(this.vec,this.vec),this},r.prototype.scale=function(t){return o.scale(this.vec,this.vec,t),this},r.prototype.scaleAndAdd=function(t,e){return o.scaleAndAdd(this.vec,this.vec,t.vec,e),this},r.prototype.lerp=function(t,e){return o.lerp(this.vec,this.vec,t.vec,e),this},["add","cross","divide","max","min","multiply","subtract"].forEach(function(t){var e=o[t];r.prototype[t]=function(t){return e(this.vec,this.vec,t.vec),this}}),r.prototype.length=function(){return o.length(this.vec)},r.prototype.squaredLength=function(){return o.squaredLength(this.vec)},["distance","dot","squaredDistance"].forEach(function(t){var e=o[t];r.prototype[t]=function(t){return e(this.vec,t.vec)}}),r.fromArray=function(t){return new r.apply(null,t)},r.clone=function(t){return new r(t.x,t.y,t.z)},t.exports=r},function(t,e,n){var r={},o=n(3).GLMAT_ARRAY_TYPE,i=n(3).GLMAT_RANDOM;r.create=function(){var t=new o(3);return t[0]=0,t[1]=0,t[2]=0,t},r.clone=function(t){var e=new o(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},r.fromValues=function(t,e,n){var r=new o(3);return r[0]=t,r[1]=e,r[2]=n,r},r.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},r.set=function(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t},r.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t},r.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},r.sub=r.subtract,r.multiply=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},r.mul=r.multiply,r.divide=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t},r.div=r.divide,r.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t},r.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t},r.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t},r.scaleAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t},r.distance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(n*n+r*r+o*o)},r.dist=r.distance,r.squaredDistance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],o=e[2]-t[2];return n*n+r*r+o*o},r.sqrDist=r.squaredDistance,r.length=function(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)},r.len=r.length,r.squaredLength=function(t){var e=t[0],n=t[1],r=t[2];return e*e+n*n+r*r},r.sqrLen=r.squaredLength,r.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},r.normalize=function(t,e){var n=e[0],r=e[1],o=e[2],i=n*n+r*r+o*o;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t},r.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},r.cross=function(t,e,n){var r=e[0],o=e[1],i=e[2],s=n[0],a=n[1],c=n[2];return t[0]=o*c-i*a,t[1]=i*s-r*c,t[2]=r*a-o*s,t},r.lerp=function(t,e,n,r){var o=e[0],i=e[1],s=e[2];return t[0]=o+r*(n[0]-o),t[1]=i+r*(n[1]-i),t[2]=s+r*(n[2]-s),t},r.random=function(t,e){e=e||1;var n=2*i()*Math.PI,r=2*i()-1,o=Math.sqrt(1-r*r)*e;return t[0]=Math.cos(n)*o,t[1]=Math.sin(n)*o,t[2]=r*e,t},r.transformMat4=function(t,e,n){var r=e[0],o=e[1],i=e[2];return t[0]=n[0]*r+n[4]*o+n[8]*i+n[12],t[1]=n[1]*r+n[5]*o+n[9]*i+n[13],t[2]=n[2]*r+n[6]*o+n[10]*i+n[14],t},r.transformMat3=function(t,e,n){var r=e[0],o=e[1],i=e[2];return t[0]=r*n[0]+o*n[3]+i*n[6],t[1]=r*n[1]+o*n[4]+i*n[7],t[2]=r*n[2]+o*n[5]+i*n[8],t},r.transformQuat=function(t,e,n){var r=e[0],o=e[1],i=e[2],s=n[0],a=n[1],c=n[2],u=n[3],f=u*r+a*i-c*o,h=u*o+c*r-s*i,l=u*i+s*o-a*r,p=-s*r-a*o-c*i;return t[0]=f*u+p*-s+h*-c-l*-a,t[1]=h*u+p*-a+l*-s-f*-c,t[2]=l*u+p*-c+f*-a-h*-s,t},r.rotateX=function(t,e,n,r){var o=[],i=[];return o[0]=e[0]-n[0],o[1]=e[1]-n[1],o[2]=e[2]-n[2],i[0]=o[0],i[1]=o[1]*Math.cos(r)-o[2]*Math.sin(r),i[2]=o[1]*Math.sin(r)+o[2]*Math.cos(r),t[0]=i[0]+n[0],t[1]=i[1]+n[1],t[2]=i[2]+n[2],t},r.rotateY=function(t,e,n,r){var o=[],i=[];return o[0]=e[0]-n[0],o[1]=e[1]-n[1],o[2]=e[2]-n[2],i[0]=o[2]*Math.sin(r)+o[0]*Math.cos(r),i[1]=o[1],i[2]=o[2]*Math.cos(r)-o[0]*Math.sin(r),t[0]=i[0]+n[0],t[1]=i[1]+n[1],t[2]=i[2]+n[2],t},r.rotateZ=function(t,e,n,r){var o=[],i=[];return o[0]=e[0]-n[0],o[1]=e[1]-n[1],o[2]=e[2]-n[2],i[0]=o[0]*Math.cos(r)-o[1]*Math.sin(r),i[1]=o[0]*Math.sin(r)+o[1]*Math.cos(r),i[2]=o[2],t[0]=i[0]+n[0],t[1]=i[1]+n[1],t[2]=i[2]+n[2],t},r.forEach=function(){var t=r.create();return function(e,n,r,o,i,s){var a,c;for(n||(n=3),r||(r=0),c=o?Math.min(o*n+r,e.length):e.length,a=r;c>a;a+=n)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}(),r.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},t.exports=r},function(t,e){if(!n)var n=1e-6;if(!r)var r="undefined"!=typeof Float32Array?Float32Array:Array;if(!o)var o=Math.random;var i={};i.setMatrixArrayType=function(t){r=t};var s=Math.PI/180;i.toRadian=function(t){return t*s},t.exports={GLMAT_EPSILON:n,GLMAT_ARRAY_TYPE:r,GLMAT_RANDOM:o,glMatrix:i}},function(t,e){"use strict";function n(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function r(t){var e=Object.getOwnPropertyNames(t);return Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(t))),e.filter(function(e){return o.call(t,e)})}var o=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(t,e){for(var o,i,s=n(t),a=1;ae;++e)i[e-1]=arguments[e];for(o=o.slice(),e=0;r=o[e];++e)l.call(r,this,i)}else switch(arguments.length){case 1:p.call(o,this);break;case 2:p.call(o,this,arguments[1]);break;case 3:p.call(o,this,arguments[1],arguments[2]);break;default:for(n=arguments.length,i=new Array(n-1),e=1;n>e;++e)i[e-1]=arguments[e];l.call(o,this,i)}},a={on:r,once:o,off:i,emit:s},c={on:f(r),once:f(o),off:f(i),emit:f(s)},u=y({},c),t.exports=e=function(t){return null==t?d(u):y(Object(t),c)},e.methods=a},function(t,e,n){"use strict";var r,o=n(7),i=n(14),s=n(15),a=n(16);r=t.exports=function(t,e){var n,r,s,c,u;return arguments.length<2||"string"!=typeof t?(c=e,e=t,t=null):c=arguments[2],null==t?(n=s=!0,r=!1):(n=a.call(t,"c"),r=a.call(t,"e"),s=a.call(t,"w")),u={value:e,configurable:n,enumerable:r,writable:s},c?o(i(c),u):u},r.gs=function(t,e,n){var r,c,u,f;return"string"!=typeof t?(u=n,n=e,e=t,t=null):u=arguments[3],null==e?e=void 0:s(e)?null==n?n=void 0:s(n)||(u=n,n=void 0):(u=e,e=n=void 0),null==t?(r=!0,c=!1):(r=a.call(t,"c"),c=a.call(t,"e")),f={get:e,set:n,configurable:r,enumerable:c},u?o(i(u),f):f}},function(t,e,n){"use strict";t.exports=n(8)()?Object.assign:n(9)},function(t,e){"use strict";t.exports=function(){var t,e=Object.assign;return"function"!=typeof e?!1:(t={foo:"raz"},e(t,{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},function(t,e,n){"use strict";var r=n(10),o=n(13),i=Math.max;t.exports=function(t,e){var n,s,a,c=i(arguments.length,2);for(t=Object(o(t)),a=function(r){try{t[r]=e[r]}catch(o){n||(n=o)}},s=1;c>s;++s)e=arguments[s],r(e).forEach(a);if(void 0!==n)throw n;return t}},function(t,e,n){"use strict";t.exports=n(11)()?Object.keys:n(12)},function(t,e){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(t){return!1}}},function(t,e){"use strict";var n=Object.keys;t.exports=function(t){return n(null==t?t:Object(t))}},function(t,e){"use strict";t.exports=function(t){if(null==t)throw new TypeError("Cannot use null or undefined");return t}},function(t,e){"use strict";var n=Array.prototype.forEach,r=Object.create,o=function(t,e){var n;for(n in t)e[n]=t[n]};t.exports=function(t){var e=r(null);return n.call(arguments,function(t){null!=t&&o(Object(t),e)}),e}},function(t,e){"use strict";t.exports=function(t){return"function"==typeof t}},function(t,e,n){"use strict";t.exports=n(17)()?String.prototype.contains:n(18)},function(t,e){"use strict";var n="razdwatrzy";t.exports=function(){return"function"!=typeof n.contains?!1:n.contains("dwa")===!0&&n.contains("foo")===!1}},function(t,e){"use strict";var n=String.prototype.indexOf;t.exports=function(t){return n.call(this,t,arguments[1])>-1}},function(t,e){"use strict";t.exports=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return t}}])}); //# sourceMappingURL=dolly.min.js.map