浏览代码

Updated namespace in general purpose particle systems example from 'THREE.Particles' to 'PHOTONS'.

mkkellogg 9 年之前
父节点
当前提交
a79dae57ea
共有 3 个文件被更改,包括 117 次插入121 次删除
  1. 0 53
      examples/js/GeneralParticleSystem.min.js
  2. 49 0
      examples/js/libs/photons.min.js
  3. 68 68
      examples/webgl_particles_general.html

+ 0 - 53
examples/js/GeneralParticleSystem.min.js

@@ -1,53 +0,0 @@
-THREE.Atlas=function(a,b){this.texture=a;this.imageCount=0;this.imageDescriptors=[];b&&this.addImageDescriptor(0,1,1,0)};THREE.Atlas.ImageDescriptor=function(a,b,c,e){this.left=a;this.top=b;this.right=c;this.bottom=e};THREE.Atlas.prototype.addImageDescriptor=function(a,b,c,e){this.imageDescriptors[this.imageCount]=new THREE.Atlas.ImageDescriptor(a,b,c,e);this.imageCount++};THREE.Atlas.prototype.getImageDescriptor=function(a){return this.imageDescriptors[a]};THREE.Atlas.prototype.getTexture=function(){return this.texture};
-THREE.Atlas.createGridAtlas=function(a,b,c,e,f,d,g,h,k){a=new THREE.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};THREE.Particles=THREE.Particles||{};THREE.Particles.Modifier=function(){};THREE.Particles.RandomModifier=function(a){THREE.Particles.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||THREE.Particles.RangeType.Cube;this.rangeEdgeClamp=void 0!==a.rangeEdgeClamp&&null!==a.rangeEdgeClamp?a.rangeEdgeClamp:!1};
-THREE.Particles.RandomModifier.prototype=Object.create(THREE.Particles.Modifier.prototype);THREE.Particles.RandomModifier.prototype.update=function(a,b){this.rangeType==THREE.Particles.RangeType.Cube?THREE.Particles.Random.getRandomVectorCube(b,this.offset,this.range,this.rangeEdgeClamp):this.rangeType==THREE.Particles.RangeType.Sphere&&THREE.Particles.Random.getRandomVectorSphere(b,this.offset,this.range,this.rangeEdgeClamp)};
-THREE.Particles.FrameSetModifier=function(a){THREE.Particles.Modifier.call(this);this.frameset=a};THREE.Particles.FrameSetModifier.prototype=Object.create(THREE.Particles.Modifier.prototype);THREE.Particles.FrameSetModifier.prototype.update=function(a,b){this.frameset.interpolateFrameValues(a.age,b)};THREE.Particles.EvenIntervalIndexModifier=function(a){THREE.Particles.Modifier.call(this);this.totalSteps=Math.floor(a||1)};THREE.Particles.EvenIntervalIndexModifier.prototype=Object.create(THREE.Particles.Modifier.prototype);
-THREE.Particles.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)};THREE.Particles=THREE.Particles||{};THREE.Particles.RangeType=Object.freeze({Cube:1,Sphere:2,Plane:3});THREE.Particles.Constants=Object.freeze({VerticesPerParticle:6,DegreesToRadians:Math.PI/180});THREE.Particles.Random=THREE.Particles.Random||{};
-THREE.Particles.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)};THREE.Particles.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)};
-THREE.Particles.SingularVector=function(a){this.x=a};THREE.Particles.SingularVector.prototype.copy=function(a){this.x=a.x};THREE.Particles.SingularVector.prototype.set=function(a){this.x=a};THREE.Particles.SingularVector.prototype.normalize=function(){};THREE.Particles.SingularVector.prototype.multiplyScalar=function(a){this.x*=a};THREE.Particles.SingularVector.prototype.lerp=function(a,b){this.x+=b*(a.x-this.x)};THREE.Particles.SingularVector.prototype.addVectors=function(a,b){a.x+=b};
-THREE.Particles.SingularVector.prototype.multiplyVectors=function(a,b){a.x*=b.x};THREE.Particles=THREE.Particles||{};
-THREE.Particles.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=THREE.Particles.ParticleSystem.DefaultInitializer;this.sizeUpdater=this.alphaUpdater=this.colorUpdater=this.atlasUpdater=THREE.Particles.ParticleSystem.DefaultUpdater;this.positionUpdater=
-THREE.Particles.ParticleSystem.DefaultPositionUpdater;this.velocityUpdater=THREE.Particles.ParticleSystem.DefaultVelocityUpdater;this.accelerationUpdater=THREE.Particles.ParticleSystem.DefaultUpdater;this.accelerationInitializer=this.velocityInitializer=this.positionInitializer=THREE.Particles.ParticleSystem.DefaultInitializer;this.rotationUpdater=THREE.Particles.ParticleSystem.DefaultRotationUpdater;this.rotationalSpeedUpdater=THREE.Particles.ParticleSystem.DefaultRotationalSpeedUpdater;this.rotationalAccelerationUpdater=
-THREE.Particles.ParticleSystem.DefaultUpdater;this.rotationalAccelerationInitializer=this.rotationalSpeedInitializer=this.rotationInitializer=THREE.Particles.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=new THREE.Matrix4};THREE.Particles.ParticleSystem.prototype=Object.create(THREE.Object3D.prototype);THREE.Particles.ParticleSystem.prototype.constructor=THREE.Particles.ParticleSystem;THREE.Particles.ParticleSystem.Shader=THREE.Particles.ParticleSystem.Shader||{};THREE.Particles.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;";
-THREE.Particles.ParticleSystem.Shader.FragmentVars="varying vec2 vUV;\nvarying vec4 vColor;\nuniform sampler2D texture;";THREE.Particles.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}";
-THREE.Particles.ParticleSystem.Shader.VertexShader=[THREE.Particles.ParticleSystem.Shader.VertexVars,THREE.Particles.ParticleSystem.Shader.ParticleVertexQuadPositionFunction,"void main() { \nvColor = customColor;\nvUV = uv;\nvec4 quadPos = getQuadPosition();\ngl_Position = projectionMatrix * viewMatrix * quadPos;\n}"].join("\n");THREE.Particles.ParticleSystem.Shader.FragmentShader=[THREE.Particles.ParticleSystem.Shader.FragmentVars,"void main() { \nvec4 textureColor = texture2D( texture,  vUV );\ngl_FragColor = vColor * textureColor;\n}"].join("\n");
-THREE.Particles.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||THREE.Particles.ParticleSystem.Shader.VertexShader;b=b||THREE.Particles.ParticleSystem.Shader.FragmentShader;return new THREE.ShaderMaterial({uniforms:c,vertexShader:a,fragmentShader:b,transparent:!0,alphaTest:.5,blending:THREE.NormalBlending,depthTest:!0,
-depthWrite:!1})};THREE.Particles.ParticleSystem.prototype.calculateAverageParticleLifeSpan=function(){for(var a=0,b=0;100>b;b++)a+=this.particleLifeSpan;this.averageParticleLifeSpan=a/100};
-THREE.Particles.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*THREE.Particles.Constants.VerticesPerParticle};
-THREE.Particles.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,
-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)};
-THREE.Particles.ParticleSystem.prototype.initializeMaterial=function(a){this.particleMaterial=a};THREE.Particles.ParticleSystem.prototype.initializeMesh=function(){this.destroyMesh();this.particleMesh=new THREE.Mesh(this.particleGeometry,this.particleMaterial);this.particleMesh.dynamic=!0;this.particleMesh.matrixAutoUpdate=!1};THREE.Particles.ParticleSystem.prototype.destroyMesh=function(){this.particleMesh&&(this.scene.remove(this.particleMesh),this.particleMesh=void 0)};
-THREE.Particles.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};THREE.Particles.ParticleSystem.prototype.mergeParameters=function(a){for(var b in a)this[b]=a[b]};
-THREE.Particles.ParticleSystem.prototype.bindInitializer=function(a,b){a&&(this[a+"Initializer"]=b)};THREE.Particles.ParticleSystem.prototype.bindUpdater=function(a,b){a&&(this[a+"Updater"]=b)};THREE.Particles.ParticleSystem.prototype.bindModifier=function(a,b){this.bindInitializer(a,b);this.bindUpdater(a,b)};
-THREE.Particles.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 THREE.Particles.FrameSet);this.colorFrameSet||(this.colorFrameSet=new THREE.Particles.FrameSet);this.alphaFrameSet||(this.alphaFrameSet=new THREE.Particles.FrameSet);this.liveParticleArray=[];this.age=this.timeSinceLastEmit=0;this.emitting=!0;this.calculateAverageParticleLifeSpan();
-this.calculateMaxParticleCount();this.initializeParticleArray();this.initializeGeometry();this.initializeMaterial(c.material);this.updateAttributesWithParticleData();this.initializeMesh()};THREE.Particles.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)}}();
-THREE.Particles.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*THREE.Particles.Constants.DegreesToRadians));b.multiplyScalar(Math.sin(m*THREE.Particles.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,a).subVectors(k,b);n.addVectors(l,a).addVectors(n,b)}}();
-THREE.Particles.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();
-for(var e=0;e<this.liveParticleCount;e++){var f=this.liveParticleArray[e],d=f.position,g=e*THREE.Particles.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,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*THREE.Particles.Constants.DegreesToRadians,k=this.particleGeometry.getAttribute("customColor"),n=this.particleGeometry.getAttribute("size"),
-l=this.particleGeometry.getAttribute("rotation"),m=0;m<THREE.Particles.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,
-THREE.Particles.Constants.VerticesPerParticle*this.liveParticleCount)}}();THREE.Particles.ParticleSystem.prototype.updateAttributeVector2XY=function(a,b,c,e){a.array[2*b]=c;a.array[2*b+1]=e;a.needsUpdate=!0};THREE.Particles.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};
-THREE.Particles.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};THREE.Particles.ParticleSystem.prototype.updateAttributeScalar=function(a,b,c){a.array[b]=c;a.needsUpdate=!0};THREE.Particles.ParticleSystem.prototype.createParticle=function(){return new THREE.Particles.Particle};THREE.Particles.ParticleSystem.prototype.initializeParticle=function(a){this.resetParticle(a)};
-THREE.Particles.ParticleSystem.prototype.resetParticle=function(a){a.age=0;a.alive=0;this.resetParticleDisplayAttributes(a);this.resetParticlePositionData(a);this.resetParticleRotationData(a)};
-THREE.Particles.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)};
-THREE.Particles.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)};
-THREE.Particles.ParticleSystem.prototype.resetParticleRotationData=function(a){this.rotationInitializer.update(a,a.rotation);this.rotationalSpeedInitializer.update(a,a.rotationalSpeed);this.rotationalAccelerationInitializer.update(a,a.rotationalAcceleration)};THREE.Particles.ParticleSystem.prototype.advanceParticle=function(a,b){a.age+=b;this.advanceParticleDisplayAttributes(a,b);this.advanceParticlePositionData(a,b);this.advanceParticleRotationData(a,b)};
-THREE.Particles.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)};
-THREE.Particles.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)};THREE.Particles.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)};
-THREE.Particles.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()};THREE.Particles.ParticleSystem.prototype.killParticle=function(a){a.alive=0};THREE.Particles.ParticleSystem.prototype.activateParticle=function(a){this.resetParticle(a);a.lifeSpan=this.particleLifeSpan;a.alive=1};
-THREE.Particles.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-1],this.deadParticleCount++,this.liveParticleCount--;this.liveParticleArray.length=this.liveParticleCount;this.deadParticleArray.length=this.deadParticleCount};
-THREE.Particles.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;
-this.liveParticleArray=this._tempParticleArray;this._tempParticleArray=e}}();
-THREE.Particles.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};
-THREE.Particles.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,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())}}}();
-THREE.Particles.ParticleSystem.prototype.deactivate=function(){this.isActive&&(this.scene.remove(this.particleMesh),this.isActive=!1)};THREE.Particles.ParticleSystem.prototype.activate=function(){this.isActive||(this.scene.add(this.particleMesh),this.isActive=!0)};THREE.Particles.ParticleSystem.DefaultPositionUpdater={update:function(a,b,c){a._tempVector3.copy(a.velocity);a._tempVector3.multiplyScalar(c);a.position.add(a._tempVector3)}};
-THREE.Particles.ParticleSystem.DefaultVelocityUpdater={update:function(a,b,c){a._tempVector3.copy(a.acceleration);a._tempVector3.multiplyScalar(c);a.velocity.add(a._tempVector3)}};THREE.Particles.ParticleSystem.DefaultRotationUpdater={update:function(a,b,c){a.rotation.set(a.rotation.x+=a.rotationalSpeed.x*c)}};THREE.Particles.ParticleSystem.DefaultRotationalSpeedUpdater={update:function(a,b,c){a.rotationalSpeed.set(a.rotationalSpeed.x+=a.rotationalAcceleration.x*c)}};
-THREE.Particles.ParticleSystem.DefaultUpdater={update:function(a,b,c){}};THREE.Particles.ParticleSystem.DefaultInitializer={update:function(a,b,c){b.set(0,0,0,0)}};
-THREE.Particles.Particle=function(){this.lifeSpan=this.alive=this.age=0;this.size=new THREE.Vector3;this.color=new THREE.Color;this.alpha=new THREE.Particles.SingularVector(0);this.atlasIndex=new THREE.Particles.SingularVector(0);this.position=new THREE.Vector3;this.velocity=new THREE.Vector3;this.acceleration=new THREE.Vector3;this.rotation=new THREE.Particles.SingularVector(0);this.rotationalSpeed=new THREE.Particles.SingularVector(0);this.rotationalAcceleration=new THREE.Particles.SingularVector(0);
-this._tempVector3=new THREE.Vector3};THREE.Particles=THREE.Particles||{};THREE.Particles.FrameSet=function(a,b,c){this.timeFrames=a||[];this.valueFrames=b||[]};THREE.Particles.FrameSet.prototype.findNextFrameForTimeValue=function(a){for(var b=0;b<this.timeFrames.length&&this.timeFrames[b]<a;)b+=1;return b};THREE.Particles.FrameSet.prototype.calculateFraction=function(a,b,c){return(c-a)/(b-a)};
-THREE.Particles.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)}};var ParticleSystemUtil={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=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)})}};

