Add Fire Particle
This commit is contained in:
parent
683440dda2
commit
958c51416b
3 changed files with 93 additions and 0 deletions
BIN
images/flare.png
Normal file
BIN
images/flare.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
images/part.png
Normal file
BIN
images/part.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 146 B |
|
@ -95,6 +95,12 @@ function createObj(loader,scene){
|
|||
m.checkCollisions = true;
|
||||
});
|
||||
};
|
||||
var f = BABYLON.Mesh.CreateBox("f1", 0.01, scene);
|
||||
f.position = new BABYLON.Vector3(5, 0.0, 15);
|
||||
createParticle(f,scene);
|
||||
var f2 = BABYLON.Mesh.CreateBox("f2", 0.01, scene);
|
||||
f2.position = new BABYLON.Vector3(-10, 0.0, -5);
|
||||
createParticle(f2,scene);
|
||||
|
||||
var boat1 = loader.addMeshTask("boat1", "", "assets/", "Cannoe.obj");
|
||||
boat1.onSuccess = function(t){
|
||||
|
@ -126,7 +132,94 @@ function createSkybox(scene) {
|
|||
skybox.material = sMaterial;
|
||||
}
|
||||
|
||||
function createParticle(object,scene){
|
||||
//Smoke
|
||||
var smokeSystem = new BABYLON.ParticleSystem("particles", 2000, scene);
|
||||
smokeSystem.particleTexture = new BABYLON.Texture("images/flare.png", scene);
|
||||
smokeSystem.emitter = object; // the starting object, the emitter
|
||||
smokeSystem.minEmitBox = new BABYLON.Vector3(-1, 1, -1); // Starting all from
|
||||
smokeSystem.maxEmitBox = new BABYLON.Vector3(1, 1, 1); // To...
|
||||
|
||||
smokeSystem.color1 = new BABYLON.Color4(0.1, 0.1, 0.1, 1.0);
|
||||
smokeSystem.color2 = new BABYLON.Color4(0.1, 0.1, 0.1, 1.0);
|
||||
smokeSystem.colorDead = new BABYLON.Color4(0, 0, 0, 0.0);
|
||||
|
||||
smokeSystem.minSize = 0.5;
|
||||
smokeSystem.maxSize = 2;
|
||||
|
||||
smokeSystem.minLifeTime = 0.3;
|
||||
smokeSystem.maxLifeTime = 1.5;
|
||||
|
||||
smokeSystem.emitRate = 500;
|
||||
|
||||
// Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
|
||||
smokeSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
|
||||
|
||||
smokeSystem.gravity = new BABYLON.Vector3(0, 0, 0);
|
||||
|
||||
smokeSystem.direction1 = new BABYLON.Vector3(0, 8, 0);
|
||||
smokeSystem.direction2 = new BABYLON.Vector3(0, 8, 0);
|
||||
|
||||
smokeSystem.minAngularSpeed = 0;
|
||||
smokeSystem.maxAngularSpeed = Math.PI;
|
||||
|
||||
smokeSystem.minEmitPower = 1;
|
||||
smokeSystem.maxEmitPower = 2;
|
||||
smokeSystem.updateSpeed = 0.005;
|
||||
|
||||
smokeSystem.start();
|
||||
|
||||
|
||||
|
||||
// Create a particle system
|
||||
var fireSystem = new BABYLON.ParticleSystem("particles", 2000, scene);
|
||||
|
||||
//Texture of each particle
|
||||
fireSystem.particleTexture = new BABYLON.Texture("images/flare.png", scene);
|
||||
|
||||
// Where the particles come from
|
||||
fireSystem.emitter = object; // the starting object, the emitter
|
||||
fireSystem.minEmitBox = new BABYLON.Vector3(-0.5, 1, -0.5); // Starting all from
|
||||
fireSystem.maxEmitBox = new BABYLON.Vector3(0.5, 1, 0.5); // To...
|
||||
|
||||
// Colors of all particles
|
||||
fireSystem.color1 = new BABYLON.Color4(1, 0.5, 0, 1.0);
|
||||
fireSystem.color2 = new BABYLON.Color4(1, 0.5, 0, 1.0);
|
||||
fireSystem.colorDead = new BABYLON.Color4(0, 0, 0, 0.0);
|
||||
|
||||
// Size of each particle (random between...
|
||||
fireSystem.minSize = 0.5;
|
||||
fireSystem.maxSize = 1;
|
||||
|
||||
// Life time of each particle (random between...
|
||||
fireSystem.minLifeTime = 0.2;
|
||||
fireSystem.maxLifeTime = 0.4;
|
||||
|
||||
// Emission rate
|
||||
fireSystem.emitRate = 500;
|
||||
|
||||
// Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
|
||||
fireSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
|
||||
|
||||
// Set the gravity of all particles
|
||||
fireSystem.gravity = new BABYLON.Vector3(0, 0, 0);
|
||||
|
||||
// Direction of each particle after it has been emitted
|
||||
fireSystem.direction1 = new BABYLON.Vector3(0, 8, 0);
|
||||
fireSystem.direction2 = new BABYLON.Vector3(0, 8, 0);
|
||||
|
||||
// Angular speed, in radians
|
||||
fireSystem.minAngularSpeed = 0;
|
||||
fireSystem.maxAngularSpeed = Math.PI;
|
||||
|
||||
// Speed
|
||||
fireSystem.minEmitPower = 1;
|
||||
fireSystem.maxEmitPower = 3;
|
||||
fireSystem.updateSpeed = 0.005;
|
||||
|
||||
// Start the particle system
|
||||
fireSystem.start();
|
||||
}
|
||||
|
||||
function createDemoScene(scene) {
|
||||
|
||||
|
|
Reference in a new issue