Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var createScene = function () {
- var scene = new BABYLON.Scene(engine);
- // Setup environment
- var light0 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(0, 2, 8), scene);
- var camera = new BABYLON.ArcRotateCamera("ArcRotateCamera", 1, 0.8, 20, new BABYLON.Vector3(0, 0, 0), scene);
- camera.attachControl(canvas, true);
- // Fountain object
- var fountain = BABYLON.Mesh.CreateBox("foutain", .1, scene);
- // Ground
- var ground = BABYLON.Mesh.CreatePlane("ground", 50.0, scene);
- ground.position = new BABYLON.Vector3(0, -10, 0);
- ground.rotation = new BABYLON.Vector3(Math.PI / 2, 0, 0);
- ground.material = new BABYLON.StandardMaterial("groundMat", scene);
- ground.material.backFaceCulling = false;
- ground.material.diffuseColor = new BABYLON.Color3(0.3, 0.3, 0.3);
- // Create a particle system
- var particleSystem = new BABYLON.ParticleSystem("particles", 2000, scene);
- //Texture of each particle
- particleSystem.particleTexture = new BABYLON.Texture("textures/flare.png", scene);
- // Where the particles come from
- particleSystem.emitter = fountain; // the starting object, the emitter
- particleSystem.minEmitBox = new BABYLON.Vector3(-1, 0, 0); // Starting all from
- particleSystem.maxEmitBox = new BABYLON.Vector3(1, 0, 0); // To...
- // Colors of all particles
- particleSystem.color1 = new BABYLON.Color3(0, 255, 0);
- particleSystem.color2 = new BABYLON.Color3(255, 0, 255);
- particleSystem.colorDead = new BABYLON.Color3(0, 0, 255);
- // Size of each particle (random between...
- particleSystem.minSize = 0.1;
- particleSystem.maxSize = 0.5;
- // Life time of each particle (random between...
- particleSystem.minLifeTime = 0.3;
- particleSystem.maxLifeTime = 1.5;
- // Emission rate
- particleSystem.emitRate = 150000;
- // Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
- particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
- // Set the gravity of all particles
- particleSystem.gravity = new BABYLON.Vector3(0, -9.81, 0);
- // Direction of each particle after it has been emitted
- particleSystem.direction1 = new BABYLON.Vector3(-7, 8, 3);
- particleSystem.direction2 = new BABYLON.Vector3(7, 8, -3);
- // Angular speed, in radians
- particleSystem.minAngularSpeed = 0;
- particleSystem.maxAngularSpeed = Math.PI;
- // Speed
- particleSystem.minEmitPower = 1;
- particleSystem.maxEmitPower = 3;
- particleSystem.updateSpeed = 0.005;
- // Start the particle system
- particleSystem.start();
- // Fountain's animation
- window.setInterval(function(){
- fountain.rotation.x += 1;
- },10);
- return scene;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement