Beispiel #1
0
        /// <summary>
        /// </summary>
        /// <param name="name">
        /// </param>
        /// <param name="newEmitter">
        /// </param>
        /// <returns>
        /// </returns>
        public virtual ParticleSystem clone(string name, object newEmitter)
        {
            var result = new ParticleSystem(name, this._capacity, this._scene);

            Tools.DeepCopy(this, result, new Array <string>("particles"), new Array <string>("_vertexDeclaration", "_vertexStrideSize"));
            if (newEmitter == null)
            {
                newEmitter = this.emitter;
            }

            result.emitter = newEmitter;
            if (this.particleTexture != null)
            {
                result.particleTexture = new Texture(this.particleTexture.url, this._scene);
            }

            result.start();
            return(result);
        }
Beispiel #2
0
        private void Scene17()
        {
            this.scene = new BABYLON.Scene(engine);
            var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);

            camera.setPosition(new BABYLON.Vector3(-5, 5, 0));
            camera.lowerBetaLimit   = 0.1;
            camera.upperBetaLimit   = (Math.PI / 2) * 0.99;
            camera.lowerRadiusLimit = 5;

            // Mirror
            var mirror = BABYLON.Mesh.CreateBox("Mirror", 1.0, scene);

            mirror.scaling = new BABYLON.Vector3(100.0, 0.01, 100.0);
            var material = new BABYLON.StandardMaterial("mirror", scene);

            material.diffuseColor  = new BABYLON.Color3(0.4, 0.4, 0.4);
            material.specularColor = new BABYLON.Color3(0, 0, 0);
            var reflectionTexture0 = new BABYLON.MirrorTexture("mirror", new BABYLON.Size {
                width = 512, height = 512
            }, scene, true);

            reflectionTexture0.mirrorPlane = new BABYLON.Plane(0, -1.0, 0, 0.0);
            reflectionTexture0.level       = 0.2;
            material.reflectionTexture     = reflectionTexture0;
            mirror.material = material;
            mirror.position = new BABYLON.Vector3(0, 0.0, 0);

            // Emitters
            var emitter0 = BABYLON.Mesh.CreateBox("emitter0", 0.1, scene);

            emitter0.isVisible = false;

            var emitter1 = BABYLON.Mesh.CreateBox("emitter1", 0.1, scene);

            emitter1.isVisible = false;

            //mirror.material.reflectionTexture.renderList.push(emitter0);
            //mirror.material.reflectionTexture.renderList.push(emitter1);

            // Particles
            var particleSystem = new BABYLON.ParticleSystem("particles", 4000, scene);

            particleSystem.particleTexture = new BABYLON.Texture("Flare.png", scene);
            particleSystem.minAngularSpeed = -0.5;
            particleSystem.maxAngularSpeed = 0.5;
            particleSystem.minSize         = 0.1;
            particleSystem.maxSize         = 0.5;
            particleSystem.minLifeTime     = 0.5;
            particleSystem.maxLifeTime     = 2.0;
            particleSystem.minEmitPower    = 0.5;
            particleSystem.maxEmitPower    = 4.0;
            particleSystem.emitter         = emitter0;
            particleSystem.emitRate        = 400;
            particleSystem.blendMode       = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
            particleSystem.minEmitBox      = new BABYLON.Vector3(-0.5, 0, -0.5);
            particleSystem.maxEmitBox      = new BABYLON.Vector3(0.5, 0, 0.5);
            particleSystem.direction1      = new BABYLON.Vector3(-1, 1, -1);
            particleSystem.direction2      = new BABYLON.Vector3(1, 1, 1);
            particleSystem.color1          = new BABYLON.Color4(1, 0, 0, 1);
            particleSystem.color2          = new BABYLON.Color4(0, 1, 1, 1);
            particleSystem.gravity         = new BABYLON.Vector3(0, -2.0, 0);
            particleSystem.start();

            var particleSystem2 = new BABYLON.ParticleSystem("particles", 4000, scene);

            particleSystem2.particleTexture = new BABYLON.Texture("Flare.png", scene);
            particleSystem2.minSize         = 0.1;
            particleSystem2.maxSize         = 0.3;
            particleSystem2.minEmitPower    = 1.0;
            particleSystem2.maxEmitPower    = 2.0;
            particleSystem2.minLifeTime     = 0.5;
            particleSystem2.maxLifeTime     = 1.0;
            particleSystem2.emitter         = emitter1;
            particleSystem2.emitRate        = 500;
            particleSystem2.blendMode       = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
            particleSystem2.minEmitBox      = new BABYLON.Vector3(0, 0, 0);
            particleSystem2.maxEmitBox      = new BABYLON.Vector3(0, 0, 0);
            particleSystem2.gravity         = new BABYLON.Vector3(0, -0.5, 0);
            particleSystem2.direction1      = new BABYLON.Vector3(0, 0, 0);
            particleSystem2.direction2      = new BABYLON.Vector3(0, 0, 0);
            particleSystem2.start();

            var alpha = 0.0;

            scene.registerBeforeRender(() =>
            {
                emitter1.position.x = 3.0 * Math.Cos(alpha);
                emitter1.position.y = 1.0;
                emitter1.position.z = 3.0 * Math.Sin(alpha);

                alpha += 0.05 * scene.getAnimationRatio();
            });

            this.scene.activeCamera.attachControl(this.canvas);
        }