http://www.sandy1219.com/3d/test3/PV3D_Quaternion.html
<textarea cols="79" rows="18" name="code" class="c-sharp">package { import flash.events.Event; import org.papervision3d.core.math.Quaternion; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.materials.BitmapFileMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.view.BasicView; /** * ReflectionView : 添加反射 */ public class PV3D_Quaternion extends BasicView { private var flag:Boolean; private var currentQuat:Quaternion = new Quaternion(); private var targetQuat:Quaternion = new Quaternion(); private var slerp:Number = 0; private var planeGroup:DisplayObject3D = new DisplayObject3D(); private var _bitMat:BitmapFileMaterial=new BitmapFileMaterial("dae/girl.jpg"); public function PV3D_Quaternion():void { super(800,800,true,true); init3D(); // surfaceHeight = -120; //this.addEventListener(Event.ENTER_FRAME,enterFrame); startRendering(); } private function init3D():void { addCellGroup( 3 , -250 , 100 ); addCellGroup( 6 , -150 , 200 ); addCellGroup( 9 , 0 , 300 ); addCellGroup( 6 , 150 , 200 ); addCellGroup( 3 , 250 , 100 ); //addCellGroup(3,-150); camera.z = 500; scene.addChild(planeGroup); } private function addCellGroup(num:Number , y:Number,r:Number):void { for(var i:int = 0; i < num; i++) { _bitMat.interactive=true; _bitMat.doubleSided=true; var plane:DisplayObject3D =new Plane(_bitMat,60,60,4,4); plane.y = y; // viewportReflection.filters = [new BlurFilter(3,3,3)]; viewport.interactive=true; //以一定角度旋转每个平面,得到类似米字型 plane.rotationY = 360 / num * i; //每个平面像各自前方平移上面定义的半径距离 plane.moveForward(r); plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER , overHander); plane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT , outHander); plane.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS , pressHander); planeGroup.addChild(plane); } } private function overHander(e:InteractiveScene3DEvent):void { viewport.buttonMode = true; } private function outHander(e:InteractiveScene3DEvent):void { viewport.buttonMode = false; } private function pressHander(e:InteractiveScene3DEvent):void { var plane:DisplayObject3D = e.currentTarget as DisplayObject3D; //degtorad var radians:Number = (planeGroup.rotationY -plane.rotationY) * Quaternion.DEGTORAD; slerp = 0; currentQuat = Quaternion.createFromMatrix(planeGroup.transform); targetQuat = Quaternion.createFromAxisAngle(0, 1, 0, radians); } override protected function onRenderTick(event:Event=null):void { slerp += (1 - slerp) * .05; var quat:Quaternion = Quaternion.slerp(currentQuat, targetQuat, slerp); planeGroup.transform = quat.matrix; /* camera.x = stage.mouseX - stage.stageWidth/2; camera.y = stage.mouseY - stage.stageHeight/2; */ super.onRenderTick(event) } } } </textarea>