package
{
import away3d.containers.View3D;
import away3d.controllers.HoverController;
import away3d.entities.Mesh;
import away3d.materials.TextureMaterial;
import away3d.primitives.SphereGeometry;
import away3d.utils.Cast; import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent; /**
* @author Frost.Yen
* @E-mail 871979853@qq.com
* @create 2015-9-23 下午3:18:40
*
*/
[SWF(width='800',height='600',frameRate="60", backgroundColor="0x000000")] public class Away3dOverall extends Sprite
{
[Embed(source = "assets/1.jpg")]
private static var BallMaterial:Class;
private var _startX:Number;
private var _startY:Number;
private var _mouseX:Number;
private var _mouseY:Number;
private var _view:View3D;
private var _cameraHoverController:HoverController;
private var _sphere:SphereGeometry;
private var _sphereMaterial:TextureMaterial;
private var _mesh:Mesh;
public function Away3dOverall()
{
if (stage) {
init();
}else {
this.addEventListener(Event.ADDED_TO_STAGE, init);
} }
private function init(e:Event = null):void {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
this.removeEventListener(Event.ADDED_TO_STAGE, init); _view = new View3D();
addChild(_view);
_view.antiAlias = 6;
//摄像机渲染范围2000
_view.camera.lens.far = 2000; _cameraHoverController = new HoverController(_view.camera, null, 90, 0, 300);
_cameraHoverController.yFactor = 1;
_sphere = new SphereGeometry(1000, 64);
//_sphere.yUp = false;
_sphereMaterial = new TextureMaterial(Cast.bitmapTexture(BallMaterial));
_sphereMaterial.bothSides = true;
_sphereMaterial.smooth = true;
_mesh = new Mesh(_sphere, _sphereMaterial);
//MeshHelper.invertFaces(_mesh); _view.camera.position = _mesh.position; _view.scene.addChild(_mesh);this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownFunction);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, onWheel);
}
private function onWheel(e:MouseEvent):void
{
if (e.delta > 0) {
if (_cameraHoverController.distance > 6) {
_cameraHoverController.distance -= 5;
}
}else if (e.delta < 0) {
if (_cameraHoverController.distance < 600) {
_cameraHoverController.distance += 5;
}
}
} private function mouseDownFunction(e:MouseEvent):void
{
_startX = _cameraHoverController.panAngle;
_startY = _cameraHoverController.tiltAngle;
_mouseX = mouseX;
_mouseY = mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
} private function mouseUpFunction(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
stage.removeEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
//stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownFunction);
} private function mouseMoveFunction(e:MouseEvent):void
{
_cameraHoverController.panAngle = (mouseX - _mouseX) * .3 + _startX;
_cameraHoverController.tiltAngle = (mouseY - _mouseY) * .3 + _startY;
} private function onEnterFrame(e:Event):void
{
_view.render();
} }
}

需要一张无缝全景图,像这样的:

[ActionScript 3.0] Away3D 非skybox的全景例子的更多相关文章

  1. [ActionScript 3.0] Away3D 天空盒(skybox)例子2

    所谓skybox就是六个面即六张图能够无缝的拼成一个正方体的盒子. package { import away3d.cameras.Camera3D; import away3d.cameras.le ...

  2. [ActionScript 3.0] Away3D 天空盒(skybox)例子

    /* SkyBox example in Away3d Demonstrates: How to use a CubeTexture to create a SkyBox object. How to ...

  3. [ActionScript 3.0] Away3D 官网实例

    /* Dynamic tree generation and placement in a night-time scene Demonstrates: How to create a height ...

  4. [ActionScript 3.0] Away3D 灯光的使用

    package { import away3d.containers.View3D; import away3d.entities.Mesh; import away3d.events.MouseEv ...

  5. [ActionScript 3.0] Away3D 旋转效果

    package { import away3d.containers.View3D; import away3d.entities.Mesh; import away3d.events.MouseEv ...

  6. ActionScript 3.0入门:Hello World、文件读写、数据存储(SharedObject)、与JS互调

    近期项目中可能要用到Flash存取数据,并与JS互调,所以就看了一下ActionScript 3.0,现把学习结果分享一下,希望对新手有帮助. 目录 ActionScript 3.0简介 Hello ...

  7. [转]ActionScript 3.0入门:Hello World、文件读写、数据存储(SharedObject)、与JS互调

    本文转自:http://www.cnblogs.com/artwl/p/3396330.html 近期项目中可能要用到Flash存取数据,并与JS互调,所以就看了一下ActionScript 3.0, ...

  8. [ActionScript 3.0] AS3.0 动态加载显示内容

    可以将下列任何外部显示资源加载到 ActionScript 3.0 应用程序中: 在 ActionScript 3.0 中创作的 SWF 文件 — 此文件可以是 Sprite.MovieClip 或扩 ...

  9. ActionScript 3.0 API 中的 Video 类

    注:这个类在Flash流媒体开发中使用的很频繁,在此记录一下它的使用方法. 包 flash.media 类 public class Video 继承 Video  DisplayObject  Ev ...

随机推荐

  1. 自定义Mvc5 Owin 验证

    public class AuthIn : IUserAuthenticate { public static ApplicationUserManager UserManager { get { r ...

  2. 【转】javascript入门系列演示·三种弹出对话框的用法实例

    对话框有三种 1:只是提醒,不能对脚本产生任何改变: 2:一般用于确认,返回 true 或者 false ,所以可以轻松用于 if...else...判断 3: 一个带输入的对话框,可以返回用户填入的 ...

  3. AngularJS初始化普通数组和对象数组

    普通数组: ng-init="persons=['john','jack']" 对象数组: ng-init="persons=[{name:'john',age:20}, ...

  4. Hadoop学习地址

    hortonworks: http://zh.hortonworks.com/hdp/downloads/ http://zh.hortonworks.com/hadoop-tutorial/supe ...

  5. jQuery点击图片弹出放大可拖动图片查看

    CSS代码: .popup-bigic { position: absolute; ; ; background: #eee; overflow: hidden; ; } .popup-bigic . ...

  6. 【linux】linux启动过程

  7. FTP主/被动模式的原理

    ---------------------------------------------------------------------------------------------------- ...

  8. python asyncio笔记

    1.什么是coroutine coroutine,最早我是在lua里面看到的,coroutine最大的好处是可以保存堆栈,让程序得以继续执行,在python里面,一般是利用yield来实现,具体可以看 ...

  9. 【solr】solr5.0整合tomcat

    1.下载 solr版本必须和lucene版本一致,这个链接http://archive.apache.org/dist/lucene/是apache子项目库,在这里可以下载lucene,我这里使用的是 ...

  10. Scala第三章学习笔记

    换行后的左大括号造成的问题: class FooHolder { def foo() { println("foo was called") } } Scala认为def foo( ...