Forked from: arfyasu's [PV3D]create cube and camera orbit diff:6 forked from: [PV3D]create cube and camera orbit takishiki forked:0favorite:0lines:32license : All rights reserved modified : 2011-07-29 17:26:35 Embed Tweet // forked from arfyasu's [PV3D]create cube and camera orbit package { import flash.events.MouseEvent; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.primitives.Cube; import org.papervision3d.view.BasicView; [SWF(backgroundColor = "#FFFFFF", width="400", height="300")] public class Main extends BasicView { public function Main() { var materialsList:MaterialsList = new MaterialsList( { front : new ColorMaterial(Math.random() * 0xffffff), back : new ColorMaterial(Math.random() * 0xffffff), left : new ColorMaterial(Math.random() * 0xffffff), right : new ColorMaterial(Math.random() * 0xffffff), top : new ColorMaterial(Math.random() * 0xffffff), bottom : new ColorMaterial(Math.random() * 0xffffff) }); //キューブ生成 var cube:Cube = new Cube(materialsList); scene.addChild(cube); stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel); stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); //レンダリングスタート startRendering(); } private function onMouseMove(e:MouseEvent):void { var pitch:Number = mouseY * 0.5; //if (pitch < 0) //pitch = 0.1; camera.orbit(-pitch, mouseX * 0.8); } public function onMouseWheel(e:MouseEvent):void { camera.zoom -= e.delta; } } } Code Fullscreen Preview Fullscreen MouseEvent.MOUSE_WHEEL delta MouseEvent.MOUSE_MOVE MouseEvent Math.random Number