Menu Home

ParticleMaterial

osbo.com | Flash | Papervision3D | ParticleMaterial

ParticleMaterial is a solid-color circle, or square, used as a texture.

Example

ParticleMaterial

Instructions

  1. Import
    import org.papervision3d.materials.special.ParticleMaterial;
  2. Declare
    private var material :ParticleMaterial;
  3. Initialize
    material = new ParticleMaterial(color, alpha, shape);
    Parameter Default Description
    color NONE color
    alpha NONE alpha
    shape 0 0 | 1
    0 - square
    1 - circle

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 Papervision3DParticleMaterial 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 Papervision3DParticleMaterial()
        {
            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