Menu Home

ParticleField

osbo.com | Flash | Papervision3D | 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);
    Parameter Default Description
    mat NONE material properties
    quantity 200 number of particles
    particleSize 4 particle size
    fieldWidth 2000 field width
    fieldHeight 2000 field height
    fieldDepth 2000 field 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

Papervision3D Official Documentation