PV3D:在Flex4中创建3D球体

阅读更多

xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
creationComplete="showIt();"
>




import flash.display.Sprite;
import flash.events.Event;

import org.papervision3d.cameras.Camera3D;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;


private var scene:Scene3D;
private var viewport:Viewport3D;
private var camera:Camera3D;
private var renderEngine:BasicRenderEngine;
private var sphere:Sphere;

private function showIt():void{
//this.stage.frameRate = 40;
scene = new Scene3D();
camera = new Camera3D();
sphere = new Sphere(null, 400,30,30);
scene.addChild(sphere);
viewport = new Viewport3D();
bc.rawChildren.addChild(viewport);
viewport.x=30;
viewport.y=10;
viewport.z=-60;
renderEngine = new BasicRenderEngine();
renderEngine.renderScene(scene,camera,viewport);
addEventListener(Event.ENTER_FRAME, render);

this.callLater(setRate);
}
private function render(e:Event):void
{
sphere.localRotationY +=1;
sphere.localRotationX +=1;
sphere.localRotationZ +=1;
renderEngine.renderScene(scene, camera, viewport);
}
private function setRate():void{
if (this.parentApplication!=null)
{
this.parentApplication.frameRate = 40;
}
}
]]>


你可能感兴趣的:(pv3d,flex)