Menu
Samaritan's Purse

CAMERA3D

Camera3D is the point of view within the 3D environment.

EXAMPLE

Camera3D

INSTRUCTIONS

  1. Import import org.papervision3d.cameras.Camera3D;
  2. Declare private var camera :Camera3D;
  3. Initialize camera = new Camera3D(fov, near, far, useCulling, useProjection);
    PARAMETER DEFAULT DESCRIPTION
    fov 60 field of view vertical degree
    near 10 clipping plane near distance
    far 5000 clipping plane far distance
    useCulling false cull objects outside view
    useProjection false projection matrix

CODE

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

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

    public class Papervision3DCamera3D extends Sprite
    {
        private var scene     :Scene3D;
        private var camera    :Camera3D;
        private var viewport :Viewport3D;
        private var renderer :BasicRenderEngine;
        private var material :ColorMaterial;
        private var material2 :ColorMaterial;
        private var material3 :ColorMaterial;
        private var object    :Plane;
        private var object2 :Plane;
        private var object3 :Plane;
        private var angle     :int = 0;

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

            camera = new Camera3D();
            camera.z = -1000;

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

            renderer = new BasicRenderEngine();

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

            material2             = new ColorMaterial(0xff0000);
            material2.doubleSided = true;

            material3             = new ColorMaterial(0x00ff00);
            material3.doubleSided = true;

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

            object2 = new Plane(material2);
            object2.z = 1000;
            scene.addChild(object2);

            object3 = new Plane(material3);
            object3.z = -1000;
            scene.addChild(object3);

            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

        private function handleEnterFrame(e:Event):void
        {
            camera.orbit(90, angle++);

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

Download

Papervision3D Official Documentation