代码如下:
package ex{ import flash.display.Sprite; import flash.events.Event; import org.papervision3d.cameras.Camera3D; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.Viewport3D; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.objects.primitives.Cylinder; import flash.filters.BlurFilter; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.materials.WireframeMaterial; import flash.filters.GlowFilter; import org.papervision3d.core.effects.BitmapLayerEffect; import org.papervision3d.view.layer.BitmapEffectLayer; import flash.display.StageScaleMode; public class Ex1 extends Sprite{ private var viewport:Viewport3D; private var scene:Scene3D; private var camera:Camera3D; private var renderer:BasicRenderEngine; private var sphere1:Sphere; private var sphere2:Sphere; private var sphere3:Sphere; private var sphere4:Sphere; private var sphere5:Sphere; private var cylinder1:Cylinder; private var cylinder2:Cylinder; private var m:WireframeMaterial; private var bfx:BitmapEffectLayer; public function Ex1(){ stage.scaleMode=StageScaleMode.NO_SCALE; viewport = new Viewport3D(500,500); viewport.filters=[new GlowFilter(0xffffff,.5,2,2,2,8)]; addChild(viewport); scene = new Scene3D(); camera = new Camera3D(); camera.x=-90; camera.y=10; renderer = new BasicRenderEngine(); m=new WireframeMaterial(); sphere1=new Sphere(m,65,20,20,null); sphere1.x=-150; sphere1.y=150; scene.addChild(sphere1); sphere2=new Sphere(m,50,20,20,null); sphere2.x=-150; sphere2.y=-150; scene.addChild(sphere2); sphere3=new Sphere(m,60,20,20,null); sphere3.x=0; sphere3.y=0; scene.addChild(sphere3); sphere4=new Sphere(m,55,20,20,null); sphere4.x=150; sphere4.y=150; scene.addChild(sphere4); sphere5=new Sphere(m,45,20,20,null); sphere5.x=150; sphere5.y=-150; scene.addChild(sphere5); cylinder1=new Cylinder(m,15,400); cylinder1.rotationZ=45; scene.addChild(cylinder1); cylinder2=new Cylinder(m,15,400); cylinder2.rotationZ=-45; scene.addChild(cylinder2); bfx = new BitmapEffectLayer(viewport, 500, 500); viewport.containerSprite.addLayer(bfx); bfx.addDisplayObject3D(sphere1); bfx.addDisplayObject3D(sphere2); bfx.addDisplayObject3D(sphere3); bfx.addDisplayObject3D(sphere4); bfx.addDisplayObject3D(sphere5); bfx.addEffect(new BitmapLayerEffect(new BlurFilter(2, 2, 15))); bfx.setScroll(3, 4); bfx.setTracking(sphere1); addEventListener(Event.ENTER_FRAME, render); } private function render(e:Event):void{ sphere1.yaw(10); sphere2.yaw(15); sphere3.yaw(25); sphere4.yaw(20); sphere5.yaw(30); cylinder1.yaw(-50); cylinder2.yaw(-50); Camera3D(camera).hover(0, viewport.containerSprite.mouseX/30, viewport.containerSprite.mouseY/30); renderer.renderScene(scene,camera,viewport); } } }
回复Comments
作者:
{commentrecontent}