To get started with PaperVision3D – the coolest 3D engine for Flash – first check out the code from svn http://svn1.cvsdude.com/osflash/papervision3d.
After checking out the files you find directories for both AS2 and AS3.
Check the Getting Started FAQ from the PV3D wiki.
Now, I’m assuming the use of AS3 because PaperVision3D development focusses on AS3 and is thus more mature. But the code below can easily be ported to AS2 too.
Okay: create a project in your fav dev-environment (I would suggest FlashDevelop) and make sure your classpath contains the path to pv3d.
Add a class ‘Main’ and paste code below:
package
{
import flash.display.*;
import flash.events.*;
// Import Papervision3D
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
/**
*
*/
public class Main extends Sprite
{
/** the Sprite to render to */
public var container :Sprite;
/** the 3D scene */
public var scene :Scene3D;
/** camera */
public var camera :Camera3D;
/** some geometry */
public var cube:Cube;
/**
* constructor
*/
public function Main()
{
init3D();
}
/**
* initialize PaperVision3D
*/
private function init3D():void
{
// Create container sprite and center it in the stage
container = new Sprite();
addChild( container );
container.x = 320;
container.y = 240;
// Create scene
scene = new Scene3D( container );
// Create camera
camera = new Camera3D();
// Create a cube with a wireframe material
cube = new Cube( new WireframeMaterial() );
// add cube to scene
scene.addChild( cube );
// add onEnterFrame handler to render our scene
this.addEventListener( Event.ENTER_FRAME, loop3D );
}
/**
* render!
*/
private function loop3D(event:Event):void
{
// Move camera with the mouse
camera.x = -container.mouseX/4;
camera.y = container.mouseY/3;
// Rotate cube around its own vertical axis
cube.yaw( 0.2 );
// Render the scene
scene.renderCamera( camera );
}
}
}
Compile, run and have fun!



July 24th, 2007 at 10:27 pm
How do I rotate a plane around an axis?
I am trying to find better documentation on papervision3D. Any good sources?
July 26th, 2007 at 4:13 am
a good source: http://www.papervision3d.org/docs/as3/
To rotate around an axis I think it’s rotationX and rotationY
August 6th, 2007 at 4:40 pm
I’m having trouble compiling your program.
I am using FlashDevelop and I put the papervision3d classpath in Global Classpaths for AS3 (pv3d is located at c:\Program Files\Papervision3D_1_5\PV3D_1_5\src).
The code completion finds the papervision3d classes just fine, but the Compile Results shows several error messages like this:
“Type was not found or was not a compile-time constant: Scene3D.”
followed by multiple, related errors:
“Call to a possibly undefined method Scene3D.”
and
“Definition org.papervision3d.scenes could not be found.”
Any ideas what I’m doing wrong? I have nothing added to the compiler setup under Project Properties, if that helps. I wondered if I should have something there but I thought the compiler would use the global classpath entries.
Thanks,
JohnR
August 7th, 2007 at 2:36 am
John,
Think you need to add the classpath to build.xml too.
Under ‘<target name=”compile”>’ add a line like this:
<arg line=”-source-path=’C:/Program Files/FlashDevelop/Library’” />
Hope this helps!
Tim K
August 10th, 2007 at 9:36 pm
Thanks for the quick reply, Tim. Sorry my response wasn’t as quick. With your suggestion in mind, I’ve got Papervision working with FlashDevelop now.
It turned out I had to update my JRE (and remove old JRE references from my classpath), add the flex compiler shell, set ANT_HOME properly, add a reference to ant.bat in the pre-build directions in FlashDevelop, add a reference to the JRE in jvm.config in flex2, and take out a bunch of things in FlashDevelop3/AS3 that only needed to be put in for FD2/AS2. Good grief!
Anyway, thanks a lot and congrats on joining the Papervision3d team!
January 4th, 2008 at 10:04 pm
I’m having the same trouble compiling test program.
Definition org.papervision3d.view:Viewport3D could not be found.
Done(1)
import org.papervision3d.view.Viewport3D;
^
I don’t understand the solution, can someone help me?
Thanks,
Riccardo