photons.min.js 22 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var PHOTONS=PHOTONS||{};PHOTONS.Atlas=function(a,b){this.texture=a;this.imageCount=0;this.imageDescriptors=[];b&&this.addImageDescriptor(0,1,1,0)};PHOTONS.Atlas.ImageDescriptor=function(a,b,c,e){this.left=a;this.top=b;this.right=c;this.bottom=e};PHOTONS.Atlas.prototype.addImageDescriptor=function(a,b,c,e){this.imageDescriptors[this.imageCount]=new PHOTONS.Atlas.ImageDescriptor(a,b,c,e);this.imageCount++};PHOTONS.Atlas.prototype.getImageDescriptor=function(a){return this.imageDescriptors[a]};
  2. PHOTONS.Atlas.prototype.getTexture=function(){return this.texture};PHOTONS.Atlas.createGridAtlas=function(a,b,c,e,f,d,g,h,k){a=new PHOTONS.Atlas(a);e=(e-b)/d;c=(c-f)/g;var n=1,l=1,m=0,p=0,q=d,r=g;h&&(n=-1,m=d-1,q=-1);k&&(l=-1,p=g-1,r=-1);for(d=p;d!=r;d+=l)for(g=m;g!=q;g+=n)h=b+e*g,k=f+c*(d+1),a.addImageDescriptor(h,k,h+e,k-c);return a};PHOTONS=PHOTONS||{};PHOTONS.Modifier=function(){};PHOTONS.RandomModifier=function(a){PHOTONS.Modifier.call(this);a||(a={});if(!a.range)throw"Particles.RandomModifier: No range specified.";if(!a.offset)throw"Particles.RandomModifier: No offset specified.";this.range=a.range;this.offset=a.offset;this.rangeType=a.rangeType||PHOTONS.RangeType.Cube;this.rangeEdgeClamp=void 0!==a.rangeEdgeClamp&&null!==a.rangeEdgeClamp?a.rangeEdgeClamp:!1};PHOTONS.RandomModifier.prototype=Object.create(PHOTONS.Modifier.prototype);
  3. PHOTONS.RandomModifier.prototype.update=function(a,b){this.rangeType==PHOTONS.RangeType.Cube?PHOTONS.Random.getRandomVectorCube(b,this.offset,this.range,this.rangeEdgeClamp):this.rangeType==PHOTONS.RangeType.Sphere&&PHOTONS.Random.getRandomVectorSphere(b,this.offset,this.range,this.rangeEdgeClamp)};PHOTONS.FrameSetModifier=function(a){PHOTONS.Modifier.call(this);this.frameset=a};PHOTONS.FrameSetModifier.prototype=Object.create(PHOTONS.Modifier.prototype);
  4. PHOTONS.FrameSetModifier.prototype.update=function(a,b){this.frameset.interpolateFrameValues(a.age,b)};PHOTONS.EvenIntervalIndexModifier=function(a){PHOTONS.Modifier.call(this);this.totalSteps=Math.floor(a||1)};PHOTONS.EvenIntervalIndexModifier.prototype=Object.create(PHOTONS.Modifier.prototype);PHOTONS.EvenIntervalIndexModifier.prototype.update=function(a,b){var c=Math.floor(a.age/a.lifeSpan*this.totalSteps);c==this.totalSteps&&0<c&&c--;b.set(c,c,c)};PHOTONS=PHOTONS||{};PHOTONS.RangeType=Object.freeze({Cube:1,Sphere:2,Plane:3});PHOTONS.Constants=Object.freeze({VerticesPerParticle:6,DegreesToRadians:Math.PI/180});PHOTONS.Random=PHOTONS.Random||{};PHOTONS.Random.getRandomVectorCube=function(a,b,c,e){a.set(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5);e&&a.multiplyScalar(1/Math.max(Math.abs(a.x),Math.max(Math.abs(a.y),Math.abs(a.z))));a.multiplyVectors(c,a);a.addVectors(b,a)};
  5. PHOTONS.Random.getRandomVectorSphere=function(a,b,c,e){a.set(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5);a.normalize();a.multiplyVectors(a,c);e||a.multiplyScalar(2*Math.random()-1);a.addVectors(a,b)};PHOTONS.SingularVector=function(a){this.x=a};PHOTONS.SingularVector.prototype.copy=function(a){this.x=a.x};PHOTONS.SingularVector.prototype.set=function(a){this.x=a};PHOTONS.SingularVector.prototype.normalize=function(){};
  6. PHOTONS.SingularVector.prototype.multiplyScalar=function(a){this.x*=a};PHOTONS.SingularVector.prototype.lerp=function(a,b){this.x+=b*(a.x-this.x)};PHOTONS.SingularVector.prototype.addVectors=function(a,b){a.x+=b};PHOTONS.SingularVector.prototype.multiplyVectors=function(a,b){a.x*=b.x};PHOTONS=PHOTONS||{};
  7. PHOTONS.ParticleSystem=function(){THREE.Object3D.call(this);this.zSort=!1;this.matrixAutoUpdate=this.simulateInLocalSpace=!0;this.releaseAtOnce=!1;this.releaseAtOnceCount=0;this.isActive=this.hasInitialReleaseOccurred=!1;this.sizeInitializer=this.alphaInitializer=this.colorInitializer=this.atlasInitializer=PHOTONS.ParticleSystem.DefaultInitializer;this.sizeUpdater=this.alphaUpdater=this.colorUpdater=this.atlasUpdater=PHOTONS.ParticleSystem.DefaultUpdater;this.positionUpdater=PHOTONS.ParticleSystem.DefaultPositionUpdater;this.velocityUpdater=
  8. PHOTONS.ParticleSystem.DefaultVelocityUpdater;this.accelerationUpdater=PHOTONS.ParticleSystem.DefaultUpdater;this.accelerationInitializer=this.velocityInitializer=this.positionInitializer=PHOTONS.ParticleSystem.DefaultInitializer;this.rotationUpdater=PHOTONS.ParticleSystem.DefaultRotationUpdater;this.rotationalSpeedUpdater=PHOTONS.ParticleSystem.DefaultRotationalSpeedUpdater;this.rotationalAccelerationUpdater=PHOTONS.ParticleSystem.DefaultUpdater;this.rotationalAccelerationInitializer=this.rotationalSpeedInitializer=
  9. this.rotationInitializer=PHOTONS.ParticleSystem.DefaultInitializer;this.particleReleaseRate=100;this.averageParticleLifeSpan=this.particleLifeSpan=1;this.calculateAverageParticleLifeSpan();this.calculateMaxParticleCount();this.deadParticleCount=this.liveParticleCount=0;this.liveParticleArray=[];this.deadParticleArray=[];this._tempParticleArray=[];this.timeSinceLastEmit=0;this.emitting=!0;this.lifespan=this.age=0;this._tempVector3=new THREE.Vector3;this._tempQuaternion=new THREE.Quaternion;this._tempMatrix4=
  10. new THREE.Matrix4};PHOTONS.ParticleSystem.prototype=Object.create(THREE.Object3D.prototype);PHOTONS.ParticleSystem.prototype.constructor=PHOTONS.ParticleSystem;PHOTONS.ParticleSystem.Shader=PHOTONS.ParticleSystem.Shader||{};PHOTONS.ParticleSystem.Shader.VertexVars="attribute vec4 customColor;\nattribute vec2 size;\nattribute float rotation;\nattribute float customIndex;\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec3 cameraaxisx;\nuniform vec3 cameraaxisy;\nuniform vec3 cameraaxisz;";
  11. PHOTONS.ParticleSystem.Shader.FragmentVars="varying vec2 vUV;\nvarying vec4 vColor;\nuniform sampler2D texture;";PHOTONS.ParticleSystem.Shader.ParticleVertexQuadPositionFunction="vec4 getQuadPosition() {\nvec3 axisX = cameraaxisx;\nvec3 axisY = cameraaxisy;\nvec3 axisZ = cameraaxisz;\naxisX *= cos( rotation );\naxisY *= sin( rotation );\naxisX += axisY;\naxisY = cross( axisZ, axisX );\nvec3 edge = vec3( 2.0, customIndex, 3.0 );\nvec3 test = vec3( customIndex, 0.5, customIndex );\nvec3 result = step( edge, test );\nfloat xFactor = -1.0 + ( result.x * 2.0 );\nfloat yFactor = -1.0 + ( result.y * 2.0 ) + ( result.z * 2.0 );\naxisX *= size.x * xFactor;\naxisY *= size.y * yFactor;\nreturn ( modelMatrix * vec4( position, 1.0 ) ) + vec4( axisX + axisY, 0.0 );\n}";
  12. PHOTONS.ParticleSystem.Shader.VertexShader=[PHOTONS.ParticleSystem.Shader.VertexVars,PHOTONS.ParticleSystem.Shader.ParticleVertexQuadPositionFunction,"void main() { \nvColor = customColor;\nvUV = uv;\nvec4 quadPos = getQuadPosition();\ngl_Position = projectionMatrix * viewMatrix * quadPos;\n}"].join("\n");PHOTONS.ParticleSystem.Shader.FragmentShader=[PHOTONS.ParticleSystem.Shader.FragmentVars,"void main() { \nvec4 textureColor = texture2D( texture, vUV );\ngl_FragColor = vColor * textureColor;\n}"].join("\n");
  13. PHOTONS.ParticleSystem.createMaterial=function(a,b,c){c=c||{};c.texture={type:"t",value:null};c.cameraaxisx={type:"v3",value:new THREE.Vector3};c.cameraaxisy={type:"v3",value:new THREE.Vector3};c.cameraaxisz={type:"v3",value:new THREE.Vector3};a=a||PHOTONS.ParticleSystem.Shader.VertexShader;b=b||PHOTONS.ParticleSystem.Shader.FragmentShader;return new THREE.ShaderMaterial({uniforms:c,vertexShader:a,fragmentShader:b,transparent:!0,alphaTest:.5,blending:THREE.NormalBlending,depthTest:!0,depthWrite:!1})};
  14. PHOTONS.ParticleSystem.prototype.calculateAverageParticleLifeSpan=function(){for(var a=0,b=0;100>b;b++)a+=this.particleLifeSpan;this.averageParticleLifeSpan=a/100};PHOTONS.ParticleSystem.prototype.calculateMaxParticleCount=function(){if(this.releaseAtOnce)this.maxParticleCount=this.releaseAtOnceCount;else{var a=this.particleLifeSpan;0!=this.lifespan&&this.lifespan<a&&(a=this.lifespan);this.maxParticleCount=Math.max(this.particleReleaseRate*a*2,1)}this.vertexCount=this.maxParticleCount*PHOTONS.Constants.VerticesPerParticle};
  15. PHOTONS.ParticleSystem.prototype.initializeGeometry=function(){this.particleGeometry=new THREE.BufferGeometry;var a=new Float32Array(4*this.vertexCount);new Float32Array(this.vertexCount);var b=new Float32Array(3*this.vertexCount),c=new Float32Array(2*this.vertexCount),e=new Float32Array(2*this.vertexCount),f=new Float32Array(this.vertexCount),d=new Float32Array(this.vertexCount),a=new THREE.BufferAttribute(a,4);a.setDynamic(!0);this.particleGeometry.addAttribute("customColor",a);b=new THREE.BufferAttribute(b,
  16. 3);b.setDynamic(!0);this.particleGeometry.addAttribute("position",b);c=new THREE.BufferAttribute(c,2);c.setDynamic(!0);this.particleGeometry.addAttribute("uv",c);e=new THREE.BufferAttribute(e,2);e.setDynamic(!0);this.particleGeometry.addAttribute("size",e);f=new THREE.BufferAttribute(f,1);f.setDynamic(!0);this.particleGeometry.addAttribute("rotation",f);d=new THREE.BufferAttribute(d,1);d.setDynamic(!0);this.particleGeometry.addAttribute("customIndex",d)};
  17. PHOTONS.ParticleSystem.prototype.initializeMaterial=function(a){this.particleMaterial=a};PHOTONS.ParticleSystem.prototype.initializeMesh=function(){this.destroyMesh();this.particleMesh=new THREE.Mesh(this.particleGeometry,this.particleMaterial);this.particleMesh.dynamic=!0;this.particleMesh.matrixAutoUpdate=!1};PHOTONS.ParticleSystem.prototype.destroyMesh=function(){this.particleMesh&&(this.scene.remove(this.particleMesh),this.particleMesh=void 0)};
  18. PHOTONS.ParticleSystem.prototype.initializeParticleArray=function(){for(var a=0;a<this.maxParticleCount;a++){var b=this.createParticle();this.initializeParticle(b);this.deadParticleArray[a]=b}this.liveParticleCount=0;this.deadParticleCount=this.maxParticleCount;this.liveParticleArray.length=this.liveParticleCount;this.deadParticleArray.length=this.deadParticleCount};PHOTONS.ParticleSystem.prototype.mergeParameters=function(a){for(var b in a)this[b]=a[b]};
  19. PHOTONS.ParticleSystem.prototype.bindInitializer=function(a,b){a&&(this[a+"Initializer"]=b)};PHOTONS.ParticleSystem.prototype.bindUpdater=function(a,b){a&&(this[a+"Updater"]=b)};PHOTONS.ParticleSystem.prototype.bindModifier=function(a,b){this.bindInitializer(a,b);this.bindUpdater(a,b)};
  20. PHOTONS.ParticleSystem.prototype.initialize=function(a,b,c){this.camera=a;this.scene=b;this.alphaFrameSet=this.colorFrameSet=this.sizeFrameSet=void 0;c&&this.mergeParameters(c);this.sizeFrameSet||(this.sizeFrameSet=new PHOTONS.FrameSet);this.colorFrameSet||(this.colorFrameSet=new PHOTONS.FrameSet);this.alphaFrameSet||(this.alphaFrameSet=new PHOTONS.FrameSet);this.liveParticleArray=[];this.age=this.timeSinceLastEmit=0;this.emitting=!0;this.calculateAverageParticleLifeSpan();this.calculateMaxParticleCount();
  21. this.initializeParticleArray();this.initializeGeometry();this.initializeMaterial(c.material);this.updateAttributesWithParticleData();this.initializeMesh()};PHOTONS.ParticleSystem.prototype.getCameraWorldAxes=function(){var a=new THREE.Quaternion;return function(b,c,e,f){b.getWorldQuaternion(a);f.set(0,0,1).applyQuaternion(a);e.set(0,1,0).applyQuaternion(a);c.crossVectors(e,f)}}();
  22. PHOTONS.ParticleSystem.prototype.generateXYAlignedQuadForParticle=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,e,f,d,g,h,k,n){var l=c.position,m=c.rotation;a.copy(e);b.copy(f);a.multiplyScalar(Math.cos(m*PHOTONS.Constants.DegreesToRadians));b.multiplyScalar(Math.sin(m*PHOTONS.Constants.DegreesToRadians));a.addVectors(a,b);b.crossVectors(d,a);a.multiplyScalar(c.size.x);b.multiplyScalar(c.size.y);g.subVectors(l,a).addVectors(g,b);h.subVectors(l,a).subVectors(h,b);k.addVectors(l,
  23. a).subVectors(k,b);n.addVectors(l,a).addVectors(n,b)}}();
  24. PHOTONS.ParticleSystem.prototype.updateAttributesWithParticleData=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;new THREE.Vector3;new THREE.Vector3;new THREE.Vector3;new THREE.Vector3;return function(){this.getCameraWorldAxes(this.camera,b,a,c);this.particleMaterial.uniforms.cameraaxisx.value.copy(b);this.particleMaterial.uniforms.cameraaxisy.value.copy(a);this.particleMaterial.uniforms.cameraaxisz.value.copy(c);this.particleMaterial.uniforms.texture.value=this.particleAtlas.getTexture();
  25. for(var e=0;e<this.liveParticleCount;e++){var f=this.liveParticleArray[e],d=f.position,g=e*PHOTONS.Constants.VerticesPerParticle,h=this.particleGeometry.getAttribute("position");this.updateAttributeVector3(h,g,d);this.updateAttributeVector3(h,g+1,d);this.updateAttributeVector3(h,g+2,d);this.updateAttributeVector3(h,g+3,d);this.updateAttributeVector3(h,g+4,d);this.updateAttributeVector3(h,g+5,d);d=this.particleAtlas.getImageDescriptor(f.atlasIndex.x);h=this.particleGeometry.getAttribute("uv");this.updateAttributeVector2XY(h,
  26. g,d.left,d.top);this.updateAttributeVector2XY(h,g+1,d.left,d.bottom);this.updateAttributeVector2XY(h,g+2,d.right,d.top);this.updateAttributeVector2XY(h,g+3,d.left,d.bottom);this.updateAttributeVector2XY(h,g+4,d.right,d.bottom);this.updateAttributeVector2XY(h,g+5,d.right,d.top);d=f.color;d.a=f.alpha.x;for(var h=f.size,f=f.rotation.x*PHOTONS.Constants.DegreesToRadians,k=this.particleGeometry.getAttribute("customColor"),n=this.particleGeometry.getAttribute("size"),l=this.particleGeometry.getAttribute("rotation"),
  27. m=0;m<PHOTONS.Constants.VerticesPerParticle;m++){var p=g+m;this.updateAttributeColor(k,p,d);this.updateAttributeVector2XY(n,p,h.x,h.y);this.updateAttributeScalar(l,p,f)}d=this.particleGeometry.getAttribute("customIndex");this.updateAttributeScalar(d,g,0);this.updateAttributeScalar(d,g+1,1);this.updateAttributeScalar(d,g+2,3);this.updateAttributeScalar(d,g+3,1);this.updateAttributeScalar(d,g+4,2);this.updateAttributeScalar(d,g+5,3)}this.particleGeometry.setDrawRange(0,PHOTONS.Constants.VerticesPerParticle*
  28. this.liveParticleCount)}}();PHOTONS.ParticleSystem.prototype.updateAttributeVector2XY=function(a,b,c,e){a.array[2*b]=c;a.array[2*b+1]=e;a.needsUpdate=!0};PHOTONS.ParticleSystem.prototype.updateAttributeVector3=function(a,b,c){a.array[3*b]=c.x;a.array[3*b+1]=c.y;a.array[3*b+2]=c.z;a.needsUpdate=!0};PHOTONS.ParticleSystem.prototype.updateAttributeColor=function(a,b,c){a.array[4*b]=c.r;a.array[4*b+1]=c.g;a.array[4*b+2]=c.b;a.array[4*b+3]=c.a;a.needsUpdate=!0};
  29. PHOTONS.ParticleSystem.prototype.updateAttributeScalar=function(a,b,c){a.array[b]=c;a.needsUpdate=!0};PHOTONS.ParticleSystem.prototype.createParticle=function(){return new PHOTONS.Particle};PHOTONS.ParticleSystem.prototype.initializeParticle=function(a){this.resetParticle(a)};PHOTONS.ParticleSystem.prototype.resetParticle=function(a){a.age=0;a.alive=0;this.resetParticleDisplayAttributes(a);this.resetParticlePositionData(a);this.resetParticleRotationData(a)};
  30. PHOTONS.ParticleSystem.prototype.resetParticleDisplayAttributes=function(a){this.atlasInitializer.update(a,a.atlasIndex,0);this.sizeInitializer.update(a,a.size,0);this.colorInitializer.update(a,a._tempVector3,0);a.color.setRGB(a._tempVector3.x,a._tempVector3.y,a._tempVector3.z);this.alphaInitializer.update(a,a.alpha,0)};
  31. PHOTONS.ParticleSystem.prototype.resetParticlePositionData=function(a){this.positionInitializer.update(a,a.position,0);this.simulateInLocalSpace||(a._tempVector3.setFromMatrixPosition(this.matrixWorld),a.position.addVectors(a._tempVector3,a.position));this.velocityInitializer.update(a,a.velocity,0);this.accelerationInitializer.update(a,a.acceleration,0)};
  32. PHOTONS.ParticleSystem.prototype.resetParticleRotationData=function(a){this.rotationInitializer.update(a,a.rotation);this.rotationalSpeedInitializer.update(a,a.rotationalSpeed);this.rotationalAccelerationInitializer.update(a,a.rotationalAcceleration)};PHOTONS.ParticleSystem.prototype.advanceParticle=function(a,b){a.age+=b;this.advanceParticleDisplayAttributes(a,b);this.advanceParticlePositionData(a,b);this.advanceParticleRotationData(a,b)};
  33. PHOTONS.ParticleSystem.prototype.advanceParticleDisplayAttributes=function(a,b){this.atlasUpdater.update(a,a.atlasIndex,b);this.sizeUpdater.update(a,a.size,b);this.colorUpdater.update(a,a._tempVector3,b);a.color.setRGB(a._tempVector3.x,a._tempVector3.y,a._tempVector3.z);this.alphaUpdater.update(a,a.alpha,b)};
  34. PHOTONS.ParticleSystem.prototype.advanceParticlePositionData=function(a,b){this.positionUpdater.update(a,a.position,b);this.velocityUpdater.update(a,a.velocity,b);this.accelerationUpdater.update(a,a.acceleration,b)};PHOTONS.ParticleSystem.prototype.advanceParticleRotationData=function(a,b){this.rotationUpdater.update(a,a.rotation,b);this.rotationalSpeedUpdater.update(a,a.rotationalSpeed,b);this.rotationalAccelerationUpdater.update(a,a.rotationalAcceleration,b)};
  35. PHOTONS.ParticleSystem.prototype.advanceParticles=function(a){for(var b=0,c=0;c<this.liveParticleCount;c++){var e=this.liveParticleArray[c];this.advanceParticle(e,a);e.age>e.lifeSpan&&(this.killParticle(e),b++)}0<b&&this.cleanupDeadParticles()};PHOTONS.ParticleSystem.prototype.killParticle=function(a){a.alive=0};PHOTONS.ParticleSystem.prototype.activateParticle=function(a){this.resetParticle(a);a.lifeSpan=this.particleLifeSpan;a.alive=1};
  36. PHOTONS.ParticleSystem.prototype.cleanupDeadParticles=function(){for(var a=this.liveParticleCount-1,b=0;a>b;){for(;0==this.liveParticleArray[a].alive&&0<a;)a--;for(;1==this.liveParticleArray[b].alive&&b<this.liveParticleCount-1;)b++;if(a<=b)break;var c=this.liveParticleArray[b];this.liveParticleArray[b]=this.liveParticleArray[a];this.liveParticleArray[a]=c}for(;0<this.liveParticleCount&&0==this.liveParticleArray[this.liveParticleCount-1].alive;)this.deadParticleArray[this.deadParticleCount]=this.liveParticleArray[this.liveParticleCount-
  37. 1],this.deadParticleCount++,this.liveParticleCount--;this.liveParticleArray.length=this.liveParticleCount;this.deadParticleArray.length=this.deadParticleCount};
  38. PHOTONS.ParticleSystem.prototype.sortParticleArray=function(){function a(a,b){return a[0]-b[0]}var b=[],c=new THREE.Vector3;return function(e){for(var f=0;f<this.liveParticleCount;f++)c.copy(this.liveParticleArray[f].position),c.applyProjection(e),b[f]||(b[f]=[0,0]),b[f][0]=c.z,b[f][1]=f;b.length=this.liveParticleCount;b.sort(a);for(f=0;f<this.liveParticleCount;f++)this._tempParticleArray[f]=this.liveParticleArray[b[f][1]];this._tempParticleArray.length=this.liveParticleCount;e=this.liveParticleArray;
  39. this.liveParticleArray=this._tempParticleArray;this._tempParticleArray=e}}();
  40. PHOTONS.ParticleSystem.prototype.activateParticles=function(a){for(var b=0;b<a;b++)if(this.liveParticleCount<this.maxParticleCount&&0<this.deadParticleCount){var c=this.deadParticleArray[this.deadParticleCount-1];this.liveParticleArray[this.liveParticleCount]=c;this.deadParticleCount--;this.liveParticleCount++;this.activateParticle(c)}else break;this.liveParticleArray.length=this.liveParticleCount;this.deadParticleArray.length=this.deadParticleCount};
  41. PHOTONS.ParticleSystem.prototype.update=function(){var a=new THREE.Matrix4;return function(b){if(this.emitting&&this.isActive){this.timeSinceLastEmit+=b;if(this.releaseAtOnce){var c=this.averageParticleLifeSpan;if(!this.hasInitialReleaseOccurred||this.timeSinceLastEmit>c&&0>=this.liveParticleCount)this.activateParticles(this.maxParticleCount),this.timeSinceLastEmit=0,this.hasInitialReleaseOccurred=!0}else if(c=1/this.particleReleaseRate,!this.hasInitialReleaseOccurred||this.timeSinceLastEmit>c)this.activateParticles(Math.max(1,
  42. Math.floor(this.timeSinceLastEmit/c))),this.timeSinceLastEmit=0,this.hasInitialReleaseOccurred=!0;this.advanceParticles(b);this.zSort&&(this.camera.updateMatrixWorld(),a.copy(this.camera.matrixWorld),a.getInverse(a),this.sortParticleArray(a));this.updateAttributesWithParticleData();this.age+=b;0!=this.lifespan&&this.age>this.lifespan&&(this.emitting=!1);this.simulateInLocalSpace&&(this.particleMesh.matrix.copy(this.matrixWorld),this.particleMesh.updateMatrixWorld())}}}();
  43. PHOTONS.ParticleSystem.prototype.deactivate=function(){this.isActive&&(this.scene.remove(this.particleMesh),this.isActive=!1)};PHOTONS.ParticleSystem.prototype.activate=function(){this.isActive||(this.scene.add(this.particleMesh),this.isActive=!0)};PHOTONS.ParticleSystem.DefaultPositionUpdater={update:function(a,b,c){a._tempVector3.copy(a.velocity);a._tempVector3.multiplyScalar(c);a.position.add(a._tempVector3)}};
  44. PHOTONS.ParticleSystem.DefaultVelocityUpdater={update:function(a,b,c){a._tempVector3.copy(a.acceleration);a._tempVector3.multiplyScalar(c);a.velocity.add(a._tempVector3)}};PHOTONS.ParticleSystem.DefaultRotationUpdater={update:function(a,b,c){a.rotation.set(a.rotation.x+=a.rotationalSpeed.x*c)}};PHOTONS.ParticleSystem.DefaultRotationalSpeedUpdater={update:function(a,b,c){a.rotationalSpeed.set(a.rotationalSpeed.x+=a.rotationalAcceleration.x*c)}};
  45. PHOTONS.ParticleSystem.DefaultUpdater={update:function(a,b,c){}};PHOTONS.ParticleSystem.DefaultInitializer={update:function(a,b,c){b.set(0,0,0,0)}};
  46. PHOTONS.Particle=function(){this.lifeSpan=this.alive=this.age=0;this.size=new THREE.Vector3;this.color=new THREE.Color;this.alpha=new PHOTONS.SingularVector(0);this.atlasIndex=new PHOTONS.SingularVector(0);this.position=new THREE.Vector3;this.velocity=new THREE.Vector3;this.acceleration=new THREE.Vector3;this.rotation=new PHOTONS.SingularVector(0);this.rotationalSpeed=new PHOTONS.SingularVector(0);this.rotationalAcceleration=new PHOTONS.SingularVector(0);this._tempVector3=new THREE.Vector3};PHOTONS=PHOTONS||{};PHOTONS.FrameSet=function(a,b,c){this.timeFrames=a||[];this.valueFrames=b||[]};PHOTONS.FrameSet.prototype.findNextFrameForTimeValue=function(a){for(var b=0;b<this.timeFrames.length&&this.timeFrames[b]<a;)b+=1;return b};PHOTONS.FrameSet.prototype.calculateFraction=function(a,b,c){return(c-a)/(b-a)};
  47. PHOTONS.FrameSet.prototype.interpolateFrameValues=function(a,b){var c=this.findNextFrameForTimeValue(a),e=c-1;if(0==c)b.copy(this.valueFrames[0]);else if(c==this.timeFrames.length)b.copy(this.valueFrames[e]);else{var f=this.calculateFraction(this.timeFrames[e],this.timeFrames[c],a);b.copy(this.valueFrames[e]);b.lerp(this.valueFrames[c],f)}};PHOTONS=PHOTONS||{};
  48. PHOTONS.Util={loadingManager:void 0,objLoader:void 0,imageLoader:void 0,initializeLoadingManager:function(){this.loadingManager=new THREE.LoadingManager;this.loadingManager.onProgress=function(a,b,c){console.log("Loaded "+b+" items out of "+c+": "+a)}},loadObj:function(a,b,c,e,f){var d=function(a){},g=function(a){console.log("ERROR: loadObj() - "+a)};this.objLoader||(this.objLoader=new THREE.OBJLoader(loadingManager));this.imageLoader||(this.imageLoader=new THREE.ImageLoader(this.loadingManager));var h=
  49. new THREE.Texture,k=this;this.imageLoader.load(b,function(b){h.image=b;h.needsUpdate=!0;k.objLoader.load(a,function(b){b.traverse(function(a){a instanceof THREE.Mesh&&(a.material=c,a.material.map=h,e&&e(a))});console.log("Finished loading model: "+a);f&&f(b)},d,g)})}};