zoukankan      html  css  js  c++  java
  • Away3D带你360°漫游全景影像

    1代码展示

    package
    {
    	import away3d.containers.View3D;
    	import away3d.controllers.HoverController;
    	import away3d.entities.Mesh;
    	import away3d.materials.TextureMaterial;
    	import away3d.primitives.SphereGeometry;
    	import away3d.textures.BitmapTexture;
    	
    	import flash.display.Loader;
    	import flash.display.Sprite;
    	import flash.events.Event;
    	import flash.events.KeyboardEvent;
    	import flash.events.MouseEvent;
    
    	[SWF(width='1024',height='512',frameRate='60')]
    	public class Study05 extends Sprite
    	{
    		[Embed(source='/../embeds/pano_sphere.jpg')]
    		private var _pano:Class;
    		
    		private var _startX:Number;
    		private var _startY:Number;
    		private var _mouseX:Number;
    		private var _mouseY:Number;
    		private var _view:View3D;
    		private var _hover:HoverController;
    		private var _mesh:Mesh;
    		private var _sphere:SphereGeometry;
    		private var _material:TextureMaterial;
    		private var _bitmap:BitmapTexture;
    		private var _delta:int;
    		
    		public function Study05()
    		{
    			_view = new View3D();
    			addChild(_view);
    			_view.camera.lens.far = 2000; // 设置照相机的渲染上限(不能低于球半径)
    			_bitmap = new BitmapTexture(new _pano().bitmapData);
    			_sphere = new SphereGeometry(1000,32,32);
    			_material = new TextureMaterial(_bitmap);
    			_material.bothSides = true;
    			_mesh = new Mesh(_sphere,_material);
    			_hover = new HoverController(_view.camera,null,90,0,300);
    			_view.scene.addChild(_mesh);
    			stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownFunction);
    			stage.addEventListener(MouseEvent.MOUSE_UP,onUpHandler);
    			stage.addEventListener(MouseEvent.MOUSE_WHEEL,onWheelHandler);
    			addEventListener(Event.ENTER_FRAME,onLoopHandler);
    		}
    		
    		
    		protected function onWheelHandler(event:MouseEvent):void
    		{
    			_delta+=event.delta;
    			_hover.distance=_delta;
    			//trace(del);
    		}
    		
    		protected function onUpHandler(event:MouseEvent):void
    		{
    			stage.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
    		}		
    		
    		private function mouseDownFunction(event:MouseEvent):void
    		{
    			
    			_startX = _hover.panAngle;
    			_startY = _hover.tiltAngle;
    			_mouseX = mouseX;
    			_mouseY = mouseY;
    			stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
    			//stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
    		}
    		
    		private function mouseMoveFunction(event:MouseEvent):void
    		{
    			_view.camera.x=_delta;
    			_hover.panAngle = (mouseX - _mouseX) * .3 + _startX;
    			_hover.tiltAngle = (mouseY - _mouseY) * .3 + _startY;
    		}
    		
    		protected function onLoopHandler(event:Event):void
    		{
    			_view.render();
    		}
    	}
    }

    2效果预览

     

  • 相关阅读:
    如何快速取得股票交易历史数据
    ArcSDE性能优化系列之ArcSDE参数篇
    2020年8月29日
    2020年8月31日
    9.2
    2020年8月25日
    2020年8月30日
    2020年8月27日
    2020年8月26日
    2020年8月28日
  • 原文地址:https://www.cnblogs.com/james1207/p/3315241.html
Copyright © 2011-2022 走看看