+ 49 - 0
examples/js/libs/photons.min.js

@@ -0,0 +1,49 @@
+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]};
+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);
+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);
+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)};
+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(){};
+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||{};
+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=
+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=
+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=
+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;";
+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}";
+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");
+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})};
+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};
+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,
+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)};
+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)};
+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]};
+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)};
+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();
+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)}}();
+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,
+a).subVectors(k,b);n.addVectors(l,a).addVectors(n,b)}}();
+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();
+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,
+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"),
+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*
+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};
+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)};
+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)};
+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)};
+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)};
+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)};
+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)};
+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};
+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-
+1],this.deadParticleCount++,this.liveParticleCount--;this.liveParticleArray.length=this.liveParticleCount;this.deadParticleArray.length=this.deadParticleCount};
+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;
+this.liveParticleArray=this._tempParticleArray;this._tempParticleArray=e}}();
+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};
+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,
+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())}}}();
+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)}};
+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)}};
+PHOTONS.ParticleSystem.DefaultUpdater={update:function(a,b,c){}};PHOTONS.ParticleSystem.DefaultInitializer={update:function(a,b,c){b.set(0,0,0,0)}};
+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)};
+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||{};
+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=
+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)})}};

+ 68 - 68
examples/webgl_particles_general.html

@@ -9,7 +9,7 @@
 	<script src="js/controls/OrbitControls.js"></script>	
 	<script src="js/loaders/OBJLoader.js"></script>
 	<script src='js/libs/dat.gui.min.js'></script>
