Guts of a Papervision Application

All Papervision applications have the following elements in common. They can be thought of as the guts of Papervision.

Scene The scene is where objects are placed. It contains the 3D environment and manages all objects rendered in Papervision3D. It extends the DisplayObjectContainer3D class to arrange the display objects.

Viewport The viewport displays the rendered scene. It’s a sprite that is painted with a snapshot of all the stuff contained in the view frustum. The viewport sprite inherits all the sprite methods and can be moved, positioned, and have effects added just like any normal sprite in flash.

Camera The camera is your eye inside of the 3D scene and defines the view from which a scene will be rendered. Different camera settings will present a scene from different points of view. When rendering, the scene is drawn as if you were looking through the camera lens.

Object An object is a combination of vertices, edges, and faces which provide a meaningful form for display, such as a car, avatar, or box. Objects are created in Papervision using primitives, or embedded or imported into Papervision from a modeling application such as Blender, Swift3D, or 3DSMax.

Material The material is the texture which is applied to an object. Textures can consist of various formats such as bitmaps, swfs, or video, and interact with light sources creating bump map effects and shaders.

Renderer The renderer draws a sequence of faces onto the viewport so that they make visual sense. Typically the renderer is set into a loop using onEnterFrame or Timer methods native to the flash player.

Running a Papervision application is like simultaneously recording and projecting your 3D scene as shown in the image below. The scene is the middle man. It’s what the camera films and what the projector projects.

Papervision Films and Projects at the Same Time

Papervision Films and Projects at the Same Time

You can think of the whole process as a combination of a movie camera and projector which both films and projects your 3D scene simultaneously. The scene is what the camera is pointed at and the objects are the items that the camera films. The materials are what your objects are dressed in and determine how the light interacts with the scene elements. The reels on your projector are your renderer and as your reels turn (using onEnterFrame or Timer methods) they cast the recorded scene onto your screen which is your viewport.

The base code distributed with Chapter 1 of the book provides a great example of these six quantities in action. Click on the links below to see a demo, or download the code.


Download: (

YouTube Video:

Click more below to see the code example.

//Flash imports
import flash.display.Sprite;

import org.papervision3d.cameras.Camera3D;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;

//Define your class

public class PapervisionClassMotion extends Sprite
//Define your properties
private var viewport:Viewport3D;
private var camera:Camera3D;
private var scene:Scene3D;
private var renderer:BasicRenderEngine;

//Define your sphere variable.

private var sphere:Sphere;
private var sphereMaterial:MaterialObject3D;
private var myTheta:Number=0;
private var myX:Number=0;
private var myY:Number=0;
private var myZ:Number=0;

public function PapervisionClassMotion()
trace(“Hello World”);

//Intiate Papervision

//Create Your Objects

//Create Renderer


//Define your methods

//Initialize Papervision
private function initPV3D():void

// Create the viewport
viewport = new Viewport3D(0, 0, true, false);

// Create the camera
camera = new Camera3D();

// Create the scene
scene = new Scene3D();

// Create the renderer
renderer = new BasicRenderEngine();


//Create your objects
private function createObjects():void
// Create a material for the sphere
sphereMaterial = new WireframeMaterial(0xFFFFFF);

// Create use wireframe material, radius 100, default 0,0,0
sphere = new Sphere(sphereMaterial, 100, 10, 10);


// Add Your Sphere to the Scene


//Loop Renderer
private function createRenderer():void{
addEventListener(Event.ENTER_FRAME, myLoop);

//Single Loop
private function myLoop(evt:Event):void
//Rotate around x-axis

//Increase angle
myTheta += 2;
//plot a circular orbit sin and cos
myX = Math.cos(myTheta * Math.PI / 180) * 100-300;
myZ = Math.sin(myTheta * Math.PI / 180) * 100;
//Set X and Z of spher
sphere.x = myX;
sphere.z = myZ;

//Fattening and scrinking
myY = 1+Math.cos(myTheta * Math.PI / 180)*.7;
sphere.scaleX=sphere.scaleZ= 1+Math.sin(myTheta * Math.PI / 180)*.7;
sphere.scaleY =myY;

//Render Scene
renderer.renderScene(scene, camera, viewport);




One Response to Guts of a Papervision Application

  1. Steve Pidgeon says:


    This is entirely new to me, so I am sure I am missing something obvious.

    When I attempt to import the zip into Flex Builder 3 it says it is invalid, when i unzip it and try to import it, it says its not a valid project.

    What am i doing wrong. I am talking about

    thank you

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: