BabylonJS - spaces
by kolar
HTML
<script src="https://dl.dropboxusercontent.com/u/12395133/babylon.1.11.js"></script>
<div id="rootDiv">
<button id="btn">Run</button>
<canvas id="canvas"></canvas>
</div>
CSS
html, body, div, canvas {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
overflow: hidden;
}
#btn {
position:fixed;
color:#555;
font-size:11px;
font-family:courier;
width:100px;
height:30px;
}
JavaScript
var canvas = document.getElementById("canvas");
var engine = new BABYLON.Engine(canvas, false);
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("Camera", 1, 0.8, 10, new BABYLON.Vector3(0, 0, 0), scene);
camera.setPosition(new BABYLON.Vector3(0, 5, -5));
var light0 = new BABYLON.HemisphericLight("Omni", new BABYLON.Vector3(0, 0, 10), scene);
scene.activeCamera.attachControl(canvas);
engine.runRenderLoop(function () {
scene.render();
});
var imgSrc = "https://dl.dropboxusercontent.com/u/12395133/babylon/cloud_dot.png";
var particleSystem;
var source = BABYLON.Mesh.CreateBox("source", 0.1, scene);
$("#btn").click(function(){
setInterval(function(){
if(particleSystem) {
particleSystem.stop();
}
particleSystem = new BABYLON.ParticleSystem("particles", 5000, scene);
particleSystem.particleTexture = new BABYLON.Texture(imgSrc, scene);
particleSystem.emitter = source;
particleSystem.color1 = new BABYLON.Color4(1, 1, 1, 1.0);
particleSystem.color2 = new BABYLON.Color4(0.5, 0.5, 1, 1.0);
particleSystem.colorDead = new BABYLON.Color4(0, 0, 0.5, 0.0);
particleSystem.minSize = 0.6;
particleSystem.maxSize = 0.8;
particleSystem.minLifeTime = 0.8;
particleSystem.maxLifeTime = 0.8;
particleSystem.emitRate = 200;
particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD;
particleSystem.gravity = new BABYLON.Vector3(0, 0, 0);
particleSystem.direction1 = new BABYLON.Vector3(10, 0, 0);
particleSystem.direction2 = new BABYLON.Vector3(0, 0, 10);
particleSystem.minAngularSpeed = 0;
particleSystem.maxAngularSpeed = 0.1;
particleSystem.minEmitPower = 2;
particleSystem.maxEmitPower = 2;
particleSystem.minEmitBox = new BABYLON.Vector3(0, 0, 0);
particleSystem.maxEmitBox = new BABYLON.Vector3(0, 0, 0);
particleSystem.updateSpeed...