-	<script src="js/GeneralParticleSystem.min.js"></script>
+	<script src="js/libs/photons.min.js"></script>
 
     <style>
 		body {
@@ -34,9 +34,9 @@
 <body>
 
 <div id="info">
-	<a href="http://threejs.org" target="_blank">three.js</a> - General purpose particle system by <a href="https://github.com/mkkellogg" target="_new">mkkellogg</a>
+	<a href="http://threejs.org" target="_blank">three.js</a> - Photons: General purpose particle system by <a href="https://github.com/mkkellogg" target="_new">mkkellogg</a>
 	<br />
-	Full source on <a href="https://github.com/mkkellogg/ParticleSystemJS" target="_new">GitHub</a>
+	Full source on <a href="https://github.com/mkkellogg/Photons" target="_new">GitHub</a>
 </div>
 
 <div id="renderingContainer" style="position: absolute; left:0px; top:0px"></div>
@@ -85,7 +85,7 @@
 		initListeners();
 
 		initLights();
-		ParticleSystemUtil.initializeLoadingManager();
+		PHOTONS.Util.initializeLoadingManager();
 		initSceneGeometry( function() {
 
 			initParticleSystems();
@@ -109,19 +109,19 @@
 
 	function initializeSmokeSystem() {
 
-		var _TPSV = THREE.Particles.SingularVector;
+		var _TPSV = PHOTONS.SingularVector;
 
 		smokeType = ParticleSystemIDs.Smoke1;
 
-		var smoke1Atlas = new THREE.Atlas( THREE.ImageUtils.loadTexture( 'textures/campfire/smokeparticle.png' ), true );
-		var smoke2Atlas = THREE.Atlas.createGridAtlas( THREE.ImageUtils.loadTexture( 'textures/campfire/smokeparticles.png' ), 0.0, 1.0, 1.0, 0.0, 4.0, 4.0, false, true );
+		var smoke1Atlas = new PHOTONS.Atlas( THREE.ImageUtils.loadTexture( 'textures/campfire/smokeparticle.png' ), true );
+		var smoke2Atlas = PHOTONS.Atlas.createGridAtlas( THREE.ImageUtils.loadTexture( 'textures/campfire/smokeparticles.png' ), 0.0, 1.0, 1.0, 0.0, 4.0, 4.0, false, true );
 
 		var altVertexShader = [
 
-			THREE.Particles.ParticleSystem.Shader.VertexVars,
+			PHOTONS.ParticleSystem.Shader.VertexVars,
 			"varying vec4 vPosition;",
 
-			THREE.Particles.ParticleSystem.Shader.ParticleVertexQuadPositionFunction,
+			PHOTONS.ParticleSystem.Shader.ParticleVertexQuadPositionFunction,
 
 			"void main()",
 			"{",
@@ -136,7 +136,7 @@
 
 		var altFragmentShader = [
 
-			THREE.Particles.ParticleSystem.Shader.FragmentVars,
+			PHOTONS.ParticleSystem.Shader.FragmentVars,
 			"varying vec4 vPosition;",
 
 			THREE.ShaderChunk[ "common" ],
@@ -171,7 +171,7 @@
 
 		var customUniforms1 = THREE.UniformsUtils.merge( [ THREE.UniformsLib[ 'lights' ], THREE.UniformsLib[ 'ambient' ] ] );
 
-		var altMaterial1 = THREE.Particles.ParticleSystem.createMaterial( altVertexShader, altFragmentShader, customUniforms1 );
+		var altMaterial1 = PHOTONS.ParticleSystem.createMaterial( altVertexShader, altFragmentShader, customUniforms1 );
 		altMaterial1.lights = true;
 		altMaterial1.blending = THREE.CustomBlending;
 		altMaterial1.blendSrc = THREE.SrcAlphaFactor;
@@ -204,67 +204,67 @@
 
 		};
 
-		var particleSystem1 = new THREE.Particles.ParticleSystem();
+		var particleSystem1 = new PHOTONS.ParticleSystem();
 		particleSystem1.initialize( camera, scene, particleSystemParams1 );
 
-		var particleSystem2 = new THREE.Particles.ParticleSystem();
+		var particleSystem2 = new PHOTONS.ParticleSystem();
 		particleSystem2.initialize( camera, scene, particleSystemParams2 );
 
-		var positionModifier = new THREE.Particles.RandomModifier(
+		var positionModifier = new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, 0, 0 ),
 				range: new THREE.Vector3( 10, 0, 10 ),
 				rangeEdgeClamp: false,
-				rangeType: THREE.Particles.RangeType.Sphere
+				rangeType: PHOTONS.RangeType.Sphere
 			} );
 
-		var velocityModifier = new THREE.Particles.RandomModifier(
+		var velocityModifier = new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, 75, 0 ),
 				range: new THREE.Vector3( 5, 30, 5 ),
 				rangeEdgeClamp: false,
-				rangeType: THREE.Particles.RangeType.Sphere
+				rangeType: PHOTONS.RangeType.Sphere
 			} );
 
-		var accelerationModifier = new THREE.Particles.RandomModifier(
+		var accelerationModifier = new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, - 22, 0 ),
 				range: new THREE.Vector3( 35, 20, 35 ),
 				rangeEdgeClamp: false,
-				rangeType: THREE.Particles.RangeType.Cube
+				rangeType: PHOTONS.RangeType.Cube
 			} );
 
-		var rotationModifier = new THREE.Particles.RandomModifier(
+		var rotationModifier = new PHOTONS.RandomModifier(
 			{
-				offset: new THREE.Particles.SingularVector( 0 ),
-				range: new THREE.Particles.SingularVector( 360 )
+				offset: new PHOTONS.SingularVector( 0 ),
+				range: new PHOTONS.SingularVector( 360 )
 			} );
 
-		var rotationalSpeedModifier = new THREE.Particles.RandomModifier(
+		var rotationalSpeedModifier = new PHOTONS.RandomModifier(
 			{
-				offset: new THREE.Particles.SingularVector( 50 ),
-				range: new THREE.Particles.SingularVector( 400 )
+				offset: new PHOTONS.SingularVector( 50 ),
+				range: new PHOTONS.SingularVector( 400 )
 			} );
 
-		var atlas1Modifier = new THREE.Particles.EvenIntervalIndexModifier ( 1 );
+		var atlas1Modifier = new PHOTONS.EvenIntervalIndexModifier ( 1 );
 
-		var sizeModifier = new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		var sizeModifier = new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0, 3 ],
 				[ new THREE.Vector2( 10, 10 ),
 				new THREE.Vector2( 40, 40 ) ],
 				false )
 		);
 
-		var alphaModifier = new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		var alphaModifier = new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0, 1.0, 2.0, 3.0 ],
 				[ new _TPSV( 0.0 ), new _TPSV( 0.1 ), new _TPSV( 0.075 ), new _TPSV( 0.0 ) ],
 				true
 				) );
 
-		var colorModifier = new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		var colorModifier = new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0.0, 1.5, 3 ],
 				[ new THREE.Vector3( 0.1, 0.1, 0.1 ),
 				new THREE.Vector3( 0.35, 0.35, 0.35 ),
@@ -282,7 +282,7 @@
 		particleSystem1.bindModifier( 'alpha', alphaModifier );
 		particleSystem1.bindModifier( 'color', colorModifier );
 
-		var atlas2Modifier = new THREE.Particles.EvenIntervalIndexModifier ( 16 );
+		var atlas2Modifier = new PHOTONS.EvenIntervalIndexModifier ( 16 );
 
 		particleSystem2.bindInitializer( 'position', positionModifier );
 		particleSystem2.bindInitializer( 'velocity', velocityModifier );
@@ -304,66 +304,66 @@
 
 	function initializeFlameSystem() {
 
-		var _TPSV = THREE.Particles.SingularVector;
+		var _TPSV = PHOTONS.SingularVector;
 
 		// ---------------------
 		// flame particle system
 		// ---------------------
 
-		var flameMaterial = THREE.Particles.ParticleSystem.createMaterial();
+		var flameMaterial = PHOTONS.ParticleSystem.createMaterial();
 		flameMaterial.blending = THREE.AdditiveBlending;
 
 		var particleSystemParams = {
 
 			material: flameMaterial,
-			particleAtlas : THREE.Atlas.createGridAtlas( THREE.ImageUtils.loadTexture( 'textures/campfire/fireloop3.jpg' ), 0.0, 1.0, 1.0, 0.0, 8.0, 8.0, false, true ),
+			particleAtlas : PHOTONS.Atlas.createGridAtlas( THREE.ImageUtils.loadTexture( 'textures/campfire/fireloop3.jpg' ), 0.0, 1.0, 1.0, 0.0, 8.0, 8.0, false, true ),
 			particleReleaseRate : 3,
 			particleLifeSpan : 3,
 			lifespan : 0
 
 		};
-		var particleSystem = new THREE.Particles.ParticleSystem();
+		var particleSystem = new PHOTONS.ParticleSystem();
 		particleSystem.initialize( camera, scene, particleSystemParams );
 
-		particleSystem.bindModifier( "atlas", new THREE.Particles.EvenIntervalIndexModifier ( 64 ) );
+		particleSystem.bindModifier( "atlas", new PHOTONS.EvenIntervalIndexModifier ( 64 ) );
 
-		particleSystem.bindModifier( "size", new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		particleSystem.bindModifier( "size", new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0, 3 ],
 				[ new THREE.Vector3( 20, 25 ),
 				new THREE.Vector3( 20, 25 ) ],
 				false )
 		) );
 
-		particleSystem.bindModifier( "alpha", new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		particleSystem.bindModifier( "alpha", new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0, 0.2, 1.2, 2.0, 3 ],
 				[ new _TPSV( 0 ), new _TPSV( .3 ), new _TPSV( 1 ), new _TPSV( 1 ), new _TPSV( 0 ) ],
 				true )
 		) );
 
-		particleSystem.bindModifier( "color", new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		particleSystem.bindModifier( "color", new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0, 3 ],
 				[ new THREE.Vector3( 1.4, 1.4, 1.4 ),
 				new THREE.Vector3( 1.4, 1.4, 1.4 ) ],
 				false )
 		) );
 
-		particleSystem.bindInitializer( 'position', new THREE.Particles.RandomModifier(
+		particleSystem.bindInitializer( 'position', new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, 0, 0 ),
 				range: new THREE.Vector3( 0, 0, 0 ),
 				rangeEdgeClamp: false,
-				rangeType: THREE.Particles.RangeType.Sphere
+				rangeType: PHOTONS.RangeType.Sphere
 			} ) );
 
-		particleSystem.bindInitializer( 'velocity', new THREE.Particles.RandomModifier(
+		particleSystem.bindInitializer( 'velocity', new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, 25, 0 ),
 				range: new THREE.Vector3( 10, 2, 10 ),
 				rangeEdgeClamp: false,
-				rangeType: THREE.Particles.RangeType.Sphere
+				rangeType: PHOTONS.RangeType.Sphere
 			} ) );
 
 		particleSystems[ ParticleSystemIDs.Flame ] = particleSystem;
@@ -374,41 +374,41 @@
 		// flame embers particle system
 		// ---------------------
 
-		var emberMaterial = THREE.Particles.ParticleSystem.createMaterial();
+		var emberMaterial = PHOTONS.ParticleSystem.createMaterial();
 		emberMaterial.blending = THREE.AdditiveBlending;
 
 		particleSystemParams = {
 
 			material: emberMaterial,
-			particleAtlas : new THREE.Atlas( THREE.ImageUtils.loadTexture( 'textures/campfire/Puff.png' ), true ),
+			particleAtlas : new PHOTONS.Atlas( THREE.ImageUtils.loadTexture( 'textures/campfire/Puff.png' ), true ),
 			particleReleaseRate : 18,
 			particleLifeSpan : 3,
 			lifespan : 0
 
 		};
-		particleSystem = new THREE.Particles.ParticleSystem();
+		particleSystem = new PHOTONS.ParticleSystem();
 		particleSystem.initialize( camera, scene, particleSystemParams );
 
-		particleSystem.bindModifier( "atlas", new THREE.Particles.EvenIntervalIndexModifier ( 1 ) );
+		particleSystem.bindModifier( "atlas", new PHOTONS.EvenIntervalIndexModifier ( 1 ) );
 
-		particleSystem.bindModifier( 'size', new THREE.Particles.RandomModifier(
+		particleSystem.bindModifier( 'size', new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( .25, .25, 0.0 ),
 				range: new THREE.Vector3( 0.05, 0.05, 0.0 ),
 				rangeEdgeClamp: false,
-				rangeType: THREE.Particles.RangeType.Sphere,
+				rangeType: PHOTONS.RangeType.Sphere,
 				runOnce: true
 			} ) );
 
-		particleSystem.bindModifier( "alpha", new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		particleSystem.bindModifier( "alpha", new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0, 0.2, 1.2, 2.0, 3 ],
 				[ new _TPSV( 0 ), new _TPSV( 1 ), new _TPSV( 1 ), new _TPSV( 1 ), new _TPSV( 0 ) ],
 				true )
 		) );
 
-		particleSystem.bindModifier( "color", new THREE.Particles.FrameSetModifier(
-			new THREE.Particles.FrameSet(
+		particleSystem.bindModifier( "color", new PHOTONS.FrameSetModifier(
+			new PHOTONS.FrameSet(
 				[ 0, 2, 3 ],
 				[ new THREE.Vector3( 1.3, 1.3, 0 ),
 				new THREE.Vector3( .75, .4, .4 ),
@@ -416,28 +416,28 @@
 				false )
 		) );
 
-		particleSystem.bindInitializer( 'position', new THREE.Particles.RandomModifier(
+		particleSystem.bindInitializer( 'position', new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, 7, 0 ),
 				range: new THREE.Vector3( 3, 0, 3 ),
 				rangeEdgeClamp: false,
-				rangeType: THREE.Particles.RangeType.Sphere
+				rangeType: PHOTONS.RangeType.Sphere
 			} ) );
 
-		particleSystem.bindInitializer( 'velocity', new THREE.Particles.RandomModifier(
+		particleSystem.bindInitializer( 'velocity', new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, 25, 0 ),
 				range: new THREE.Vector3( 15, 25, 15 ),
 				rangeEdgeClamp: true,
-				rangeType: THREE.Particles.RangeType.Sphere
+				rangeType: PHOTONS.RangeType.Sphere
 			} ) );
 
-		particleSystem.bindModifier( 'acceleration', new THREE.Particles.RandomModifier(
+		particleSystem.bindModifier( 'acceleration', new PHOTONS.RandomModifier(
 			{
 				offset: new THREE.Vector3( 0, 15, 0 ),
 				range: new THREE.Vector3( 180, 280, 180 ),
 				rangeEdgeClamp: true,
-				rangeType: THREE.Particles.RangeType.Sphere
+				rangeType: PHOTONS.RangeType.Sphere
 			} ) );
 
 		particleSystems[ ParticleSystemIDs.FlameEmbers ] = particleSystem;
@@ -487,7 +487,7 @@
 
 		window.addEventListener( 'resize', onWindowResize, false );
 
-	}
+	    }
 
 	function initRenderer() {
 
@@ -577,7 +577,7 @@
 
 		} );
 
-		ParticleSystemUtil.loadObj( 'models/campfire/campfire.obj', 'models/campfire/campfire_texture.png', campFireMaterial,
+		PHOTONS.Util.loadObj( 'models/campfire/campfire.obj', 'models/campfire/campfire_texture.png', campFireMaterial,
 
 			function( mesh ) {
 
@@ -610,7 +610,7 @@
 
 		} );
 
-		ParticleSystemUtil.loadObj( 'models/campfire/brownrock.obj', 'models/campfire/brownrock.png', rockMaterial,
+		PHOTONS.Util.loadObj( 'models/campfire/brownrock.obj', 'models/campfire/brownrock.png', rockMaterial,
 
 			function( mesh ) {
 
@@ -657,7 +657,7 @@
 
 		} );
 
-		ParticleSystemUtil.loadObj( 'models/campfire/pinetree_doubleface.obj', 'models/campfire/pinetree.jpg', treeMaterial,
+		PHOTONS.Util.loadObj( 'models/campfire/pinetree_doubleface.obj', 'models/campfire/pinetree.jpg', treeMaterial,
 
 			function( mesh ) {