papervision3d light and a flatshadedcube
// forked from mash's papervision3d simple example (cube)
package {
import flash.display.*;
import flash.events.*;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.*;
import org.papervision3d.objects.*;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
public class PV3D_01 extends Sprite {
private var camera :Camera3D;
private var scene :Scene3D;
private var viewport :Viewport3D;
private var renderer :BasicRenderEngine;
private var cube :Cube;
public function PV3D_01() {
camera = new Camera3D();
camera.x = 0;
camera.y = 0;
camera.z = -1000;
scene = new Scene3D();
viewport = new Viewport3D( stage.stageWidth, stage.stageHeight );
renderer = new BasicRenderEngine();
addChild( viewport );
var light:PointLight3D = new PointLight3D(false);
light.x = 0;
light.y = 0;
light.z = -1000;
var materials :MaterialsList = new MaterialsList( { all : new FlatShadeMaterial(light, 0xD7261C ) } );
cube = new Cube( materials );
cube.x = 0;
cube.y = 0;
cube.z = 0;
scene.addChild( cube );
addEventListener( Event.ENTER_FRAME, onEnterFrame );
}
public function onEnterFrame(e:Event): void {
cube.rotationX += ( mouseX - stage.stageWidth /2 ) / 200;
cube.rotationY += ( mouseY - stage.stageHeight/2 ) / 200;
renderer.renderScene( scene, camera, viewport );
}
}
}