博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Away3D带你360°漫游全景影像
阅读量:5994 次
发布时间:2019-06-20

本文共 2434 字,大约阅读时间需要 8 分钟。

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效果预览

 

你可能感兴趣的文章
[android] AndroidManifest.xml - 【 manifest -> permission】
查看>>
20150728月度会议
查看>>
explain mysql性能优化
查看>>
NoSql---MongoDB基本操作
查看>>
【移动开发】WIFI热点通信(二)
查看>>
C#多线程编程实例 螺纹与窗口交互
查看>>
ByteBuffer用法小结
查看>>
使用linux mysql客户端建立表时遇到格式解析的问题
查看>>
find the mincost route(最小环,最短路,floyd)
查看>>
TCP 的那些事儿(上)
查看>>
Discuz!NT3.6与网站整合(操作用户信息)解决方案
查看>>
【今日推荐】10大流行的 Metro UI 风格的 Bootstrap 主题和模板
查看>>
Swift - 实现拨打电话
查看>>
在线代码编辑、保存与运行网址推荐
查看>>
博客园添加访问人数统计
查看>>
Yii2 RBAC 用到的表
查看>>
在使用DBMS_LOB.WRITEAPPEND()追加Clob内容的时候,报数字或值异常
查看>>
hibernate 在做更新和删除的时候一定要把事务开启
查看>>
将已有jar添加至本地maven仓库
查看>>
获取用户的真实ip
查看>>