Home Menu

FogFilter

FogFilter applies varying levels of visibility based on the object's location within the scene.

Example

FogFilter

Instructions

  1. Import
    import org.papervision3d.core.render.filter.FogFilter;
  2. Initialize
    renderer.filter = new FogFilter(material, segments, minDepth, maxDepth, useViewportLayer);
    Parameter Default Description
    material NONE color
    segments 8 levels of visibility
    minDepth 200 minimum depth
    maxDepth 4000 maximum depth
    useViewportLayer null viewport layer used

Code

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

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.core.render.filter.FogFilter;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.materials.special.FogMaterial;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.Viewport3D;

    public class Papervision3DFogFilter extends Sprite
    {
        private var scene    :Scene3D;
        private var camera   :Camera3D;
        private var viewport :Viewport3D;
        private var renderer :BasicRenderEngine;
        private var material :ColorMaterial;
        private var object   :DisplayObject3D;
        private var object2  :Plane;

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

            camera = new Camera3D();

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

            renderer        = new BasicRenderEngine();
            renderer.filter = new FogFilter(new FogMaterial(0xffffff), 8, 200, 2000);

            material             = new ColorMaterial(0x000000);
            material.doubleSided = true;

            object = new DisplayObject3D();
            scene.addChild(object);

            object2   = new Plane(material);
            object2.x = -500;
            object.addChild(object2);

            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

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

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

Download

Papervision3D Official Documentation

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms