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

BitmapViewportMaterial

BitmapViewportMaterial is a bitmap viewport used as a texture.

Example

BitmapViewportMaterial

Instructions

  1. Import
    import org.papervision3d.materials.BitmapViewportMaterial;
  2. Declare
    private var material :BitmapViewportMaterial;
  3. Initialize
    material = new BitmapViewportMaterial(bitmapViewport, precise);
    ParameterDefaultDescription
    bitmapViewportNONEbitmap viewport
    precisefalsefix distortion

Code

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

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.materials.BitmapViewportMaterial;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.primitives.Cone;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.BitmapViewport3D;
    import org.papervision3d.view.Viewport3D;

    public class Papervision3DBitmapViewportMaterial extends Sprite
    {
        private var scene     :Scene3D;
        private var scene2    :Scene3D;
        private var camera    :Camera3D;
        private var viewport  :BitmapViewport3D;
        private var viewport2 :Viewport3D;
        private var renderer  :BasicRenderEngine;
        private var material  :ColorMaterial;
        private var material2 :BitmapViewportMaterial;
        private var object    :Cone;
        private var object2   :Plane;

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

            scene2 = new Scene3D();

            camera = new Camera3D();

            viewport = new BitmapViewport3D();

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

            renderer = new BasicRenderEngine();

            material = new ColorMaterial(0xff0000);

            material2             = new BitmapViewportMaterial(viewport, true);
            material2.doubleSided = true;

            object = new Cone(material, 400, 600);
            scene.addChild(object);

            object2 = new Plane(material2);
            scene2.addChild(object2);

            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

        private function handleEnterFrame(e:Event):void
        {
            object.pitch(1);
            renderer.renderScene(scene, camera, viewport);

            object2.yaw(1);
            renderer.renderScene(scene2, camera, viewport2);
        }
    }
}

Download

HomeMenu