UNPKG

three.proton

Version:

three.Proton is an easily customizable html5 particle engine for three.js

10 lines 46.5 kB
/*! * three.proton v0.1.3 * https://github.com/a-jie/three.proton * * Copyright 2011-2017, A-JIE * Licensed under the MIT license * http://www.opensource.org/licenses/mit-license * */ (function(a,b){typeof define=="function"&&define.amd?define([],b):typeof exports=="object"?module.exports=b():a.Proton=b()})(this,function(){function bc(a,b,c,d){bc._super_.call(this),this.camera=a,this.renderer=b,this.dis=c||20,d=d||"1234";for(var e=1;e<5;e++)this["d"+e]=d.indexOf(e+"")>=0;this.name="ScreenZone"}function bb(b,c,d,e,f,g){var h,i,j,k,l,e;bb._super_.call(this),a.Util.isUndefined(c,d,e,f,g)?(h=i=j=0,k=l=e=b||100):a.Util.isUndefined(e,f,g)?(h=i=j=0,k=b,l=c,e=d):(h=b,i=c,j=d,k=e,l=f,e=g),this.x=h,this.y=i,this.z=j,this.width=k,this.height=l,this.depth=e,this.friction=.85,this.max=6}function ba(b,c,d){var e,f,g;ba._super_.call(this),a.Util.isUndefined(b,c,d)?e=f=g=0:(e=b,f=c,g=d),this.x=e,this.y=e,this.z=e}function _(a,b){_._super_.call(this),a instanceof THREE.Geometry?this.geometry=a:this.geometry=a.geometry,this.scale=b||1}function $(b,c,d,e){var f,g,h,i;$._super_.call(this),a.Util.isUndefined(c,d,e)?(f=g=h=0,i=b||100):(f=b,g=c,h=d,i=e),this.x=f,this.y=f,this.z=f,this.radius=i,this.the=this.phi=0}function Z(b,c,d,e,f,g){Z._super_.call(this),b instanceof a.Vector3D?(this.x1=b.x,this.y1=b.y,this.z1=b.z,this.x2=e.x,this.y2=e.y,this.z2=e.z):(this.x1=b,this.y1=c,this.z1=d,this.x2=e,this.y2=f,this.z2=g)}function Y(){this.vector=new a.Vector3D(0,0,0),this.random=0,this.crossType="dead",this.log=!0}function X(){X._super_.call(this),this.targetPool=new a.Pool,this.materialPool=new a.Pool,this.name="CustomRender"}function W(a){W._super_.call(this,a),this._body=new THREE.Sprite(new THREE.SpriteMaterial({color:16777215})),this.name="SpriteRender"}function V(a){V._super_.call(this),this.points=a,this.name="PointsRender"}function U(b){U._super_.call(this),this.container=b,this._targetPool=new a.Pool,this._materialPool=new a.Pool,this._body=new THREE.Mesh(new THREE.BoxGeometry(50,50,50),new THREE.MeshLambertMaterial({color:"#ff0000"})),this.name="MeshRender"}function T(){this.name="BaseRender"}function Q(b,c,d){this.mouseTarget=a.Util.initValue(b,window),this.ease=a.Util.initValue(c,.7),this._allowEmitting=!1,this.initEventHandler(),Q._super_.call(this,d)}function P(a){this.selfBehaviours=[],P._super_.call(this,a)}function O(b){this.initializes=[],this.particles=[],this.behaviours=[],this.currentEmitTime=0,this.totalEmitTimes=-1,this.damping=.006,this.bindEmitter=!0,this.rate=new a.Rate(1,.1),O._super_.call(this,b),this.id="emitter_"+O.ID++,this.cID=0,this.name="Emitter"}function N(a,b,c,d,e,f,g){N._super_.call(this,f,g),N.prototype.reset(a,b,c,d,e),this.name="Spring"}function M(a,b,c,d){M._super_.call(this,c,d),this.reset(a,b),this.name="Color"}function L(a,b,c,d,e){L._super_.call(this,d,e),this.reset(a,b,c),this.name="Rotate"}function K(a,b,c,d){K._super_.call(this,c,d),this.reset(a,b),this.name="Scale"}function J(a,b,c,d){J._super_.call(this,c,d),this.reset(a,b),this.name="Alpha"}function I(a,b,c,d){I._super_.call(this,c,d),this.reset(a,b),this.name="CrossZone"}function H(a,b,c,d,e){H._super_.call(this,d,e),this.reset(a,b,c),this.name="Collision"}function G(a,b,c){G._super_.call(this,0,-a,0,b,c),this.name="Gravity"}function F(a,b,c,d,e){F._super_.call(this,a,b,c,d,e),this.force*=-1,this.name="Repulsion"}function E(a,b,c,d,e,f){E._super_.call(this,e,f),this.reset(a,b,c,d),this.time=0,this.name="RandomDrift"}function D(b,c,d,e,f){D._super_.call(this,e,f),this.targetPosition=a.Util.initValue(b,new a.Vector3D),this.radius=a.Util.initValue(d,1e3),this.force=a.Util.initValue(this.normalizeValue(c),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new a.Vector3D,this.lengthSq=0,this.name="Attraction"}function C(a,b,c,d,e){C._super_.call(this,d,e),C.prototype.reset.call(this,a,b,c),this.name="Force"}function B(b,c,d){B._super_.call(this),this.body=a.createArraySpan(b),this.w=c,this.h=a.Util.initValue(d,this.w)}function A(b,c,d){A._super_.call(this),this.radius=a.createSpan(b,c,d)}function z(b,c,d){z._super_.call(this),this.massPan=a.createSpan(b,c,d)}function y(b,c,d){y._super_.call(this),this.reset(b,c,d),this.dirVec=new a.Vector3D(0,0,0),this.name="Velocity"}function x(){x._super_.call(this),this.reset.apply(this,arguments)}function w(b,c,d){w._super_.call(this),this.lifePan=a.createSpan(b,c,d)}function u(){this.name="Initialize"}function t(b,c){this.numPan=a.createSpan(a.Util.initValue(b,1)),this.timePan=a.createSpan(a.Util.initValue(c,1)),this.startTime=0,this.nextTime=0,this.init()}function s(b,c){this.id="Behaviour_"+s.id++,this.life=a.Util.initValue(b,Infinity),this.easing=a.Util.initValue(c,a.ease.setEasingByName(a.ease.easeLinear)),this.age=0,this.energy=1,this.dead=!1,this.name="Behaviour"}function r(a,b,c,d,e,f){this.x=a,this.y=b,this.z=c,this.width=d,this.height=e,this.depth=f,this.bottom=this.y+this.height,this.right=this.x+this.width,this.right=this.x+this.width}function p(b){this._arr=a.Util.isArray(b)?b:[b]}function o(b,c,d){this._isArray=!1,a.Util.isArray(b)?(this._isArray=!0,this.a=b):(this.a=a.Util.initValue(b,1),this.b=a.Util.initValue(c,this.a),this._center=a.Util.initValue(d,!1))}function i(){this.cID=0,this.list={}}function h(b){this.id="particle_"+h.ID++,this.name="Particle",this.reset("init"),a.Util.setPrototypeByObj(this,b)}function b(){this.initialize()}function a(b,c){this.preParticles=a.Util.initValue(b,a.POOL_MAX),this.integrationType=a.Util.initValue(c,a.EULER),this.emitters=[],this.renderers=[],this.pool=new a.Pool,a.integrator=new a.Integration(this.integrationType)}a.POOL_MAX=500,a.TIME_STEP=60,a.PI=3.142,a.DR=a.PI/180,a.MEASURE=100,a.EULER="euler",a.RK2="runge-kutta2",a.RK4="runge-kutta4",a.VERLET="verlet",a.PARTICLE_CREATED="partilcleCreated",a.PARTICLE_UPDATE="partilcleUpdate",a.PARTICLE_SLEEP="particleSleep",a.PARTICLE_DEAD="partilcleDead",a.PROTON_UPDATE="protonUpdate",a.PROTON_UPDATE_AFTER="protonUpdateAfter",a.EMITTER_ADDED="emitterAdded",a.EMITTER_REMOVED="emitterRemoved",a.bindEmtterEvent=!1,a.prototype={addRender:function(a){this.renderers.push(a),a.init(this)},removeRender:function(a){this.renderers.splice(this.renderers.indexOf(a),1),a.remove(this)},addEmitter:function(a){this.emitters.push(a),a.parent=this,this.dispatchEvent("EMITTER_ADDED",a)},removeEmitter:function(a){a.parent==this&&(this.emitters.splice(this.emitters.indexOf(a),1),a.parent=null,this.dispatchEvent("EMITTER_REMOVED",a))},update:function(a){this.dispatchEvent("PROTON_UPDATE",this);var b=a||.0167;if(b>0){var c=this.emitters.length;while(c--)this.emitters[c].update(b)}this.dispatchEvent("PROTON_UPDATE_AFTER",this)},getCount:function(){var a=0,b,c=this.emitters.length;for(b=0;b<c;b++)a+=this.emitters[b].particles.length;return a},destroy:function(){var a=0,b=this.emitters.length;for(a;a<b;a++)this.emitters[a].destroy(),delete this.emitters[a];this.emitters.length=0,this.pool.destroy()}},b.initialize=function(a){a.addEventListener=c.addEventListener,a.removeEventListener=c.removeEventListener,a.removeAllEventListeners=c.removeAllEventListeners,a.hasEventListener=c.hasEventListener,a.dispatchEvent=c.dispatchEvent};var c=b.prototype;c._listeners=null,c.initialize=function(){},c.addEventListener=function(a,b){this._listeners?this.removeEventListener(a,b):this._listeners={},this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push(b);return b},c.removeEventListener=function(a,b){if(!!this._listeners){if(!this._listeners[a])return;var c=this._listeners[a];for(var d=0,e=c.length;d<e;d++)if(c[d]==b){e==1?delete this._listeners[a]:c.splice(d,1);break}}},c.removeAllEventListeners=function(a){a?this._listeners&&delete this._listeners[a]:this._listeners=null},c.dispatchEvent=function(a,b){var c=!1,d=this._listeners;if(a&&d){var e=d[a];if(!e)return c;e=e.slice();var f,g=e.length;while(g--){var f=e[g];c=c||f(b)}}return!!c},c.hasEventListener=function(a){var b=this._listeners;return!!b&&!!b[a]},b.initialize(a.prototype),a.EventDispatcher=b;var d=d||{initValue:function(a,b){var a=a!=null&&a!=undefined?a:b;return a},isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},destroyArray:function(a){a.length=0},destroyObject:function(a){for(var b in a)delete a[b]},isUndefined:function(){for(var a in arguments){var b=arguments[a];if(b!==undefined)return!1}return!0},setVectorByObj:function(a,b){b.x!==undefined&&(a.p.x=b.x),b.y!==undefined&&(a.p.y=b.y),b.z!==undefined&&(a.p.z=b.z),b.vx!==undefined&&(a.v.x=b.vx),b.vy!==undefined&&(a.v.y=b.vy),b.vz!==undefined&&(a.v.z=b.vz),b.ax!==undefined&&(a.a.x=b.ax),b.ay!==undefined&&(a.a.y=b.ay),b.az!==undefined&&(a.a.z=b.az),b.p!==undefined&&a.p.copy(b.p),b.v!==undefined&&a.v.copy(b.v),b.a!==undefined&&a.a.copy(b.a),b.position!==undefined&&a.p.copy(b.position),b.velocity!==undefined&&a.v.copy(b.velocity),b.accelerate!==undefined&&a.a.copy(b.accelerate)},setPrototypeByObj:function(a,b,c){for(var e in b)a.hasOwnProperty(e)&&(c?c.indexOf(e)<0&&(a[e]=d._getValue(b[e])):a[e]=d._getValue(b[e]));return a},_getValue:function(a){return a instanceof o?a.getValue():a},inherits:function(a,b){a._super_=b;if(Object.create)a.prototype=Object.create(b.prototype,{constructor:{value:a}});else{var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}}};a.Util=d;var e=e||{getRGB:function(a){var b={};if(typeof a=="number")d=Math.floor(a),b.r=(a>>16&255)/255,b.g=(a>>8&255)/255,b.b=(a&255)/255;else if(typeof a=="string"){var c;if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))b.r=Math.min(255,parseInt(c[1],10))/255,b.g=Math.min(255,parseInt(c[2],10))/255,b.b=Math.min(255,parseInt(c[3],10))/255;else if(c=/^\#([A-Fa-f0-9]+)$/.exec(a)){var d=c[1];b.r=parseInt(d.charAt(0)+d.charAt(1),16)/255,b.g=parseInt(d.charAt(2)+d.charAt(3),16)/255,b.b=parseInt(d.charAt(4)+d.charAt(5),16)/255}}else a instanceof THREE.Color&&(b.r=a.r,b.g=a.g,b.b=a.b);return b}};a.ColorUtil=e;var f={toScreenPos:function(){var a=new THREE.Vector3;return function(b,c,d){a.copy(b),a.project(c),a.x=Math.round((a.x+1)*d.width/2),a.y=Math.round((-a.y+1)*d.height/2),a.z=0;return a}}(),toSpacePos:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c;return function(d,e,f){a.set(d.x/f.width*2-1,-(d.y/f.height)*2+1,.5),a.unproject(e),b.copy(a.sub(e.position).normalize()),c=-e.position.z/b.z,a.copy(e.position),a.add(b.multiplyScalar(c));return a}}(),getTexture:function(){var b={};return function(c){if(c instanceof THREE.Texture)return c;if(typeof c=="string"){var d=a.PUID.hash(c);b[d]||(b[d]=new THREE.Texture(c));return b[d]}if(c instanceof Image){var d=a.PUID.hash(c.src);b[d]||(b[d]=new THREE.Texture(c));return b[d]}}}()};a.THREEUtil=f;var g=g||{_id:0,_uids:{},id:function(a){for(var b in this._uids)if(this._uids[b]==a)return b;var c="PUID_"+this._id++;this._uids[c]=a;return c},hash:function(a){return}};a.PUID=g,h.ID=0,h.prototype={getDirection:function(){return Math.atan2(this.v.x,-this.v.y)*(180/a.PI)},reset:function(b){this.life=Infinity,this.age=0,this.energy=1,this.dead=!1,this.sleep=!1,this.body=null,this.parent=null,this.mass=1,this.radius=10,this.alpha=1,this.scale=1,this.useColor=!1,this.useAlpha=!1,this.easing=a.ease.setEasingByName(a.ease.easeLinear),b?(this.p=new a.Vector3D,this.v=new a.Vector3D,this.a=new a.Vector3D,this.old={},this.old.p=this.p.clone(),this.old.v=this.v.clone(),this.old.a=this.a.clone(),this.behaviours=[],this.transform={},this.color={r:0,g:0,b:0},this.rotation=new a.Vector3D):(this.p.set(0,0,0),this.v.set(0,0,0),this.a.set(0,0,0),this.old.p.set(0,0,0),this.old.v.set(0,0,0),this.old.a.set(0,0,0),this.color.r=0,this.color.g=0,this.color.b=0,this.rotation.clear(),a.Util.destroyObject(this.transform),this.removeAllBehaviours());return this},update:function(a,b){if(!this.sleep){this.age+=a;var c=this.behaviours.length;while(c--)this.behaviours[c]&&this.behaviours[c].applyBehaviour(this,a,b)}if(this.age>=this.life)this.destroy();else{var d=this.easing(this.age/this.life);this.energy=Math.max(1-d,0)}},addBehaviour:function(a){this.behaviours.push(a),a.initialize(this)},addBehaviours:function(a){var b=a.length;while(b--)this.addBehaviour(a[b])},removeBehaviour:function(a){var b=this.behaviours.indexOf(a);b>-1&&this.behaviours.splice(b,1)},removeAllBehaviours:function(){a.Util.destroyArray(this.behaviours)},destroy:function(){this.removeAllBehaviours(),this.energy=0,this.dead=!0,this.parent=null}},a.Particle=h,i.prototype={create:function(a){this.cID++;return typeof a=="function"?new a:a.clone()},getCount:function(){var a=0;for(var b in this.list)a+=this.list[b].length;return a++},get:function(b){var c,d=b.__puid||a.PUID.id(b);this.list[d]&&this.list[d].length>0?c=this.list[d].pop():c=this.create(b),c.__puid=b.__puid||d;return c},expire:function(a){return this._getList(a.__puid).push(a)},destroy:function(){for(var a in this.list)this.list[a].length=0,delete this.list[a]},_getList:function(a){a=a||"default",this.list[a]||(this.list[a]=[]);return this.list[a]}},a.Pool=i;var j={randomAToB:function(a,b,c){return c?(Math.random()*(b-a)>>0)+a:a+Math.random()*(b-a)},randomFloating:function(a,b,c){return j.randomAToB(a-b,a+b,c)},randomZone:function(a){},degreeTransform:function(b){return b*a.PI/180},toColor16:function(a){return"#"+a.toString(16)},randomColor:function(){return"#"+("00000"+(Math.random()*16777216<<0).toString(16)).slice(-6)},lerp:function(a,b,c){return b+(a-b)*c},getNormal:function(a,b){a.x==0&&a.y==0?a.z==0?b.set(1,0,1):b.set(1,1,-a.y/a.z):a.x==0?b.set(1,0,1):b.set(-a.y/a.x,1,1);return b.normalize()},axisRotate:function(a,b,c,d){var e=Math.cos(d),f=Math.sin(d),g=c.dot(b)*(1-e);a.copy(c),a.cross(b).scalar(f),a.addValue(b.x*e,b.y*e,b.z*e),a.addValue(c.x*g,c.y*g,c.z*g)}};a.MathUtils=j;var l=function(b){this.type=a.Util.initValue(b,a.EULER)};l.prototype={integrate:function(a,b,c){this.euler(a,b,c)},euler:function(a,b,c){a.sleep||(a.old.p.copy(a.p),a.old.v.copy(a.v),a.a.scalar(1/a.mass),a.v.add(a.a.scalar(b)),a.p.add(a.old.v.scalar(b)),c&&a.v.scalar(c),a.a.clear())}},a.Integration=l;var m=function(a,b,c){this.x=a||0,this.y=b||0,this.z=c||0};m.prototype={set:function(a,b,c){this.x=a,this.y=b,this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},getGradient:function(){if(this.x!=0)return Math.atan2(this.y,this.x);if(this.y>0)return a.PI/2;if(this.y<0)return-a.PI/2},copy:function(a){this.x=a.x,this.y=a.y,this.z=a.z;return this},add:function(a,b){if(b!==undefined)return this.addVectors(a,b);this.x+=a.x,this.y+=a.y,this.z+=a.z;return this},addValue:function(a,b,c){this.x+=a,this.y+=b,this.z+=c;return this},addVectors:function(a,b){this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z;return this},addScalar:function(a){this.x+=a,this.y+=a,this.z+=a;return this},sub:function(a,b){if(b!==undefined)return this.subVectors(a,b);this.x-=a.x,this.y-=a.y,this.z-=a.z;return this},subVectors:function(a,b){this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z;return this},scalar:function(a){this.x*=a,this.y*=a,this.z*=a;return this},divideScalar:function(a){a!==0?(this.x/=a,this.y/=a,this.z/=a):this.set(0,0,0);return this},negate:function(){return this.scalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},cross:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y,this.y=d*a.x-b*a.z,this.z=b*a.y-c*a.x;return this},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g,this.y=e*f-c*h,this.z=c*g-d*f;return this},eulerFromDir:function(a){},applyEuler:function(){var b;return function(c){b===undefined&&(b=new a.Quaternion),this.applyQuaternion(b.setFromEuler(c));return this}}(),applyAxisAngle:function(){var b;return function(c,d){b===undefined&&(b=new a.Quaternion),this.applyQuaternion(b.setFromAxisAngle(c,d));return this}}(),applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z,h=a.w,i=h*b+f*d-g*c,j=h*c+g*b-e*d,k=h*d+e*c-f*b,l=-e*b-f*c-g*d;this.x=i*h+l*-e+j*-g-k*-f,this.y=j*h+l*-f+k*-e-i*-g,this.z=k*h+l*-g+i*-f-j*-e;return this},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y,d=this.z-a.z;return b*b+c*c+d*d},lerp:function(a,b){this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this.z+=(a.z-this.z)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},clear:function(){this.x=0,this.y=0,this.z=0;return this},clone:function(){return new a.Vector3D(this.x,this.y,this.z)},toString:function(){return"x:"+this.x+"y:"+this.y+"z:"+this.z}},a.Vector3D=m;var n=function(a,b,c){this.radius=a||1,this.phi=c||0,this.theta=b||0};n.prototype={set:function(a,b,c){this.radius=a||1,this.phi=c||0,this.theta=b||0;return this},setRadius:function(a){this.radius=a;return this},setPhi:function(a){this.phi=a;return this},setTheta:function(a){this.theta=a;return this},copy:function(a){this.radius=a.radius,this.phi=a.phi,this.theta=a.theta;return this},toVector3D:function(){return new a.Vector3D(this.getX(),this.getY(),this.getZ())},getX:function(){return this.radius*Math.sin(this.theta)*Math.cos(this.phi)},getY:function(){return-this.radius*Math.sin(this.theta)*Math.sin(this.phi)},getZ:function(){return this.radius*Math.cos(this.theta)},normalize:function(){this.radius=1;return this},equals:function(a){return a.radius===this.radius&&a.phi===this.phi&&a.theta===this.theta},clear:function(){this.radius=0,this.phi=0,this.theta=0;return this},clone:function(){return new n(this.radius,this.phi,this.theta)}},a.Polar3D=n,o.prototype={getValue:function(b){return this._isArray?this.a[this.a.length*Math.random()>>0]:this._center?a.MathUtils.randomFloating(this.a,this.b,b):a.MathUtils.randomAToB(this.a,this.b,b)}},a.createSpan=function(a,b,c){if(a instanceof o)return a;return b===undefined?new o(a):c===undefined?new o(a,b):new o(a,b,c)},a.Span=o,a.Util.inherits(p,a.Span),p.prototype.getValue=function(){var b=this._arr[this._arr.length*Math.random()>>0];return b=="random"||b=="Random"?a.MathUtils.randomColor():b},a.createArraySpan=function(b){if(!b)return null;return b instanceof a.ArraySpan?b:new a.ArraySpan(b)},a.ArraySpan=p;var q=function(a,b,c,d){this.x=a||0,this.y=b||0,this.z=c||0,this.w=d!==undefined?d:1};q.prototype={set:function(a,b,c,d){this.x=a,this.y=b,this.z=c,this.w=d;return this},clone:function(){return new a.Quaternion(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w;return this},setFromEuler:function(a){var b=Math.cos(a.x/2),c=Math.cos(a.y/2),d=Math.cos(a.z/2),e=Math.sin(a.x/2),f=Math.sin(a.y/2),g=Math.sin(a.z/2);this.x=e*c*d+b*f*g,this.y=b*f*d-e*c*g,this.z=b*c*g+e*f*d,this.w=b*c*d-e*f*g;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d,this.y=a.y*d,this.z=a.z*d,this.w=Math.cos(c);return this},normalize:function(){var a=this.length();a===0?(this.x=0,this.y=0,this.z=0,this.w=1):(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w}},a.Quaternion=q,r.prototype={contains:function(a,b,c){return a<=this.right&&a>=this.x&&b<=this.bottom&&b>=this.y&&c<=this.depth&&c>=this.z?!0:!1}},a.Box=r,s.id=0,s.prototype={reset:function(b,c){this.life=a.Util.initValue(b,Infinity),this.easing=a.Util.initValue(c,a.ease.setEasingByName(a.ease.easeLinear))},normalizeForce:function(b){return b.scalar(a.MEASURE)},normalizeValue:function(b){return b*a.MEASURE},initialize:function(a){},applyBehaviour:function(a,b,c){if(!this.dead){this.age+=b;if(this.age>=this.life){this.energy=0,this.dead=!0;return}var d=this.easing(a.age/a.life);this.energy=Math.max(1-d,0)}},destroy:function(){}},a.Behaviour=s,t.prototype={init:function(){this.startTime=0,this.nextTime=this.timePan.getValue()},getValue:function(a){this.startTime+=a;if(this.startTime>=this.nextTime){this.init();return this.numPan.b==1?this.numPan.getValue("Float")>.5?1:0:this.numPan.getValue("Int")}return 0}},a.Rate=t,u.prototype.reset=function(){},u.prototype.init=function(a,b){b?this.initialize(b):this.initialize(a)},u.prototype.initialize=function(a){},a.Initialize=u;var v={initialize:function(b,c,d){var e=d.length;while(e--){var f=d[e];f instanceof a.Initialize?f.init(b,c):v.init(b,c,f)}v.bindEmitter(b,c)},init:function(b,c,d){a.Util.setPrototypeByObj(c,d),a.Util.setVectorByObj(c,d)},bindEmitter:function(a,b){a.bindEmitter&&(b.p.add(a.p),b.v.add(a.v),b.a.add(a.a),b.v.applyEuler(a.rotation))}};a.InitializeUtil=v,a.Util.inherits(w,a.Initialize),w.prototype.initialize=function(a){this.lifePan.a==Infinity||this.lifePan.a=="infi"?a.life=Infinity:a.life=this.lifePan.getValue()},a.Life=w,a.Util.inherits(x,a.Initialize),x.prototype.reset=function(){this.zones?this.zones.length=0:this.zones=[];var a=Array.prototype.slice.call(arguments);this.zones=this.zones.concat(a)},x.prototype.addZone=function(){var a=Array.prototype.slice.call(arguments);this.zones=this.zones.concat(a)},x.prototype.initialize=function(){var a;return function(a){var b=this.zones[Math.random()*this.zones.length>>0];b.getPosition(),a.p.x=b.vector.x,a.p.y=b.vector.y,a.p.z=b.vector.z}}(),a.Position=x,a.P=x,a.Util.inherits(y,a.Initialize),y.prototype.reset=function(b,c,d){b instanceof a.Vector3D?(this.radiusPan=a.createSpan(1),this.dir=b.clone(),this.tha=c*a.DR,this._useV=!0):b instanceof a.Polar3D?(this.tha=c*a.DR,this.dirVec=b.toVector3D(),this._useV=!1):(this.radiusPan=a.createSpan(b),this.dir=c.clone().normalize(),this.tha=d*a.DR,this._useV=!0)},y.prototype.normalize=function(b){return b*a.MEASURE},y.prototype.initialize=function(){var b,c=new a.Vector3D(0,0,1),d=new a.Vector3D(0,0,0);return function(e){b=this.tha*Math.random(),this._useV&&this.dirVec.copy(this.dir).scalar(this.radiusPan.getValue()),a.MathUtils.getNormal(this.dirVec,c),d.copy(this.dirVec).applyAxisAngle(c,b),d.applyAxisAngle(this.dirVec.normalize(),Math.random()*a.PI*2),e.v.copy(d);return this}}(),a.Velocity=y,a.V=y,a.Util.inherits(z,a.Initialize),z.prototype.initialize=function(a){a.mass=this.massPan.getValue()},a.Mass=z,a.Util.inherits(A,a.Initialize),A.prototype.reset=function(b,c,d){this.radius=a.createSpan(b,c,d)},A.prototype.initialize=function(a){a.radius=this.radius.getValue(),a.transform.oldRadius=a.radius},a.Radius=A,a.Util.inherits(B,a.Initialize),B.prototype.initialize=function(a){var b=this.body.getValue();this.w?a.body={width:this.w,height:this.h,body:b}:a.body=b},a.Body=B,a.Util.inherits(C,a.Behaviour),C.prototype.reset=function(b,c,d){this.force=this.normalizeForce(new a.Vector3D(b,c,d)),this.force.id=Math.random()},C.prototype.applyBehaviour=function(a,b,c){C._super_.prototype.applyBehaviour.call(this,a,b,c),a.a.add(this.force)},a.F=a.Force=C,a.Util.inherits(D,a.Behaviour),D.prototype.reset=function(b,c,d,e,f){this.targetPosition=a.Util.initValue(b,new a.Vector3D),this.radius=a.Util.initValue(d,1e3),this.force=a.Util.initValue(this.normalizeValue(c),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new a.Vector3D,this.lengthSq=0,e&&D._super_.prototype.reset.call(this,e,f)},D.prototype.applyBehaviour=function(a,b,c){D._super_.prototype.applyBehaviour.call(this,a,b,c),this.attractionForce.copy(this.targetPosition),this.attractionForce.sub(a.p),this.lengthSq=this.attractionForce.lengthSq(),this.lengthSq>4e-6&&this.lengthSq<this.radiusSq&&(this.attractionForce.normalize(),this.attractionForce.scalar(1-this.lengthSq/this.radiusSq),this.attractionForce.scalar(this.force),a.a.add(this.attractionForce))},a.Attraction=D,a.Util.inherits(E,a.Behaviour),E.prototype.reset=function(b,c,d,e,f,g){this.randomFoce=this.normalizeForce(new a.Vector3D(b,c,d)),this.delayPan=a.createSpan(e||.03),this.time=0,f&&E._super_.prototype.reset.call(this,f,g)},E.prototype.applyBehaviour=function(b,c,d){E._super_.prototype.applyBehaviour.call(this,b,c,d),this.time+=c;if(this.time>=this.delayPan.getValue()){var e=a.MathUtils.randomAToB(-this.randomFoce.x,this.randomFoce.x),f=a.MathUtils.randomAToB(-this.randomFoce.y,this.randomFoce.y),g=a.MathUtils.randomAToB(-this.randomFoce.z,this.randomFoce.z);b.a.addValue(e,f,g),this.time=0}},a.RandomDrift=E,a.Util.inherits(F,a.Attraction),F.prototype.reset=function(a,b,c,d,e){F._super_.prototype.reset.call(this,a,b,c,d,e),this.force*=-1},a.Repulsion=F,a.Util.inherits(G,a.Force),G.prototype.reset=function(a,b,c){G._super_.prototype.reset.call(this,0,-a,0,b,c)},a.Gravity=G,a.G=G,a.Util.inherits(H,a.Behaviour),H.prototype.reset=function(b,c,d,e,f){this.emitter=b,this.useMass=c,this.callback=d,this.particles=[],this.delta=new a.Vector3D,e&&H._super_.prototype.reset.call(this,e,f)},H.prototype.applyBehaviour=function(a,b,c){var d=this.emitter?this.emitter.particles.slice(c):this.particles.slice(c),e,f,g,h,i,j,k=d.length;while(k--){e=d[k];if(e==a)continue;this.delta.copy(e.p).sub(a.p),f=this.delta.lengthSq(),h=a.radius+e.radius,f<=h*h&&(g=h-Math.sqrt(f),g+=.5,i=this._getAverageMass(a,e),j=this._getAverageMass(e,a),a.p.add(this.delta.clone().normalize().scalar(g*-i)),e.p.add(this.delta.normalize().scalar(g*j)),this.callback&&this.callback(a,e))}},H.prototype._getAverageMass=function(a,b){return this.useMass?b.mass/(a.mass+b.mass):.5},a.Collision=H,a.Util.inherits(I,a.Behaviour),I.prototype.reset=function(b,c,d,e){var f,g;typeof b=="string"?(g=b,f=c):(g=c,f=b),this.zone=f,this.zone.crossType=a.Util.initValue(g,"dead"),d&&I._super_.prototype.reset.call(this,d,e)},I.prototype.applyBehaviour=function(a,b,c){I._super_.prototype.applyBehaviour.call(this,a,b,c),this.zone.crossing.call(this.zone,a)},a.CrossZone=I,a.Util.inherits(J,a.Behaviour),J.prototype.reset=function(b,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=a.createSpan(a.Util.initValue(b,1)),this.b=a.createSpan(c),d&&J._super_.prototype.reset.call(this,d,e)},J.prototype.initialize=function(a){a.useAlpha=!0,a.transform.alphaA=this.a.getValue(),this._same?a.transform.alphaB=a.transform.alphaA:a.transform.alphaB=this.b.getValue()},J.prototype.applyBehaviour=function(b,c,d){J._super_.prototype.applyBehaviour.call(this,b,c,d),b.alpha=a.MathUtils.lerp(b.transform.alphaA,b.transform.alphaB,this.energy),b.alpha<.002&&(b.alpha=0)},a.Alpha=J,a.Util.inherits(K,a.Behaviour),K.prototype.reset=function(b,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=a.createSpan(a.Util.initValue(b,1)),this.b=a.createSpan(c),d&&K._super_.prototype.reset.call(this,d,e)},K.prototype.initialize=function(a){a.transform.scaleA=this.a.getValue(),a.transform.oldRadius=a.radius,this._same?a.transform.scaleB=a.transform.scaleA:a.transform.scaleB=this.b.getValue()},K.prototype.applyBehaviour=function(b,c,d){K._super_.prototype.applyBehaviour.call(this,b,c,d),b.scale=a.MathUtils.lerp(b.transform.scaleA,b.transform.scaleB,this.energy),b.scale<5e-4&&(b.scale=0),b.radius=b.transform.oldRadius*b.scale},a.Scale=K,a.Util.inherits(L,a.Behaviour),L.prototype.reset=function(b,c,d,e,f){this.a=b||0,this.b=c||0,this.c=d||0,b===undefined||b=="same"?this._type="same":c==undefined?this._type="set":d===undefined?this._type="to":(this._type="add",this.a=a.createSpan(this.a*a.DR),this.b=a.createSpan(this.b*a.DR),this.c=a.createSpan(this.c*a.DR)),e&&L._super_.prototype.reset.call(this,e,f)},L.prototype.initialize=function(b){switch(this._type){case"same":break;case"set":this._setRotation(b.rotation,this.a);break;case"to":b.transform.fR=b.transform.fR||new a.Vector3D,b.transform.tR=b.transform.tR||new a.Vector3D,this._setRotation(b.transform.fR,this.a),this._setRotation(b.transform.tR,this.b);break;case"add":b.transform.addR=new a.Vector3D(this.a.getValue(),this.b.getValue(),this.c.getValue())}},L.prototype._setRotation=function(b,c){b=b||new a.Vector3D;if(c=="random"){var d=a.MathUtils.randomAToB(-a.PI,a.PI),e=a.MathUtils.randomAToB(-a.PI,a.PI),f=a.MathUtils.randomAToB(-a.PI,a.PI);b.set(d,e,f)}else c instanceof a.Vector3D&&b.copy(c)},L.prototype.applyBehaviour=function(b,c,d){L._super_.prototype.applyBehaviour.call(this,b,c,d);switch(this._type){case"same":b.rotation||(b.rotation=new a.Vector3D),b.rotation.eulerFromDir(b.v);break;case"set":break;case"to":b.rotation.x=a.MathUtils.lerp(b.transform.fR.x,b.transform.tR.x,this.energy),b.rotation.y=a.MathUtils.lerp(b.transform.fR.y,b.transform.tR.y,this.energy),b.rotation.z=a.MathUtils.lerp(b.transform.fR.z,b.transform.tR.z,this.energy);break;case"add":b.rotation.add(b.transform.addR)}},a.Rotate=L,a.Util.inherits(M,a.Behaviour),M.prototype.reset=function(b,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=a.createArraySpan(b),this.b=a.createArraySpan(c),d&&M._super_.prototype.reset.call(this,d,e)},M.prototype.initialize=function(b){b.transform.colorA=a.ColorUtil.getRGB(this.a.getValue()),b.useColor=!0,this._same?b.transform.colorB=b.transform.colorA:b.transform.colorB=a.ColorUtil.getRGB(this.b.getValue())},M.prototype.applyBehaviour=function(b,c,d){M._super_.prototype.applyBehaviour.call(this,b,c,d),this._same?(b.color.r=b.transform.colorA.r,b.color.g=b.transform.colorA.g,b.color.b=b.transform.colorA.b):(b.color.r=a.MathUtils.lerp(b.transform.colorA.r,b.transform.colorB.r,this.energy),b.color.g=a.MathUtils.lerp(b.transform.colorA.g,b.transform.colorB.g,this.energy),b.color.b=a.MathUtils.lerp(b.transform.colorA.b,b.transform.colorB.b,this.energy))},a.Color=M,a.Util.inherits(N,a.Behaviour),N.prototype.reset=function(b,c,d,e,f){this.pos?this.pos.set(b,c,d):this.pos=new a.Vector3D(b,c,d),this.spring=e||.1,this.friction=f||.98},N.prototype.applyBehaviour=function(a,b,c){N._super_.prototype.applyBehaviour.call(this,a,b,c),a.v.x+=(this.pos.x-a.p.x)*this.spring,a.v.y+=(this.pos.y-a.p.y)*this.spring,a.v.z+=(this.pos.z-a.p.z)*this.spring},a.Spring=N,O.ID=0,a.Util.inherits(O,a.Particle),a.EventDispatcher.initialize(O.prototype),O.prototype.emit=function(b,c){this.currentEmitTime=0,this.totalEmitTimes=a.Util.initValue(b,Infinity),c==!0||c=="life"||c=="destroy"?this.life=b=="once"?1:this.totalEmitTimes:isNaN(c)||(this.life=c),this.rate.init()},O.prototype.stopEmit=function(){this.totalEmitTimes=-1,this.currentEmitTime=0},O.prototype.removeAllParticles=function(){var a=this.particles.length;while(a--)this.particles[a].dead=!0},O.prototype.createParticle=function(b,c){var d=this.parent.pool.get(a.Particle);this.setupParticle(d,b,c),this.parent&&this.parent.dispatchEvent("PARTICLE_CREATED",d),a.bindEmtterEvent&&this.dispatchEvent("PARTICLE_CREATED",d);return d},O.prototype.addSelfInitialize=function(a){a.init?a.init(this):this.initAll()},O.prototype.addInitialize=function(){var a=arguments.length;while(a--)this.initializes.push(arguments[a])},O.prototype.removeInitialize=function(a){var b=this.initializes.indexOf(a);b>-1&&this.initializes.splice(b,1)},O.prototype.removeInitializers=function(){a.Util.destroyArray(this.initializes)},O.prototype.addBehaviour=function(){var a=arguments.length;while(a--)this.behaviours.push(arguments[a])},O.prototype.removeBehaviour=function(a){var b=this.behaviours.indexOf(a);b>-1&&this.behaviours.splice(b,1)},O.prototype.removeAllBehaviours=function(){a.Util.destroyArray(this.behaviours)},O.prototype.integrate=function(b){var c=1-this.damping;a.integrator.integrate(this,b,c);var d=this.particles.length;while(d--){var e=this.particles[d];e.update(b,d),a.integrator.integrate(e,b,c),this.parent&&this.parent.dispatchEvent("PARTICLE_UPDATE",e),a.bindEmtterEvent&&this.dispatchEvent("PARTICLE_UPDATE",e)}},O.prototype.emitting=function(a){if(this.totalEmitTimes=="once"){var b=this.rate.getValue(99999);b>0&&(this.cID=b);while(b--)this.createParticle();this.totalEmitTimes="none"}else if(!isNaN(this.totalEmitTimes)){this.currentEmitTime+=a;if(this.currentEmitTime<this.totalEmitTimes){var b=this.rate.getValue(a);b>0&&(this.cID=b);while(b--)this.createParticle()}}},O.prototype.update=function(b){this.age+=b,(this.dead||this.age>=this.life)&&this.destroy(),this.emitting(b),this.integrate(b);var c,d=this.particles.length;while(d--)c=this.particles[d],c.dead&&(this.parent&&this.parent.dispatchEvent("PARTICLE_DEAD",c),a.bindEmtterEvent&&this.dispatchEvent("PARTICLE_DEAD",c),this.parent.pool.expire(c.reset()),this.particles.splice(d,1))},O.prototype.setupParticle=function(b,c,d){var e=this.initializes,f=this.behaviours;c&&(a.Util.isArray(c)?e=c:e=[c]),d&&(a.Util.isArray(d)?f=d:f=[d]),a.InitializeUtil.initialize(this,b,e),b.addBehaviours(f),b.parent=this,this.particles.push(b)},O.prototype.destroy=function(){this.dead=!0,this.energy=0,this.totalEmitTimes=-1,this.particles.length==0&&(this.removeInitializers(),this.removeAllBehaviours(),this.parent&&this.parent.removeEmitter(this))},a.Emitter=O,a.Util.inherits(P,a.Emitter),P.prototype.addSelfBehaviour=function(){var a=arguments.length,b;for(b=0;b<a;b++)this.selfBehaviours.push(arguments[b])},P.prototype.removeSelfBehaviour=function(a){var b=this.selfBehaviours.indexOf(a);b>-1&&this.selfBehaviours.splice(b,1)},P.prototype.update=function(a){P._super_.prototype.update.call(this,a);if(!this.sleep){var b=this.selfBehaviours.length,c;for(c=0;c<b;c++)this.selfBehaviours[c].applyBehaviour(this,a,c)}},a.BehaviourEmitter=P,a.Util.inherits(Q,a.Emitter),Q.prototype.initEventHandler=function(){var a=this;this.mousemoveHandler=function(b){a.mousemove.call(a,b)},this.mousedownHandler=function(b){a.mousedown.call(a,b)},this.mouseupHandler=function(b){a.mouseup.call(a,b)},this.mouseTarget.addEventListener("mousemove",this.mousemoveHandler,!1)},Q.prototype.emit=function(){this._allowEmitting=!0},Q.prototype.stopEmit=function(){this._allowEmitting=!1},Q.prototype.setCameraAndCanvas=function(a,b){this.camera=a,this.canvas=b},Q.prototype.mousemove=function(b){if(b.layerX||b.layerX==0)this.p.x+=(b.layerX-this.p.x)*this.ease,this.p.y+=(b.layerY-this.p.y)*this.ease;else if(b.offsetX||b.offsetX==0)this.p.x+=(b.offsetX-this.p.x)*this.ease,this.p.y+=(b.offsetY-this.p.y)*this.ease;this.p.copy(a.THREEUtil.toSpacePos(this.p,this.camera,this.canvas)),this._allowEmitting&&Q._super_.prototype.emit.call(this,"once")},Q.prototype.destroy=function(){Q._super_.prototype.destroy.call(this),this.mouseTarget.removeEventListener("mousemove",this.mousemoveHandler,!1)},a.FollowEmitter=Q;var R=R||{easeLinear:function(a){return a},easeInQuad:function(a){return Math.pow(a,2)},easeOutQuad:function(a){return-(Math.pow(a-1,2)-1)},easeInOutQuad:function(a){if((a/=.5)<1)return.5*Math.pow(a,2);return-0.5*((a-=2)*a-2)},easeInCubic:function(a){return Math.pow(a,3)},easeOutCubic:function(a){return Math.pow(a-1,3)+1},easeInOutCubic:function(a){if((a/=.5)<1)return.5*Math.pow(a,3);return.5*(Math.pow(a-2,3)+2)},easeInQuart:function(a){return Math.pow(a,4)},easeOutQuart:function(a){return-(Math.pow(a-1,4)-1)},easeInOutQuart:function(a){if((a/=.5)<1)return.5*Math.pow(a,4);return-0.5*((a-=2)*Math.pow(a,3)-2)},easeInSine:function(b){return-Math.cos(b*(a.PI/2))+1},easeOutSine:function(b){return Math.sin(b*(a.PI/2))},easeInOutSine:function(b){return-0.5*(Math.cos(a.PI*b)-1)},easeInExpo:function(a){return a===0?0:Math.pow(2,10*(a-1))},easeOutExpo:function(a){return a===1?1:-Math.pow(2,-10*a)+1},easeInOutExpo:function(a){if(a===0)return 0;if(a===1)return 1;if((a/=.5)<1)return.5*Math.pow(2,10*(a-1));return.5*(-Math.pow(2,-10*--a)+2)},easeInCirc:function(a){return-(Math.sqrt(1-a*a)-1)},easeOutCirc:function(a){return Math.sqrt(1-Math.pow(a-1,2))},easeInOutCirc:function(a){if((a/=.5)<1)return-0.5*(Math.sqrt(1-a*a)-1);return.5*(Math.sqrt(1-(a-=2)*a)+1)},easeInBack:function(a){var b=1.70158;return a*a*((b+1)*a-b)},easeOutBack:function(a){var b=1.70158;return(a=a-1)*a*((b+1)*a+b)+1},easeInOutBack:function(a){var b=1.70158;if((a/=.5)<1)return.5*a*a*(((b*=1.525)+1)*a-b);return.5*((a-=2)*a*(((b*=1.525)+1)*a+b)+2)},setEasingByName:function(a){return R[a]?R[a]:R.easeLinear}};for(var S in R)S!="setEasingByName"&&(a[S]=R[S]);a.ease=R,T.prototype={init:function(a){var b=this;this.proton=a,this.proton.addEventListener("PROTON_UPDATE",function(a){b.onProtonUpdate.call(b,a)}),this.proton.addEventListener("PARTICLE_CREATED",function(a){b.onParticleCreated.call(b,a)}),this.proton.addEventListener("PARTICLE_UPDATE",function(a){b.onParticleUpdate.call(b,a)}),this.proton.addEventListener("PARTICLE_DEAD",function(a){b.onParticleDead.call(b,a)})},remove:function(a){this.proton=null},onParticleCreated:function(a){},onParticleUpdate:function(a){},onParticleDead:function(a){},onProtonUpdate:function(a){}},a.BaseRender=T,a.Util.inherits(U,a.BaseRender),U.prototype.onProtonUpdate=function(){},U.prototype.onParticleCreated=function(b){if(!b.target){b.body||(b.body=this._body),b.target=this._targetPool.get(b.body);if(b.useAlpha||b.useColor)b.target.material.__puid=a.PUID.id(b.body.material),b.target.material=this._materialPool.get(b.target.material)}b.target&&(b.target.position.copy(b.p),this.container.add(b.target))},U.prototype.onParticleUpdate=function(a){a.target&&(a.target.position.copy(a.p),a.target.rotation.set(a.rotation.x,a.rotation.y,a.rotation.z),this.scale(a),a.useAlpha&&(a.target.material.opacity=a.alpha,a.target.material.transparent=!0),a.useColor&&a.target.material.color.copy(a.color))},U.prototype.scale=function(a){a.target.scale.set(a.scale,a.scale,a.scale)},U.prototype.onParticleDead=function(a){a.target&&((a.useAlpha||a.useColor)&&this._materialPool.expire(a.target.material),this._targetPool.expire(a.target),this.container.remove(a.target),a.target=null)},a.MeshRender=U,a.Util.inherits(V,a.BaseRender),V.prototype.onProtonUpdate=function(){},V.prototype.onParticleCreated=function(a){a.target||(a.target=new THREE.Vector3),a.target.copy(a.p),this.points.geometry.vertices.push(a.target)},V.prototype.onParticleUpdate=function(a){a.target&&a.target.copy(a.p)},V.prototype.onParticleDead=function(a){if(a.target){var b=this.points.geometry.vertices.indexOf(a.target);b>-1&&this.points.geometry.vertices.splice(b,1),a.target=null}},a.PointsRender=V,a.Util.inherits(W,a.MeshRender),W.prototype.scale=function(a){a.target.scale.set(a.scale*a.radius,a.scale*a.radius,1)},a.SpriteRender=W,a.Util.inherits(X,a.BaseRender),X.prototype.onProtonUpdate=function(){},X.prototype.onParticleCreated=function(a){},X.prototype.onParticleUpdate=function(a){},X.prototype.onParticleDead=function(a){},a.CustomRender=X,Y.prototype={getPosition:function(){return null},crossing:function(a){switch(this.crossType){case"bound":this._bound(a);break;case"cross":this._cross(a);break;case"dead":this._dead(a)}},_dead:function(a){},_bound:function(a){},_cross:function(a){}},a.Zone=Y,a.Util.inherits(Z,a.Zone),Z.prototype.getPosition=function(){this.random=Math.random(),this.vector.x=this.x1+this.random*(this.x2-this.x1),this.vector.y=this.y1+this.random*(this.y2-this.y1),this.vector.z=this.z1+this.random*(this.z2-this.z1);return this.vector},Z.prototype.crossing=function(a){this.log&&(console.error("Sorry LineZone does not support crossing method"),this.log=!1)},a.LineZone=Z,a.Util.inherits($,a.Zone),$.prototype.getPosition=function(){var b,c,d;return function(){this.random=Math.random(),d=this.random*this.radius,tha=a.PI*Math.random(),c=a.PI*2*Math.random(),this.vector.x=this.x+d*Math.sin(tha)*Math.cos(c),this.vector.y=this.y+d*Math.sin(c)*Math.sin(tha),this.vector.z=this.z+d*Math.cos(tha);return this.vector}}(),$.prototype._dead=function(a){var b=a.p.distanceTo(this);b-a.radius>this.radius&&(a.dead=!0)},$.prototype._bound=function(){var b=new a.Vector3D,c=new a.Vector3D,d;return function(a){var e=a.p.distanceTo(this);e+a.radius>=this.radius&&(b.copy(a.p).sub(this).normalize(),c.copy(a.v),d=2*c.dot(b),a.v.sub(b.scalar(d)))}}(),$.prototype._cross=function(a){this.log&&(console.error("Sorry SphereZone does not support _cross method"),this.log=!1)},a.SphereZone=$,a.Util.inherits(_,a.Zone),_.prototype.getPosition=function(){var a=this.geometry.vertices,b=a[a.length*Math.random()>>0];this.vector.x=b.x*this.scale,this.vector.y=b.y*this.scale,this.vector.z=b.z*this.scale;return this.vector},_.prototype.crossing=function(a){this.log&&(console.error("Sorry MeshZone does not support crossing method"),this.log=!1)},a.MeshZone=_,a.Util.inherits(ba,a.Zone),ba.prototype.getPosition=function(){this.vector.x=this.x,this.vector.y=this.y,this.vector.z=this.z;return this.vector},ba.prototype.crossing=function(a){this.log&&(console.error("Sorry PointZone does not support crossing method"),this.log=!1)},a.PointZone=ba,a.Util.inherits(bb,a.Zone),bb.prototype.getPosition=function(){this.vector.x=this.x+a.MathUtils.randomAToB(-0.5,.5)*this.width,this.vector.y=this.y+a.MathUtils.randomAToB(-0.5,.5)*this.height,this.vector.z=this.z+a.MathUtils.randomAToB(-0.5,.5)*this.depth;return this.vector},bb.prototype._dead=function(a){a.p.x+a.radius<this.x-this.width/2?a.dead=!0:a.p.x-a.radius>this.x+this.width/2&&(a.dead=!0),a.p.y+a.radius<this.y-this.height/2?a.dead=!0:a.p.y-a.radius>this.y+this.height/2&&(a.dead=!0),a.p.z+a.radius<this.z-this.depth/2?a.dead=!0:a.p.z-a.radius>this.z+this.depth/2&&(a.dead=!0)},bb.prototype._bound=function(a){a.p.x-a.radius<this.x-this.width/2?(a.p.x=this.x-this.width/2+a.radius,a.v.x*=-this.friction,this._static(a,"x")):a.p.x+a.radius>this.x+this.width/2&&(a.p.x=this.x+this.width/2-a.radius,a.v.x*=-this.friction,this._static(a,"x")),a.p.y-a.radius<this.y-this.height/2?(a.p.y=this.y-this.height/2+a.radius,a.v.y*=-this.friction,this._static(a,"y")):a.p.y+a.radius>this.y+this.height/2&&(a.p.y=this.y+this.height/2-a.radius,a.v.y*=-this.friction,this._static(a,"y")),a.p.z-a.radius<this.z-this.depth/2?(a.p.z=this.z-this.depth/2+a.radius,a.v.z*=-this.friction,this._static(a,"z")):a.p.z+a.radius>this.z+this.depth/2&&(a.p.z=this.z+this.depth/2-a.radius,a.v.z*=-this.friction,this._static(a,"z"))},bb.prototype._static=function(a,b){a.v[b]*a.a[b]>0||Math.abs(a.v[b])<Math.abs(a.a[b])*.0167*this.max&&(a.v[b]=0,a.a[b]=0)},bb.prototype._cross=function(a){a.p.x+a.radius<this.x-this.width/2&&a.v.x<=0?a.p.x=this.x+this.width/2+a.radius:a.p.x-a.radius>this.x+this.width/2&&a.v.x>=0&&(a.p.x=this.x-this.width/2-a.radius),a.p.y+a.radius<this.y-this.height/2&&a.v.y<=0?a.p.y=this.y+this.height/2+a.radius:a.p.y-a.radius>this.y+this.height/2&&a.v.y>=0&&(a.p.y=this.y-this.height/2-a.radius),a.p.z+a.radius<this.z-this.depth/2&&a.v.z<=0?a.p.z=this.z+this.depth/2+a.radius:a.p.z-a.radius>this.z+this.depth/2&&a.v.z>=0&&(a.p.z=this.z-this.depth/2-a.radius)},a.BoxZone=bb,a.Util.inherits(bc,a.Zone),bc.prototype.getPosition=function(){var b=new a.Vector3D,c;return function(){c=this.renderer.domElement,b.x=Math.random()*c.width,b.y=Math.random()*c.height,this.vector.copy(a.THREEUtil.toSpacePos(b,this.camera,c));return this.vector}}(),bc.prototype._dead=function(b){var c=a.THREEUtil.toScreenPos(b.p,this.camera,this.renderer.domElement),d=this.renderer.domElement;c.y+b.radius<-this.dis&&this.d1?b.dead=!0:c.y-b.radius>d.height+this.dis&&this.d3&&(b.dead=!0),c.x+b.radius<-this.dis&&this.d4?b.dead=!0:c.x-b.radius>d.width+this.dis&&this.d2&&(b.dead=!0)},bc.prototype._cross=function(){var b=new a.Vector3D;return function(c){var d=a.THREEUtil.toScreenPos(c.p,this.camera,this.renderer.domElement),e=this.renderer.domElement;d.y+c.radius<-this.dis?(b.x=d.x,b.y=e.height+this.dis+c.radius,c.p.y=a.THREEUtil.toSpacePos(b,this.camera,e).y):d.y-c.radius>e.height+this.dis&&(b.x=d.x,b.y=-this.dis-c.radius,c.p.y=a.THREEUtil.toSpacePos(b,this.camera,e).y),d.x+c.radius<-this.dis?(b.y=d.y,b.x=e.width+this.dis+c.radius,c.p.x=a.THREEUtil.toSpacePos(b,this.camera,e).x):d.x-c.radius>e.width+this.dis&&(b.y=d.y,b.x=-this.dis-c.radius,c.p.x=a.THREEUtil.toSpacePos(b,this.camera,e).x)}}(),bc.prototype._bound=function(b){var c=a.THREEUtil.toScreenPos(b.p,this.camera,this.renderer.domElement),d=this.renderer.domElement;c.y+b.radius<-this.dis?b.v.y*=-1:c.y-b.radius>d.height+this.dis&&(b.v.y*=-1),c.x+b.radius<-this.dis?b.v.y*=-1:c.x-b.radius>d.width+this.dis&&(b.v.y*=-1)},a.ScreenZone=bc;var bd=function(){if(window.console&&window.console.trace){var a=Array.prototype.slice.call(arguments),b=arguments[0]+"";if(b.indexOf("+")==0){var c=parseInt(arguments[0]);bd.once<c&&(a.shift(),console.trace.apply(console,a),bd.once++)}else a.unshift("+15"),bd.apply(console,a)}};bd.once=0,a.log=bd;var be=be||{addEventListener:function(a,b){a.addEventListener("PROTON_UPDATE",function(a){b(a)})},drawZone:function(b,c,d){var e,f,g;d instanceof a.PointZone?e=new THREE.SphereGeometry(15):d instanceof a.LineZone||(d instanceof a.BoxZone?e=new THREE.BoxGeometry(d.width,d.height,d.depth):d instanceof a.SphereZone?e=new THREE.SphereGeometry(d.radius,10,10):d instanceof a.MeshZone&&(d.geometry instanceof THREE.Geometry?e=d.geometry:e=d.geometry.geometry,e=new THREE.SphereGeometry(d.radius,10,10))),f=new THREE.MeshBasicMaterial({color:"#2194ce",wireframe:!0}),g=new THREE.Mesh(e,f),c.add(g),this.addEventListener(b,function(a){g.position.set(d.x,d.y,d.z)})},drawEmitter:function(a,b,c,d){var e=new THREE.OctahedronGeometry(15),f=new THREE.MeshBasicMaterial({color:d||"#aaa",wireframe:!0}),g=new THREE.Mesh(e,f);b.add(g),this.addEventListener(a,function(){g.position.copy(c.p),g.rotation.set(c.rotation.x,c.rotation.y,c.rotation.z)})},renderInfo:function(){function b(a){var b=a.emitters[0];return Math.round(b.p.x)+","+Math.round(b.p.y)+","+Math.round(b.p.z)}function a(a){var b=a=="material"?"_materialPool":"_targetPool",c=proton.renderers[0];return c[b].cID}return function(c,d){this.addInfo(d);var e="";switch(this._infoType){case 2:e+="emitter:"+c.emitters.length+"<br>",e+="em speed:"+c.emitters[0].cID+"<br>",e+="pos:"+b(c);break;case 3:e+=c.renderers[0].name+"<br>",e+="target:"+a("target")+"<br>",e+="material:"+a("material");break;default:e+="particles:"+c.getCount()+"<br>",e+="pool:"+c.pool.getCount()+"<br>",e+="total:"+(c.getCount()+c.pool.getCount())}this._infoCon.innerHTML=e}}(),addInfo:function(){return function(a){var b=this;if(!this._infoCon){this._infoCon=document.createElement("div"),this._infoCon.style.cssText=["position:fixed;bottom:0px;left:0;cursor:pointer;","opacity:0.9;z-index:10000;padding:10px;font-size:12px;","width:120px;height:50px;background-color:#002;color:#0ff;"].join(""),this._infoType=1,this._infoCon.addEventListener("click",function(a){b._infoType++,b._infoType>3&&(b._infoType=1)},!1);var c,d;switch(a){case 2:c="#201",d="#f08";break;case 3:c="#020",d="#0f0";break;default:c="#002",d="#0ff"}this._infoCon.style["background-color"]=c,this._infoCon.style.color=d}this._infoCon.parentNode||document.body.appendChild(this._infoCon)}}()};a.Debug=be;return a})