I have been trying to understand Papervision 3d for the last couple of months, but all the examples are using collada or some elaborate functionality. I just wanted to test something simple. So I made a rotating box it rotates on the y axis.
Here how it goes in Flash CS3:
- add an image into the library
- set the linkage name to test.
- make sure width = 336 / height = 335 (for this example)
- and add this script
[as]
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
var container:Sprite = new Sprite();
container.x = stage.stageWidth * 0.5;
container.y = stage.stageHeight * 0.5;
addChild(container);
var scene:Scene3D = new Scene3D(container);
var camera:Camera3D = new Camera3D(p, 10);
var bam:BitmapAssetMaterial = new BitmapAssetMaterial(“test”)
bam.oneSide = false;
bam.smooth = true;
var p:Cube = new Cube(bam, 336, 335, 335, 5, 5, 5);
scene.addChild(p);
scene.renderCamera(camera);
addEventListener(Event.ENTER_FRAME, onFrame);
function onFrame(event:Event):void
{
p.rotationX % 360 == 0 ? p.rotationX = 1 : p.rotationX += 1;
trace(p.rotationX)
//p.rotationY = stage.mouseY – (stage.stageHeight * 0.5);
scene.renderCamera(camera);
}
[/as]
thats it
If i’m only supposed to copy/paste this code (having the papervision libraries in the same directory), this code does not work, gives the following errors:
Scene 1, Layer ‘actions’, Frame 1, Line 22 1061: Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.
Scene 1, Layer ‘actions’, Frame 1, Line 18 1180: Call to a possibly undefined method Cube.
Scene 1, Layer ‘actions’, Frame 1, Line 11 1137: Incorrect number of arguments. Expected no more than 0.
Scene 1, Layer ‘actions’, Frame 1, Line 32 1061: Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.
Scene 1, Layer ‘actions’, Frame 1, Line 18 1046: Type was not found or was not a compile-time constant: Cube.
Am i missing anything here?
By the way, i use Flash CS5, should i be doing this in Flash builder?!
I did every thing in Flash Builder or Flex Builder, which ever one you have