浏览代码

Combined source files for general purpose particle system example into single minified library.

mkkellogg 9 年之前
父节点
当前提交
9413be9222

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

@@ -0,0 +1,53 @@
+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)})}};

+ 0 - 99
examples/js/particles_general/Atlas.js

@@ -1,99 +0,0 @@
-/**
-* @author Mark Kellogg - http://www.github.com/mkkellogg
-*/
-
-THREE.Atlas = function( texture, createFirstFullFrame ) {
-
-	this.texture = texture;
-	this.imageCount = 0;
-	this.imageDescriptors = [];
-
-	if ( createFirstFullFrame ) {
-
-		this.addImageDescriptor( 0, 1, 1, 0 );
-
-	}
-
-};
-
-THREE.Atlas.ImageDescriptor = function( left, top, right, bottom ) {
-
-	this.left = left;
-	this.top = top;
-	this.right = right;
-	this.bottom = bottom;
-
-};
-
-THREE.Atlas.prototype.addImageDescriptor = function( left, top, right, bottom ) {
-
-	this.imageDescriptors[ this.imageCount ] = new THREE.Atlas.ImageDescriptor( left, top, right, bottom );
-	this.imageCount ++;
-
-};
-
-THREE.Atlas.prototype.getImageDescriptor = function( index ) {
-
-	return this.imageDescriptors[ index ];
-
-};
-
-THREE.Atlas.prototype.getTexture = function() {
-
-	return this.texture;
-
-};
-
-THREE.Atlas.createGridAtlas = function( texture, left, top, right, bottom, xCount, yCount, reverseX, reverseY ) {
-
-	var atlas = new THREE.Atlas( texture );
-
-	var width = right - left;
-	var height = top - bottom;
-
-	var xBlockSize = width / xCount;
-	var yBlockSize = height / yCount;
-
-	var xInc = 1;
-	var yInc = 1;
-
-	var xStart = 0;
-	var yStart = 0;
-
-	var xFinish = xCount;
-	var yFinish = yCount;
-
-	if ( reverseX ) {
-
-		xInc = - 1;
-		xStart = xCount - 1;
-		xFinish = - 1;
-
-	}
-
-	if ( reverseY ) {
-
-		yInc = - 1;
-		yStart = yCount - 1;
-		yFinish = - 1;
-
-	}
-
-	for ( var y = yStart; y != yFinish; y += yInc ) {
-
-		for ( var x = xStart; x != xFinish; x += xInc ) {
-
-			var currentLeft = left + xBlockSize * x;
-			var currentTop = bottom + yBlockSize * ( y + 1 );
-			var currentRight = currentLeft + xBlockSize;
-			var currentBottom = currentTop - yBlockSize;
-
-			atlas.addImageDescriptor( currentLeft, currentTop, currentRight, currentBottom );
-
-		}
-
-	}
-
-	return atlas;
-
-};

+ 0 - 105
examples/js/particles_general/ParticleModifiers.js

@@ -1,105 +0,0 @@
-/**
-* @author Mark Kellogg - http://www.github.com/mkkellogg
-*/
-
-THREE.Particles = THREE.Particles || {};
-
-//=======================================
-// Base Modifier
-//=======================================
-
-THREE.Particles.Modifier = function() {
-
-
-}
-
-//=======================================
-// Random Modifier
-//=======================================
-
-THREE.Particles.RandomModifier = function( params ) {
-
-	THREE.Particles.Modifier.call( this );
-
-	if ( ! params ) params = {};
-
-	if ( ! params.range ) {
-
-		throw "Particles.RandomModifier: No range specified.";
-
-	}
-
-	if ( ! params.offset ) {
-
-		throw "Particles.RandomModifier: No offset specified.";
-
-	}
-
-	this.range = params.range;
-	this.offset = params.offset;
-	this.rangeType = params.rangeType || THREE.Particles.RangeType.Cube;
-	this.rangeEdgeClamp = params.rangeEdgeClamp !== undefined && params.rangeEdgeClamp !== null ? params.rangeEdgeClamp : false ;
-
-}
-
-THREE.Particles.RandomModifier.prototype = Object.create( THREE.Particles.Modifier.prototype );
-
-THREE.Particles.RandomModifier.prototype.update = function( particle, target ) {
-
-	if ( this.rangeType == THREE.Particles.RangeType.Cube ) {
-
-		THREE.Particles.Random.getRandomVectorCube( target, this.offset, this.range, this.rangeEdgeClamp );
-
-	} else if ( this.rangeType == THREE.Particles.RangeType.Sphere ) {
-
-		THREE.Particles.Random.getRandomVectorSphere( target, this.offset, this.range, this.rangeEdgeClamp );
-
-	}
-
-}
-
-
-//=======================================
-// FrameSet Modifier
-//=======================================
-
-THREE.Particles.FrameSetModifier = function( frameset ) {
-
-	THREE.Particles.Modifier.call( this );
-
-	this.frameset = frameset;
-
-}
-
-THREE.Particles.FrameSetModifier.prototype = Object.create( THREE.Particles.Modifier.prototype );
-
-THREE.Particles.FrameSetModifier.prototype.update = function( particle, target ) {
-
-	this.frameset.interpolateFrameValues( particle.age, target );
-
-}
-
-
-//=======================================
-// EvenIntervalIndex Modifier
-//=======================================
-
-THREE.Particles.EvenIntervalIndexModifier = function( totalSteps ) {
-
-	THREE.Particles.Modifier.call( this );
-	this.totalSteps = Math.floor( totalSteps || 1 );
-
-}
-
-THREE.Particles.EvenIntervalIndexModifier.prototype = Object.create( THREE.Particles.Modifier.prototype );
-
-THREE.Particles.EvenIntervalIndexModifier.prototype.update = function( particle, target ) {
-
-	var fraction = particle.age / particle.lifeSpan;
-	var step = Math.floor( fraction * this.totalSteps );
-	if ( step == this.totalSteps && step > 0 ) step --;
-
-	target.set( step, step, step );
-
-}
-

+ 0 - 968
examples/js/particles_general/ParticleSystem.js

