Papervision 3D Base Template
Posted: May 27th, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »Sets up the ground, origin point, and basic camera movement. Meant to be used as a document class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | package { import flash.display.*; import flash.events.*; import org.papervision3d.view.BasicView; import org.papervision3d.objects.primitives.*; import org.papervision3d.materials.MovieMaterial; import org.papervision3d.events.InteractiveScene3DEvent; import gs.TweenLite; import gs.easing.*; public class PopupMain extends MovieClip { private var _w:BasicView; // world, sets up BasicView private var _origin:Plane; // origin private var _ground:Plane; // ground private var _destX:Number; private var _destY:Number; public function PopupMain():void { initMaterials(); initPapervision(); } private function initPapervision():void { _w = new BasicView(stage.stageWidth, stage.stageHeight, false, true); _origin = new Plane(null, 30, 30); _ground = new Plane(null, 1200, 1200, 6, 6); _ground.rotationX = 90; // _ground.rotationY = 45; addChild(_w); _w.scene.addChild(_origin); _w.scene.addChild(_ground); addEventListener(Event.ENTER_FRAME, onRender); } private function initMaterials():void { } private function onRender(e:Event):void { _destX = (mouseX - stage.stageWidth / 2) * 2; _destY = (stage.stageHeight - mouseY) * 2; if (mouseY < 100) { _destX = 0; _destY = 500; } _w.camera.x += (_destX - _w.camera.x) / 4; _w.camera.y += (_destY - _w.camera.y) / 4; _w.singleRender(); } } } |
Leave a Reply