package { import flash.display.*; import flash.events.*; import flash.utils.*; import org.papervision3d.cameras.*; import org.papervision3d.materials.*; import org.papervision3d.materials.special.*; import org.papervision3d.materials.utils.*; import org.papervision3d.objects.*; import org.papervision3d.objects.primitives.*; import org.papervision3d.render.*; import org.papervision3d.view.*; [SWF(width="720", height="480", backgroundColor = "0x000000", frameRate = "60")] public class Main extends BasicView { private var plane :DisplayObject3D; private var cube :DisplayObject3D; [Embed(source = "fx.png")] private var BitmapClass:Class; public function Main() { super(0, 0, true, false, CameraType.TARGET); cube = new Cube(new MaterialsList( { all:new BitmapMaterial(new BitmapClass().bitmapData, true) } )); cube.x = 400; var planeMaterial:CompositeMaterial = new CompositeMaterial(); planeMaterial.addMaterial(new ColorMaterial(0xFFFFFF, .5)); planeMaterial.addMaterial(new WireframeMaterial(0xFFFFFF)); plane = new Plane(planeMaterial, 1500, 1500); plane.material.doubleSided = true; plane.material.tiled = true; plane.pitch(90); scene.addChild(plane); scene.addChild(cube); renderer = new QuadrantRenderEngine(QuadrantRenderEngine.ALL_FILTERS); startRendering() stage.addEventListener(MouseEvent.CLICK, clickHandler); } private function clickHandler(e:MouseEvent):void { if(renderer is QuadrantRenderEngine) renderer = new BasicRenderEngine(); else renderer = new QuadrantRenderEngine(QuadrantRenderEngine.ALL_FILTERS); } protected override function onRenderTick(e:Event = null):void { cube.y = Math.sin(getTimer() / 400) * 400; cube.x = Math.cos(getTimer() / 400) * 100; cube.roll(1); // rotate by mouse interactive camera.x += (Math.sin(mouseX / stage.stageWidth * 3 * Math.PI) * 1200 - camera.x) * .1; camera.z += (Math.cos(mouseX / stage.stageWidth * 3 * Math.PI) * 1200 - camera.z) * .1; camera.y += (mouseY / stage.stageHeight * 2000 - 500 - camera.y) * .05; super.onRenderTick(e) } } }