2008/07/01 | [papervision3d2] 全景图
类别(做生活) | 评论(2) | 阅读(57) | 发表于 13:49


代码如下:
package ex{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.materials.MovieAssetMaterial;
	import org.papervision3d.objects.primitives.Cube;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.cameras.FreeCamera3D;
	import org.papervision3d.view.Viewport3D;
	import org.papervision3d.materials.utils.MaterialsList;
	import flash.events.MouseEvent;
	public class Ex3 extends MovieClip {
		private var viewport:Viewport3D;
		private var scene:Scene3D;
		private var camera:FreeCamera3D;
		private var renderer:BasicRenderEngine;
		private var cube:Cube;
		public function Ex3() {
			stage.scaleMode=StageScaleMode.NO_SCALE;				
			viewport = new Viewport3D(400,400);
			addChild(viewport);
			scene = new Scene3D();
			camera = new FreeCamera3D();
			renderer = new BasicRenderEngine();
			camera.z=0	
			camera.focus = 100;
			var ms:MaterialsList = new MaterialsList();
			ms.addMaterial(new MovieAssetMaterial("Top",true),"top");
			ms.addMaterial(new MovieAssetMaterial("Bottom",true),"bottom");
			ms.addMaterial(new MovieAssetMaterial("Left",true),"left");
			ms.addMaterial(new MovieAssetMaterial("Right",true),"right");
			ms.addMaterial(new MovieAssetMaterial("Front",true),"front");
			ms.addMaterial(new MovieAssetMaterial("Back",true),"back");	
			cube = new Cube( ms, 5000, 5000, 5000,16,16,16,Cube.ALL,Cube.NONE);
			scene.addChild( cube, "Cube" );
			addEventListener( Event.ENTER_FRAME, enterFrameHandle );
			addEventListener( MouseEvent.CLICK,clickHandle );
		}
		private function enterFrameHandle(e:Event):void {
			camera.rotationY -= Math.max(-10,Math.min((camera.rotationY-viewport.containerSprite.mouseX)/10,10));
			renderer.renderScene(scene,camera,viewport);
		}
		private function clickHandle(e:Event):void {
			camera.focus=camera.focus-viewport.containerSprite.mouseY;
			if (camera.focus<50) camera.focus=50;
			if (camera.focus>1000) camera.focus=1000;
		}		
	}
}
12

评论Comments

日志分类
首页[67]
说故事[8]
看世界[15]
冶情操[9]
贴图片[15]
做生活[20]