Esempio: Animazione con Caurina Tweener
import flash.display.Sprite; import flash.events.Event; import org.papervision3d.view.Viewport3D; import org.papervision3d.scenes.Scene3D; import org.papervision3d.cameras.Camera3D; import org.papervision3d.materials.*; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.primitives.*; import org.papervision3d.render.BasicRenderEngine; import caurina.transitions.Tweener; var viewport: Viewport3D; var scena: Scene3D; var camera: Camera3D; var materiale: ColorMaterial; var renderer: BasicRenderEngine; viewport = new Viewport3D(550, 400, false, true); addChild(viewport); scena = new Scene3D(); camera = new Camera3D(); renderer = new BasicRenderEngine(); materiale = new ColorMaterial(0x333333); var cubo1:Cube = new Cube( new MaterialsList({all:new ColorMaterial(0x330033)}), 300, 200, 150); var cubo2:Cube = new Cube(new MaterialsList( {all:new ColorMaterial(0x333300)}), 300, 200, 150); posiziona(cubo1,0,-200,100); posiziona(cubo2,-300,-200,-200); cubo1.rotationY = 30; cubo2.rotationY = 30; scena.addChild(cubo1); scena.addChild(cubo2); Tweener.addTween(camera, { x:-2900, y:1400, z:0, time:5, transition:"easeinoutexpo", onComplete:anim} ); function anim () { if (camera.x==-2900) Tweener.addTween(camera, { x:0, y:2900, z:-100, time:5, transition:"easeinoutexpo", onComplete:anim }); if (camera.x==0) Tweener.addTween(camera, { x:-300, y:-850, z:-700, time:5, transition:"easeinoutexpo", onComplete:anim }); if (camera.x==-300) Tweener.addTween(camera, { x:-2900, y:1400, z:0, time:5, transition:"easeinoutexpo", onComplete:anim }); // trace (camera.x); } addEventListener(Event.ENTER_FRAME, onEnterFrame); function onEnterFrame(e:Event):void { camera.lookAt(cubo1); renderer.renderScene(scena, camera, viewport); } function posiziona(do3d,x,y,z) { do3d.x=x; do3d.y=y; do3d.z=z; }