Esempio: un cubo che ruota
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; var viewport: Viewport3D; var scena: Scene3D; var camera: Camera3D; var materiale: ColorMaterial; var renderer: BasicRenderEngine; var solido: Cube; // Inizializziamo la Viewport viewport = new Viewport3D(550, 400, false, true); addChild(viewport); scena = new Scene3D(); camera = new Camera3D(); renderer = new BasicRenderEngine(); materiale = new ColorMaterial(0x333333); solido = new Cube(new MaterialsList({all:materiale}), 300, 200, 150); scena.addChild(solido); // Aggiungiamo la rotazione addEventListener(Event.ENTER_FRAME, onEnterFrame); function onEnterFrame(e:Event):void { solido.rotationY += 2; solido.rotationX += 2; renderer.renderScene(scena, camera, viewport); }