Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

ParticleField

ParticleField is a random distribution of particles over a specified area.

Example

ParticleField

Instructions

  1. Import
    import org.papervision3d.objects.special.ParticleField;
  2. Declare
    private var object :ParticleField;
  3. Initialize
    object = new ParticleField(mat, quantity, particleSize, fieldWidth, fieldHeight, fieldDepth);
    ParameterDefaultDescription
    matNONEmaterial properties
    quantity200number of particles
    particleSize4particle size
    fieldWidth2000field width
    fieldHeight2000field height
    fieldDepth2000field depth
  4. Add
    scene.addChild(object);

Code

package
{
    import flash.display.Sprite;
    import flash.events.Event;

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.materials.special.ParticleMaterial;
    import org.papervision3d.objects.special.ParticleField;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.Viewport3D;

    public class Papervision3DParticleField extends Sprite
    {
        private var scene    :Scene3D;
        private var camera   :Camera3D;
        private var viewport :Viewport3D;
        private var renderer :BasicRenderEngine;
        private var material :ParticleMaterial;
        private var object   :ParticleField;

        public function Papervision3DParticleField()
        {
            scene = new Scene3D();

            camera = new Camera3D();

            viewport                  = new Viewport3D();
            viewport.autoScaleToStage = true;
            addChild(viewport);

            renderer = new BasicRenderEngine();

            material             = new ParticleMaterial(0x000000, 1);
            material.doubleSided = true;

            object = new ParticleField(material);
            scene.addChild(object);

            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

        private function handleEnterFrame(e:Event):void
        {
            object.yaw(1);

            renderer.renderScene(scene, camera, viewport);
        }
    }
}

Download

HomeMenu