![]() #Particle world vs particle playground updatecall setParticles() to update the mesh and draw it.The way to fix the particle status and then to display them at this status is to call SPS.setParticles().Įach time you call setParticles() the particles are rendered at their current status. Once you've done it, you need to manage your solid particles. So the initial stuff to do is to create the SPS, then to add as many shapes you need and at last to build the SPS mesh. It provides some methods to access then and to manage these solid particles. You have to see it like a big mesh that you can create ( buildMesh) from many shape models, some BJS existing meshes, ( addShape) that will be its solid particles. This means it doesn't know how the particles will move, rotate, if they have a mass, if there are forces, etc. SPS = null // tells the GC the reference can be cleaned up also #Particle world vs particle playground freeIf you don't need your SPS any longer, you can dispose it to free the memory SPS.dispose() () // prevents from re-computing the normals each frame Note you can also use the standard BJS mesh freezeXXX() methods if the SPS mesh is immobile or if the normals aren't needed : () // prevents from re-computing the World Matrix each frame If you are familiar with how BJS works, you could compare the SPS and its mesh creation to some classical BJS mesh creation (vertex and indice settings) and the particle management to the World Matrix computation (rotation, scaling, positioning). If you need to animate them later on and these colors don't change, just set then SPS.computeParticleColor to false once before runing the render loop which will call setParticles() each frame. If these properties are set to false, they don't prevent from using the related feature (ie : the particles can still have a color even if SPS.computeParticleColor is set to false), they just prevent from updating the value of the particle property on the next setParticle() call.Įxample : if your particles have colors, you can set their colors wihtin the initParticles() call and you can call then once the setParticles() method to set these colors. These affect the SPS.setParticles() process only. SPS.computeParticleVertex = false // prevents from calling the custom updateParticleVertex() functionĪll these properties, except SPS.computeParticleVertex, are enabled set to true by default. SPS.computeParticleColor = false // prevents from computing lor SPS.computeParticleTexture = false // prevents from computing particle.uvs If you don't need some given features (ex : particle colors), you can disable/enable them at any time (disabling a feature will improve the performance) : SPS.computeParticleRotation = false // prevents from computing particle.rotation Here again, you can add your own properties like capacity or rate if needed. It's not set by any SPS default functions. SPS.counter : this is a counter for your own usage.SPS.nbParticles : this is number of particles in the SPS.You should iterate over this array in initParticles() function for instance. SPS.particles : this is the array containing all the particles.This is usefull if you want to apply a given behavior to some particle types only. Its underlying mesh name will be the SPS name.Įxample : var SPS = new SolidParticleSystem("SPS", scene) If you particles have to be animated, define their individual behavior in updateParticle(particle) and just call setParticles() within the render loop.įirst you create an empty SPS and you add particles to it with the addShape(mesh, nb) method as many times you need.Call setParticles() to update the SPS mesh and to draw it.Init all your particles : set their positions, colors, uvs, age, etc with initParticles().Your SPS is then ready to manage particles. When done, build the SPS mesh with buildMesh().Redo this as many times as needed with any model.Then, add particles in the SPS from a mesh model with addShape(model, number).First, create your SPS with new SolidParticleSystem().Actually, each particle is a copy of some BJS mesh geometry : vertices, indices, uvs. The particles can be built from any BJS existing mesh as a model. This means it has no emitter, no particle physics, no particle recycler. It provides some methods to manage the particles. It can be scaled, rotated, translated, enlighted, textured, moved, etc. The solid particles are simply separate parts or faces fo this big mesh.Īs it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |