Because the project needs to use Flash to develop 3D animation, it reminds me of the several popular Flash 3D libraries that I never knew where to find PV3D and Away3D, it is said that PV3D has high performance but is not flexible. Away3D is flexible but has low performance. Performance is indeed a very important factor to consider, the performance of the two is poor, there is no ready-to-use answer on the Internet, so you can do it yourself. It took some time to run the successful PV3D and Away3D examples and then start the test:
Test content: displays the rotated sphere. The sphere surface is divided into 20000 triangles and the radius is set to 200. Do not use light.
Flash size: 800*600, fps: 30, LOW quality.
PV3D measured value: 15.6 fps
Away3D measured value: 4.23 fps
Although the performance of both can only be described as unsightly, The 15fps of PV3D is also tolerable considering that it is not used to develop 3D games with flash.
Away3D source code
package {import away3d.cameras.*;import away3d.containers.*;import away3d.core.utils.*;import away3d.lights.*;import away3d.materials.*;import away3d.primitives.*;import flash.display.*;import flash.events.*;import flash.geom.*;[SWF(backgroundColor="#000000", frameRate="30", quality="LOW", width="800", height="600")]public class GE extends Sprite{//texture for globe[Embed(source="test.png")] public static var EarthImage:Class;private var scene:Scene3D;private var camera:Camera3D;private var view:View3D;private var t:Date;private var total:int;private var material:PhongBitmapMaterial;//scene objectsprivate var sphere:Sphere;private var spherecontainer:ObjectContainer3D;public function GE() {init();}private function init():void{initEngine();initMaterials();initObjects();initListeners();total=0;t=new Date();}private function initEngine():void{scene = new Scene3D();camera = new Camera3D();camera.z = -50;view = new View3D();view.scene= scene;view.camera = camera;addChild(view);}private function initMaterials():void{material = new PhongBitmapMaterial(Cast.bitmap(EarthImage));material.specular = 0x1A1A1A;material.shininess = 10;}private function initObjects():void{sphere = new Sphere();sphere.material = material;sphere.radius = 200;sphere.segmentsW = 100;sphere.segmentsH = 100;spherecontainer = new ObjectContainer3D(sphere);scene.addChild(spherecontainer);}private function initListeners():void{addEventListener(Event.ENTER_FRAME, onEnterFrame);addEventListener(MouseEvent.CLICK,onClick);onResize();}private function onClick(e:Event):void{var t2:Date=new Date();var inv:int=t2.getTime()-t.getTime();trace(total);trace(inv/total);}private function onEnterFrame(e:Event):void{total+=1;sphere.rotationY += 10;view.render();} }
PV3D source code
package {import flash.display.Sprite;import flash.events.*;import org.papervision3d.cameras.Camera3D;import org.papervision3d.materials.*;import org.papervision3d.materials.utils.MaterialsList;import org.papervision3d.objects.primitives.Cube;import org.papervision3d.objects.primitives.Sphere;import org.papervision3d.render.BasicRenderEngine;import org.papervision3d.scenes.Scene3D;import org.papervision3d.view.Viewport3D;[SWF ( width = '800', height = '600', backgroundColor = '#000000', frameRate = '30' ) ]public class test extends Sprite {private var viewport:Viewport3D;private var scene:Scene3D;private var camera:Camera3D;private var renderer:BasicRenderEngine;private var cube:Cube;private var ball:Sphere;private var total:int;private var t:Date;public function test(){initPapervision3D();createCube();beginRender();total=0;t=new Date();}private function initPapervision3D():void{viewport = new Viewport3D();addChild(viewport);scene = new Scene3D();camera = new Camera3D();renderer = new BasicRenderEngine();}private function createCube():void{var mp:BitmapFileMaterial = new BitmapFileMaterial("earth512.png");ball = new Sphere(mp, 500, 100, 100); scene.addChild(ball);}private function beginRender():void{addEventListener(Event.ENTER_FRAME, render);addEventListener(MouseEvent.CLICK,onClick);}private function onClick(e:MouseEvent):void{var t2:Date=new Date();var inv:int=t2.getTime()-t.getTime();trace(total);trace(inv/total);}private function render(e:Event):void{total+=1;ball.yaw(2);renderer.renderScene(scene, camera, viewport);}}}
PS: PV3D forgot to set the quality. flash is set to HIGH by default, but the performance gap is so obvious that changing to LOW will only increase the gap.