Menu
Samaritan's Purse

REFLECTIONVIEW

ReflectionView is BasicView with relfection.

EXAMPLE

ReflectionView

INSTRUCTIONS - EXTENDING REFLECTIONVIEW

  1. Import import org.papervision3d.core.effects.view.ReflectionView;
  2. Call super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
    PARAMETER DEFAULT DESCRIPTION
    viewportWidth 640 viewport width
    viewportHeight 480 viewport height
    scaleToStage true set viewport size to stage size
    interactive false listen for mouse events
    cameraType "Target" "Target" | "Free" | "Debug" | "Spring"
    "Target" - camera with target x:0 y:0 z:0
    "Free" - camera without target
    "Debug" - camera with mouse/keyboard control and display information
    "Spring" - camera with spring effect
  3. Render singleRender();

CODE - EXTENDING REFLECTIONVIEW

´╗┐package
{
    import flash.events.Event;
    import flash.filters.BlurFilter;

    import org.papervision3d.core.effects.view.ReflectionView;
    import org.papervision3d.events.InteractiveScene3DEvent;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.primitives.Plane;

    public class Papervision3DReflectionViewExtension extends ReflectionView
    {
        private var material :ColorMaterial;
        private var object :Plane;
        private var object2 :Plane;
        private var object3 :Plane;

        public function Papervision3DReflectionViewExtension()
        {
            super(640, 480, true, true, "Target");

            surfaceHeight             = -550;
            viewportReflection.filters = [new BlurFilter(4, 4, 1)];

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

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

            object2 = new Plane(material);
            object2.x = -550;
            scene.addChild(object2);

            object3 = new Plane(material);
            object3.x = 550;
            scene.addChild(object3);

            object.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, handleObjectOver);
            object.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, handleObjectOut);
            object.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, handleObjectPress);

            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

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

            singleRender();
        }

        private function handleObjectOver(e:InteractiveScene3DEvent):void
        {
            viewport.containerSprite.buttonMode = true;
        }

        private function handleObjectOut(e:InteractiveScene3DEvent):void
        {
            viewport.containerSprite.buttonMode = false;
        }

        private function handleObjectPress(e:InteractiveScene3DEvent):void
        {
            object.material             = new ColorMaterial(Math.random() * 0xFFFFFF);
            object.material.doubleSided = true;
            object.material.interactive = true;
        }
    }
}

Download

INSTRUCTIONS - EXTENDING SPRITE

  1. Import import org.papervision3d.core.effects.view.ReflectionView;
  2. Declare private var view :ReflectionView;
  3. Initialize view = new ReflectionView(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
    PARAMETER DEFAULT DESCRIPTION
    viewportWidth 640 viewport width
    viewportHeight 480 viewport height
    scaleToStage true set viewport size to stage size
    interactive false listen for mouse events
    cameraType "Target" "Target" | "Free" | "Debug" | "Spring"
    "Target" - camera with target x:0 y:0 z:0
    "Free" - camera without target
    "Debug" - camera with mouse/keyboard control and display information
    "Spring" - camera with spring effect
  4. Add addChild(view);
  5. Render view.singleRender();

CODE - EXTENDING SPRITE

´╗┐package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.BlurFilter;

    import org.papervision3d.core.effects.view.ReflectionView;
    import org.papervision3d.events.InteractiveScene3DEvent;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.primitives.Plane;

    public class Papervision3DReflectionView extends Sprite
    {
        private var view     :ReflectionView;
        private var material :ColorMaterial;
        private var object :Plane;
        private var object2 :Plane;
        private var object3 :Plane;

        public function Papervision3DReflectionView()
        {
            view = new ReflectionView(640, 480, true, true, "Target");
            addChild(view);

            view.surfaceHeight             = -550;
            view.viewportReflection.filters = [new BlurFilter(4, 4, 1)];

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

            object = new Plane(material);
            view.scene.addChild(object);

            object2 = new Plane(material);
            object2.x = -550;
            view.scene.addChild(object2);

            object3 = new Plane(material);
            object3.x = 550;
            view.scene.addChild(object3);

            object.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, handleObjectOver);
            object.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, handleObjectOut);
            object.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, handleObjectPress);

            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

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

            view.singleRender();
        }

        private function handleObjectOver(e:InteractiveScene3DEvent):void
        {
            view.viewport.containerSprite.buttonMode = true;
        }

        private function handleObjectOut(e:InteractiveScene3DEvent):void
        {
            view.viewport.containerSprite.buttonMode = false;
        }

        private function handleObjectPress(e:InteractiveScene3DEvent):void
        {
            object.material             = new ColorMaterial(Math.random() * 0xFFFFFF);
            object.material.doubleSided = true;
            object.material.interactive = true;
        }
    }
}

Download

Papervision3D Official Documentation