Menu
Samaritan's Purse

MOVIEMATERIAL

MovieMaterial is a movie clip used as a texture.

EXAMPLE

MovieMaterial

INSTRUCTIONS

  1. Import import org.papervision3d.materials.MovieMaterial;
  2. Declare private var material :MovieMaterial;
  3. Initialize material = new MovieMaterial(movieAsset, transparent, animated, precise, rect);
    PARAMETER DEFAULT DESCRIPTION
    movieAsset null movie clip
    transparent false no fill color in empty areas
    animated false update each render loop
    precise false fix distortion
    rect null rectangle

CODE

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

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.events.InteractiveScene3DEvent;
    import org.papervision3d.materials.MovieMaterial;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.Viewport3D;

    public class Papervision3DMovieMaterial extends Sprite
    {
        private var scene    :Scene3D;
        private var viewport :Viewport3D;
        private var camera :Camera3D;
        private var renderer :BasicRenderEngine;
        private var material :MovieMaterial;
        private var object :Plane;

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

            camera = new Camera3D();

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

            renderer = new BasicRenderEngine();

            var movie :MovieClip = new MovieClip();
            movie.graphics.beginFill(0x000000);
            movie.graphics.drawCircle(0, 0, 250);
            movie.graphics.endFill();

            material             = new MovieMaterial(movie, true, false, true);
            material.doubleSided = true;
            material.interactive = true;

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

            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);

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

        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
        {
            var movie :MovieClip = new MovieClip();
            movie.graphics.beginFill(Math.random() * 0xFFFFFF);
            movie.graphics.drawCircle(0, 0, 250);
            movie.graphics.endFill();

            material.texture = movie;
        }
    }
}

Download

Papervision3D Official Documentation