@@ -1,968 +0,0 @@
-/**
-* @author Mark Kellogg - http://www.github.com/mkkellogg
-*/
-
-//=======================================
-// Particle system
-//=======================================
-
-THREE.Particles = THREE.Particles || {};
-
-THREE.Particles.ParticleSystem = function() {
-
-	THREE.Object3D.call( this );
-
-	this.zSort = false;
-	this.simulateInLocalSpace = true;
-	this.matrixAutoUpdate = true;
-
-	this.releaseAtOnce = false;
-	this.releaseAtOnceCount = 0.0;
-	this.hasInitialReleaseOccurred = false;
-	this.isActive = false;
-
-	this.atlasInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.colorInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.alphaInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.sizeInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.atlasUpdater = THREE.Particles.ParticleSystem.DefaultUpdater;
-	this.colorUpdater = THREE.Particles.ParticleSystem.DefaultUpdater;
-	this.alphaUpdater = THREE.Particles.ParticleSystem.DefaultUpdater;
-	this.sizeUpdater = THREE.Particles.ParticleSystem.DefaultUpdater;
-
-	// Particle position and position modifiers (velocity and acceleration)
-	this.positionUpdater = THREE.Particles.ParticleSystem.DefaultPositionUpdater;
-	this.velocityUpdater = THREE.Particles.ParticleSystem.DefaultVelocityUpdater;
-	this.accelerationUpdater = THREE.Particles.ParticleSystem.DefaultUpdater;
-	this.positionInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.velocityInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.accelerationInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-
-	// Particle rotation and rotation modifiers (rotational speed and rotational acceleration)
-	this.rotationUpdater = THREE.Particles.ParticleSystem.DefaultRotationUpdater;
-	this.rotationalSpeedUpdater = THREE.Particles.ParticleSystem.DefaultRotationalSpeedUpdater;
-	this.rotationalAccelerationUpdater = THREE.Particles.ParticleSystem.DefaultUpdater;
-	this.rotationInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.rotationalSpeedInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-	this.rotationalAccelerationInitializer = THREE.Particles.ParticleSystem.DefaultInitializer;
-
-	this.particleReleaseRate = 100;
-	this.particleLifeSpan = 1.0;
-	this.averageParticleLifeSpan = 1.0;
-	this.calculateAverageParticleLifeSpan();
-
-	this.calculateMaxParticleCount();
-	this.liveParticleCount = 0;
-	this.deadParticleCount = 0;
-	this.liveParticleArray = [];
-	this.deadParticleArray = [];
-
-	this._tempParticleArray = [];
-
-	this.timeSinceLastEmit = 0.0;
-	this.emitting = true;
-	this.age = 0.0;
-	this.lifespan = 0;
-
-	// temporary storage
-	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;
-
-//=======================================
-// Particle system default shader
-//=======================================
-THREE.Particles.ParticleSystem.Shader = THREE.Particles.ParticleSystem.Shader || {};
-
-THREE.Particles.ParticleSystem.Shader.VertexVars = [
-
-	"attribute vec4 customColor;",
-	"attribute vec2 size;",
-	"attribute float rotation;",
-	"attribute float customIndex;",
-	"varying vec2 vUV;",
-	"varying vec4 vColor;",
-	"uniform vec3 cameraaxisx;",
-	"uniform vec3 cameraaxisy;",
-	"uniform vec3 cameraaxisz;",
-
-].join( "\n" );
-
-THREE.Particles.ParticleSystem.Shader.FragmentVars = [
-
-	"varying vec2 vUV;",
-	"varying vec4 vColor;",
-	"uniform sampler2D texture;",
-
-].join( "\n" );
-
-THREE.Particles.ParticleSystem.Shader.ParticleVertexQuadPositionFunction = [
-
-	"vec4 getQuadPosition() {",
-
-		"vec3 axisX = cameraaxisx;",
-		"vec3 axisY = cameraaxisy;",
-		"vec3 axisZ = cameraaxisz;",
-
-		"axisX *= cos( rotation );",
-		"axisY *= sin( rotation );",
-
-		"axisX += axisY;",
-		"axisY = cross( axisZ, axisX );",
-
-		"vec3 edge = vec3( 2.0, customIndex, 3.0 );",
-		"vec3 test = vec3( customIndex, 0.5, customIndex );",
-		"vec3 result = step( edge, test );",
-
-		"float xFactor = -1.0 + ( result.x * 2.0 );",
-		"float yFactor = -1.0 + ( result.y * 2.0 ) + ( result.z * 2.0 );",
-
-		"axisX *= size.x * xFactor;",
-		"axisY *= size.y * yFactor;",
-
-		"return ( modelMatrix * vec4( position, 1.0 ) ) + vec4( axisX + axisY, 0.0 );",
-
-	"}",
-
-].join( "\n" );
-
-THREE.Particles.ParticleSystem.Shader.VertexShader = [
-
-	THREE.Particles.ParticleSystem.Shader.VertexVars,
-	THREE.Particles.ParticleSystem.Shader.ParticleVertexQuadPositionFunction,
-
-	"void main() { ",
-
-		"vColor = customColor;",
-		"vUV = uv;",
-		"vec4 quadPos = getQuadPosition();",
-		"gl_Position = projectionMatrix * viewMatrix * quadPos;",
-
-	"}"
-
-].join( "\n" );
-
-THREE.Particles.ParticleSystem.Shader.FragmentShader = [
-
-	THREE.Particles.ParticleSystem.Shader.FragmentVars,
-
-	"void main() { ",
-
-	    "vec4 textureColor = texture2D( texture,  vUV );",
-		"gl_FragColor = vColor * textureColor;",
-
-	"}"
-
-].join( "\n" );
-
-THREE.Particles.ParticleSystem.createMaterial = function( vertexShader, fragmentShader, customUniforms ) {
-
-	customUniforms = customUniforms || {};
-
-	customUniforms.texture = { type: "t", value: null };
-	customUniforms.cameraaxisx = { type: "v3", value: new THREE.Vector3() };
-	customUniforms.cameraaxisy = { type: "v3", value: new THREE.Vector3() };
-	customUniforms.cameraaxisz = { type: "v3", value: new THREE.Vector3() };
-
-	vertexShader = vertexShader || THREE.Particles.ParticleSystem.Shader.VertexShader;
-	fragmentShader = fragmentShader || THREE.Particles.ParticleSystem.Shader.FragmentShader;
-
-	return new THREE.ShaderMaterial(
-	{
-		uniforms: customUniforms,
-		vertexShader: vertexShader,
-		fragmentShader: fragmentShader,
-
-		transparent: true,
-		alphaTest: 0.5,
-
-		blending: THREE.NormalBlending,
-
-		depthTest: true,
-		depthWrite: false
-	} );
-
-}
-
-//=======================================
-// Particle system functions
-//=======================================
-
-THREE.Particles.ParticleSystem.prototype.calculateAverageParticleLifeSpan = function() {
-
-	var total = 0.0;
-
-	for ( var i = 0; i < 100; i ++ ) {
-
-		total += this.particleLifeSpan;
-
-	}
-
-	total /= 100.0;
-
-	this.averageParticleLifeSpan = total;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.calculateMaxParticleCount = function() {
-
-	if ( this.releaseAtOnce ) {
-
-		this.maxParticleCount = this.releaseAtOnceCount;
-
-	} else {
-
-		var minLifeSpan = this.particleLifeSpan;
-		if ( this.lifespan != 0 && this.lifespan < minLifeSpan ) minLifeSpan = this.lifespan;
-		this.maxParticleCount = Math.max( this.particleReleaseRate * minLifeSpan * 2, 1.0 );
-
-	}
-
-	this.vertexCount = this.maxParticleCount * THREE.Particles.Constants.VerticesPerParticle;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.initializeGeometry = function() {
-
-	this.particleGeometry = new THREE.BufferGeometry();
-	var particleColor = new Float32Array( this.vertexCount * 4 );
-	var particleAlpha = new Float32Array( this.vertexCount );
-	var positions = new Float32Array( this.vertexCount * 3 );
-	var uvs = new Float32Array( this.vertexCount * 2 );
-	var size = new Float32Array( this.vertexCount * 2 );
-	var rotation = new Float32Array( this.vertexCount );
-	var index = new Float32Array( this.vertexCount );
-
-	var particleColorAttribute = new THREE.BufferAttribute( particleColor, 4 );
-	particleColorAttribute.setDynamic( true );
-	this.particleGeometry.addAttribute( 'customColor', particleColorAttribute );
-
-	var positionAttribute = new THREE.BufferAttribute( positions, 3 );
-	positionAttribute.setDynamic( true );
-	this.particleGeometry.addAttribute( 'position', positionAttribute );
-
-	var uvAttribute = new THREE.BufferAttribute( uvs, 2 );
-	uvAttribute.setDynamic( true );
-	this.particleGeometry.addAttribute( 'uv', uvAttribute );
-
-	var sizeAttribute = new THREE.BufferAttribute( size, 2 );
-	sizeAttribute.setDynamic( true );
-	this.particleGeometry.addAttribute( 'size', sizeAttribute );
-
-	var rotationAttribute = new THREE.BufferAttribute( rotation, 1 );
-	rotationAttribute.setDynamic( true );
-	this.particleGeometry.addAttribute( 'rotation', rotationAttribute );
-
-	var indexAttribute = new THREE.BufferAttribute( index, 1 );
-	indexAttribute.setDynamic( true );
-	this.particleGeometry.addAttribute( 'customIndex', indexAttribute );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.initializeMaterial = function( material ) {
-
-	this.particleMaterial = material;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.initializeMesh = function() {
-
-	this.destroyMesh();
-
-	this.particleMesh = new THREE.Mesh( this.particleGeometry, this.particleMaterial );
-	this.particleMesh.dynamic = true;
-	this.particleMesh.matrixAutoUpdate = false;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.destroyMesh = function() {
-
-	if ( this.particleMesh ) {
-
-		scene.remove( this.particleMesh );
-		this.particleMesh = undefined;
-
-	}
-
-}
-
-THREE.Particles.ParticleSystem.prototype.initializeParticleArray = function() {
-
-	for ( var i = 0; i < this.maxParticleCount; i ++ ) {
-
-		var particle = this.createParticle();
-		this.initializeParticle( particle );
-		this.deadParticleArray[ i ] = particle;
-
-	}
-
-	this.liveParticleCount = 0;
-	this.deadParticleCount = this.maxParticleCount;
-
-	this.liveParticleArray.length = this.liveParticleCount;
-	this.deadParticleArray.length = this.deadParticleCount;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.mergeParameters = function( parameters ) {
-
-	for ( var key in parameters ) {
-
-		this[ key ] = parameters[ key ];
-
-	}
-
-}
-
-THREE.Particles.ParticleSystem.prototype.bindInitializer = function( name, modifier ) {
-
-	if ( name ) {
-
-		this[ name + "Initializer" ] = modifier;
-
-	}
-
-}
-
-THREE.Particles.ParticleSystem.prototype.bindUpdater = function( name, modifier ) {
-
-	if ( name ) {
-
-		this[ name + "Updater" ] = modifier;
-
-	}
-
-}
-
-THREE.Particles.ParticleSystem.prototype.bindModifier = function( name, modifier ) {
-
-	this.bindInitializer( name, modifier );
-	this.bindUpdater( name, modifier );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.initialize = function( camera, parameters ) {
-
-	this.camera = camera;
-
-	this.sizeFrameSet = undefined;
-	this.colorFrameSet = undefined;
-	this.alphaFrameSet = undefined;
-
-	if ( parameters ) {
-
-		this.mergeParameters ( parameters );
-
-	}
-
-	if ( ! this.sizeFrameSet ) this.sizeFrameSet = new THREE.Particles.FrameSet();
-	if ( ! this.colorFrameSet ) this.colorFrameSet = new THREE.Particles.FrameSet();
-	if ( ! this.alphaFrameSet ) this.alphaFrameSet = new THREE.Particles.FrameSet();
-
-	this.liveParticleArray = [];
-	this.timeSinceLastEmit = 0.0;
-	this.age = 0.0;
-	this.emitting = true;
-
-	this.calculateAverageParticleLifeSpan();
-	this.calculateMaxParticleCount();
-	this.initializeParticleArray();
-
-	this.initializeGeometry();
-	this.initializeMaterial( parameters.material );
-	this.updateAttributesWithParticleData();
-	this.initializeMesh();
-
-}
-
-THREE.Particles.ParticleSystem.prototype.getCameraWorldAxes = function() {
-
-	var quaternion = new THREE.Quaternion();
-
-	return function getCameraWorldAxes( camera, axisX, axisY, axisZ ) {
-
-		camera.getWorldQuaternion( quaternion );
-		axisZ.set( 0, 0, 1 ).applyQuaternion( quaternion );
-		axisY.set( 0, 1, 0 ).applyQuaternion( quaternion );
-		axisX.crossVectors( axisY, axisZ );
-
-	}
-
-}();
-
-THREE.Particles.ParticleSystem.prototype.generateXYAlignedQuadForParticle = function() {
-
-	var vectorX = new THREE.Vector3();
-	var vectorY = new THREE.Vector3();
-
-	return function generateXYAlignedQuadForParticle( particle, axisX, axisY, axisZ, pos1, pos2, pos3, pos4 ) {
-
-		var position = particle.position;
-		var rotation = particle.rotation;
-
-		vectorX.copy( axisX );
-		vectorY.copy( axisY );
-
-		vectorX.multiplyScalar( Math.cos( rotation * THREE.Particles.Constants.DegreesToRadians ) );
-		vectorY.multiplyScalar( Math.sin( rotation * THREE.Particles.Constants.DegreesToRadians ) );
-
-		vectorX.addVectors( vectorX, vectorY );
-		vectorY.crossVectors( axisZ, vectorX );
-
-		vectorX.multiplyScalar( particle.size.x );
-		vectorY.multiplyScalar( particle.size.y );
-
-		pos1.subVectors( position, vectorX ).addVectors( pos1, vectorY );
-		pos2.subVectors( position, vectorX ).subVectors( pos2, vectorY );
-		pos3.addVectors( position, vectorX ).subVectors( pos3, vectorY );
-		pos4.addVectors( position, vectorX ).addVectors( pos4, vectorY );
-
-	}
-
-}();
-
-THREE.Particles.ParticleSystem.prototype.updateAttributesWithParticleData = function() {
-
-	var vectorY = new THREE.Vector3();
-	var vectorX = new THREE.Vector3();
-	var vectorZ = new THREE.Vector3();
-
-	var quadPos1 = new THREE.Vector3();
-	var quadPos2 = new THREE.Vector3();
-	var quadPos3 = new THREE.Vector3();
-	var quadPos4 = new THREE.Vector3();
-
-	return function updateAttributesWithParticleData() {
-
-		this.getCameraWorldAxes( this.camera, vectorX, vectorY, vectorZ );
-
-		this.particleMaterial.uniforms.cameraaxisx.value.copy( vectorX );
-		this.particleMaterial.uniforms.cameraaxisy.value.copy( vectorY );
-		this.particleMaterial.uniforms.cameraaxisz.value.copy( vectorZ );
-		this.particleMaterial.uniforms.texture.value = this.particleAtlas.getTexture();
-
-		for ( var p = 0; p < this.liveParticleCount; p ++ ) {
-
-			var particle = this.liveParticleArray[ p ];
-			var position = particle.position;
-
-			var baseIndex = p * THREE.Particles.Constants.VerticesPerParticle;
-
-			var attributePosition = this.particleGeometry.getAttribute( 'position' );
-			this.updateAttributeVector3( attributePosition, baseIndex, position );
-			this.updateAttributeVector3( attributePosition, baseIndex + 1, position );
-			this.updateAttributeVector3( attributePosition, baseIndex + 2, position );
-			this.updateAttributeVector3( attributePosition, baseIndex + 3, position );
-			this.updateAttributeVector3( attributePosition, baseIndex + 4, position );
-			this.updateAttributeVector3( attributePosition, baseIndex + 5, position );
-
-			var imageDesc = this.particleAtlas.getImageDescriptor( particle.atlasIndex.x );
-			var attributeUV = this.particleGeometry.getAttribute( 'uv' );
-			this.updateAttributeVector2XY( attributeUV, baseIndex, imageDesc.left, imageDesc.top );
-			this.updateAttributeVector2XY( attributeUV, baseIndex + 1, imageDesc.left, imageDesc.bottom );
-			this.updateAttributeVector2XY( attributeUV, baseIndex + 2, imageDesc.right, imageDesc.top );
-			this.updateAttributeVector2XY( attributeUV, baseIndex + 3, imageDesc.left, imageDesc.bottom );
-			this.updateAttributeVector2XY( attributeUV, baseIndex + 4, imageDesc.right, imageDesc.bottom );
-			this.updateAttributeVector2XY( attributeUV, baseIndex + 5, imageDesc.right, imageDesc.top );
-
-			var color = particle.color;
-			var alpha = particle.alpha.x;
-			color.a = alpha;
-			var size = particle.size;
-			var rotation = particle.rotation.x * THREE.Particles.Constants.DegreesToRadians
-
-			var attributeColor = this.particleGeometry.getAttribute( 'customColor' );
-			var attributeSize = this.particleGeometry.getAttribute( 'size' );
-			var attributeRotation = this.particleGeometry.getAttribute( 'rotation' );
-			for ( var i = 0; i < THREE.Particles.Constants.VerticesPerParticle; i ++ ) {
-
-				var index = baseIndex + i;
-				this.updateAttributeColor( attributeColor, index, color );
-				this.updateAttributeVector2XY( attributeSize, index, size.x, size.y );
-				this.updateAttributeScalar( attributeRotation, index, rotation );
-
-			}
-
-			var attributeIndex = this.particleGeometry.getAttribute( 'customIndex' );
-			this.updateAttributeScalar( attributeIndex, baseIndex, 0 );
-			this.updateAttributeScalar( attributeIndex, baseIndex + 1, 1 );
-			this.updateAttributeScalar( attributeIndex, baseIndex + 2, 3 );
-			this.updateAttributeScalar( attributeIndex, baseIndex + 3, 1 );
-			this.updateAttributeScalar( attributeIndex, baseIndex + 4, 2 );
-			this.updateAttributeScalar( attributeIndex, baseIndex + 5, 3 );
-
-		}
-
-		this.particleGeometry.setDrawRange( 0, THREE.Particles.Constants.VerticesPerParticle * this.liveParticleCount );
-
-	}
-
-}();
-
-THREE.Particles.ParticleSystem.prototype.updateAttributeVector2XY = function( attribute, index, x, y ) {
-
-	attribute.array[ index * 2 ] = x;
-	attribute.array[ index * 2 + 1 ] = y;
-	attribute.needsUpdate = true;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.updateAttributeVector3 = function( attribute, index, value ) {
-
-	attribute.array[ index * 3 ] = value.x;
-	attribute.array[ index * 3 + 1 ] = value.y;
-	attribute.array[ index * 3 + 2 ] = value.z;
-	attribute.needsUpdate = true;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.updateAttributeColor = function( attribute, index, value ) {
-
-	attribute.array[ index * 4 ] = value.r;
-	attribute.array[ index * 4 + 1 ] = value.g;
-	attribute.array[ index * 4 + 2 ] = value.b;
-	attribute.array[ index * 4 + 3 ] = value.a;
-	attribute.needsUpdate = true;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.updateAttributeScalar = function( attribute, index, value ) {
-
-	attribute.array[ index ] = value;
-	attribute.needsUpdate = true;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.createParticle = function() {
-
-	var particle = new THREE.Particles.Particle();
-	return particle;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.initializeParticle = function( particle ) {
-
-	 this.resetParticle( particle );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.resetParticle = function( particle ) {
-
-	particle.age = 0;
-	particle.alive = 0;
-
-	this.resetParticleDisplayAttributes( particle );
-	this.resetParticlePositionData( particle );
-	this.resetParticleRotationData( particle );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.resetParticleDisplayAttributes = function( particle ) {
-
-	this.atlasInitializer.update( particle, particle.atlasIndex, 0 );
-	this.sizeInitializer.update( particle, particle.size, 0 );
-	this.colorInitializer.update( particle, particle._tempVector3, 0 );
-	particle.color.setRGB( particle._tempVector3.x, particle._tempVector3.y, particle._tempVector3.z );
-	this.alphaInitializer.update( particle, particle.alpha, 0 );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.resetParticlePositionData = function( particle ) {
-
-	this.positionInitializer.update( particle, particle.position, 0 );
-
-	if ( ! this.simulateInLocalSpace ) {
-
-		particle._tempVector3.setFromMatrixPosition( this.matrixWorld );
-		particle.position.addVectors( particle._tempVector3, particle.position );
-
-	}
-
-	this.velocityInitializer.update( particle, particle.velocity, 0 );
-	this.accelerationInitializer.update( particle, particle.acceleration, 0 );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.resetParticleRotationData = function( particle ) {
-
-	this.rotationInitializer.update( particle, particle.rotation );
-	this.rotationalSpeedInitializer.update( particle, particle.rotationalSpeed );
-	this.rotationalAccelerationInitializer.update( particle, particle.rotationalAcceleration );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.advanceParticle = function( particle, deltaTime ) {
-
-	particle.age += deltaTime;
-
-	this.advanceParticleDisplayAttributes( particle, deltaTime );
-	this.advanceParticlePositionData( particle, deltaTime );
-	this.advanceParticleRotationData( particle, deltaTime );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.advanceParticleDisplayAttributes = function( particle, deltaTime ) {
-
-	this.atlasUpdater.update( particle, particle.atlasIndex, deltaTime );
-	this.sizeUpdater.update( particle, particle.size, deltaTime );
-	this.colorUpdater.update( particle, particle._tempVector3, deltaTime );
-	particle.color.setRGB( particle._tempVector3.x, particle._tempVector3.y, particle._tempVector3.z );
-	this.alphaUpdater.update( particle, particle.alpha, deltaTime );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.advanceParticlePositionData = function( particle, deltaTime ) {
-
-	this.positionUpdater.update( particle, particle.position, deltaTime );
-	this.velocityUpdater.update( particle, particle.velocity, deltaTime );
-	this.accelerationUpdater.update( particle, particle.acceleration, deltaTime );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.advanceParticleRotationData = function( particle, deltaTime ) {
-
-	this.rotationUpdater.update( particle, particle.rotation, deltaTime );
-	this.rotationalSpeedUpdater.update( particle, particle.rotationalSpeed, deltaTime );
-	this.rotationalAccelerationUpdater.update( particle, particle.rotationalAcceleration, deltaTime );
-
-}
-
-THREE.Particles.ParticleSystem.prototype.advanceParticles = function( deltaTime ) {
-
-	var deadCount = 0;
-
-	for ( var i = 0; i < this.liveParticleCount; i ++ )
-	{
-
-		var particle = this.liveParticleArray[ i ];
-		this.advanceParticle( particle, deltaTime );
-
-		if ( particle.age > particle.lifeSpan )
-		{
-
-			this.killParticle( particle );
-			deadCount ++;
-
-		}
-
-	}
-
-	if ( deadCount > 0 ) {
-
-		this.cleanupDeadParticles();
-
-	}
-
-}
-
-THREE.Particles.ParticleSystem.prototype.killParticle = function( particle ) {
-
-	particle.alive = 0.0;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.activateParticle = function( particle ) {
-
-	this.resetParticle( particle );
-	particle.lifeSpan = this.particleLifeSpan;
-	particle.alive = 1.0;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.cleanupDeadParticles = function() {
-
-	var topAlive = this.liveParticleCount - 1;
-	var bottomDead = 0;
-	while ( topAlive > bottomDead ) {
-
-		while ( this.liveParticleArray[ topAlive ].alive == 0.0 && topAlive > 0 ) {
-
-			topAlive --;
-
-		}
-
-		while ( this.liveParticleArray[ bottomDead ].alive == 1.0 && bottomDead < this.liveParticleCount - 1 ) {
-
-			bottomDead ++;
-
-		}
-
-		if ( topAlive <= bottomDead ) {
-
-			break;
-
-		}
-
-		var swap = this.liveParticleArray[ bottomDead ];
-		this.liveParticleArray[ bottomDead ] = this.liveParticleArray[ topAlive ];
-		this.liveParticleArray[ topAlive ] = swap;
-
-	}
-
-	while ( this.liveParticleCount > 0 && this.liveParticleArray[ this.liveParticleCount - 1 ].alive == 0.0 ) {
-
-		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 numericalSort( a, b ) {
-
-		return a[ 0 ] - b[ 0 ];
-
-	};
-
-	var _sortParticleArray = [];
-	var projectedPosition = new THREE.Vector3();
-
-	return function sortParticleArray( mvpMatrix ) {
-
-		for ( var p = 0; p < this.liveParticleCount; p ++ ) {
-
-			var position = this.liveParticleArray[ p ].position;
-			projectedPosition.copy( position );
-			projectedPosition.applyProjection( mvpMatrix );
-
-			if ( ! _sortParticleArray[ p ] ) {
-
-				_sortParticleArray[ p ] = [ 0, 0 ];
-
-			}
-
-			_sortParticleArray[ p ][ 0 ] = projectedPosition.z;
-			_sortParticleArray[ p ][ 1 ] = p;
-
-		}
-
-		_sortParticleArray.length = this.liveParticleCount;
-		_sortParticleArray.sort( numericalSort );
-
-		for ( p = 0; p < this.liveParticleCount; p ++ ) {
-
-			var originalIndex = _sortParticleArray[ p ][ 1 ];
-			this._tempParticleArray[ p ] = this.liveParticleArray[ originalIndex ];
-
-		}
-
-		this._tempParticleArray.length = this.liveParticleCount;
-
-		var temp = this.liveParticleArray;
-		this.liveParticleArray = this._tempParticleArray;
-		this._tempParticleArray = temp;
-
-	}
-
-}();
-
-THREE.Particles.ParticleSystem.prototype.activateParticles = function( count ) {
-
-	for ( var i = 0; i < count; i ++ ) {
-
-		if ( this.liveParticleCount < this.maxParticleCount && this.deadParticleCount > 0 ) {
-
-			var newParticle = this.deadParticleArray[ this.deadParticleCount - 1 ];
-			this.liveParticleArray[ this.liveParticleCount ] = newParticle;
-			this.deadParticleCount --;
-			this.liveParticleCount ++;
-
-			this.activateParticle ( newParticle );
-
-		} else {
-
-			break;
-
-		}
-
-	}
-
-	this.liveParticleArray.length = this.liveParticleCount;
-	this.deadParticleArray.length = this.deadParticleCount;
-
-}
-
-THREE.Particles.ParticleSystem.prototype.update = function() {
-
-	var tempMatrix4 = new THREE.Matrix4();
-
-	return function update( deltaTime ) {
-
-		if ( ! this.emitting )return;
-		if ( ! this.isActive )return;
-
-		this.timeSinceLastEmit += deltaTime;
-
-		if ( this.releaseAtOnce ) {
-
-			var waitTime = this.averageParticleLifeSpan;
-
-			if ( ! this.hasInitialReleaseOccurred || ( this.timeSinceLastEmit > waitTime && this.liveParticleCount <= 0 ) ) {
-
-				this.activateParticles( this.maxParticleCount );
-				this.timeSinceLastEmit = 0.0;
-				this.hasInitialReleaseOccurred = true;
-
-			}
-
-		} else {
-
-			var emitUnitTime = 1.0 / this.particleReleaseRate;
-			if ( ! this.hasInitialReleaseOccurred || this.timeSinceLastEmit > emitUnitTime ) {
-
-				var releaseCount = Math.max( 1, Math.floor( this.timeSinceLastEmit / emitUnitTime ) );
-				this.activateParticles( releaseCount );
-				this.timeSinceLastEmit = 0.0;
-				this.hasInitialReleaseOccurred = true;
-
-			}
-
-		}
-
-		this.advanceParticles( deltaTime );
-
-		if ( this.zSort ) {
-
-			this.camera.updateMatrixWorld();
-			tempMatrix4.copy( this.camera.matrixWorld );
-			tempMatrix4.getInverse( tempMatrix4 );
-			this.sortParticleArray( tempMatrix4 );
-
-		}
-
-		this.updateAttributesWithParticleData();
-
-		this.age += deltaTime;
-		if ( this.lifespan != 0 && this.age > this.lifespan ) {
-
-			 this.emitting = false;
-
-		}
-
-		if ( this.simulateInLocalSpace ) {
-
-			this.particleMesh.matrix.copy( this.matrixWorld );
-			this.particleMesh.updateMatrixWorld();
-
-		}
-
-	}
-
-}();
-
-THREE.Particles.ParticleSystem.prototype.deactivate = function() {
-
-	if ( this.isActive ) {
-
-		scene.remove( this.particleMesh );
-		this.isActive = false;
-
-	}
-
-}
-
-THREE.Particles.ParticleSystem.prototype.activate = function() {
-
-	if ( ! this.isActive ) {
-
-		scene.add( this.particleMesh );
-		this.isActive = true;
-
-	}
-
-}
-
-THREE.Particles.ParticleSystem.DefaultPositionUpdater = {
-
-	update : function( particle, target, deltaTime ) {
-
-		particle._tempVector3.copy( particle.velocity );
-		particle._tempVector3.multiplyScalar( deltaTime );
-		particle.position.add( particle._tempVector3 );
-
-	}
-}
-
-THREE.Particles.ParticleSystem.DefaultVelocityUpdater = {
-
-	update : function( particle, target, deltaTime ) {
-
-		particle._tempVector3.copy( particle.acceleration );
-		particle._tempVector3.multiplyScalar( deltaTime );
-		particle.velocity.add( particle._tempVector3 );
-
-	}
-}
-
-THREE.Particles.ParticleSystem.DefaultRotationUpdater = {
-
-	update : function( particle, target, deltaTime ) {
-
-		particle.rotation.set( particle.rotation.x += particle.rotationalSpeed.x * deltaTime );
-
-	}
-}
-
-THREE.Particles.ParticleSystem.DefaultRotationalSpeedUpdater = {
-
-	update : function( particle, target, deltaTime ) {
-
-		particle.rotationalSpeed.set( particle.rotationalSpeed.x += particle.rotationalAcceleration.x * deltaTime );
-
-	}
-}
-
-THREE.Particles.ParticleSystem.DefaultUpdater = {
-
-	update : function( particle, target, deltaTime ) {
-
-
-	}
-}
-
-THREE.Particles.ParticleSystem.DefaultInitializer = {
-
-	update : function( particle, target, deltaTime ) {
-
-		target.set( 0, 0, 0, 0 );
-
-	}
-}
-
-//=======================================
-// Particle object
-//=======================================
-
-THREE.Particles.Particle = function() {
-
-	this.age = 0;
-	this.alive = 0;
-	this.lifeSpan = 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();
-
-}

+ 0 - 56
examples/js/particles_general/ParticleSystemFrameset.js

@@ -1,56 +0,0 @@
-/**
-* @author Mark Kellogg - http://www.github.com/mkkellogg
-*/
-
-THREE.Particles = THREE.Particles || {};
-
-THREE.Particles.FrameSet = function( timeFrames, valueFrames, isScalar ) {
-
-	this.timeFrames = timeFrames || [];
-	this.valueFrames = valueFrames || [];
-
-}
-
-THREE.Particles.FrameSet.prototype.findNextFrameForTimeValue = function( t ) {
-
-	var frameIndex = 0;
-
-	while ( frameIndex < this.timeFrames.length && this.timeFrames[ frameIndex ] < t ) {
-
-		frameIndex = frameIndex + 1;
-
-	}
-
-	return frameIndex;
-
-}
-
-THREE.Particles.FrameSet.prototype.calculateFraction = function( a, b, z ) {
-
-	return ( z - a ) / ( b - a );
-
-}
-
-THREE.Particles.FrameSet.prototype.interpolateFrameValues = function( t, target ) {
-
-	var nextFrameIndex = this.findNextFrameForTimeValue( t );
-	var currentFrameIndex = nextFrameIndex - 1;
-
-	if ( nextFrameIndex == 0 ) {
-
-		target.copy( this.valueFrames[ 0 ] );
-
-	} else if ( nextFrameIndex == this.timeFrames.length ) {
-
-		target.copy( this.valueFrames[ currentFrameIndex ] );
-
-	} else {
-
-		var fraction = this.calculateFraction( this.timeFrames[ currentFrameIndex ], this.timeFrames[ nextFrameIndex ], t );
-
-		target.copy( this.valueFrames[ currentFrameIndex ] );
-		target.lerp( this.valueFrames[ nextFrameIndex ], fraction );
-
-	}
-
-}

+ 0 - 94
examples/js/particles_general/ParticleSystemUtil.js

@@ -1,94 +0,0 @@
-/**
-* @author Mark Kellogg - http://www.github.com/mkkellogg
-*/
-
-var ParticleSystemUtil = {
-
-	loadingManager: undefined,
-	objLoader: undefined,
-	imageLoader: undefined,
-
-	initializeLoadingManager: function() {
-
-		this.loadingManager = new THREE.LoadingManager();
-		this.loadingManager.onProgress = function( item, loaded, total ) {
-
-			console.log( "Loaded " + loaded + " items out of " + total + ": " + item);
-
-		};
-
-	},
-
-
-	loadObj: function( objFile, textureFile, material, onMesh, onLoadComplete ) {
-
-		var onProgress = function( xhr ) {
-
-			if ( xhr.lengthComputable ) {
-
-				var percentComplete = xhr.loaded / xhr.total * 100;
-				//console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
-
-			}
-
-		};
-
-		var onError = function( xhr ) {
-
-			console.log( "ERROR: loadObj() - " + xhr );
-
-		};
-
-		if ( ! this.objLoader ) {
-
-			this.objLoader = new THREE.OBJLoader( loadingManager );
-
-		}
-		if ( ! this.imageLoader ) {
-
-			this.imageLoader = new THREE.ImageLoader( this.loadingManager );
-
-
-		}
-
-		var texture = new THREE.Texture();
-		var _this = this;
-		this.imageLoader.load( textureFile, function( image ) {
-
-			texture.image = image;
-			texture.needsUpdate = true;
-			
-			_this.objLoader.load( objFile, function( object ) {
-
-				object.traverse( function( child ) {
-
-					if ( child instanceof THREE.Mesh ) {
-
-						child.material = material;
-						child.material.map = texture;
-
-						if ( onMesh ) {
-
-							onMesh ( child );
-
-						}
-
-					}
-
-				} );
-
-
-				console.log( "Finished loading model: " + objFile );
-				if ( onLoadComplete ) {
-
-					onLoadComplete( object );
-
-				}
-
-			}, onProgress, onError );
-
-		} );
-
-	}
-
-}

+ 0 - 117
examples/js/particles_general/Particles.js

@@ -1,117 +0,0 @@
-/**
-* @author Mark Kellogg - http://www.github.com/mkkellogg
-*/
-
-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.0
-
-} );
-
-
-THREE.Particles.Random = THREE.Particles.Random || {};
-
-THREE.Particles.Random.getRandomVectorCube = function( vector, offset, range, edgeClamp ) {
-
-	var x = Math.random() - 0.5;
-	var y = Math.random() - 0.5;
-	var z = Math.random() - 0.5;
-	var w = Math.random() - 0.5;
-
-	vector.set( x, y, z, w );
-
-	if ( edgeClamp ) {
-
-		var max = Math.max ( Math.abs( vector.x ), Math.max ( Math.abs( vector.y ), Math.abs( vector.z ) ) );
-		vector.multiplyScalar( 1.0 / max );
-
-	}
-
-	vector.multiplyVectors( range, vector );
-	vector.addVectors( offset, vector );
-
-}
-
-THREE.Particles.Random.getRandomVectorSphere = function( vector, offset, range, edgeClamp ) {
-
-	var x = Math.random() - 0.5;
-	var y = Math.random() - 0.5;
-	var z = Math.random() - 0.5;
-	var w = Math.random() - 0.5;
-
-	vector.set( x, y, z, w );
-	vector.normalize();
-
-	vector.multiplyVectors( vector, range );
-
-	if ( ! edgeClamp ) {
-
-		var adjust = Math.random() * 2.0 - 1.0;
-		vector.multiplyScalar( adjust );
-
-	}
-
-	vector.addVectors( vector, offset );
-
-}
-
-THREE.Particles.SingularVector = function( x ) {
-
-	this.x = x;
-
-}
-
-
-THREE.Particles.SingularVector.prototype.copy = function( dest ) {
-
-	this.x = dest.x;
-
-}
-
-THREE.Particles.SingularVector.prototype.set = function( x ) {
-
-	this.x = x;
-
-}
-
-THREE.Particles.SingularVector.prototype.normalize = function() {
-
-	//return this;
-
-}
-
-THREE.Particles.SingularVector.prototype.multiplyScalar = function( x ) {
-
-	this.x *= x;
-
-}
-
-THREE.Particles.SingularVector.prototype.lerp = function( dest, f ) {
-
-	this.x = this.x + f * ( dest.x - this.x );
-
-}
-
-THREE.Particles.SingularVector.prototype.addVectors = function( vector, offset ) {
-
-	vector.x += offset;
-
-}
-
-THREE.Particles.SingularVector.prototype.multiplyVectors = function( vector, rangeVector ) {
-
-	vector.x *= rangeVector.x;
-
-}
-

+ 10 - 19
examples/webgl_particles_general.html

@@ -9,12 +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/particles_general/Atlas.js"></script>
-	<script src="js/particles_general/Particles.js"></script>
-	<script src="js/particles_general/ParticleSystem.js"></script>
-	<script src="js/particles_general/ParticleSystemFrameset.js"></script>
-	<script src="js/particles_general/ParticleModifiers.js"></script>
-	<script src="js/particles_general/ParticleSystemUtil.js"></script>
+	<script src="js/GeneralParticleSystem.min.js"></script>
 
     <style>
 		body {
@@ -39,7 +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">mkkellogg</a>
+	<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>
+	<br />
+	Full source on <a href="https://github.com/mkkellogg/ParticleSystemJS" target="_new">GitHub</a>
 </div>
 
 <div id="renderingContainer" style="position: absolute; left:0px; top:0px"></div>
@@ -95,7 +92,7 @@
 			startParticleSystemEnvironment ( ParticleEnvironmentIDs.Campfire );
 			initRenderer();
 			initControls();
-			    initStats();
+			initStats();
 			animate();
 
 		} );
@@ -208,10 +205,10 @@
 		};
 
 		var particleSystem1 = new THREE.Particles.ParticleSystem();
-		particleSystem1.initialize( camera, particleSystemParams1 );
+		particleSystem1.initialize( camera, scene, particleSystemParams1 );
 
 		var particleSystem2 = new THREE.Particles.ParticleSystem();
-		particleSystem2.initialize( camera, particleSystemParams2 );
+		particleSystem2.initialize( camera, scene, particleSystemParams2 );
 
 		var positionModifier = new THREE.Particles.RandomModifier(
 			{
@@ -326,7 +323,7 @@
 
 		};
 		var particleSystem = new THREE.Particles.ParticleSystem();
-		particleSystem.initialize( camera, particleSystemParams );
+		particleSystem.initialize( camera, scene, particleSystemParams );
 
 		particleSystem.bindModifier( "atlas", new THREE.Particles.EvenIntervalIndexModifier ( 64 ) );
 
@@ -355,7 +352,6 @@
 
 		particleSystem.bindInitializer( 'position', new THREE.Particles.RandomModifier(
 			{
-				isScalar: false,
 				offset: new THREE.Vector3( 0, 0, 0 ),
 				range: new THREE.Vector3( 0, 0, 0 ),
 				rangeEdgeClamp: false,
@@ -364,7 +360,6 @@
 
 		particleSystem.bindInitializer( 'velocity', new THREE.Particles.RandomModifier(
 			{
-				isScalar: false,
 				offset: new THREE.Vector3( 0, 25, 0 ),
 				range: new THREE.Vector3( 10, 2, 10 ),
 				rangeEdgeClamp: false,
@@ -392,13 +387,12 @@
 
 		};
 		particleSystem = new THREE.Particles.ParticleSystem();
-		particleSystem.initialize( camera, particleSystemParams );
+		particleSystem.initialize( camera, scene, particleSystemParams );
 
 		particleSystem.bindModifier( "atlas", new THREE.Particles.EvenIntervalIndexModifier ( 1 ) );
 
 		particleSystem.bindModifier( 'size', new THREE.Particles.RandomModifier(
 			{
-				isScalar: false,
 				offset: new THREE.Vector3( .25, .25, 0.0 ),
 				range: new THREE.Vector3( 0.05, 0.05, 0.0 ),
 				rangeEdgeClamp: false,
@@ -424,7 +418,6 @@
 
 		particleSystem.bindInitializer( 'position', new THREE.Particles.RandomModifier(
 			{
-				isScalar: false,
 				offset: new THREE.Vector3( 0, 7, 0 ),
 				range: new THREE.Vector3( 3, 0, 3 ),
 				rangeEdgeClamp: false,
@@ -433,7 +426,6 @@
 
 		particleSystem.bindInitializer( 'velocity', new THREE.Particles.RandomModifier(
 			{
-				isScalar: false,
 				offset: new THREE.Vector3( 0, 25, 0 ),
 				range: new THREE.Vector3( 15, 25, 15 ),
 				rangeEdgeClamp: true,
@@ -442,7 +434,6 @@
 
 		particleSystem.bindModifier( 'acceleration', new THREE.Particles.RandomModifier(
 			{
-				isScalar: false,
 				offset: new THREE.Vector3( 0, 15, 0 ),
 				range: new THREE.Vector3( 180, 280, 180 ),
 				rangeEdgeClamp: true,
@@ -496,7 +487,7 @@
 
 		window.addEventListener( 'resize', onWindowResize, false );
 
-	    }
+	}
 
 	function initRenderer() {